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

Fix S2275: InvalidCastExteption when analyzing single argument method #302

Closed
nnpcYvIVl opened this issue May 12, 2017 · 0 comments
Closed
Assignees
Labels
Type: Bug Exceptions and blocking issues during analysis.
Milestone

Comments

@nnpcYvIVl
Copy link

nnpcYvIVl commented May 12, 2017

RSPEC-S2275

Console.WriteLine(ulong.MaxValue);

Throws the following error

Warning	AD0001	Analyzer 'SonarAnalyzer.Rules.CSharp.StringFormatValidator' threw an exception of type 'System.InvalidCastException' with message 'Unable to cast object of type 'System.UInt64' to type 'System.String'.'.	ConsoleApp3		1	Active	Analyzer 'SonarAnalyzer.Rules.CSharp.StringFormatValidator' threw the following exception:
'Exception occurred with following context:
Compilation: ConsoleApp3
SyntaxTree: C:\Download\ConsoleApp3\ConsoleApp3\Program.cs
SyntaxNode: Console.WriteLine(ulong.MaxValue ... [InvocationExpressionSyntax]@[239..272) (12,12)-(12,45)

System.InvalidCastException: Unable to cast object of type 'System.UInt64' to type 'System.String'.
   at SonarAnalyzer.Rules.CSharp.StringFormatValidator.CheckForFormatStringIssues(SyntaxNodeAnalysisContext analysisContext)
   at SonarAnalyzer.Helpers.DiagnosticAnalyzerContextHelper.<>c__DisplayClass0_0`1.<RegisterSyntaxNodeActionInNonGenerated>b__0(SyntaxNodeAnalysisContext c)
   at SonarAnalyzer.Helpers.SonarAnalysisContext.<>c__DisplayClass12_0`1.<RegisterSyntaxNodeAction>b__0(SyntaxNodeAnalysisContext c)
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c__DisplayClass42_1`1.<ExecuteSyntaxNodeAction>b__1()
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock(DiagnosticAnalyzer analyzer, Action analyze, Nullable`1 info)
@fmallet fmallet added the Type: Bug Exceptions and blocking issues during analysis. label May 13, 2017
@fmallet fmallet added this to the 5.11 milestone May 13, 2017
@valhristov valhristov changed the title AD0001 Exception Fix S2275: InvalidCastExteption when analyzing single argument method May 15, 2017
@valhristov valhristov self-assigned this May 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Exceptions and blocking issues during analysis.
Projects
None yet
Development

No branches or pull requests

3 participants