WiseTechGlobal / WTG.Analyzers

Analyzers from WiseTech Global to enforce our styles, behaviours, and prevent common mistakes.
Other
16 stars 3 forks source link

OverflowException in WTG2005 code fix. #117

Closed brian-reichle closed 4 years ago

brian-reichle commented 4 years ago

Attempting to apply the WTG2005 code fix to the following code will result in an OverflowException:

il.Emit(OpCodes.Ldc_I4, 0xffffffff);
System.OverflowException : Value was either too large or too small for an Int32.
   at System.Convert.ToInt32(UInt32 value)
   at System.UInt32.System.IConvertible.ToInt32(IFormatProvider provider)
   at System.Convert.ToInt32(Object value,IFormatProvider provider)
   at WTG.Analyzers.EmitConversionVisitor.VisitLiteralExpression(LiteralExpressionSyntax node)
   at Microsoft.CodeAnalysis.CSharp.Syntax.LiteralExpressionSyntax.Accept[TResult](CSharpSyntaxVisitor`1 visitor)
   at WTG.Analyzers.EmitCodeFixProvider.ConvertArgument(InvocationExpressionSyntax invoke)
   at async WTG.Analyzers.EmitCodeFixProvider.ConvertArgumentFixAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeActions.CodeAction.GetChangedSolutionAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeActions.CodeAction.ComputeOperationsAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeActions.CodeAction.GetPreviewOperationsAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedAction.GetPreviewResultAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedActionWithNestedFlavors.<>c__DisplayClass11_0.<GetPreviewAsync>b__0(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.PerformFunctionAsync[T](<Unknown Parameters>)