Repository navigation
Support dynamic-typed members in the source generator and analyzer - #2319
Open
1AbdullahButt wants to merge 1 commit into
Open
1AbdullahButt wants to merge 1 commit into
1AbdullahButt wants to merge 1 commit into
Conversation
A member typed as `dynamic` (or a collection of `dynamic`) made the MessagePack analyzer and source generator throw NotSupportedException, because QualifiedTypeName and CodeAnalysisUtilities had no case for IDynamicTypeSymbol. Treat `dynamic` as `object`, which is what it is at runtime, and list it with the other built-in types. Fixes MessagePack-CSharp#2318 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
|
@dotnet-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2318
A member typed as
dynamicmade the analyzer throwAD0001and the source generator fail withCS8785(NotSupportedException: Specified method is not supported.).QualifiedTypeName.Createand the helpers inCodeAnalysisUtilitiesonly handled array, named and type-parameter symbols, so anIDynamicTypeSymbolreached thethrow.This change treats
dynamicthe same asobject, which is what it compiles to:QualifiedTypeName.CreatemapsIDynamicTypeSymboltoSystem.Object, soList<dynamic>orDictionary<string, dynamic>also work.GetArity,GetTypeParametersandGetTypeArgumentsreturn 0 / empty for it, like for a type parameter.dynamicanddynamic[]are added to the built-in type list next toobjectandobject[], so no extra formatter is collected for them.Test:
MsgPack00xAnalyzerTests.DynamicTypedMemberscovers adynamicfield,dynamic[],List<dynamic>andDictionary<string, dynamic>. Onmasterit fails with the AD0001 above; with this change the wholeMessagePack.SourceGenerator.Testsproject passes (161 passed, 9 skipped), run in themcr.microsoft.com/dotnet/sdk:10.0image.🤖 Generated with Claude Code