-
Notifications
You must be signed in to change notification settings - Fork 470
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
Implement CA1308: NormalizeStringsToUppercase #886
Conversation
Tagging @dotnet/roslyn-analysis for review. |
@@ -4,45 +4,98 @@ | |||
using Microsoft.CodeAnalysis; | |||
using Microsoft.CodeAnalysis.Diagnostics; | |||
using Analyzer.Utilities; | |||
using System.Linq; |
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.
Sort using
Strings should be normalized to uppercase. A small group of characters, when they are converted to lowercase, cannot make a round trip. To make a round trip means to convert the characters from one locale to another locale that represents character data differently, and then to accurately retrieve the original characters from the converted characters. MSDN help: https://msdn.microsoft.com/en-us/library/bb386042.aspx TODO: Implement a fixer Fixes dotnet#416
|
||
compilationStartContext.RegisterOperationAction(operationAnalysisContext => | ||
{ | ||
if (operationAnalysisContext.Operation.IsInvalid) |
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.
Do we have to write this test in every operation analyzer? If so, we should have an analyzer analyzer for it.
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.
@JohnHamby @genlu can advice.
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.
Theoretically, checking for validity shouldn't be necessary here--the various properties of operation nodes are supposed to be available safely. In practice, today, some properties might misbehave for invalid nodes.
We could enhance the API to include a means to indicate during registration that the action should run only for nodes for which IsInvalid is false.
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.
We could enhance the API to include a means to indicate during registration that the action should run only for nodes for which IsInvalid is false.
+1 on this, let me file an issue.
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.
Opened dotnet/roslyn#10080
👍 |
Strings should be normalized to uppercase. A small group of characters, when they are converted to lowercase, cannot make a round trip. To make a round trip means to convert the characters from one locale to another locale that represents character data differently, and then to accurately retrieve the original characters from the converted characters.
MSDN help: https://msdn.microsoft.com/en-us/library/bb386042.aspx
TODO: Implement a fixer
Fixes #416