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

Port CA2208: InstantiateArgumentExceptionsCorrectly #742

Merged
merged 5 commits into from
Dec 8, 2015

Conversation

nguerrera
Copy link
Contributor

#531 (fixer to follow in another PR)

compilationContext =>
{
Compilation compilation = compilationContext.Compilation;
ITypeSymbol stringType = compilation.GetSpecialType(SpecialType.System_String);
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need to fetch/store the special types. Instead you can directly ask for the special type on the type symbols. Basically replace your argument.Parameter.Type != stringType checks with argument.Parameter.Type.SpecialType != SpecialType.System_String

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool. Fixed.

@nguerrera nguerrera force-pushed the argument-exception-port branch from d18758b to ff57cee Compare December 7, 2015 22:51
@nguerrera nguerrera force-pushed the argument-exception-port branch from ff57cee to 7f2836b Compare December 7, 2015 22:55


private const string s_helpUri = "https://msdn.microsoft.com/en-us/library/ms182347.aspx";

internal static DiagnosticDescriptor NoArgumentsRule = new DiagnosticDescriptor(RuleId,
Copy link
Contributor

Choose a reason for hiding this comment

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

/cc @srivatsn This seems to be another rule where FXCop generates different diagnostic messages for same Rule ID. @nguerrera We have decided to avoid having multiple descriptors with the same Rule ID which differ only in the containing message. You should create a single descriptor with a placeholder message format "{0}" and provide specific message as a messageArgument to Diagnostic.Create method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@nguerrera nguerrera changed the title [WIP] Port CA2208: InstantiateArgumentExceptionsCorrectly Port CA2208: InstantiateArgumentExceptionsCorrectly Dec 8, 2015
@srivatsn
Copy link
Contributor

srivatsn commented Dec 8, 2015

LGTM

@nguerrera
Copy link
Contributor Author

Thanks, @srivatsn. @mavasani, anything else?

@mavasani
Copy link
Contributor

mavasani commented Dec 8, 2015

👍

nguerrera added a commit that referenced this pull request Dec 8, 2015
Port CA2208: InstantiateArgumentExceptionsCorrectly
@nguerrera nguerrera merged commit 71d5978 into dotnet:master Dec 8, 2015
@nguerrera nguerrera deleted the argument-exception-port branch December 8, 2015 19:08
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