Skip to content

Implement FxCop CA1307 Specify StringComparison #915

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

Merged
merged 5 commits into from
Apr 12, 2016

Conversation

basoundr
Copy link

@basoundr basoundr commented Apr 5, 2016

This change implements the FxCop rule CA1307 to pick the overload with
StringComparison if possible.

@basoundr
Copy link
Author

basoundr commented Apr 5, 2016

Tagging @dotnet/roslyn-analysis

});
}

public static IEnumerable<IMethodSymbol> GetMethodOverloadsWithDesiredParameterAtTrailing(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add doc comments please.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comments

@basoundr
Copy link
Author

basoundr commented Apr 7, 2016

@dotnet-bot retest Windows Release please
// Previous failure: http://dotnet-ci.cloudapp.net/job/dotnet_roslyn-analyzers/job/master/job/windows_release_prtest/88/
// Retest reason: Nuget failure

@basoundr
Copy link
Author

basoundr commented Apr 7, 2016

@dotnet/roslyn-analysis good to checkin?

public static class IEnumerableOfIMethodSymbolExtensions
{
/// <summary>
/// Returns a list of method symbols from a given list of the method symbols, which has its parameter type as
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a very specific helper. Are you planning to use this for any future analyzers? Otherwise, I would recommend moving this into the analyzer file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is used in the analyzer SpecifyIFormatProvider.cs for which I have a PR out #912. This helper will be shared between them

@basoundr
Copy link
Author

basoundr commented Apr 7, 2016

@mavasani Addressed your comments

@mavasani
Copy link

mavasani commented Apr 8, 2016

👍

This change implements the FxCop rule CA1307 to pick the overload with
StringComparison if possible.
Modify the diagnostic message to report shorted message and the
remainder of the message has been moved to the description.

Moved some private helpers over to  some extension methods

Also the method comparison is not displaystring based instead using Type
Symbol comparison
@basoundr basoundr force-pushed the CA1307StringComparison branch from 8e58bf2 to 6f81f9c Compare April 11, 2016 21:54
@basoundr
Copy link
Author

@srivatsn @mavasani I have modified the diagnostic message for CA1305 and CA1307 to be shorter and also introduced some helpers. Please review this change :)

</data>
<data name="SpecifyStringComparisonMessage" xml:space="preserve">
<value>Specify StringComparison</value>
<value>Because the behavior of '{0}' could vary based on the current user's locale settings, replace this call in '{1}' with a call to '{2}'.</value>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the new message much better 👍

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor grammar suggestion: avoid starting the sentence with "Because". You might want to just remove the term "because" in the diagnostic.

@mavasani
Copy link

👍

@basoundr basoundr force-pushed the CA1307StringComparison branch from bbdeab3 to 3d6a359 Compare April 12, 2016 04:36
@basoundr basoundr merged commit 0ed985e into dotnet:master Apr 12, 2016
@basoundr basoundr deleted the CA1307StringComparison branch April 12, 2016 04:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants