Repository navigation
Description
As a follow up to #46681 and #49319, I looked at the rest of the APIs that were missing from Reflection.Emit:
Compat issues with assembly System.Reflection.Emit:
MembersMustExist : Member 'public System.Reflection.Emit.ModuleBuilder System.Reflection.Emit.AssemblyBuilder.DefineDynamicModule(System.String, System.Boolean)' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public System.Reflection.Module System.Reflection.Emit.ConstructorBuilder.GetModule()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public System.String System.Reflection.Emit.ConstructorBuilder.Signature.get()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public System.Reflection.Module System.Reflection.Emit.MethodBuilder.GetModule()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public System.String System.Reflection.Emit.MethodBuilder.Signature.get()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public System.Diagnostics.SymbolStore.ISymbolDocumentWriter System.Reflection.Emit.ModuleBuilder.DefineDocument(System.String, System.Guid, System.Guid, System.Guid)' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'protected System.ModuleHandle System.Reflection.Emit.ModuleBuilder.GetModuleHandleImpl()' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public System.Boolean System.Reflection.Emit.ModuleBuilder.IsTransient()' does not exist in the reference but it does exist in the implementation.
Total Issues: 8
The following APIs don't exist (and shouldn't) in .NET Core because we don't support saving the generated assembly to disk. (#15704)
AssemblyBuilder.DefineDynamicModuleModuleBuilder.DefineDocument
The following API is because of an implementation detail, and doesn't need to be exposed since it has never been exposed:
ModuleBuilder.GetModuleHandleImpl(See the code comment for an explanation)
That leaves the following APIs to be decided if we should bring them back:
Module ConstructorBuilder.GetModuleModule MethodBuilder.GetModulestring ConstructorBuilder.Signaturestring MethodBuilder.Signaturebool ModuleBuilder.IsTransient
-
The
Signatureproperties seem pretty simple. They return a string represenation of the signature of the method. -
The
GetModule()methods are interesting because these types already have aModuleproperty on them. Looking at the code, theGetModule()method and theModuleproperty don't have the same code, but eventually return the same thing - the module of the type containing this Method. -
I'm not exactly sure what
IsTransientmeans, and the MSDN doc doesn't give a good explanation.
Returns a value that indicates whether this dynamic module is transient.
Looking at the code, on mono it always returns true. On coreclr, it calls into the native runtime, and the only place I can see setting the flag, always sets it to true as well.
runtime/src/coreclr/vm/assembly.cpp
Line 180 in b38ea6a
| m_pManifest = ReflectionModule::Create(this, GetManifestFile(), pamTracker, REFEMIT_MANIFEST_MODULE_NAME, TRUE); |
So I guess after all that, the only API I'd recommend adding back is the ConstructorBuilder.Signature and MethodBuilder.Signature properties. I don't think we need to add the other missing APIs.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
jkotas commentedon Mar 10, 2021
We have said that we are done with bringing back APIs from .NET Framework. If we want to add these APIs, they should be reviewed as brand new additions.
jkotas commentedon Mar 10, 2021
Looks like the APIs on the list are public in the implementation, but missing in the ref file. I think we should just mark them private/internal in the implementation, or delete them if they are not actually used.
buyaa-n commentedon May 12, 2021
@eerhardt are you OK with just removing the implementation of those APIs as @jkotas suggested (I choose to remove them because I don't see they are actually used). If you are OK with that i am gonna remove the
api-suggestionlabel and mark itup-for-grubs. Or do you still want to add an API proposal to add them in ref and go through API review?eerhardt commentedon May 12, 2021
I'm 100% fine with removing the implementation. If we made it this long without someone complaining, they must not be necessary. We can always add them in the future if someone does find a need for them.
Remove Reflection.Emit APIs
i3arnon commentedon Jul 22, 2021
I can take this if that's fine.
I made a PR removing the unused code.
I'm not sure how to generate the RefApiCompatBaseline though..
krwq commentedon Jul 22, 2021
@i3arnon I believe you just need to remove this file https://github.com/dotnet/runtime/blob/57bfe474518ab5b7cfe6bf7424a79ce3af9d6657/src/libraries/System.Reflection.Emit/src/MatchingRefApiCompatBaseline.txt (or the entries you have fixed)
KalleOlaviNiemitalo commentedon Jul 24, 2021
According to the AssemblyBuilder.DefineDynamicModule docs, the methods that have a
string fileNameparameter define a persistable module, and the methods without this parameter define a transient module. AssemblyBuilder.Save then "saves all non-transient dynamic modules".Remove Reflection.Emit APIs (#56153)