Skip to content

Fix handling of records in RCS1223#1051

Merged
josefpihrt merged 3 commits intodotnet:mainfrom
jamesHargreaves12:fix/RCS1223
Mar 15, 2023
Merged

Fix handling of records in RCS1223#1051
josefpihrt merged 3 commits intodotnet:mainfrom
jamesHargreaves12:fix/RCS1223

Conversation

@jamesHargreaves12
Copy link
Copy Markdown
Contributor

Currently, this analyzer will throw the following error when it comes across a record:
System.Exception : Analyzer execution threw exception Analyzer 'Roslynator.CSharp.Analysis.MarkTypeWithDebuggerDisplayAttributeAnalyzer' threw an exception of type 'System.InvalidCastException' with message 'Unable to cast object of type 'Microsoft.CodeAnalysis.CSharp.Syntax.RecordDeclarationSyntax' to type 'Microsoft.CodeAnalysis.CSharp.Syntax.ClassDeclarationSyntax'.'.
This shows up as an AD0001 Diagnostic.

Casting Instead to TypeDeclerationSyntax means that we can also handle records correctly. There is no behaviour change for either Struct or Class if we cast to TypeDeclerationSyntax.

@jamesHargreaves12 jamesHargreaves12 changed the title with fix and test Fix RCS1223 Mar 13, 2023
@jamesHargreaves12 jamesHargreaves12 changed the title Fix RCS1223 Fix RCS1223 handling of records Mar 13, 2023
@jamesHargreaves12 jamesHargreaves12 changed the title Fix RCS1223 handling of records Fix handling of records in RCS1223 Mar 13, 2023
@josefpihrt josefpihrt merged commit fe8135a into dotnet:main Mar 15, 2023
@josefpihrt
Copy link
Copy Markdown
Collaborator

Nice! 👍

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.

2 participants