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

Do not use ALC name for AssemblyName #82754

Merged
merged 1 commit into from
Feb 28, 2023
Merged

Conversation

buyaa-n
Copy link
Member

@buyaa-n buyaa-n commented Feb 28, 2023

DispatchProxy uses Reflection.Emit internally and used to use only one AssemblyBuilder for all proxy types.

In .NET 7 that fixed with #62095, now it creates a separate AssemblyBuilder, for each AssemblyLoadContext of the proxy type and also used the ALC name for creating AssemblyName

In some cases, ALC name could include a path:

AssemblyLoadContext alc = new IndividualAssemblyLoadContext($"Assembly.LoadFile({normalizedPath})");
and special characters used for the path is not valid name for AssemblyName constructor and throws.

With this PR we are just using the same name for each ALC, we might want to pass the AssemblyLoadContext.Name as @KalleOlaviNiemitalo suggested for debugging purpose, but ALC info probably should be passed/solved appropriately with #62234 instead, or if needed we can update accordingly later.

See more details from #80387

@ghost
Copy link

ghost commented Feb 28, 2023

Tagging subscribers to this area: @dotnet/area-system-reflection
See info in area-owners.md if you want to be subscribed.

Issue Details

DispatchProxy uses Reflection.Emit internally and used to use only one AssemblyBuilder for all proxy types.

In .NET 7 that fixed with #62095, now it creates a separate AssemblyBuilder, for each AssemblyLoadContext of the proxy type and also used the ALC name for creating AssemblyName

In some cases, ALC name could include a path:

AssemblyLoadContext alc = new IndividualAssemblyLoadContext($"Assembly.LoadFile({normalizedPath})");
and special characters used for the path is not valid name for AssemblyName constructor and throws.

With this PR we are just using the same name for each ALC, we might want to pass the AssemblyLoadContext.Name as @KalleOlaviNiemitalo suggested for debugging purpose, but ALC info probably should be passed/solved appropriately with #62234 instead, or if needed we can update accordingly later.

See more details from #80387

Author: buyaa-n
Assignees: buyaa-n
Labels:

area-System.Reflection

Milestone: -

@AaronRobinsonMSFT
Copy link
Member

AaronRobinsonMSFT commented Feb 28, 2023

@elinor-fung and @vitek-karas FYI

@buyaa-n
Copy link
Member Author

buyaa-n commented Feb 28, 2023

The failure is unrelated and known

@buyaa-n buyaa-n merged commit 5c9c120 into dotnet:main Feb 28, 2023
@buyaa-n buyaa-n deleted the update-name branch February 28, 2023 17:58
@buyaa-n
Copy link
Member Author

buyaa-n commented Feb 28, 2023

/backport to release/7.0

@github-actions
Copy link
Contributor

Started backporting to release/7.0: https://github.com/dotnet/runtime/actions/runs/4295951511

@github-actions
Copy link
Contributor

@buyaa-n backporting to release/7.0 failed, the patch most likely resulted in conflicts:

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

Applying: Do not use ALC name for AssemblyName
Using index info to reconstruct a base tree...
M	src/libraries/System.Reflection.DispatchProxy/src/System/Reflection/DispatchProxyGenerator.cs
M	src/libraries/System.Reflection.DispatchProxy/tests/DispatchProxyTests.cs
Falling back to patching base and 3-way merge...
Auto-merging src/libraries/System.Reflection.DispatchProxy/tests/DispatchProxyTests.cs
CONFLICT (content): Merge conflict in src/libraries/System.Reflection.DispatchProxy/tests/DispatchProxyTests.cs
Auto-merging src/libraries/System.Reflection.DispatchProxy/src/System/Reflection/DispatchProxyGenerator.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Do not use ALC name for AssemblyName
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
Contributor

@buyaa-n an error occurred while backporting to release/7.0, please check the run log for details!

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

buyaa-n added a commit that referenced this pull request Mar 1, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Mar 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants