-
Notifications
You must be signed in to change notification settings - Fork 467
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
CA2246 Warning for unobvious assignment #2717
CA2246 Warning for unobvious assignment #2717
Conversation
...deQuality.Analyzers/Core/QualityGuidelines/MicrosoftQualityGuidelinesAnalyzersResources.resx
Outdated
Show resolved
Hide resolved
...deQuality.Analyzers/Core/QualityGuidelines/MicrosoftQualityGuidelinesAnalyzersResources.resx
Outdated
Show resolved
Hide resolved
...ality.Analyzers/Core/QualityGuidelines/ReferingToObjectAndReassigningItInTheSameStatement.cs
Outdated
Show resolved
Hide resolved
...ality.Analyzers/Core/QualityGuidelines/ReferingToObjectAndReassigningItInTheSameStatement.cs
Outdated
Show resolved
Hide resolved
...ality.Analyzers/Core/QualityGuidelines/ReferingToObjectAndReassigningItInTheSameStatement.cs
Outdated
Show resolved
Hide resolved
...deQuality.Analyzers/Core/QualityGuidelines/MicrosoftQualityGuidelinesAnalyzersResources.resx
Outdated
Show resolved
Hide resolved
...yzers/UnitTests/QualityGuidelines/ReferingToObjectAndReassigningItInTheSameStatementTests.cs
Outdated
Show resolved
Hide resolved
...yzers/UnitTests/QualityGuidelines/ReferingToObjectAndReassigningItInTheSameStatementTests.cs
Outdated
Show resolved
Hide resolved
...deQuality.Analyzers/Core/QualityGuidelines/MicrosoftQualityGuidelinesAnalyzersResources.resx
Outdated
Show resolved
Hide resolved
...ality.Analyzers/Core/QualityGuidelines/ReferingToObjectAndReassigningItInTheSameStatement.cs
Outdated
Show resolved
Hide resolved
...ality.Analyzers/Core/QualityGuidelines/ReferingToObjectAndReassigningItInTheSameStatement.cs
Outdated
Show resolved
Hide resolved
...yzers/UnitTests/QualityGuidelines/ReferingToObjectAndReassigningItInTheSameStatementTests.cs
Outdated
Show resolved
Hide resolved
...ality.Analyzers/Core/QualityGuidelines/ReferingToObjectAndReassigningItInTheSameStatement.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, looks good. @maxkoshevoi would you be able to address the review comments?
Also tagging @dotnet/roslyn-analysis for an additional review of the PR and proposed rule itself.
Yes, I'll do it in the next couple of days |
…gToObjectAndReassigningItInTheSameStatement
…ndReassigningObjectInSameStatement
…tps://github.com/maxkoshevoi/roslyn-analyzers into 2527-compiler-warnings-with-unobvious-assignment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggested a new description - let me know if I got the logic correct.
...deQuality.Analyzers/Core/QualityGuidelines/MicrosoftQualityGuidelinesAnalyzersResources.resx
Outdated
Show resolved
Hide resolved
...deQuality.Analyzers/Core/QualityGuidelines/MicrosoftQualityGuidelinesAnalyzersResources.resx
Outdated
Show resolved
Hide resolved
Co-Authored-By: Genevieve Warren <[email protected]>
...deQuality.Analyzers/Core/QualityGuidelines/MicrosoftQualityGuidelinesAnalyzersResources.resx
Outdated
Show resolved
Hide resolved
@maxkoshevoi I can merge the PR once you fix up the resource strings and xlf files. |
All done. Thanks a lot for your help! |
...t.CodeQuality.Analyzers/Core/QualityGuidelines/AssigningSymbolAndItsMemberInSameStatement.cs
Outdated
Show resolved
Hide resolved
@maxkoshevoi There seem to be merge conflicts in |
@maxkoshevoi Did you sync the latest sources from master? |
Yes, I did (and I've merged my branch with remote master to be sure)
…On Sat, Sep 7, 2019, 15:56 Manish Vasani ***@***.***> wrote:
@maxkoshevoi <https://github.com/maxkoshevoi> Did you sync the latest
sources from master?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2717?email_source=notifications&email_token=ABSNYCMPJIXAP7BJMICIUZTQIOQHBA5CNFSM4IHWSBBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6EYHUA#issuecomment-529105872>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABSNYCIYMRDKAUGMW2ZHSATQIOQHBANCNFSM4IHWSBBA>
.
|
@maxkoshevoi I figured out the reason for your merge conflicts. Your PR is updating src/Microsoft.CodeQuality.Analyzers/Core/QualityGuidelines/MicrosoftQualityGuidelinesAnalyzersResources.resx , but that resource file no longer exists in master. The resource strings from that resx file have been moved to https://github.com/dotnet/roslyn-analyzers/blob/master/src/Microsoft.CodeQuality.Analyzers/Core/MicrosoftCodeQualityAnalyzersResources.resx Can you merge latest master sources and move your added resource strings to the new resx file? Thanks! |
...t.CodeQuality.Analyzers/Core/QualityGuidelines/AssigningSymbolAndItsMemberInSameStatement.cs
Outdated
Show resolved
Hide resolved
… generated code analysis
I'll try to address the issue today, but it could take a bit longer since I
didn't worked with VB before.
…On Thu, Sep 12, 2019, 04:12 Manish Vasani ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In
src/Microsoft.CodeQuality.Analyzers/Core/QualityGuidelines/AssigningSymbolAndItsMemberInSameStatement.cs
<#2717 (comment)>
:
> @@ -0,0 +1,97 @@
+// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+using System.Collections.Immutable;
+using Analyzer.Utilities;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Operations;
+
+namespace Microsoft.CodeQuality.Analyzers.QualityGuidelines
+{
+ /// <summary>
+ /// CA2246: Prevent objects from being referenced in statements where they are reassigned
+ /// </summary>
+ [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)]
@maxkoshevoi <https://github.com/maxkoshevoi> I can merge the PR once you
address this comment.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2717?email_source=notifications&email_token=ABSNYCMHZP4WHZG7QEI6GFTQJGJQ5A5CNFSM4IHWSBBKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCEOY5RA#discussion_r323521311>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABSNYCM44DJIAGXQ4ZTLFO3QJGJQ5ANCNFSM4IHWSBBA>
.
|
@maxkoshevoi Can you make the analyzer itself be C# only then? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution!
Filed https://github.com/MicrosoftDocs/visualstudio-docs/issues/3916 to track adding documentation for the rule and #2847 to track updating analyzer's helpLinkUri once the documentation has been added. |
This is related to issue #2527
I've done what I can here. This is my first time contributing to large repository, so I would love to hear any feedback.
I think name of the analyzer could be shorter and more understandable.
Here's how warning currently looks (
C
isclass
andS
isstruct
):Thanks!