Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CA1416 incorrectly warning on LdapSessionOptions.SecureSocketLayer on Linux #62462

Closed
iinuwa opened this issue Dec 6, 2021 · 3 comments
Closed

Comments

@iinuwa
Copy link
Contributor

iinuwa commented Dec 6, 2021

Description

CA1416 is being raised by the analyzer when accessing the LdapSessionOptions.SecureSocketLayer property on Linux, with a message saying that it is only supported on Windows. The code is supported, however, and it executes just fine.

There are no attributes on the SecureSocketLayer property in the .NET 6.0 source code that I can see that would be causing this warning to be raised.

Reproduction Steps

dotnet new console
dotnet package add System.DirectoryServices.Protocols
// Program.cs
using System.DirectoryServices.Protocols;
using System.Net;

var ldapIdentifier = new LdapDirectoryIdentifier("localhost", 636);
var ldapConnection = new LdapConnection(ldapIdentifier, new NetworkCredential("CN=admin,DC=example,DC=com", "password"))
{
    AuthType = AuthType.Basic
};
ldapConnection.SessionOptions.SecureSocketLayer = true;

Expected behavior

Warning should not show because setting LdapSessionOptions.SecureSocketLayer is supported on Linux.

Actual behavior

CA1416 is thrown:

[{
	"resource": "/src/project/Program.cs",
	"owner": "csharp",
	"code": "CA1416",
	"severity": 4,
	"message": "This call site is reachable on all platforms. 'LdapSessionOptions.SecureSocketLayer' is supported on: 'windows'. [Project]",
	"source": "csharp",
	"startLineNumber": ...,
	"startColumn": ...,
	"endLineNumber": ...,
	"endColumn": ...
}]

Regression?

No response

Known Workarounds

#pragma warning disable CA1416
ldapConnection.SessionOptions.SecureSocketLayer = true;
#pragma warning restore CA1416

Configuration

.NET Version: 6.0
OS: Ubuntu Linux 20.04
Architecture: x64
IDE: VS Code, C# Extension version 1.23.17

Other information

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.DirectoryServices untriaged New issue has not been triaged by the area owner labels Dec 6, 2021
@ghost
Copy link

ghost commented Dec 6, 2021

Tagging subscribers to this area: @dotnet/area-system-directoryservices, @jay98014
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

CA1416 is being raised by the analyzer when accessing the LdapSessionOptions.SecureSocketLayer property on Linux, with a message saying that it is only supported on Windows. The code is supported, however, and it executes just fine.

There are no attributes on the SecureSocketLayer property in the .NET 6.0 source code that I can see that would be causing this warning to be raised.

Reproduction Steps

dotnet new console
dotnet package add System.DirectoryServices.Protocols
// Program.cs
using System.DirectoryServices.Protocols;
using System.Net;

var ldapIdentifier = new LdapDirectoryIdentifier("localhost", 636);
var ldapConnection = new LdapConnection(ldapIdentifier, new NetworkCredential("CN=admin,DC=example,DC=com", "password"))
{
    AuthType = AuthType.Basic
};
ldapConnection.SessionOptions.SecureSocketLayer = true;

Expected behavior

Warning should not show because setting LdapSessionOptions.SecureSocketLayer is supported on Linux.

Actual behavior

CA1416 is thrown:

[{
	"resource": "/src/project/Program.cs",
	"owner": "csharp",
	"code": "CA1416",
	"severity": 4,
	"message": "This call site is reachable on all platforms. 'LdapSessionOptions.SecureSocketLayer' is supported on: 'windows'. [Project]",
	"source": "csharp",
	"startLineNumber": ...,
	"startColumn": ...,
	"endLineNumber": ...,
	"endColumn": ...
}]

Regression?

No response

Known Workarounds

#pragma warning disable CA1416
ldapConnection.SessionOptions.SecureSocketLayer = true;
#pragma warning enable CA1416

Configuration

.NET Version: 6.0
OS: Ubuntu Linux 20.04
Architecture: x64
IDE: VS Code, C# Extension version 1.23.17

Other information

No response

Author: iinuwa
Assignees: -
Labels:

area-System.DirectoryServices, untriaged

Milestone: -

@joperezr
Copy link
Member

joperezr commented Dec 6, 2021

Thanks for logging the issue @iinuwa, this has actually already been fixed in main via #61388. We basically missed to remove this attribute after adding the original implementation. Can you try latest package out of main to see if that fixes your issue?

@joperezr joperezr removed the untriaged New issue has not been triaged by the area owner label Dec 6, 2021
@stephentoub
Copy link
Member

Closing as fixed.

@ghost ghost locked as resolved and limited conversation to collaborators Feb 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants