Skip to content

TypeName parsing API - #100094

Merged
adamsitnik merged 52 commits into
dotnet:mainfrom
adamsitnik:typeNameParser
Apr 24, 2024
Merged

TypeName parsing API#100094
adamsitnik merged 52 commits into
dotnet:mainfrom
adamsitnik:typeNameParser

Conversation

@adamsitnik

@adamsitnik adamsitnik commented Mar 21, 2024

Copy link
Copy Markdown
Member

fixes #97566
fixes #100867

- allow ignoring errors (return null)
- assembly name parsing
- report errorIndex in the ex message
- fix Full Framework build
- fix nested types support
- implement NativeAOT part
… methods, move "allowFullyQualifiedName" to Options bag
…me and they are consistent with Sytem.Type APIs
… in test project and cover with tests, fix edge case bugs
Comment thread src/libraries/Common/src/System/Reflection/Metadata/AssemblyNameInfo.cs Outdated
Comment thread src/libraries/Common/src/System/Reflection/AssemblyNameParser.cs Outdated
adamsitnik and others added 2 commits April 24, 2024 16:26
- don't throw TypeLoadException in the parser, let loader do that
- add Debug.Assert(typeName.IsSimple) for clarity
- always include invalid character index in the error message
- remove resources added to CoreLib (they are never going to be used)
- use [DoesNotReturn] and implement proper throw helper pattern
- remove outdated comment about name validation
- AssemblyNameInfo.Flags should return the exact value provided in ctor
- don't allocate FullName until it's really needed
- refactor Make and Resovle methods into one method
- fix the test: specify namespace to make sure the type loader loads System.Int32 and later throws TypeLoadException for byref to byref
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
@jeffhandley

Copy link
Copy Markdown
Member

/backport to release/9.0-preview4

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/9.0-preview4: https://github.com/dotnet/runtime/actions/runs/8823414508

@github-actions

Copy link
Copy Markdown
Contributor

@jeffhandley backporting to release/9.0-preview4 failed, the patch most likely resulted in conflicts:

$ git am --3way --ignore-whitespace --keep-non-patch changes.patch

Applying: TypeNameParser first ref and configurable input validation
Applying: assembly name parsing
Applying: initial generic type info parsing
Applying: decorator parsing
Applying: Handle single dimensional array indexing
Applying: implement TypeName.GetType
Applying: nested types support
Applying: support ignore case
Applying: integrate with System.Private.CoreLib:
Using index info to reconstruct a base tree...
M	src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj
M	src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems
Falling back to patching base and 3-way merge...
Removing src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeNameParser.cs
Auto-merging src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems
Auto-merging src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj
Applying: integrate with System.Private.CoreLib:
Using index info to reconstruct a base tree...
M	src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj
M	src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems
Falling back to patching base and 3-way merge...
Auto-merging src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems
Removing src/coreclr/System.Private.CoreLib/src/System/Reflection/TypeNameResolver.cs
Auto-merging src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj
Applying: integrate with System.Private.CoreLib for Mono and clr tools, improve perf
Applying: build fix 1/n
Applying: make TypeNameParser internal, extend TypeName with Parse and TryParse methods, move "allowFullyQualifiedName" to Options bag
Applying: introduce TotalComplexity
Applying: introduce FullName, so we have Name, FullName and AssemblyQualifiedName and they are consistent with Sytem.Type APIs
Applying: back tick error handling
Applying: move helper methods to a standalone helper type, include it as a link in test project and cover with tests, fix edge case bugs
Applying: increase test coverage, improve edge case handling
Applying: sample SerializationBinder that uses the new APIs
Applying: cover more serialization binder scenarios with the tests to ensure the API is complete
Applying: strict mode parsing: type names
Applying: strict mode parsing: assembly names
Applying: fix the build and apply some design changes
Applying: add escaping support
Applying: fix the last failing tests, increase test coverage, fix the perf, fix the build
Applying: apply changes based on the 1st API Design Review
Applying: apply changes based on the final API Design Review
Applying: solve the TODOs
Using index info to reconstruct a base tree...
M	src/libraries/System.Private.CoreLib/src/Resources/Strings.resx
Falling back to patching base and 3-way merge...
Auto-merging src/libraries/System.Private.CoreLib/src/Resources/Strings.resx
CONFLICT (content): Merge conflict in src/libraries/System.Private.CoreLib/src/Resources/Strings.resx
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0028 solve the TODOs
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

@github-actions

Copy link
Copy Markdown
Contributor

@jeffhandley an error occurred while backporting to release/9.0-preview4, please check the run log for details!

Error: git am failed, most likely due to a merge conflict.

@jeffhandley

Copy link
Copy Markdown
Member

We're holding off on the backport for now. We may decide to proceed with it on Thursday though.

@JulieLeeMSFT

Copy link
Copy Markdown
Member

@adamsitnik, as @TIHan mentioned, we have widespread test failures which seem to happen after this PR. Could you please take a quick look? CC @jeffhandley.

matouskozak pushed a commit to matouskozak/runtime that referenced this pull request Apr 30, 2024
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
@LoopedBard3

LoopedBard3 commented May 2, 2024

Copy link
Copy Markdown
Member

Likely caused improvements:
Linux arm64: dotnet/perf-autofiling-issues#33683

michaelgsharp pushed a commit to michaelgsharp/runtime that referenced this pull request May 9, 2024
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Ruihan-Yin pushed a commit to Ruihan-Yin/runtime that referenced this pull request May 30, 2024
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.