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

CSharpImmutableObjectMethodAnalyzer does not work when MS.CA.Workspaces is not installed #1128

Closed
svick opened this issue Apr 4, 2017 · 1 comment · Fixed by #6321
Closed
Assignees
Labels
Area-Microsoft.CodeAnalysis.Analyzers Bug The product is not behaving according to its current intended design False_Positive A diagnostic is reported for non-problematic case help wanted The issue is up-for-grabs, and can be claimed by commenting
Milestone

Comments

@svick
Copy link
Contributor

svick commented Apr 4, 2017

Analyzer package

Microsoft.CodeAnalysis.Analyzers

Analyzer

CSharpImmutableObjectMethodAnalyzer

Repro steps

  1. Create a new C# project.

  2. Install the package Microsoft.CodeAnalysis.CSharp, but not Microsoft.CodeAnalysis.CSharp.Workspaces

  3. Write code that doesn't use the returned value from a method on an immutable object:

    var namespaceNode = SyntaxFactory.NamespaceDeclaration(
        SyntaxFactory.ParseName("Root.MyNamespace1"));
    var classNode = SyntaxFactory.ClassDeclaration("MyClass");
    
    namespaceNode.AddMembers(classNode);

Expected behavior

The last line reports:

RS1014 'NamespaceDeclarationSyntax' is immutable and 'AddMembers' will not have any effect on it. Consider using the return value from 'AddMembers'.

Actual behavior

No warning.


This is caused by this line, which means that when symbols from MS.CA.Workspaces are not found, the analyzer does nothing.

@mavasani mavasani added this to the 15.3 milestone Apr 14, 2017
@mavasani mavasani added the Bug The product is not behaving according to its current intended design label Apr 14, 2017
@jinujoseph jinujoseph modified the milestones: Unknown, 15.3 Apr 26, 2017
@sharwell sharwell added help wanted The issue is up-for-grabs, and can be claimed by commenting and removed Up for Grabs labels Aug 1, 2019
@Evangelink
Copy link
Member

Relates to #4564 and #615

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Microsoft.CodeAnalysis.Analyzers Bug The product is not behaving according to its current intended design False_Positive A diagnostic is reported for non-problematic case help wanted The issue is up-for-grabs, and can be claimed by commenting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants