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 handling of records in RCS1223 #1051

Merged
merged 3 commits into from
Mar 15, 2023

Conversation

jamesHargreaves12
Copy link
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
Collaborator

Nice! 👍

Haarmees pushed a commit to Haarmees/Roslynator that referenced this pull request Oct 30, 2023
Co-authored-by: Josef Pihrt <josef.pihrt@outlook.com>
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