WiseTechGlobal / WTG.Analyzers

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

WTG1018 InvalidCastException #124

Closed yaakov-h closed 4 years ago

yaakov-h commented 4 years ago
* Solution: ConfigurationModel.Validation.sln (7/7)...
  - Found 9 projects.
Analyzer 'WTG.Analyzers.BooleanLiteralAnalyzer' threw an exception of type 'System.InvalidCastException' with message 'Unable to cast object of type 'Microsoft.CodeAnalysis.CSharp.Syntax.TupleExpressionSyntax' to type 'Microsoft.CodeAnalysis.CSharp.Syntax.ArgumentListSyntax'.'.

I'm not sure yet exactly which code is triggering this.

yaakov-h commented 4 years ago

Another error:

* Solution: WinMobile.sln (1/7)...
  - Found 8 projects.
Analyzer 'WTG.Analyzers.BooleanLiteralAnalyzer' threw an exception of type 'System.IndexOutOfRangeException' with message 'Index was outside the bounds of the array.'.
yaakov-h commented 4 years ago

The IndexOutOfRangeException looks to be due to the argument being a params array:

void Foo(params object[] args) { ... }

Foo("Thing", true); // Explode
yaakov-h commented 4 years ago

InvalidCastException is due to the argument being a tuple argument, not a method argument:

return (true, null);