From d619c69fb2a6276274dbad7794b08a69e9b53ef0 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 1 Dec 2025 13:41:28 -0800 Subject: [PATCH 1/7] Update AsmResolver.DotNet to version 6.0.0-development.317 Bumps the AsmResolver.DotNet package version from 6.0.0-development.282 to 6.0.0-development.317 for improved features and bug fixes. --- src/Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 5b1aa5b5c..66abf3e0d 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -3,7 +3,7 @@ true - + From dbad064623ef7a7413f85eac3b4ebf47282ad07d Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Thu, 11 Dec 2025 09:49:32 -0800 Subject: [PATCH 2/7] Remove unnecessary .Import(module) calls Refactored code to eliminate redundant .Import(module) calls on type and method references throughout builder and factory classes. This simplifies the codebase and ensures references are used directly, improving maintainability and clarity. --- ...ynamicCustomMappedTypeMapEntriesBuilder.cs | 2 +- .../InteropTypeDefinitionBuilder.Delegate.cs | 92 +++-- ...nteropTypeDefinitionBuilder.EventSource.cs | 12 +- ...nitionBuilder.IAsyncActionWithProgress1.cs | 40 +- ...pTypeDefinitionBuilder.IAsyncOperation1.cs | 26 +- ...ionBuilder.IAsyncOperationWithProgress2.cs | 38 +- ...teropTypeDefinitionBuilder.IDictionary2.cs | 198 +++++----- ...teropTypeDefinitionBuilder.IEnumerable1.cs | 48 +-- ...teropTypeDefinitionBuilder.IEnumerator1.cs | 56 +-- .../InteropTypeDefinitionBuilder.IList1.cs | 152 +++---- ...DefinitionBuilder.IMapChangedEventArgs1.cs | 26 +- ...opTypeDefinitionBuilder.IObservableMap2.cs | 44 +-- ...ypeDefinitionBuilder.IObservableVector1.cs | 44 +-- ...eDefinitionBuilder.IReadOnlyDictionary2.cs | 74 ++-- ...ropTypeDefinitionBuilder.IReadOnlyList1.cs | 40 +- ...teropTypeDefinitionBuilder.KeyValuePair.cs | 14 +- .../InteropTypeDefinitionBuilder.SzArray.cs | 48 +-- ...opTypeDefinitionBuilder.UserDefinedType.cs | 22 +- .../Builders/InteropTypeDefinitionBuilder.cs | 61 ++- .../WindowsRuntimeTypeHierarchyBuilder.cs | 18 +- .../Extensions/MethodDefinitionExtensions.cs | 2 +- .../InteropCustomAttributeFactory.cs | 40 +- .../InteropMemberDefinitionFactory.cs | 10 +- ...onFactory.IAsyncActionWithProgress1Impl.cs | 8 +- ...pMethodDefinitionFactory.IAsyncInfoImpl.cs | 24 +- ...thodDefinitionFactory.IAsyncInfoMethods.cs | 60 +-- ...dDefinitionFactory.IAsyncOperation1Impl.cs | 10 +- ...ethodDefinitionFactory.IEnumerable1Impl.cs | 8 +- ...ethodDefinitionFactory.IEnumerator1Impl.cs | 34 +- ...hodDefinitionFactory.IKeyValuePair2Impl.cs | 13 +- ...nitionFactory.IMapChangedEventArgs1Impl.cs | 20 +- ...odDefinitionFactory.IObservableMap2Impl.cs | 40 +- ...efinitionFactory.IObservableVector1Impl.cs | 40 +- ...hodDefinitionFactory.IVectorViewMethods.cs | 18 +- ...odDefinitionFactory.KeyValuePairMethods.cs | 8 +- ...thodDefinitionFactory.SzArrayMarshaller.cs | 10 +- .../InteropMethodRewriteFactory.RetVal.cs | 22 +- ...InteropMethodRewriteFactory.ReturnValue.cs | 10 +- .../WellKnownCilMethodBodyFactory.cs | 26 +- .../WellKnownMemberDefinitionFactory.cs | 8 +- ...onFactory.IgnoreAccessChecksToAttribute.cs | 4 +- .../WellKnownTypeDefinitionFactory.cs | 370 +++++++++--------- .../Generation/InteropGenerator.Discover.cs | 2 +- 43 files changed, 918 insertions(+), 924 deletions(-) diff --git a/src/WinRT.Interop.Generator/Builders/DynamicCustomMappedTypeMapEntriesBuilder.cs b/src/WinRT.Interop.Generator/Builders/DynamicCustomMappedTypeMapEntriesBuilder.cs index ebd0afec8..e13f5f7b3 100644 --- a/src/WinRT.Interop.Generator/Builders/DynamicCustomMappedTypeMapEntriesBuilder.cs +++ b/src/WinRT.Interop.Generator/Builders/DynamicCustomMappedTypeMapEntriesBuilder.cs @@ -151,7 +151,7 @@ private static void WindowsRuntimeExposedType( name: (Utf8String)$"{trimTarget.Name}ComWrappersMarshallerAttribute"); // The '[ComWrappersMarshaller]' type should always exist for all custom-mapped types, throw if it doesn't - if (comWrappersMarshallerTypeReference.Import(module).Resolve() is not TypeDefinition comWrappersMarshallerType) + if (comWrappersMarshallerTypeReference.Resolve() is not TypeDefinition comWrappersMarshallerType) { throw WellKnownInteropExceptions.CustomMappedTypeComWrappersMarshallerAttributeTypeResolveError(comWrappersMarshallerTypeReference); } diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.Delegate.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.Delegate.cs index fa27beecd..afa256d91 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.Delegate.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.Delegate.cs @@ -100,7 +100,7 @@ public static void ImplType( // Labels for jumps CilInstruction ldloc_0_returnHResult = new(Ldloc_0); CilInstruction ldarg_0_tryStart = new(Ldarg_0); - CilInstruction call_catchStartMarshalException = new(Call, interopReferences.RestrictedErrorInfoExceptionMarshallerConvertToUnmanaged.Import(module)); + CilInstruction call_catchStartMarshalException = new(Call, interopReferences.RestrictedErrorInfoExceptionMarshallerConvertToUnmanaged); // Create a method body for the 'Invoke' method invokeMethod.CilMethodBody = new CilMethodBody() @@ -112,12 +112,12 @@ public static void ImplType( { // '.try' code { ldarg_0_tryStart }, - { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(delegateType).Import(module) }, + { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(delegateType) }, { Ldarg_1 }, - { Call, interopReferences.WindowsRuntimeObjectMarshallerConvertToManaged.Import(module) }, + { Call, interopReferences.WindowsRuntimeObjectMarshallerConvertToManaged }, { Ldarg_2 }, - { Call, interopReferences.WindowsRuntimeObjectMarshallerConvertToManaged.Import(module) }, - { Callvirt, interopReferences.DelegateInvoke(delegateType, module).Import(module) }, + { Call, interopReferences.WindowsRuntimeObjectMarshallerConvertToManaged }, + { Callvirt, interopReferences.DelegateInvoke(delegateType, module) }, { Ldc_I4_0 }, { Stloc_0 }, { Leave_S, ldloc_0_returnHResult.CreateLabel() }, @@ -140,7 +140,7 @@ public static void ImplType( TryEnd = call_catchStartMarshalException.CreateLabel(), HandlerStart = call_catchStartMarshalException.CreateLabel(), HandlerEnd = ldloc_0_returnHResult.CreateLabel(), - ExceptionType = interopReferences.Exception.Import(module) + ExceptionType = interopReferences.Exception } } }; @@ -193,14 +193,14 @@ public static void ReferenceImplType( // Jump labels CilInstruction nop_beforeTry = new(Nop); CilInstruction ldarg_1_tryStart = new(Ldarg_1); - CilInstruction call_catchStartMarshalException = new(Call, interopReferences.RestrictedErrorInfoExceptionMarshallerConvertToUnmanaged.Import(module)); + CilInstruction call_catchStartMarshalException = new(Call, interopReferences.RestrictedErrorInfoExceptionMarshallerConvertToUnmanaged); CilInstruction ldloc_0_returnHResult = new(Ldloc_0); // Declare 2 local variables: // [0]: 'int' (the 'HRESULT' to return) // [1]: 'WindowsRuntimeObjectReferenceValue' to use to marshal the delegate CilLocalVariable loc_0_hresult = new(module.CorLibTypeFactory.Int32); - CilLocalVariable loc_1_referenceValue = new(interopReferences.WindowsRuntimeObjectReferenceValue.ToValueTypeSignature().Import(module)); + CilLocalVariable loc_1_referenceValue = new(interopReferences.WindowsRuntimeObjectReferenceValue.ToValueTypeSignature()); // Create a method body for the 'get_Value' method valueMethod.CilMethodBody = new CilMethodBody() @@ -220,11 +220,11 @@ public static void ReferenceImplType( // '.try' code { ldarg_1_tryStart }, { Ldarg_0 }, - { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(delegateType).Import(module) }, + { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(delegateType) }, { Call, marshallerType.GetMethod("ConvertToUnmanaged"u8) }, { Stloc_1 }, { Ldloca_S, loc_1_referenceValue }, - { Call, interopReferences.WindowsRuntimeObjectReferenceValueDetachThisPtrUnsafe.Import(module) }, + { Call, interopReferences.WindowsRuntimeObjectReferenceValueDetachThisPtrUnsafe }, { Stind_I }, { Ldc_I4_0 }, { Stloc_0 }, @@ -248,7 +248,7 @@ public static void ReferenceImplType( TryEnd = call_catchStartMarshalException.CreateLabel(), HandlerStart = call_catchStartMarshalException.CreateLabel(), HandlerEnd = ldloc_0_returnHResult.CreateLabel(), - ExceptionType = interopReferences.Exception.Import(module) + ExceptionType = interopReferences.Exception } } }; @@ -331,7 +331,7 @@ public static void ComWrappersCallbackType( attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: module.CorLibTypeFactory.Object.ToTypeDefOrRef()) { - Interfaces = { new InterfaceImplementation(interopReferences.IWindowsRuntimeObjectComWrappersCallback.Import(module)) } + Interfaces = { new InterfaceImplementation(interopReferences.IWindowsRuntimeObjectComWrappersCallback) } }; module.TopLevelTypes.Add(callbackType); @@ -346,7 +346,7 @@ public static void ComWrappersCallbackType( returnType: module.CorLibTypeFactory.Object, parameterTypes: [ module.CorLibTypeFactory.Void.MakePointerType(), - interopReferences.CreatedWrapperFlags.Import(module).MakeByReferenceType()])) + interopReferences.CreatedWrapperFlags.MakeByReferenceType()])) { CilOutParameterIndices = [2], CilMethodBody = new CilMethodBody @@ -358,9 +358,9 @@ public static void ComWrappersCallbackType( { Ldarg_0 }, { Call, get_IidMethod }, { Ldarg_1 }, - { Call, interopReferences.WindowsRuntimeComWrappersMarshalCreateObjectReferenceUnsafe.Import(module) }, + { Call, interopReferences.WindowsRuntimeComWrappersMarshalCreateObjectReferenceUnsafe }, { Ldftn, nativeDelegateType.GetMethod("Invoke"u8) }, - { Newobj, interopReferences.Delegate_ctor(delegateType).Import(module) }, + { Newobj, interopReferences.Delegate_ctor(delegateType) }, { Ret } } } @@ -368,7 +368,7 @@ public static void ComWrappersCallbackType( // Add and implement the 'CreateObject' method callbackType.AddMethodImplementation( - declaration: interopReferences.IWindowsRuntimeObjectComWrappersCallbackCreateObject.Import(module), + declaration: interopReferences.IWindowsRuntimeObjectComWrappersCallbackCreateObject, method: createObjectMethod); } @@ -397,7 +397,7 @@ public static void NativeDelegateType( module.TopLevelTypes.Add(nativeDelegateType); // Construct the 'Invoke' method on the delegate type, so we can get the constructed parameter types - MethodSignature invokeSignature = delegateType.Import(module).Resolve()!.GetMethod("Invoke"u8).Signature!.InstantiateGenericTypes(GenericContext.FromType(delegateType)); + MethodSignature invokeSignature = delegateType.Resolve()!.GetMethod("Invoke"u8).Signature!.InstantiateGenericTypes(GenericContext.FromType(delegateType)); // Define the 'Invoke' method as follows: // @@ -408,9 +408,9 @@ public static void NativeDelegateType( signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Void, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature().Import(module), - invokeSignature.ParameterTypes[0].Import(module), - invokeSignature.ParameterTypes[1].Import(module)])) + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), + invokeSignature.ParameterTypes[0], + invokeSignature.ParameterTypes[1]])) { CilMethodBody = new CilMethodBody() }; nativeDelegateType.Methods.Add(invokeMethod); @@ -420,9 +420,7 @@ public static void NativeDelegateType( CilInstructionCollection invokeInstructions = invokeBody.Instructions; // Import 'WindowsRuntimeObjectReferenceValue', compute it just once - TypeSignature windowsRuntimeObjectReferenceValueType = interopReferences.WindowsRuntimeObjectReferenceValue - .Import(module) - .ToValueTypeSignature(); + TypeSignature windowsRuntimeObjectReferenceValueType = interopReferences.WindowsRuntimeObjectReferenceValue.ToValueTypeSignature(); // Declare the local variables: // [0]: 'WindowsRuntimeObjectReferenceValue' (for 'thisValue') @@ -438,48 +436,48 @@ public static void NativeDelegateType( // Load the local [0] _ = invokeInstructions.Add(Ldarg_0); - _ = invokeInstructions.Add(Callvirt, interopReferences.WindowsRuntimeObjectReferenceAsValue.Import(module)); + _ = invokeInstructions.Add(Callvirt, interopReferences.WindowsRuntimeObjectReferenceAsValue); _ = invokeInstructions.Add(Stloc_0); // '.try' for local [0] CilInstruction try_0 = invokeInstructions.Add(Ldarg_1); - _ = invokeInstructions.Add(Call, interopReferences.WindowsRuntimeObjectMarshallerConvertToUnmanaged.Import(module)); + _ = invokeInstructions.Add(Call, interopReferences.WindowsRuntimeObjectMarshallerConvertToUnmanaged); _ = invokeInstructions.Add(Stloc_1); // '.try' for local [1] CilInstruction try_1 = invokeInstructions.Add(Ldarg_2); - _ = invokeInstructions.Add(Call, interopReferences.WindowsRuntimeObjectMarshallerConvertToUnmanaged.Import(module)); + _ = invokeInstructions.Add(Call, interopReferences.WindowsRuntimeObjectMarshallerConvertToUnmanaged); _ = invokeInstructions.Add(Stloc_2); // 'Invoke' call for the native delegate (and 'try' for local [2]) CilInstruction try_2 = invokeInstructions.Add(Ldloca_S, invokeBody.LocalVariables[0]); - _ = invokeInstructions.Add(Call, interopReferences.WindowsRuntimeObjectReferenceValueGetThisPtrUnsafe.Import(module)); + _ = invokeInstructions.Add(Call, interopReferences.WindowsRuntimeObjectReferenceValueGetThisPtrUnsafe); _ = invokeInstructions.Add(Stloc_3); _ = invokeInstructions.Add(Ldloc_3); _ = invokeInstructions.Add(Ldloca_S, invokeBody.LocalVariables[1]); - _ = invokeInstructions.Add(Call, interopReferences.WindowsRuntimeObjectReferenceValueGetThisPtrUnsafe.Import(module)); + _ = invokeInstructions.Add(Call, interopReferences.WindowsRuntimeObjectReferenceValueGetThisPtrUnsafe); _ = invokeInstructions.Add(Ldloca_S, invokeBody.LocalVariables[2]); - _ = invokeInstructions.Add(Call, interopReferences.WindowsRuntimeObjectReferenceValueGetThisPtrUnsafe.Import(module)); + _ = invokeInstructions.Add(Call, interopReferences.WindowsRuntimeObjectReferenceValueGetThisPtrUnsafe); _ = invokeInstructions.Add(Ldloc_3); _ = invokeInstructions.Add(Ldind_I); _ = invokeInstructions.Add(Ldfld, interopDefinitions.DelegateVftbl.Fields[3]); - _ = invokeInstructions.Add(Calli, WellKnownTypeSignatureFactory.InvokeImpl(interopReferences).Import(module).MakeStandAloneSignature()); - _ = invokeInstructions.Add(Call, interopReferences.RestrictedErrorInfoThrowExceptionForHR.Import(module)); + _ = invokeInstructions.Add(Calli, WellKnownTypeSignatureFactory.InvokeImpl(interopReferences).MakeStandAloneSignature()); + _ = invokeInstructions.Add(Call, interopReferences.RestrictedErrorInfoThrowExceptionForHR); _ = invokeInstructions.Add(Leave_S, ret.CreateLabel()); // 'finally' for local [2] CilInstruction finally_2 = invokeInstructions.Add(Ldloca_S, invokeBody.LocalVariables[2]); - _ = invokeInstructions.Add(Call, interopReferences.WindowsRuntimeObjectReferenceValueDispose.Import(module)); + _ = invokeInstructions.Add(Call, interopReferences.WindowsRuntimeObjectReferenceValueDispose); _ = invokeInstructions.Add(Endfinally); // 'finally' for local [1] CilInstruction finally_1 = invokeInstructions.Add(Ldloca_S, invokeBody.LocalVariables[1]); - _ = invokeInstructions.Add(Call, interopReferences.WindowsRuntimeObjectReferenceValueDispose.Import(module)); + _ = invokeInstructions.Add(Call, interopReferences.WindowsRuntimeObjectReferenceValueDispose); _ = invokeInstructions.Add(Endfinally); // 'finally' for local [0] CilInstruction finally_0 = invokeInstructions.Add(Ldloca_S, invokeBody.LocalVariables[0]); - _ = invokeInstructions.Add(Call, interopReferences.WindowsRuntimeObjectReferenceValueDispose.Import(module)); + _ = invokeInstructions.Add(Call, interopReferences.WindowsRuntimeObjectReferenceValueDispose); _ = invokeInstructions.Add(Endfinally); invokeInstructions.Add(ret); @@ -541,7 +539,7 @@ public static void ComWrappersMarshallerAttribute( ns: InteropUtf8NameFactory.TypeNamespace(delegateType), name: InteropUtf8NameFactory.TypeName(delegateType, "ComWrappersMarshallerAttribute"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, - baseType: interopReferences.WindowsRuntimeComWrappersMarshallerAttribute.Import(module)); + baseType: interopReferences.WindowsRuntimeComWrappersMarshallerAttribute); module.TopLevelTypes.Add(marshallerType); @@ -551,10 +549,10 @@ public static void ComWrappersMarshallerAttribute( marshallerType.Methods.Add(ctor); _ = ctor.CilMethodBody!.Instructions.Insert(0, Ldarg_0); - _ = ctor.CilMethodBody!.Instructions.Insert(1, Call, interopReferences.WindowsRuntimeComWrappersMarshallerAttribute_ctor.Import(module)); + _ = ctor.CilMethodBody!.Instructions.Insert(1, Call, interopReferences.WindowsRuntimeComWrappersMarshallerAttribute_ctor); // The 'ComputeVtables' method returns the 'ComWrappers.ComInterfaceEntry*' type - PointerTypeSignature computeVtablesReturnType = interopReferences.ComInterfaceEntry.Import(module).MakePointerType(); + PointerTypeSignature computeVtablesReturnType = interopReferences.ComInterfaceEntry.MakePointerType(); // Define the 'ComputeVtables' method as follows: // @@ -579,12 +577,12 @@ public static void ComWrappersMarshallerAttribute( // Add and implement the 'ComputeVtables' method marshallerType.AddMethodImplementation( - declaration: interopReferences.WindowsRuntimeComWrappersMarshallerAttributeComputeVtables.Import(module), + declaration: interopReferences.WindowsRuntimeComWrappersMarshallerAttributeComputeVtables, method: computeVtablesMethod); // Import the 'UnboxToManaged' method for the delegate - IMethodDescriptor windowsRuntimeDelegateMarshallerUnboxToManaged2Descriptor = interopReferences.WindowsRuntimeDelegateMarshallerUnboxToManaged2 - .Import(module) + IMethodDescriptor windowsRuntimeDelegateMarshallerUnboxToManaged2Descriptor = + interopReferences.WindowsRuntimeDelegateMarshallerUnboxToManaged2 .MakeGenericInstanceMethod(delegateComWrappersCallbackType.ToReferenceTypeSignature()); // Define the 'CreateObject' method as follows: @@ -597,7 +595,7 @@ public static void ComWrappersMarshallerAttribute( returnType: module.CorLibTypeFactory.Object, parameterTypes: [ module.CorLibTypeFactory.Void.MakePointerType(), - interopReferences.CreatedWrapperFlags.Import(module).MakeByReferenceType()])) + interopReferences.CreatedWrapperFlags.MakeByReferenceType()])) { CilOutParameterIndices = [2], CilInstructions = @@ -614,7 +612,7 @@ public static void ComWrappersMarshallerAttribute( // Add and implement the 'CreateObject' method marshallerType.AddMethodImplementation( - declaration: interopReferences.WindowsRuntimeComWrappersMarshallerAttributeCreateObject.Import(module), + declaration: interopReferences.WindowsRuntimeComWrappersMarshallerAttributeCreateObject, method: createObjectMethod); } @@ -647,8 +645,8 @@ public static void Marshaller( module.TopLevelTypes.Add(marshallerType); // Prepare the external types we need in the implemented methods - TypeSignature delegateType2 = delegateType.Import(module); - TypeSignature windowsRuntimeObjectReferenceValueType = interopReferences.WindowsRuntimeObjectReferenceValue.Import(module).ToValueTypeSignature(); + TypeSignature delegateType2 = delegateType; + TypeSignature windowsRuntimeObjectReferenceValueType = interopReferences.WindowsRuntimeObjectReferenceValue.ToValueTypeSignature(); // Define the 'ConvertToUnmanaged' method as follows: // @@ -664,7 +662,7 @@ public static void Marshaller( { { Ldarg_0 }, { Call, get_IidMethod }, - { Call, interopReferences.WindowsRuntimeDelegateMarshallerConvertToUnmanaged.Import(module) }, + { Call, interopReferences.WindowsRuntimeDelegateMarshallerConvertToUnmanaged }, { Ret } } }; @@ -674,7 +672,6 @@ public static void Marshaller( // Construct a descriptor for 'WindowsRuntimeDelegateMarshaller.ConvertToManaged<>(void*)' IMethodDescriptor windowsRuntimeDelegateMarshallerConvertToManaged = interopReferences.WindowsRuntimeDelegateMarshallerConvertToManaged - .Import(module) .MakeGenericInstanceMethod(delegateComWrappersCallbackType.ToReferenceTypeSignature()); // Define the 'ConvertToManaged' method as follows: @@ -712,7 +709,7 @@ public static void Marshaller( { { Ldarg_0 }, { Call, get_ReferenceIidMethod }, - { Call, interopReferences.WindowsRuntimeDelegateMarshallerBoxToUnmanaged.Import(module) }, + { Call, interopReferences.WindowsRuntimeDelegateMarshallerBoxToUnmanaged }, { Ret } } }; @@ -722,7 +719,6 @@ public static void Marshaller( // Construct a descriptor for 'WindowsRuntimeDelegateMarshaller.UnboxToManaged<>(void*)' IMethodDescriptor windowsRuntimeDelegateMarshallerUnboxToManaged = interopReferences.WindowsRuntimeDelegateMarshallerUnboxToManaged - .Import(module) .MakeGenericInstanceMethod(delegateComWrappersCallbackType.ToReferenceTypeSignature()); // Define the 'UnboxToManaged' method as follows: diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.EventSource.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.EventSource.cs index c7440235f..b4cd0eccd 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.EventSource.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.EventSource.cs @@ -161,7 +161,7 @@ private static void DerivedEventSource( ns: "ABI.WindowsRuntime.InteropServices"u8, name: InteropUtf8NameFactory.TypeName(baseEventSourceSignature), attributes: TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, - baseType: baseEventSourceSignature.Import(module).ToTypeDefOrRef()); + baseType: baseEventSourceSignature.ToTypeDefOrRef()); module.TopLevelTypes.Add(eventSourceType); @@ -176,7 +176,7 @@ private static void DerivedEventSource( MethodDefinition ctor = MethodDefinition.CreateConstructor( module: module, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), module.CorLibTypeFactory.Int32]); eventSourceType.Methods.Add(ctor); @@ -184,7 +184,7 @@ private static void DerivedEventSource( _ = ctor.CilMethodBody!.Instructions.Insert(0, Ldarg_0); _ = ctor.CilMethodBody!.Instructions.Insert(1, Ldarg_1); _ = ctor.CilMethodBody!.Instructions.Insert(2, Ldarg_2); - _ = ctor.CilMethodBody!.Instructions.Insert(3, Call, baseEventSource_ctor.Import(module)); + _ = ctor.CilMethodBody!.Instructions.Insert(3, Call, baseEventSource_ctor); // Define the 'ConvertToUnmanaged' method as follows: // @@ -193,8 +193,8 @@ private static void DerivedEventSource( name: "ConvertToUnmanaged"u8, attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Virtual, signature: MethodSignature.CreateInstance( - returnType: interopReferences.WindowsRuntimeObjectReferenceValue.Import(module).ToValueTypeSignature(), - parameterTypes: [delegateType.Import(module)])) + returnType: interopReferences.WindowsRuntimeObjectReferenceValue.ToValueTypeSignature(), + parameterTypes: [delegateType])) { CilInstructions = { @@ -206,7 +206,7 @@ private static void DerivedEventSource( // Add and implement the 'ConvertToUnmanaged' method eventSourceType.AddMethodImplementation( - declaration: baseEventSourceConvertToUnmanaged.Import(module), + declaration: baseEventSourceConvertToUnmanaged, method: convertToUnmanagedMethod); } } diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IAsyncActionWithProgress1.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IAsyncActionWithProgress1.cs index daee341c9..1d5cc255e 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IAsyncActionWithProgress1.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IAsyncActionWithProgress1.cs @@ -46,7 +46,7 @@ public static void Methods( attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: module.CorLibTypeFactory.Object.ToTypeDefOrRef()) { - Interfaces = { new InterfaceImplementation(interopReferences.IAsyncActionWithProgressMethodsImpl1.MakeGenericReferenceType(progressType).Import(module).ToTypeDefOrRef()) } + Interfaces = { new InterfaceImplementation(interopReferences.IAsyncActionWithProgressMethodsImpl1.MakeGenericReferenceType(progressType).ToTypeDefOrRef()) } }; module.TopLevelTypes.Add(actionMethodsType); @@ -66,7 +66,7 @@ public static void Methods( module: module); actionMethodsType.AddMethodImplementation( - declaration: interopReferences.IAsyncActionWithProgressMethodsImpl1get_Progress(progressType).Import(module), + declaration: interopReferences.IAsyncActionWithProgressMethodsImpl1get_Progress(progressType), method: get_ProgressMethod); // Get the generated 'ConvertToUnmanaged' method to marshal the 'AsyncActionProgressHandler' instance to native @@ -84,7 +84,7 @@ public static void Methods( module: module); actionMethodsType.AddMethodImplementation( - declaration: interopReferences.IAsyncActionWithProgressMethodsImpl1set_Progress(progressType).Import(module), + declaration: interopReferences.IAsyncActionWithProgressMethodsImpl1set_Progress(progressType), method: set_ProgressMethod); // Get the generated 'ConvertToManaged' method to marshal the 'AsyncActionWithProgressCompletedHandler' instance to managed @@ -102,7 +102,7 @@ public static void Methods( module: module); actionMethodsType.AddMethodImplementation( - declaration: interopReferences.IAsyncActionWithProgressMethodsImpl1get_Completed(progressType).Import(module), + declaration: interopReferences.IAsyncActionWithProgressMethodsImpl1get_Completed(progressType), method: get_CompletedMethod); // Get the generated 'ConvertToUnmanaged' method to marshal the 'AsyncActionWithProgressCompletedHandler' instance to native @@ -120,7 +120,7 @@ public static void Methods( module: module); actionMethodsType.AddMethodImplementation( - declaration: interopReferences.IAsyncActionWithProgressMethodsImpl1set_Completed(progressType).Import(module), + declaration: interopReferences.IAsyncActionWithProgressMethodsImpl1set_Completed(progressType), method: set_CompletedMethod); // Define the 'GetResults' method as follows: @@ -131,18 +131,18 @@ public static void Methods( attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Static, signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Void, - parameterTypes: [interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature()])) + parameterTypes: [interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature()])) { CilInstructions = { { Ldarg_0 }, - { Call, interopReferences.IAsyncActionWithProgressGetResults.Import(module) }, + { Call, interopReferences.IAsyncActionWithProgressGetResults }, { Ret } } }; actionMethodsType.AddMethodImplementation( - declaration: interopReferences.IAsyncActionWithProgressMethodsImpl1GetResults(progressType).Import(module), + declaration: interopReferences.IAsyncActionWithProgressMethodsImpl1GetResults(progressType), method: getResultsMethod); } @@ -277,11 +277,11 @@ public static void InterfaceImpl( attributes: TypeAttributes.Interface | TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: null) { - CustomAttributes = { new CustomAttribute(interopReferences.DynamicInterfaceCastableImplementationAttribute_ctor.Import(module)) }, + CustomAttributes = { new CustomAttribute(interopReferences.DynamicInterfaceCastableImplementationAttribute_ctor) }, Interfaces = { - new InterfaceImplementation(actionType.Import(module).ToTypeDefOrRef()), - new InterfaceImplementation(interopReferences.IAsyncInfo.Import(module)) + new InterfaceImplementation(actionType.ToTypeDefOrRef()), + new InterfaceImplementation(interopReferences.IAsyncInfo) } }; @@ -294,11 +294,11 @@ public static void InterfaceImpl( MethodDefinition get_ProgressMethod = new( name: $"Windows.Foundation.IAsyncActionWithProgress<{progressType.FullName}>.get_Progress", attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceAccessorMethod, - signature: MethodSignature.CreateInstance(interopReferences.AsyncActionProgressHandler1.MakeGenericReferenceType(progressType).Import(module))); + signature: MethodSignature.CreateInstance(interopReferences.AsyncActionProgressHandler1.MakeGenericReferenceType(progressType))); // Add and implement the 'get_Progress' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IAsyncActionWithProgress1get_Progress(progressType).Import(module), + declaration: interopReferences.IAsyncActionWithProgress1get_Progress(progressType), method: get_ProgressMethod); // Create a body for the 'get_Progress' method @@ -315,11 +315,11 @@ public static void InterfaceImpl( attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceAccessorMethod, signature: MethodSignature.CreateInstance( returnType: module.CorLibTypeFactory.Void, - parameterTypes: [interopReferences.AsyncActionProgressHandler1.MakeGenericReferenceType(progressType).Import(module)])); + parameterTypes: [interopReferences.AsyncActionProgressHandler1.MakeGenericReferenceType(progressType)])); // Add and implement the 'set_Progress' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IAsyncActionWithProgress1set_Progress(progressType).Import(module), + declaration: interopReferences.IAsyncActionWithProgress1set_Progress(progressType), method: set_ProgressMethod); // Create a body for the 'set_Progress' method @@ -349,11 +349,11 @@ public static void InterfaceImpl( MethodDefinition get_CompletedMethod = new( name: $"Windows.Foundation.IAsyncActionWithProgress<{progressType.FullName}>.get_Completed", attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceAccessorMethod, - signature: MethodSignature.CreateInstance(interopReferences.AsyncActionWithProgressCompletedHandler1.MakeGenericReferenceType(progressType).Import(module))); + signature: MethodSignature.CreateInstance(interopReferences.AsyncActionWithProgressCompletedHandler1.MakeGenericReferenceType(progressType))); // Add and implement the 'get_Completed' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IAsyncActionWithProgress1get_Completed(progressType).Import(module), + declaration: interopReferences.IAsyncActionWithProgress1get_Completed(progressType), method: get_CompletedMethod); // Create a body for the 'get_Completed' method @@ -370,11 +370,11 @@ public static void InterfaceImpl( attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceAccessorMethod, signature: MethodSignature.CreateInstance( returnType: module.CorLibTypeFactory.Void, - parameterTypes: [interopReferences.AsyncActionWithProgressCompletedHandler1.MakeGenericReferenceType(progressType).Import(module)])); + parameterTypes: [interopReferences.AsyncActionWithProgressCompletedHandler1.MakeGenericReferenceType(progressType)])); // Add and implement the 'set_Completed' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IAsyncActionWithProgress1set_Completed(progressType).Import(module), + declaration: interopReferences.IAsyncActionWithProgress1set_Completed(progressType), method: set_CompletedMethod); // Create a body for the 'set_Completed' method @@ -405,7 +405,7 @@ public static void InterfaceImpl( // Add and implement the 'GetResults' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IAsyncActionWithProgress1GetResults(progressType).Import(module), + declaration: interopReferences.IAsyncActionWithProgress1GetResults(progressType), method: getResultsMethod); // Create a body for the 'GetResults' method diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IAsyncOperation1.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IAsyncOperation1.cs index e45035665..894951f39 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IAsyncOperation1.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IAsyncOperation1.cs @@ -45,7 +45,7 @@ public static void Methods( attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: module.CorLibTypeFactory.Object.ToTypeDefOrRef()) { - Interfaces = { new InterfaceImplementation(interopReferences.IAsyncOperationMethodsImpl1.MakeGenericReferenceType(resultType).Import(module).ToTypeDefOrRef()) } + Interfaces = { new InterfaceImplementation(interopReferences.IAsyncOperationMethodsImpl1.MakeGenericReferenceType(resultType).ToTypeDefOrRef()) } }; module.TopLevelTypes.Add(operationMethodsType); @@ -65,7 +65,7 @@ public static void Methods( module: module); operationMethodsType.AddMethodImplementation( - declaration: interopReferences.IAsyncOperationMethodsImpl1get_Completed(resultType).Import(module), + declaration: interopReferences.IAsyncOperationMethodsImpl1get_Completed(resultType), method: get_CompletedMethod); // Get the generated 'ConvertToUnmanaged' method to marshal the 'AsyncOperationCompletedHandler' instance to native @@ -83,7 +83,7 @@ public static void Methods( module: module); operationMethodsType.AddMethodImplementation( - declaration: interopReferences.IAsyncOperationMethodsImpl1set_Completed(resultType).Import(module), + declaration: interopReferences.IAsyncOperationMethodsImpl1set_Completed(resultType), method: set_CompletedMethod); // Define the 'GetResults' method: @@ -95,7 +95,7 @@ public static void Methods( module: module); operationMethodsType.AddMethodImplementation( - declaration: interopReferences.IAsyncOperationMethodsImpl1GetResults(resultType).Import(module), + declaration: interopReferences.IAsyncOperationMethodsImpl1GetResults(resultType), method: getResultsMethod); } @@ -230,11 +230,11 @@ public static void InterfaceImpl( attributes: TypeAttributes.Interface | TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: null) { - CustomAttributes = { new CustomAttribute(interopReferences.DynamicInterfaceCastableImplementationAttribute_ctor.Import(module)) }, + CustomAttributes = { new CustomAttribute(interopReferences.DynamicInterfaceCastableImplementationAttribute_ctor) }, Interfaces = { - new InterfaceImplementation(operationType.Import(module).ToTypeDefOrRef()), - new InterfaceImplementation(interopReferences.IAsyncInfo.Import(module)) + new InterfaceImplementation(operationType.ToTypeDefOrRef()), + new InterfaceImplementation(interopReferences.IAsyncInfo) } }; @@ -247,11 +247,11 @@ public static void InterfaceImpl( MethodDefinition get_CompletedMethod = new( name: $"Windows.Foundation.IAsyncOperation<{resultType.FullName}>.get_Completed", attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceAccessorMethod, - signature: MethodSignature.CreateInstance(interopReferences.AsyncOperationCompletedHandler1.MakeGenericReferenceType(resultType).Import(module))); + signature: MethodSignature.CreateInstance(interopReferences.AsyncOperationCompletedHandler1.MakeGenericReferenceType(resultType))); // Add and implement the 'get_Completed' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IAsyncOperation1get_Completed(resultType).Import(module), + declaration: interopReferences.IAsyncOperation1get_Completed(resultType), method: get_CompletedMethod); // Create a body for the 'get_Completed' method @@ -268,11 +268,11 @@ public static void InterfaceImpl( attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceAccessorMethod, signature: MethodSignature.CreateInstance( returnType: module.CorLibTypeFactory.Void, - parameterTypes: [interopReferences.AsyncOperationCompletedHandler1.MakeGenericReferenceType(resultType).Import(module)])); + parameterTypes: [interopReferences.AsyncOperationCompletedHandler1.MakeGenericReferenceType(resultType)])); // Add and implement the 'set_Completed' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IAsyncOperation1set_Completed(resultType).Import(module), + declaration: interopReferences.IAsyncOperation1set_Completed(resultType), method: set_CompletedMethod); // Create a body for the 'set_Completed' method @@ -299,11 +299,11 @@ public static void InterfaceImpl( MethodDefinition getResultsMethod = new( name: $"Windows.Foundation.IAsyncOperation<{resultType.FullName}>.GetResults", attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceMethod, - signature: MethodSignature.CreateInstance(resultType.Import(module))); + signature: MethodSignature.CreateInstance(resultType)); // Add and implement the 'GetResults' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IAsyncOperation1GetResults(resultType).Import(module), + declaration: interopReferences.IAsyncOperation1GetResults(resultType), method: getResultsMethod); // Create a body for the 'GetResults' method diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IAsyncOperationWithProgress2.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IAsyncOperationWithProgress2.cs index 0d856babb..71e719925 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IAsyncOperationWithProgress2.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IAsyncOperationWithProgress2.cs @@ -46,7 +46,7 @@ public static void Methods( attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: module.CorLibTypeFactory.Object.ToTypeDefOrRef()) { - Interfaces = { new InterfaceImplementation(interopReferences.IAsyncOperationWithProgressMethodsImpl2.MakeGenericReferenceType(resultType, progressType).Import(module).ToTypeDefOrRef()) } + Interfaces = { new InterfaceImplementation(interopReferences.IAsyncOperationWithProgressMethodsImpl2.MakeGenericReferenceType(resultType, progressType).ToTypeDefOrRef()) } }; module.TopLevelTypes.Add(operationMethodsType); @@ -70,7 +70,7 @@ public static void Methods( module: module); operationMethodsType.AddMethodImplementation( - declaration: interopReferences.IAsyncOperationWithProgressMethodsImpl2get_Progress(resultType, progressType).Import(module), + declaration: interopReferences.IAsyncOperationWithProgressMethodsImpl2get_Progress(resultType, progressType), method: get_ProgressMethod); // Get the generated 'ConvertToUnmanaged' method to marshal the 'AsyncOperationProgressHandler' instance to native @@ -88,7 +88,7 @@ public static void Methods( module: module); operationMethodsType.AddMethodImplementation( - declaration: interopReferences.IAsyncOperationWithProgressMethodsImpl2set_Progress(resultType, progressType).Import(module), + declaration: interopReferences.IAsyncOperationWithProgressMethodsImpl2set_Progress(resultType, progressType), method: set_ProgressMethod); // Get the generated 'ConvertToManaged' method to marshal the 'AsyncOperationWithProgressCompletedHandler' instance to managed @@ -106,7 +106,7 @@ public static void Methods( module: module); operationMethodsType.AddMethodImplementation( - declaration: interopReferences.IAsyncOperationWithProgressMethodsImpl2get_Completed(resultType, progressType).Import(module), + declaration: interopReferences.IAsyncOperationWithProgressMethodsImpl2get_Completed(resultType, progressType), method: get_CompletedMethod); // Get the generated 'ConvertToUnmanaged' method to marshal the 'AsyncOperationWithProgressCompletedHandler' instance to native @@ -124,7 +124,7 @@ public static void Methods( module: module); operationMethodsType.AddMethodImplementation( - declaration: interopReferences.IAsyncOperationWithProgressMethodsImpl2set_Completed(resultType, progressType).Import(module), + declaration: interopReferences.IAsyncOperationWithProgressMethodsImpl2set_Completed(resultType, progressType), method: set_CompletedMethod); // Define the 'GetResults' method: @@ -136,7 +136,7 @@ public static void Methods( module: module); operationMethodsType.AddMethodImplementation( - declaration: interopReferences.IAsyncOperationWithProgressMethodsImpl2GetResults(resultType, progressType).Import(module), + declaration: interopReferences.IAsyncOperationWithProgressMethodsImpl2GetResults(resultType, progressType), method: getResultsMethod); } @@ -273,11 +273,11 @@ public static void InterfaceImpl( attributes: TypeAttributes.Interface | TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: null) { - CustomAttributes = { new CustomAttribute(interopReferences.DynamicInterfaceCastableImplementationAttribute_ctor.Import(module)) }, + CustomAttributes = { new CustomAttribute(interopReferences.DynamicInterfaceCastableImplementationAttribute_ctor) }, Interfaces = { - new InterfaceImplementation(operationType.Import(module).ToTypeDefOrRef()), - new InterfaceImplementation(interopReferences.IAsyncInfo.Import(module)) + new InterfaceImplementation(operationType.ToTypeDefOrRef()), + new InterfaceImplementation(interopReferences.IAsyncInfo) } }; @@ -294,11 +294,11 @@ public static void InterfaceImpl( MethodDefinition get_ProgressMethod = new( name: $"Windows.Foundation.IAsyncOperationWithProgress<{resultType.FullName},{progressType.FullName}>.get_Progress", attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceAccessorMethod, - signature: MethodSignature.CreateInstance(asyncOperationProgressHandlerType.Import(module))); + signature: MethodSignature.CreateInstance(asyncOperationProgressHandlerType)); // Add and implement the 'get_Progress' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IAsyncOperationWithProgress2get_Progress(resultType, progressType).Import(module), + declaration: interopReferences.IAsyncOperationWithProgress2get_Progress(resultType, progressType), method: get_ProgressMethod); // Create a body for the 'get_Progress' method @@ -315,11 +315,11 @@ public static void InterfaceImpl( attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceAccessorMethod, signature: MethodSignature.CreateInstance( returnType: module.CorLibTypeFactory.Void, - parameterTypes: [asyncOperationProgressHandlerType.Import(module)])); + parameterTypes: [asyncOperationProgressHandlerType])); // Add and implement the 'set_Progress' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IAsyncOperationWithProgress2set_Progress(resultType, progressType).Import(module), + declaration: interopReferences.IAsyncOperationWithProgress2set_Progress(resultType, progressType), method: set_ProgressMethod); // Create a body for the 'set_Progress' method @@ -349,11 +349,11 @@ public static void InterfaceImpl( MethodDefinition get_CompletedMethod = new( name: $"Windows.Foundation.IAsyncOperationWithProgress<{resultType.FullName},{progressType.FullName}>.get_Completed", attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceAccessorMethod, - signature: MethodSignature.CreateInstance(asyncOperationWithProgressCompletedHandlerType.Import(module))); + signature: MethodSignature.CreateInstance(asyncOperationWithProgressCompletedHandlerType)); // Add and implement the 'get_Completed' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IAsyncOperationWithProgress2get_Completed(resultType, progressType).Import(module), + declaration: interopReferences.IAsyncOperationWithProgress2get_Completed(resultType, progressType), method: get_CompletedMethod); // Create a body for the 'get_Completed' method @@ -370,11 +370,11 @@ public static void InterfaceImpl( attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceAccessorMethod, signature: MethodSignature.CreateInstance( returnType: module.CorLibTypeFactory.Void, - parameterTypes: [asyncOperationWithProgressCompletedHandlerType.Import(module)])); + parameterTypes: [asyncOperationWithProgressCompletedHandlerType])); // Add and implement the 'set_Completed' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IAsyncOperationWithProgress2set_Completed(resultType, progressType).Import(module), + declaration: interopReferences.IAsyncOperationWithProgress2set_Completed(resultType, progressType), method: set_CompletedMethod); // Create a body for the 'set_Completed' method @@ -401,11 +401,11 @@ public static void InterfaceImpl( MethodDefinition getResultsMethod = new( name: $"Windows.Foundation.IAsyncOperationWithProgress<{resultType.FullName},{progressType.FullName}>.GetResults", attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceMethod, - signature: MethodSignature.CreateInstance(resultType.Import(module))); + signature: MethodSignature.CreateInstance(resultType)); // Add and implement the 'GetResults' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IAsyncOperationWithProgress2GetResults(resultType, progressType).Import(module), + declaration: interopReferences.IAsyncOperationWithProgress2GetResults(resultType, progressType), method: getResultsMethod); // Create a body for the 'GetResults' method diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IDictionary2.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IDictionary2.cs index 6f05e21aa..d1c5d8fa9 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IDictionary2.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IDictionary2.cs @@ -45,7 +45,7 @@ public static void Interface( attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: module.CorLibTypeFactory.Object.ToTypeDefOrRef()) { - Interfaces = { new InterfaceImplementation(interopReferences.IWindowsRuntimeInterface.Import(module)) } + Interfaces = { new InterfaceImplementation(interopReferences.IWindowsRuntimeInterface) } }; module.TopLevelTypes.Add(interfaceType); @@ -65,7 +65,7 @@ public static void Interface( // Add and implement the 'get_IID' method interfaceType.AddMethodImplementation( - declaration: interopReferences.IWindowsRuntimeInterfaceget_IID.Import(module), + declaration: interopReferences.IWindowsRuntimeInterfaceget_IID, method: get_IidMethod2); } @@ -212,7 +212,7 @@ public static void IMapMethods( attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: module.CorLibTypeFactory.Object.ToTypeDefOrRef()) { - Interfaces = { new InterfaceImplementation(interopReferences.IMapMethodsImpl2.MakeGenericReferenceType(keyType, valueType).Import(module).ToTypeDefOrRef()) } + Interfaces = { new InterfaceImplementation(interopReferences.IMapMethodsImpl2.MakeGenericReferenceType(keyType, valueType).ToTypeDefOrRef()) } }; module.TopLevelTypes.Add(mapMethodsType); @@ -229,13 +229,13 @@ public static void IMapMethods( signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Boolean, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), - keyType.Import(module)])) + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), + keyType])) { NoInlining = true }; // Add and implement the 'HasKey' method mapMethodsType.AddMethodImplementation( - declaration: interopReferences.IMapMethodsImpl2HasKey(keyType, valueType).Import(module), + declaration: interopReferences.IMapMethodsImpl2HasKey(keyType, valueType), method: hasKeyMethod); // Create a method body for the 'HasKey' method @@ -251,15 +251,15 @@ public static void IMapMethods( name: "Lookup"u8, attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Static, signature: MethodSignature.CreateStatic( - returnType: valueType.Import(module), + returnType: valueType, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), - keyType.Import(module)])) + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), + keyType])) { NoInlining = true }; // Add and implement the 'Lookup' method mapMethodsType.AddMethodImplementation( - declaration: interopReferences.IMapMethodsImpl2Lookup(keyType, valueType).Import(module), + declaration: interopReferences.IMapMethodsImpl2Lookup(keyType, valueType), method: lookupMethod); // Create a method body for the 'Lookup' method @@ -277,14 +277,14 @@ public static void IMapMethods( signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Boolean, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), - keyType.Import(module), - valueType.Import(module)])) + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), + keyType, + valueType])) { NoInlining = true }; // Add and implement the 'Insert' method mapMethodsType.AddMethodImplementation( - declaration: interopReferences.IMapMethodsImpl2Insert(keyType, valueType).Import(module), + declaration: interopReferences.IMapMethodsImpl2Insert(keyType, valueType), method: insertMethod); // Create a method body for the 'Insert' method @@ -302,13 +302,13 @@ public static void IMapMethods( signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Boolean, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), - keyType.Import(module)])) + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), + keyType])) { NoInlining = true }; // Add and implement the 'Remove' method mapMethodsType.AddMethodImplementation( - declaration: interopReferences.IMapMethodsImpl2Remove(keyType, valueType).Import(module), + declaration: interopReferences.IMapMethodsImpl2Remove(keyType, valueType), method: removeMethod); // Create a method body for the 'Remove' method @@ -354,16 +354,16 @@ public static void IDictionaryMethods( name: "Item"u8, attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Static, signature: MethodSignature.CreateStatic( - returnType: valueType.Import(module), + returnType: valueType, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), - keyType.Import(module)])) + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), + keyType])) { CilInstructions = { { Ldarg_0 }, { Ldarg_1 }, - { Call, interopReferences.IDictionaryMethods2get_Item(keyType, valueType, mapMethodsType).Import(module) }, + { Call, interopReferences.IDictionaryMethods2get_Item(keyType, valueType, mapMethodsType) }, { Ret } } }; @@ -379,16 +379,16 @@ public static void IDictionaryMethods( signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Void, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), - keyType.Import(module), - valueType.Import(module)])) + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), + keyType, + valueType])) { CilInstructions = { { Ldarg_0 }, { Ldarg_1 }, { Ldarg_2 }, - { Call, interopReferences.IDictionaryMethods2set_Item(keyType, valueType, mapMethodsType).Import(module) }, + { Call, interopReferences.IDictionaryMethods2set_Item(keyType, valueType, mapMethodsType) }, { Ret } } }; @@ -404,16 +404,16 @@ public static void IDictionaryMethods( signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Void, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), - keyType.Import(module), - valueType.Import(module)])) + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), + keyType, + valueType])) { CilInstructions = { { Ldarg_0 }, { Ldarg_1 }, { Ldarg_2 }, - { Call, interopReferences.IDictionaryMethods2Add(keyType, valueType, mapMethodsType).Import(module) }, + { Call, interopReferences.IDictionaryMethods2Add(keyType, valueType, mapMethodsType) }, { Ret } } }; @@ -429,14 +429,14 @@ public static void IDictionaryMethods( signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Boolean, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), - keyType.Import(module)])) + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), + keyType])) { CilInstructions = { { Ldarg_0 }, { Ldarg_1 }, - { Call, interopReferences.IDictionaryMethods2Remove(keyType, valueType, mapMethodsType).Import(module) }, + { Call, interopReferences.IDictionaryMethods2Remove(keyType, valueType, mapMethodsType) }, { Ret } } }; @@ -451,12 +451,12 @@ public static void IDictionaryMethods( attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Static, signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Int32, - parameterTypes: [interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature()])) + parameterTypes: [interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature()])) { CilInstructions = { { Ldarg_0 }, - { Call, interopReferences.IDictionaryMethodsCount.Import(module) }, + { Call, interopReferences.IDictionaryMethodsCount }, { Ret } } }; @@ -472,14 +472,14 @@ public static void IDictionaryMethods( signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Boolean, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), - keyType.Import(module)])) + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), + keyType])) { CilInstructions = { { Ldarg_0 }, { Ldarg_1 }, - { Call, interopReferences.IDictionaryMethods2ContainsKey(keyType, valueType, mapMethodsType).Import(module) }, + { Call, interopReferences.IDictionaryMethods2ContainsKey(keyType, valueType, mapMethodsType) }, { Ret } } }; @@ -495,9 +495,9 @@ public static void IDictionaryMethods( signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Boolean, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), - keyType.Import(module), - valueType.Import(module).MakeByReferenceType()])) + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), + keyType, + valueType.MakeByReferenceType()])) { CilOutParameterIndices = [3], CilInstructions = @@ -505,7 +505,7 @@ public static void IDictionaryMethods( { Ldarg_0 }, { Ldarg_1 }, { Ldarg_2 }, - { Call, interopReferences.IDictionaryMethods2TryGetValue(keyType, valueType, mapMethodsType).Import(module) }, + { Call, interopReferences.IDictionaryMethods2TryGetValue(keyType, valueType, mapMethodsType) }, { Ret } } }; @@ -521,14 +521,14 @@ public static void IDictionaryMethods( signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Void, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), - interopReferences.KeyValuePair2.MakeGenericValueType(keyType, valueType).Import(module)])) + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), + interopReferences.KeyValuePair2.MakeGenericValueType(keyType, valueType)])) { CilInstructions = { { Ldarg_0 }, { Ldarg_1 }, - { Call, interopReferences.IDictionaryMethods2AddKeyValuePair(keyType, valueType, mapMethodsType).Import(module) }, + { Call, interopReferences.IDictionaryMethods2AddKeyValuePair(keyType, valueType, mapMethodsType) }, { Ret } } }; @@ -544,14 +544,14 @@ public static void IDictionaryMethods( signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Boolean, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), - interopReferences.KeyValuePair2.MakeGenericValueType(keyType, valueType).Import(module)])) + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), + interopReferences.KeyValuePair2.MakeGenericValueType(keyType, valueType)])) { CilInstructions = { { Ldarg_0 }, { Ldarg_1 }, - { Call, interopReferences.IDictionaryMethods2RemoveKeyValuePair(keyType, valueType, mapMethodsType).Import(module) }, + { Call, interopReferences.IDictionaryMethods2RemoveKeyValuePair(keyType, valueType, mapMethodsType) }, { Ret } } }; @@ -566,12 +566,12 @@ public static void IDictionaryMethods( attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Static, signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Void, - parameterTypes: [interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature()])) + parameterTypes: [interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature()])) { CilInstructions = { { Ldarg_0 }, - { Call, interopReferences.IDictionaryMethodsClear.Import(module) }, + { Call, interopReferences.IDictionaryMethodsClear }, { Ret } } }; @@ -587,14 +587,14 @@ public static void IDictionaryMethods( signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Boolean, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), - interopReferences.KeyValuePair2.MakeGenericValueType(keyType, valueType).Import(module)])) + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), + interopReferences.KeyValuePair2.MakeGenericValueType(keyType, valueType)])) { CilInstructions = { { Ldarg_0 }, { Ldarg_1 }, - { Call, interopReferences.IDictionaryMethods2Contains(keyType, valueType, mapMethodsType).Import(module) }, + { Call, interopReferences.IDictionaryMethods2Contains(keyType, valueType, mapMethodsType) }, { Ret } } }; @@ -619,9 +619,9 @@ public static void IDictionaryMethods( signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Void, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), - interopReferences.KeyValuePair2.MakeGenericValueType(keyType, valueType).Import(module).MakeSzArrayType(), + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), + interopReferences.KeyValuePair2.MakeGenericValueType(keyType, valueType).MakeSzArrayType(), module.CorLibTypeFactory.Int32])) { CilInstructions = @@ -630,7 +630,7 @@ public static void IDictionaryMethods( { Ldarg_1 }, { Ldarg_2 }, { Ldarg_3 }, - { Call, interopReferences.IDictionaryMethods2CopyTo(keyType, valueType, mapMethodsType, iterableMethodsType).Import(module) }, + { Call, interopReferences.IDictionaryMethods2CopyTo(keyType, valueType, mapMethodsType, iterableMethodsType) }, { Ret } } }; @@ -788,13 +788,13 @@ public static void InterfaceImpl( attributes: TypeAttributes.Interface | TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: null) { - CustomAttributes = { new CustomAttribute(interopReferences.DynamicInterfaceCastableImplementationAttribute_ctor.Import(module)) }, + CustomAttributes = { new CustomAttribute(interopReferences.DynamicInterfaceCastableImplementationAttribute_ctor) }, Interfaces = { - new InterfaceImplementation(dictionaryType.Import(module).ToTypeDefOrRef()), - new InterfaceImplementation(collectionType.Import(module).ToTypeDefOrRef()), - new InterfaceImplementation(enumerableType.Import(module).ToTypeDefOrRef()), - new InterfaceImplementation(interopReferences.IEnumerable.Import(module)) + new InterfaceImplementation(dictionaryType.ToTypeDefOrRef()), + new InterfaceImplementation(collectionType.ToTypeDefOrRef()), + new InterfaceImplementation(enumerableType.ToTypeDefOrRef()), + new InterfaceImplementation(interopReferences.IEnumerable) } }; @@ -807,11 +807,11 @@ public static void InterfaceImpl( MethodDefinition get_ItemMethod = new( name: $"System.Collections.Generic.IDictionary<{keyType.FullName},{valueType.FullName}>.get_Item", attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceAccessorMethod, - signature: MethodSignature.CreateInstance(valueType.Import(module), keyType.Import(module))); + signature: MethodSignature.CreateInstance(valueType, keyType)); // Add and implement the 'get_Item' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IDictionary2get_Item(keyType, valueType).Import(module), + declaration: interopReferences.IDictionary2get_Item(keyType, valueType), method: get_ItemMethod); // Create a body for the 'get_Item' method @@ -828,11 +828,11 @@ public static void InterfaceImpl( attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceAccessorMethod, signature: MethodSignature.CreateInstance( returnType: module.CorLibTypeFactory.Void, - parameterTypes: [keyType.Import(module), valueType.Import(module)])); + parameterTypes: [keyType, valueType])); // Add and implement the 'set_Item' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IDictionary2set_Item(keyType, valueType).Import(module), + declaration: interopReferences.IDictionary2set_Item(keyType, valueType), method: set_ItemMethod); // Create a body for the 'set_Item' method @@ -859,19 +859,19 @@ public static void InterfaceImpl( MethodDefinition get_KeysMethod = new( name: $"System.Collections.Generic.IDictionary<{keyType.FullName},{valueType.FullName}>.get_Keys", attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceAccessorMethod, - signature: MethodSignature.CreateInstance(interopReferences.ICollection1.MakeGenericReferenceType(keyType).Import(module))) + signature: MethodSignature.CreateInstance(interopReferences.ICollection1.MakeGenericReferenceType(keyType))) { CilInstructions = { { Ldarg_0 }, - { Newobj, interopReferences.DictionaryKeyCollection2_ctor(keyType, valueType).Import(module) }, + { Newobj, interopReferences.DictionaryKeyCollection2_ctor(keyType, valueType) }, { Ret } } }; // Add and implement the 'get_Keys' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IDictionary2get_Keys(keyType, valueType).Import(module), + declaration: interopReferences.IDictionary2get_Keys(keyType, valueType), method: get_KeysMethod); // Create the 'Keys' property @@ -887,19 +887,19 @@ public static void InterfaceImpl( MethodDefinition get_ValuesMethod = new( name: $"System.Collections.Generic.IDictionary<{keyType.FullName},{valueType.FullName}>.get_Values", attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceAccessorMethod, - signature: MethodSignature.CreateInstance(interopReferences.ICollection1.MakeGenericReferenceType(valueType).Import(module))) + signature: MethodSignature.CreateInstance(interopReferences.ICollection1.MakeGenericReferenceType(valueType))) { CilInstructions = { { Ldarg_0 }, - { Newobj, interopReferences.DictionaryValueCollection2_ctor(keyType, valueType).Import(module) }, + { Newobj, interopReferences.DictionaryValueCollection2_ctor(keyType, valueType) }, { Ret } } }; // Add and implement the 'get_Values' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IDictionary2get_Values(keyType, valueType).Import(module), + declaration: interopReferences.IDictionary2get_Values(keyType, valueType), method: get_ValuesMethod); // Create the 'Values' property @@ -917,11 +917,11 @@ public static void InterfaceImpl( attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceMethod, signature: MethodSignature.CreateInstance( returnType: module.CorLibTypeFactory.Boolean, - parameterTypes: [keyType.Import(module)])); + parameterTypes: [keyType])); // Add and implement the 'ContainsKey' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IDictionary2ContainsKey(keyType, valueType).Import(module), + declaration: interopReferences.IDictionary2ContainsKey(keyType, valueType), method: containsKeyMethod); // Create a body for the 'ContainsKey' method @@ -938,12 +938,12 @@ public static void InterfaceImpl( attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceMethod, signature: MethodSignature.CreateInstance( returnType: module.CorLibTypeFactory.Boolean, - parameterTypes: [keyType.Import(module), valueType.Import(module).MakeByReferenceType()])) + parameterTypes: [keyType, valueType.MakeByReferenceType()])) { CilOutParameterIndices = [2] }; // Add and implement the 'TryGetValue' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IDictionary2TryGetValue(keyType, valueType).Import(module), + declaration: interopReferences.IDictionary2TryGetValue(keyType, valueType), method: tryGetValueMethod); // Create a body for the 'TryGetValue' method @@ -965,11 +965,11 @@ public static void InterfaceImpl( attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceMethod, signature: MethodSignature.CreateInstance( returnType: module.CorLibTypeFactory.Void, - parameterTypes: [keyType.Import(module), valueType.Import(module)])); + parameterTypes: [keyType, valueType])); // Add and implement the 'Add' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IDictionary2Add(keyType, valueType).Import(module), + declaration: interopReferences.IDictionary2Add(keyType, valueType), method: addMethod); // Create a body for the 'Add' method @@ -986,11 +986,11 @@ public static void InterfaceImpl( attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceMethod, signature: MethodSignature.CreateInstance( returnType: module.CorLibTypeFactory.Boolean, - parameterTypes: [keyType.Import(module)])); + parameterTypes: [keyType])); // Add and implement the 'Remove' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IDictionary2Remove(keyType, valueType).Import(module), + declaration: interopReferences.IDictionary2Remove(keyType, valueType), method: removeMethod); // Create a body for the 'Remove' method @@ -1007,11 +1007,11 @@ public static void InterfaceImpl( attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceMethod, signature: MethodSignature.CreateInstance( returnType: module.CorLibTypeFactory.Void, - parameterTypes: [keyValuePairType.Import(module)])); + parameterTypes: [keyValuePairType])); // Add and implement the 'Add' ('KeyValuePair<,>') method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.ICollection1Add(keyValuePairType).Import(module), + declaration: interopReferences.ICollection1Add(keyValuePairType), method: addKeyValuePairMethod); // Create a body for the 'Add' ('KeyValuePair<,>') method @@ -1028,11 +1028,11 @@ public static void InterfaceImpl( attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceMethod, signature: MethodSignature.CreateInstance( returnType: module.CorLibTypeFactory.Boolean, - parameterTypes: [keyValuePairType.Import(module)])); + parameterTypes: [keyValuePairType])); // Add and implement the 'Remove' ('KeyValuePair<,>') method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.ICollection1Remove(keyValuePairType).Import(module), + declaration: interopReferences.ICollection1Remove(keyValuePairType), method: removeKeyValuePairMethod); // Create a body for the 'Remove' ('KeyValuePair<,>') method @@ -1049,11 +1049,11 @@ public static void InterfaceImpl( attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceMethod, signature: MethodSignature.CreateInstance( returnType: module.CorLibTypeFactory.Boolean, - parameterTypes: [keyValuePairType.Import(module)])); + parameterTypes: [keyValuePairType])); // Add and implement the 'Contains' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.ICollection1Contains(keyValuePairType).Import(module), + declaration: interopReferences.ICollection1Contains(keyValuePairType), method: containsMethod); // Create a body for the 'Contains' method @@ -1071,28 +1071,28 @@ public static void InterfaceImpl( signature: MethodSignature.CreateInstance( returnType: module.CorLibTypeFactory.Void, parameterTypes: [ - keyValuePairType.MakeSzArrayType().Import(module), + keyValuePairType.MakeSzArrayType(), module.CorLibTypeFactory.Int32])) { // Create a body for the 'CopyTo' method. This method is special: we also need to pass a 'WindowsRuntimeObjectReference' // for the 'IEnumerable>' interface, as it needs to enumerate the key-value pairs. So here we // are emitting code manually, to save the current 'WindowsRuntimeObject', resolve the two references, and forward the call. - CilLocalVariables = { new CilLocalVariable(interopReferences.WindowsRuntimeObject.Import(module).ToReferenceTypeSignature()) }, + CilLocalVariables = { new CilLocalVariable(interopReferences.WindowsRuntimeObject.ToReferenceTypeSignature()) }, CilInstructions = { { Ldarg_0 }, - { Castclass, interopReferences.WindowsRuntimeObject.Import(module) }, + { Castclass, interopReferences.WindowsRuntimeObject }, { Stloc_0 }, { Ldloc_0 }, - { Ldtoken, dictionaryType.Import(module).ToTypeDefOrRef() }, - { Call, interopReferences.TypeGetTypeFromHandle.Import(module) }, - { Callvirt, interopReferences.Typeget_TypeHandle.Import(module) }, - { Callvirt, interopReferences.WindowsRuntimeObjectGetObjectReferenceForInterface.Import(module) }, + { Ldtoken, dictionaryType.ToTypeDefOrRef() }, + { Call, interopReferences.TypeGetTypeFromHandle }, + { Callvirt, interopReferences.Typeget_TypeHandle }, + { Callvirt, interopReferences.WindowsRuntimeObjectGetObjectReferenceForInterface }, { Ldloc_0 }, - { Ldtoken, enumerableType.Import(module).ToTypeDefOrRef() }, - { Call, interopReferences.TypeGetTypeFromHandle.Import(module) }, - { Callvirt, interopReferences.Typeget_TypeHandle.Import(module) }, - { Callvirt, interopReferences.WindowsRuntimeObjectGetObjectReferenceForInterface.Import(module) }, + { Ldtoken, enumerableType.ToTypeDefOrRef() }, + { Call, interopReferences.TypeGetTypeFromHandle }, + { Callvirt, interopReferences.Typeget_TypeHandle }, + { Callvirt, interopReferences.WindowsRuntimeObjectGetObjectReferenceForInterface }, { Ldarg_1 }, { Ldarg_2 }, { Call, dictionaryMethodsType.GetMethod("CopyTo"u8) }, @@ -1102,7 +1102,7 @@ public static void InterfaceImpl( // Add and implement the 'CopyTo' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.ICollection1CopyTo(keyValuePairType).Import(module), + declaration: interopReferences.ICollection1CopyTo(keyValuePairType), method: copyToMethod); // Create the 'get_Count' getter method @@ -1113,7 +1113,7 @@ public static void InterfaceImpl( // Add and implement the 'get_Count' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.ICollection1get_Count(keyValuePairType).Import(module), + declaration: interopReferences.ICollection1get_Count(keyValuePairType), method: get_CountMethod); // Create a body for the 'get_Count' method @@ -1148,7 +1148,7 @@ public static void InterfaceImpl( // Add and implement the 'get_IsReadOnly' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.ICollection1get_IsReadOnly(keyValuePairType).Import(module), + declaration: interopReferences.ICollection1get_IsReadOnly(keyValuePairType), method: get_IsReadOnlyMethod); // Create the 'IsReadOnly' property diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IEnumerable1.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IEnumerable1.cs index 8e8c7750f..779922e74 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IEnumerable1.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IEnumerable1.cs @@ -46,7 +46,7 @@ public static void Interface( attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: module.CorLibTypeFactory.Object.ToTypeDefOrRef()) { - Interfaces = { new InterfaceImplementation(interopReferences.IWindowsRuntimeInterface.Import(module)) } + Interfaces = { new InterfaceImplementation(interopReferences.IWindowsRuntimeInterface) } }; module.TopLevelTypes.Add(interfaceType); @@ -66,7 +66,7 @@ public static void Interface( // Add and implement the 'get_IID' method interfaceType.AddMethodImplementation( - declaration: interopReferences.IWindowsRuntimeInterfaceget_IID.Import(module), + declaration: interopReferences.IWindowsRuntimeInterfaceget_IID, method: get_IidMethod2); } @@ -96,7 +96,7 @@ public static void IIterableMethods( attributes: TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: module.CorLibTypeFactory.Object.ToTypeDefOrRef()) { - Interfaces = { new InterfaceImplementation(interopReferences.IIterableMethodsImpl1.MakeGenericReferenceType(elementType).Import(module).ToTypeDefOrRef()) } + Interfaces = { new InterfaceImplementation(interopReferences.IIterableMethodsImpl1.MakeGenericReferenceType(elementType).ToTypeDefOrRef()) } }; module.TopLevelTypes.Add(iterableMethodsType); @@ -111,13 +111,13 @@ public static void IIterableMethods( name: "First"u8, attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Static, signature: MethodSignature.CreateStatic( - returnType: interopReferences.IEnumerator1.MakeGenericReferenceType(elementType).Import(module), - parameterTypes: [interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature()])) + returnType: interopReferences.IEnumerator1.MakeGenericReferenceType(elementType), + parameterTypes: [interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature()])) { NoInlining = true }; // Add and implement the 'First' method iterableMethodsType.AddMethodImplementation( - declaration: interopReferences.IIterableMethodsImpl1First(elementType).Import(module), + declaration: interopReferences.IIterableMethodsImpl1First(elementType), method: firstMethod); // Get the generated 'ConvertToManaged' method to marshal the 'IEnumerator' instance to managed @@ -130,10 +130,10 @@ public static void IIterableMethods( // [1]: 'void*' (for 'thisPtr') // [2]: 'void*' (the enumerator pointer that was retrieved) // [3]: 'IEnumerator<>' (the marshalled enumerator) - CilLocalVariable loc_0_thisValue = new(interopReferences.WindowsRuntimeObjectReferenceValue.ToValueTypeSignature().Import(module)); + CilLocalVariable loc_0_thisValue = new(interopReferences.WindowsRuntimeObjectReferenceValue.ToValueTypeSignature()); CilLocalVariable loc_1_thisPtr = new(module.CorLibTypeFactory.Void.MakePointerType()); CilLocalVariable loc_2_enumeratorPtr = new(module.CorLibTypeFactory.Void.MakePointerType()); - CilLocalVariable loc_3_enumerator = new(interopReferences.IEnumerator1.MakeGenericReferenceType(elementType).Import(module)); + CilLocalVariable loc_3_enumerator = new(interopReferences.IEnumerator1.MakeGenericReferenceType(elementType)); // Jump labels CilInstruction ldloca_s_0_tryStart = new(Ldloca_S, loc_0_thisValue); @@ -151,25 +151,25 @@ public static void IIterableMethods( { // Initialize 'thisValue' { Ldarg_0 }, - { Callvirt, interopReferences.WindowsRuntimeObjectReferenceAsValue.Import(module) }, + { Callvirt, interopReferences.WindowsRuntimeObjectReferenceAsValue }, { Stloc_0 }, // '.try' code { ldloca_s_0_tryStart }, - { Call, interopReferences.WindowsRuntimeObjectReferenceValueGetThisPtrUnsafe.Import(module) }, + { Call, interopReferences.WindowsRuntimeObjectReferenceValueGetThisPtrUnsafe }, { Stloc_1 }, { Ldloc_1 }, { Ldloca_S, loc_2_enumeratorPtr }, { Ldloc_1 }, { Ldind_I }, { Ldfld, interopDefinitions.IEnumerable1Vftbl.GetField("First"u8) }, - { Calli, WellKnownTypeSignatureFactory.IEnumerable1FirstImpl(interopReferences).Import(module).MakeStandAloneSignature() }, - { Call, interopReferences.RestrictedErrorInfoThrowExceptionForHR.Import(module) }, + { Calli, WellKnownTypeSignatureFactory.IEnumerable1FirstImpl(interopReferences).MakeStandAloneSignature() }, + { Call, interopReferences.RestrictedErrorInfoThrowExceptionForHR }, { Leave_S, nop_finallyEnd.CreateLabel() }, // '.finally' code { ldloca_s_0_finallyStart }, - { Call, interopReferences.WindowsRuntimeObjectReferenceValueDispose.Import(module) }, + { Call, interopReferences.WindowsRuntimeObjectReferenceValueDispose }, { Endfinally }, { nop_finallyEnd }, @@ -179,7 +179,7 @@ public static void IIterableMethods( { Stloc_3 }, { Leave_S, ldloc_3_finallyEnd.CreateLabel() }, { ldloc_2_finallyStart }, - { Call, interopReferences.WindowsRuntimeUnknownMarshallerFree.Import(module) }, + { Call, interopReferences.WindowsRuntimeUnknownMarshallerFree }, { Endfinally }, { ldloc_3_finallyEnd }, { Ret } @@ -244,8 +244,8 @@ public static void IEnumerableMethods( name: "GetEnumerator"u8, attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Static, signature: MethodSignature.CreateStatic( - returnType: interopReferences.IEnumerator1.MakeGenericReferenceType(elementType).Import(module), - parameterTypes: [interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature()])); + returnType: interopReferences.IEnumerator1.MakeGenericReferenceType(elementType), + parameterTypes: [interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature()])); enumerableMethodsType.Methods.Add(getEnumeratorMethod); @@ -397,11 +397,11 @@ public static void InterfaceImpl( attributes: TypeAttributes.Interface | TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: null) { - CustomAttributes = { new CustomAttribute(interopReferences.DynamicInterfaceCastableImplementationAttribute_ctor.Import(module)) }, + CustomAttributes = { new CustomAttribute(interopReferences.DynamicInterfaceCastableImplementationAttribute_ctor) }, Interfaces = { - new InterfaceImplementation(enumerableType.Import(module).ToTypeDefOrRef()), - new InterfaceImplementation(interopReferences.IEnumerable.Import(module)) + new InterfaceImplementation(enumerableType.ToTypeDefOrRef()), + new InterfaceImplementation(interopReferences.IEnumerable) } }; @@ -411,11 +411,11 @@ public static void InterfaceImpl( MethodDefinition enumerable1GetEnumeratorMethod = new( name: $"System.Collections.Generic.IEnumerable<{elementType.FullName}>.GetEnumerator", attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceMethod, - signature: MethodSignature.CreateInstance(interopReferences.IEnumerator1.MakeGenericReferenceType(elementType).Import(module))); + signature: MethodSignature.CreateInstance(interopReferences.IEnumerator1.MakeGenericReferenceType(elementType))); // Add and implement the 'IEnumerable.GetEnumerator' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IEnumerable1GetEnumerator(elementType).Import(module), + declaration: interopReferences.IEnumerable1GetEnumerator(elementType), method: enumerable1GetEnumeratorMethod); // Create a method body for the 'IEnumerable.GetEnumerator' method @@ -430,11 +430,11 @@ public static void InterfaceImpl( MethodDefinition enumerableGetEnumeratorMethod = new( name: "System.Collections.IEnumerable.GetEnumerator"u8, attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceMethod, - signature: MethodSignature.CreateInstance(interopReferences.IEnumerator.Import(module).ToReferenceTypeSignature())); + signature: MethodSignature.CreateInstance(interopReferences.IEnumerator.ToReferenceTypeSignature())); // Add and implement the 'IEnumerable.GetEnumerator' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IEnumerableGetEnumerator.Import(module), + declaration: interopReferences.IEnumerableGetEnumerator, method: enumerableGetEnumeratorMethod); // Create a method body for the 'IEnumerable.GetEnumerator' method @@ -443,7 +443,7 @@ public static void InterfaceImpl( Instructions = { { Ldarg_0 }, - { Callvirt, interopReferences.IEnumerable1GetEnumerator(elementType).Import(module) }, + { Callvirt, interopReferences.IEnumerable1GetEnumerator(elementType) }, { Ret } } }; diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IEnumerator1.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IEnumerator1.cs index b3865e57b..acfe1a34b 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IEnumerator1.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IEnumerator1.cs @@ -48,7 +48,7 @@ public static void IIteratorMethods( attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: module.CorLibTypeFactory.Object.ToTypeDefOrRef()) { - Interfaces = { new InterfaceImplementation(interopReferences.IIteratorMethodsImpl1.MakeGenericReferenceType(elementType).Import(module).ToTypeDefOrRef()) } + Interfaces = { new InterfaceImplementation(interopReferences.IIteratorMethodsImpl1.MakeGenericReferenceType(elementType).ToTypeDefOrRef()) } }; module.TopLevelTypes.Add(iteratorMethodsType); @@ -60,22 +60,22 @@ public static void IIteratorMethods( name: "Current"u8, attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Static, signature: MethodSignature.CreateStatic( - returnType: enumeratorType.TypeArguments[0].Import(module), - parameterTypes: [interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature()])) + returnType: enumeratorType.TypeArguments[0], + parameterTypes: [interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature()])) { NoInlining = true }; // Add and implement the 'Current' method iteratorMethodsType.AddMethodImplementation( - declaration: interopReferences.IIteratorMethodsImpl1Current(elementType).Import(module), + declaration: interopReferences.IIteratorMethodsImpl1Current(elementType), method: currentMethod); // Declare the local variables: // [0]: 'WindowsRuntimeObjectReferenceValue' (for 'thisValue') // [1]: 'void*' (for 'thisPtr') // [2]: '' (the native value that was retrieved) - CilLocalVariable loc_0_thisValue = new(interopReferences.WindowsRuntimeObjectReferenceValue.ToValueTypeSignature().Import(module)); + CilLocalVariable loc_0_thisValue = new(interopReferences.WindowsRuntimeObjectReferenceValue.ToValueTypeSignature()); CilLocalVariable loc_1_thisPtr = new(module.CorLibTypeFactory.Void.MakePointerType()); - CilLocalVariable loc_2_currentNative = new(elementType.GetAbiType(interopReferences).Import(module)); + CilLocalVariable loc_2_currentNative = new(elementType.GetAbiType(interopReferences)); // Jump labels CilInstruction ldloca_s_0_tryStart = new(Ldloca_S, loc_0_thisValue); @@ -91,25 +91,25 @@ public static void IIteratorMethods( { // Initialize 'thisValue' { Ldarg_0 }, - { Callvirt, interopReferences.WindowsRuntimeObjectReferenceAsValue.Import(module) }, + { Callvirt, interopReferences.WindowsRuntimeObjectReferenceAsValue }, { Stloc_0 }, // '.try' code { ldloca_s_0_tryStart }, - { Call, interopReferences.WindowsRuntimeObjectReferenceValueGetThisPtrUnsafe.Import(module) }, + { Call, interopReferences.WindowsRuntimeObjectReferenceValueGetThisPtrUnsafe }, { Stloc_1 }, { Ldloc_1 }, { Ldloca_S, loc_2_currentNative }, { Ldloc_1 }, { Ldind_I }, { Ldfld, interopDefinitions.IEnumerator1Vftbl.GetField("get_Current"u8) }, - { Calli, WellKnownTypeSignatureFactory.IEnumerator1CurrentImpl(interopReferences).Import(module).MakeStandAloneSignature() }, - { Call, interopReferences.RestrictedErrorInfoThrowExceptionForHR.Import(module) }, + { Calli, WellKnownTypeSignatureFactory.IEnumerator1CurrentImpl(interopReferences).MakeStandAloneSignature() }, + { Call, interopReferences.RestrictedErrorInfoThrowExceptionForHR }, { Leave_S, nop_finallyEnd.CreateLabel() }, // '.finally' code { ldloca_s_0_finallyStart }, - { Call, interopReferences.WindowsRuntimeObjectReferenceValueDispose.Import(module) }, + { Call, interopReferences.WindowsRuntimeObjectReferenceValueDispose }, { Endfinally }, { nop_finallyEnd }, { nop_returnValueRewrite } @@ -142,12 +142,12 @@ public static void IIteratorMethods( attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Static, signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Boolean, - parameterTypes: [interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature()])) + parameterTypes: [interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature()])) { CilInstructions = { { Ldarg_0 }, - { Call, interopReferences.IIteratorMethodsHasCurrent.Import(module) }, + { Call, interopReferences.IIteratorMethodsHasCurrent }, { Ret } } }; @@ -162,12 +162,12 @@ public static void IIteratorMethods( attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Static, signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Boolean, - parameterTypes: [interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature()])) + parameterTypes: [interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature()])) { CilInstructions = { { Ldarg_0 }, - { Call, interopReferences.IIteratorMethodsMoveNext.Import(module) }, + { Call, interopReferences.IIteratorMethodsMoveNext }, { Ret } } }; @@ -311,12 +311,12 @@ public static void InterfaceImpl( attributes: TypeAttributes.Interface | TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: null) { - CustomAttributes = { new CustomAttribute(interopReferences.DynamicInterfaceCastableImplementationAttribute_ctor.Import(module)) }, + CustomAttributes = { new CustomAttribute(interopReferences.DynamicInterfaceCastableImplementationAttribute_ctor) }, Interfaces = { - new InterfaceImplementation(enumeratorType.Import(module).ToTypeDefOrRef()), - new InterfaceImplementation(interopReferences.IEnumerator.Import(module)), - new InterfaceImplementation(interopReferences.IDisposable.Import(module)) + new InterfaceImplementation(enumeratorType.ToTypeDefOrRef()), + new InterfaceImplementation(interopReferences.IEnumerator), + new InterfaceImplementation(interopReferences.IDisposable) } }; @@ -326,11 +326,11 @@ public static void InterfaceImpl( MethodDefinition get_IEnumerator1CurrentMethod = new( name: $"System.Collections.Generic.IEnumerator<{elementType.FullName}>.get_Current", attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceAccessorMethod, - signature: MethodSignature.CreateInstance(elementType.Import(module))); + signature: MethodSignature.CreateInstance(elementType)); // Add and implement the 'IEnumerator.Current' get accessor method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IEnumerator1get_Current(elementType).Import(module), + declaration: interopReferences.IEnumerator1get_Current(elementType), method: get_IEnumerator1CurrentMethod); // Create a method body for the 'IEnumerator.Current' property @@ -360,7 +360,7 @@ public static void InterfaceImpl( // Add and implement the 'IEnumerator.Current' get accessor method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IEnumeratorget_Current.Import(module), + declaration: interopReferences.IEnumeratorget_Current, method: get_IEnumeratorCurrentMethod); // Create a method body for the 'IEnumerator.Current' property @@ -369,14 +369,14 @@ public static void InterfaceImpl( Instructions = { { Ldarg_0 }, - { Callvirt, interopReferences.IEnumerator1get_Current(elementType).Import(module) }, + { Callvirt, interopReferences.IEnumerator1get_Current(elementType) }, } }; // If the element type is a value type, we need to box it if (elementType.IsValueType) { - _ = get_IEnumeratorCurrentMethod.CilMethodBody.Instructions.Add(Box, elementType.Import(module).ToTypeDefOrRef()); + _ = get_IEnumeratorCurrentMethod.CilMethodBody.Instructions.Add(Box, elementType.ToTypeDefOrRef()); } // Add the return @@ -401,7 +401,7 @@ public static void InterfaceImpl( // Add and implement the 'MoveNext' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IEnumeratorMoveNext.Import(module), + declaration: interopReferences.IEnumeratorMoveNext, method: moveNextMethod); // Create a method body for the 'MoveNext' method @@ -420,7 +420,7 @@ public static void InterfaceImpl( // Add and implement the 'Reset' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IEnumeratorReset.Import(module), + declaration: interopReferences.IEnumeratorReset, method: resetMethod); // Create a method body for the 'Reset' method @@ -428,7 +428,7 @@ public static void InterfaceImpl( { Instructions = { - { Newobj, interopReferences.NotSupportedException_ctor.Import(module) }, + { Newobj, interopReferences.NotSupportedException_ctor }, { Throw } } }; @@ -441,7 +441,7 @@ public static void InterfaceImpl( // And and implement the 'Dispose' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IDisposableDispose.Import(module), + declaration: interopReferences.IDisposableDispose, method: disposeMethod); // Create a method body for the 'Dispose' method diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IList1.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IList1.cs index 82b89cfad..1d63a72fe 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IList1.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IList1.cs @@ -45,7 +45,7 @@ public static void Interface( attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: module.CorLibTypeFactory.Object.ToTypeDefOrRef()) { - Interfaces = { new InterfaceImplementation(interopReferences.IWindowsRuntimeInterface.Import(module)) } + Interfaces = { new InterfaceImplementation(interopReferences.IWindowsRuntimeInterface) } }; module.TopLevelTypes.Add(interfaceType); @@ -65,7 +65,7 @@ public static void Interface( // Add and implement the 'get_IID' method interfaceType.AddMethodImplementation( - declaration: interopReferences.IWindowsRuntimeInterfaceget_IID.Import(module), + declaration: interopReferences.IWindowsRuntimeInterfaceget_IID, method: get_IidMethod2); } @@ -132,7 +132,7 @@ public static void IVectorMethods( attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: module.CorLibTypeFactory.Object.ToTypeDefOrRef()) { - Interfaces = { new InterfaceImplementation(interopReferences.IVectorMethodsImpl1.MakeGenericReferenceType(elementType).Import(module).ToTypeDefOrRef()) } + Interfaces = { new InterfaceImplementation(interopReferences.IVectorMethodsImpl1.MakeGenericReferenceType(elementType).ToTypeDefOrRef()) } }; module.TopLevelTypes.Add(vectorMethodsType); @@ -150,7 +150,7 @@ public static void IVectorMethods( // Add and implement the 'GetAt' method vectorMethodsType.AddMethodImplementation( - declaration: interopReferences.IVectorMethodsImpl1GetAt(elementType).Import(module), + declaration: interopReferences.IVectorMethodsImpl1GetAt(elementType), method: getAtMethod); // Define the 'SetAt' method as follows: @@ -162,14 +162,14 @@ public static void IVectorMethods( signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Void, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), module.CorLibTypeFactory.UInt32, - elementType.Import(module)])) + elementType])) { NoInlining = true }; // Add and implement the 'SetAt' method vectorMethodsType.AddMethodImplementation( - declaration: interopReferences.IVectorMethodsImpl1SetAt(elementType).Import(module), + declaration: interopReferences.IVectorMethodsImpl1SetAt(elementType), method: setAtMethod); // Create a method body for the 'SetAt' method @@ -187,13 +187,13 @@ public static void IVectorMethods( signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Void, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), - elementType.Import(module)])) + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), + elementType])) { NoInlining = true }; // Add and implement the 'Append' method vectorMethodsType.AddMethodImplementation( - declaration: interopReferences.IVectorMethodsImpl1Append(elementType).Import(module), + declaration: interopReferences.IVectorMethodsImpl1Append(elementType), method: appendMethod); // Create a method body for the 'Append' method @@ -211,8 +211,8 @@ public static void IVectorMethods( signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Boolean, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), - elementType.Import(module), + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), + elementType, module.CorLibTypeFactory.UInt32.MakeByReferenceType()])) { NoInlining = true, @@ -221,7 +221,7 @@ public static void IVectorMethods( // Add and implement the 'IndexOf' method vectorMethodsType.AddMethodImplementation( - declaration: interopReferences.IVectorMethodsImpl1IndexOf(elementType).Import(module), + declaration: interopReferences.IVectorMethodsImpl1IndexOf(elementType), method: indexOfMethod); // Create a method body for the 'IndexOf' method @@ -239,14 +239,14 @@ public static void IVectorMethods( signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Void, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), module.CorLibTypeFactory.UInt32, - elementType.Import(module)])) + elementType])) { NoInlining = true }; // Add and implement the 'InsertAt' method vectorMethodsType.AddMethodImplementation( - declaration: interopReferences.IVectorMethodsImpl1InsertAt(elementType).Import(module), + declaration: interopReferences.IVectorMethodsImpl1InsertAt(elementType), method: insertAtMethod); // Create a method body for the 'InsertAt' method @@ -289,9 +289,9 @@ public static void IListMethods( name: "Item"u8, attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Static, signature: MethodSignature.CreateStatic( - returnType: elementType.Import(module), + returnType: elementType, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), module.CorLibTypeFactory.Int32])); listMethodsType.Methods.Add(get_ItemMethod); @@ -303,7 +303,7 @@ public static void IListMethods( { { Ldarg_0 }, { Ldarg_1 }, - { Call, interopReferences.IListMethods1get_Item(elementType, vectorMethodsType).Import(module) }, + { Call, interopReferences.IListMethods1get_Item(elementType, vectorMethodsType) }, { Ret } } }; @@ -317,9 +317,9 @@ public static void IListMethods( signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Void, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), module.CorLibTypeFactory.Int32, - elementType.Import(module)])); + elementType])); listMethodsType.Methods.Add(set_ItemMethod); @@ -331,7 +331,7 @@ public static void IListMethods( { Ldarg_0 }, { Ldarg_1 }, { Ldarg_2 }, - { Call, interopReferences.IListMethods1set_Item(elementType, vectorMethodsType).Import(module) }, + { Call, interopReferences.IListMethods1set_Item(elementType, vectorMethodsType) }, { Ret } } }; @@ -344,7 +344,7 @@ public static void IListMethods( attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Static, signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Int32, - parameterTypes: [interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature()])); + parameterTypes: [interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature()])); listMethodsType.Methods.Add(countMethod); @@ -354,7 +354,7 @@ public static void IListMethods( Instructions = { { Ldarg_0 }, - { Call, interopReferences.IListMethodsCount.Import(module) }, + { Call, interopReferences.IListMethodsCount }, { Ret } } }; @@ -368,8 +368,8 @@ public static void IListMethods( signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Void, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), - elementType.Import(module)])); + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), + elementType])); listMethodsType.Methods.Add(addMethod); @@ -380,7 +380,7 @@ public static void IListMethods( { { Ldarg_0 }, { Ldarg_1 }, - { Call, interopReferences.IListMethods1Add(elementType, vectorMethodsType).Import(module) }, + { Call, interopReferences.IListMethods1Add(elementType, vectorMethodsType) }, { Ret } } }; @@ -394,8 +394,8 @@ public static void IListMethods( signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Boolean, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), - elementType.Import(module)])); + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), + elementType])); listMethodsType.Methods.Add(containsMethod); @@ -406,7 +406,7 @@ public static void IListMethods( { { Ldarg_0 }, { Ldarg_1 }, - { Call, interopReferences.IListMethods1Contains(elementType, vectorMethodsType).Import(module) }, + { Call, interopReferences.IListMethods1Contains(elementType, vectorMethodsType) }, { Ret } } }; @@ -420,8 +420,8 @@ public static void IListMethods( signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Void, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), - elementType.Import(module).MakeSzArrayType(), + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), + elementType.MakeSzArrayType(), module.CorLibTypeFactory.Int32])); listMethodsType.Methods.Add(copyToMethod); @@ -434,7 +434,7 @@ public static void IListMethods( { Ldarg_0 }, { Ldarg_1 }, { Ldarg_2 }, - { Call, interopReferences.IListMethods1CopyTo(elementType, vectorMethodsType).Import(module) }, + { Call, interopReferences.IListMethods1CopyTo(elementType, vectorMethodsType) }, { Ret } } }; @@ -448,8 +448,8 @@ public static void IListMethods( signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Boolean, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), - elementType.Import(module)])); + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), + elementType])); listMethodsType.Methods.Add(removeMethod); @@ -460,7 +460,7 @@ public static void IListMethods( { { Ldarg_0 }, { Ldarg_1 }, - { Call, interopReferences.IListMethods1Remove(elementType, vectorMethodsType).Import(module) }, + { Call, interopReferences.IListMethods1Remove(elementType, vectorMethodsType) }, { Ret } } }; @@ -474,7 +474,7 @@ public static void IListMethods( signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Void, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), module.CorLibTypeFactory.Int32])); listMethodsType.Methods.Add(removeAtMethod); @@ -486,7 +486,7 @@ public static void IListMethods( { { Ldarg_0 }, { Ldarg_1 }, - { Call, interopReferences.IListMethodsRemoveAt.Import(module) }, + { Call, interopReferences.IListMethodsRemoveAt }, { Ret } } }; @@ -500,8 +500,8 @@ public static void IListMethods( signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Int32, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), - elementType.Import(module)])); + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), + elementType])); listMethodsType.Methods.Add(indexOfMethod); @@ -512,7 +512,7 @@ public static void IListMethods( { { Ldarg_0 }, { Ldarg_1 }, - { Call, interopReferences.IListMethods1IndexOf(elementType, vectorMethodsType).Import(module) }, + { Call, interopReferences.IListMethods1IndexOf(elementType, vectorMethodsType) }, { Ret } } }; @@ -526,9 +526,9 @@ public static void IListMethods( signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Void, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), module.CorLibTypeFactory.Int32, - elementType.Import(module)])); + elementType])); listMethodsType.Methods.Add(insertMethod); @@ -540,7 +540,7 @@ public static void IListMethods( { Ldarg_0 }, { Ldarg_1 }, { Ldarg_2 }, - { Call, interopReferences.IListMethods1Insert(elementType, vectorMethodsType).Import(module) }, + { Call, interopReferences.IListMethods1Insert(elementType, vectorMethodsType) }, { Ret } } }; @@ -553,7 +553,7 @@ public static void IListMethods( attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Static, signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Void, - parameterTypes: [interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature()])); + parameterTypes: [interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature()])); listMethodsType.Methods.Add(clearMethod); @@ -563,7 +563,7 @@ public static void IListMethods( Instructions = { { Ldarg_0 }, - { Call, interopReferences.IListMethodsClear.Import(module) }, + { Call, interopReferences.IListMethodsClear }, { Ret } } }; @@ -716,13 +716,13 @@ public static void InterfaceImpl( attributes: TypeAttributes.Interface | TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: null) { - CustomAttributes = { new CustomAttribute(interopReferences.DynamicInterfaceCastableImplementationAttribute_ctor.Import(module)) }, + CustomAttributes = { new CustomAttribute(interopReferences.DynamicInterfaceCastableImplementationAttribute_ctor) }, Interfaces = { - new InterfaceImplementation(listType.Import(module).ToTypeDefOrRef()), - new InterfaceImplementation(collectionType.Import(module).ToTypeDefOrRef()), - new InterfaceImplementation(enumerableType.Import(module).ToTypeDefOrRef()), - new InterfaceImplementation(interopReferences.IEnumerable.Import(module)) + new InterfaceImplementation(listType.ToTypeDefOrRef()), + new InterfaceImplementation(collectionType.ToTypeDefOrRef()), + new InterfaceImplementation(enumerableType.ToTypeDefOrRef()), + new InterfaceImplementation(interopReferences.IEnumerable) } }; @@ -735,11 +735,11 @@ public static void InterfaceImpl( MethodDefinition get_ItemMethod = new( name: $"System.Collections.Generic.IList<{elementType.FullName}>.get_Item", attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceAccessorMethod, - signature: MethodSignature.CreateInstance(elementType.Import(module), module.CorLibTypeFactory.Int32)); + signature: MethodSignature.CreateInstance(elementType, module.CorLibTypeFactory.Int32)); // Add and implement the 'get_Item' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IList1get_Item(elementType).Import(module), + declaration: interopReferences.IList1get_Item(elementType), method: get_ItemMethod); // Create a body for the 'get_Item' method @@ -758,11 +758,11 @@ public static void InterfaceImpl( returnType: module.CorLibTypeFactory.Void, parameterTypes: [ module.CorLibTypeFactory.Int32, - elementType.Import(module)])); + elementType])); // Add and implement the 'set_Item' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IList1set_Item(elementType).Import(module), + declaration: interopReferences.IList1set_Item(elementType), method: set_ItemMethod); // Create a body for the 'set_Item' method @@ -789,11 +789,11 @@ public static void InterfaceImpl( MethodDefinition indexOfMethod = new( name: $"System.Collections.Generic.IList<{elementType.FullName}>.IndexOf", attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceMethod, - signature: MethodSignature.CreateInstance(module.CorLibTypeFactory.Int32, elementType.Import(module))); + signature: MethodSignature.CreateInstance(module.CorLibTypeFactory.Int32, elementType)); // Add and implement the 'IndexOf' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IList1get_Item(elementType).Import(module), + declaration: interopReferences.IList1get_Item(elementType), method: indexOfMethod); // Create a body for the 'IndexOf' method @@ -812,11 +812,11 @@ public static void InterfaceImpl( returnType: module.CorLibTypeFactory.Void, parameterTypes: [ module.CorLibTypeFactory.Int32, - elementType.Import(module)])); + elementType])); // Add and implement the 'Insert' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IList1Insert(elementType).Import(module), + declaration: interopReferences.IList1Insert(elementType), method: insertMethod); // Create a body for the 'Insert' method @@ -835,7 +835,7 @@ public static void InterfaceImpl( // Add and implement the 'RemoveAt' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IList1RemoveAt(elementType).Import(module), + declaration: interopReferences.IList1RemoveAt(elementType), method: removeAtMethod); // Create a body for the 'RemoveAt' method @@ -854,7 +854,7 @@ public static void InterfaceImpl( // Add and implement the 'get_Count' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.ICollection1get_Count(elementType).Import(module), + declaration: interopReferences.ICollection1get_Count(elementType), method: get_CountMethod); // Create a body for the 'get_Count' method @@ -882,7 +882,7 @@ public static void InterfaceImpl( // Add and implement the 'get_IsReadOnly' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.ICollection1get_IsReadOnly(elementType).Import(module), + declaration: interopReferences.ICollection1get_IsReadOnly(elementType), method: get_IsReadOnlyMethod); // Create a body for the 'get_IsReadOnly' method @@ -908,11 +908,11 @@ public static void InterfaceImpl( MethodDefinition addMethod = new( name: $"System.Collections.Generic.ICollection<{elementType.FullName}>.Add", attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceMethod, - signature: MethodSignature.CreateInstance(module.CorLibTypeFactory.Void, elementType.Import(module))); + signature: MethodSignature.CreateInstance(module.CorLibTypeFactory.Void, elementType)); // Add and implement the 'Add' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.ICollection1Add(elementType).Import(module), + declaration: interopReferences.ICollection1Add(elementType), method: addMethod); // Create a body for the 'Add' method @@ -931,7 +931,7 @@ public static void InterfaceImpl( // Add and implement the 'Clear' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.ICollection1Clear(elementType).Import(module), + declaration: interopReferences.ICollection1Clear(elementType), method: clearMethod); // Create a body for the 'Clear' method @@ -946,11 +946,11 @@ public static void InterfaceImpl( MethodDefinition containsMethod = new( name: $"System.Collections.Generic.ICollection<{elementType.FullName}>.Contains", attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceMethod, - signature: MethodSignature.CreateInstance(module.CorLibTypeFactory.Boolean, elementType.Import(module))); + signature: MethodSignature.CreateInstance(module.CorLibTypeFactory.Boolean, elementType)); // Add and implement the 'Contains' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.ICollection1Contains(elementType).Import(module), + declaration: interopReferences.ICollection1Contains(elementType), method: containsMethod); // Create a body for the 'Contains' method @@ -968,12 +968,12 @@ public static void InterfaceImpl( signature: MethodSignature.CreateInstance( returnType: module.CorLibTypeFactory.Void, parameterTypes: [ - elementType.MakeSzArrayType().Import(module), + elementType.MakeSzArrayType(), module.CorLibTypeFactory.Int32])); // Add and implement the 'CopyTo' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.ICollection1CopyTo(elementType).Import(module), + declaration: interopReferences.ICollection1CopyTo(elementType), method: copyToMethod); // Create a body for the 'CopyTo' method @@ -988,11 +988,11 @@ public static void InterfaceImpl( MethodDefinition removeMethod = new( name: $"System.Collections.Generic.ICollection<{elementType.FullName}>.Remove", attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceMethod, - signature: MethodSignature.CreateInstance(module.CorLibTypeFactory.Boolean, elementType.Import(module))); + signature: MethodSignature.CreateInstance(module.CorLibTypeFactory.Boolean, elementType)); // Add and implement the 'Remove' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.ICollection1Remove(elementType).Import(module), + declaration: interopReferences.ICollection1Remove(elementType), method: removeMethod); // Create a body for the 'Remove' method @@ -1007,11 +1007,11 @@ public static void InterfaceImpl( MethodDefinition enumerable1GetEnumeratorMethod = new( name: $"System.Collections.Generic.IEnumerable<{elementType.FullName}>.GetEnumerator", attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceMethod, - signature: MethodSignature.CreateInstance(interopReferences.IEnumerator1.MakeGenericReferenceType(elementType).Import(module))); + signature: MethodSignature.CreateInstance(interopReferences.IEnumerator1.MakeGenericReferenceType(elementType))); // Add and implement the 'IEnumerable.GetEnumerator' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IEnumerable1GetEnumerator(elementType).Import(module), + declaration: interopReferences.IEnumerable1GetEnumerator(elementType), method: enumerable1GetEnumeratorMethod); // Create a method body for the 'IEnumerable.GetEnumerator' method @@ -1026,11 +1026,11 @@ public static void InterfaceImpl( MethodDefinition enumerableGetEnumeratorMethod = new( name: "System.Collections.IEnumerable.GetEnumerator"u8, attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceMethod, - signature: MethodSignature.CreateInstance(interopReferences.IEnumerator.Import(module).ToReferenceTypeSignature())); + signature: MethodSignature.CreateInstance(interopReferences.IEnumerator.ToReferenceTypeSignature())); // Add and implement the 'IEnumerable.GetEnumerator' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IEnumerableGetEnumerator.Import(module), + declaration: interopReferences.IEnumerableGetEnumerator, method: enumerableGetEnumeratorMethod); // Create a method body for the 'IEnumerable.GetEnumerator' method @@ -1039,7 +1039,7 @@ public static void InterfaceImpl( Instructions = { { Ldarg_0 }, - { Callvirt, interopReferences.IEnumerable1GetEnumerator(elementType).Import(module) }, + { Callvirt, interopReferences.IEnumerable1GetEnumerator(elementType) }, { Ret } } }; diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IMapChangedEventArgs1.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IMapChangedEventArgs1.cs index ddce82f70..9d8f97c04 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IMapChangedEventArgs1.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IMapChangedEventArgs1.cs @@ -45,7 +45,7 @@ public static void Methods( attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: module.CorLibTypeFactory.Object.ToTypeDefOrRef()) { - Interfaces = { new InterfaceImplementation(interopReferences.IMapChangedEventArgsImpl1.MakeGenericReferenceType(elementType).Import(module).ToTypeDefOrRef()) } + Interfaces = { new InterfaceImplementation(interopReferences.IMapChangedEventArgsImpl1.MakeGenericReferenceType(elementType).ToTypeDefOrRef()) } }; module.TopLevelTypes.Add(argsMethodsType); @@ -57,13 +57,13 @@ public static void Methods( name: "CollectionChange"u8, attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Static, signature: MethodSignature.CreateStatic( - returnType: interopReferences.CollectionChange.ToValueTypeSignature().Import(module), - parameterTypes: [interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature()])) + returnType: interopReferences.CollectionChange.ToValueTypeSignature(), + parameterTypes: [interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature()])) { CilInstructions = { { Ldarg_0 }, - { Call, interopReferences.IMapChangedEventArgsMethodsCollectionChange.Import(module) }, + { Call, interopReferences.IMapChangedEventArgsMethodsCollectionChange }, { Ret } } }; @@ -77,12 +77,12 @@ public static void Methods( name: "Key"u8, attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Static, signature: MethodSignature.CreateStatic( - returnType: elementType.Import(module), - parameterTypes: [interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature()])); + returnType: elementType, + parameterTypes: [interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature()])); // Add and implement the 'Key' method argsMethodsType.AddMethodImplementation( - declaration: interopReferences.IMapChangedEventArgsImpl1Key(elementType).Import(module), + declaration: interopReferences.IMapChangedEventArgsImpl1Key(elementType), method: keyMethod); // Create a method body for the 'Key' method @@ -232,8 +232,8 @@ public static void InterfaceImpl( attributes: TypeAttributes.Interface | TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: null) { - CustomAttributes = { new CustomAttribute(interopReferences.DynamicInterfaceCastableImplementationAttribute_ctor.Import(module)) }, - Interfaces = { new InterfaceImplementation(argsType.Import(module).ToTypeDefOrRef()) } + CustomAttributes = { new CustomAttribute(interopReferences.DynamicInterfaceCastableImplementationAttribute_ctor) }, + Interfaces = { new InterfaceImplementation(argsType.ToTypeDefOrRef()) } }; module.TopLevelTypes.Add(interfaceImplType); @@ -242,11 +242,11 @@ public static void InterfaceImpl( MethodDefinition get_CollectionChangeMethod = new( name: $"Windows.Foundation.Collections.IMapChangedEventArgs<{elementType.FullName}>.get_CollectionChange", attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceAccessorMethod, - signature: MethodSignature.CreateInstance(interopReferences.CollectionChange.ToValueTypeSignature().Import(module))); + signature: MethodSignature.CreateInstance(interopReferences.CollectionChange.ToValueTypeSignature())); // Add and implement the 'CollectionChange' get accessor method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IMapChangedEventArgs1get_CollectionChange(elementType).Import(module), + declaration: interopReferences.IMapChangedEventArgs1get_CollectionChange(elementType), method: get_CollectionChangeMethod); // Create a method body for the 'CollectionChange' property @@ -272,11 +272,11 @@ public static void InterfaceImpl( MethodDefinition get_KeyMethod = new( name: $"Windows.Foundation.Collections.IMapChangedEventArgs<{elementType.FullName}>.get_Key", attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceAccessorMethod, - signature: MethodSignature.CreateInstance(elementType.Import(module))); + signature: MethodSignature.CreateInstance(elementType)); // Add and implement the 'Key' get accessor method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IMapChangedEventArgs1get_Key(elementType).Import(module), + declaration: interopReferences.IMapChangedEventArgs1get_Key(elementType), method: get_KeyMethod); // Create a method body for the 'Key' property diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IObservableMap2.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IObservableMap2.cs index c707f8ec2..768ff1657 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IObservableMap2.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IObservableMap2.cs @@ -59,7 +59,7 @@ public static void EventSourceFactory( interopReferences.MapChangedEventHandler2EventSource.MakeGenericReferenceType(keyType, valueType)); // 'Value' field with the cached factory delegate - factoryType.Fields.Add(new FieldDefinition("Value"u8, FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.InitOnly, funcType.Import(module))); + factoryType.Fields.Add(new FieldDefinition("Value"u8, FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.InitOnly, funcType)); // Add the parameterless constructor factoryType.Methods.Add(MethodDefinition.CreateDefaultConstructor(module)); @@ -79,10 +79,10 @@ public static void EventSourceFactory( name: "Callback"u8, attributes: MethodAttributes.Private | MethodAttributes.HideBySig, signature: MethodSignature.CreateInstance( - returnType: interopReferences.MapChangedEventHandler2EventSource.MakeGenericReferenceType(keyType, valueType).Import(module), + returnType: interopReferences.MapChangedEventHandler2EventSource.MakeGenericReferenceType(keyType, valueType), parameterTypes: [ - interopReferences.WindowsRuntimeObject.ToReferenceTypeSignature().Import(module), - interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature().Import(module)])) + interopReferences.WindowsRuntimeObject.ToReferenceTypeSignature(), + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature()])) { CilInstructions = { @@ -107,7 +107,7 @@ public static void EventSourceFactory( // Create the delegate type and store it in the 'Value' field _ = cctor.CilInstructions.Add(Ldsfld, factoryType.Fields[0]); _ = cctor.CilInstructions.Add(Ldftn, callbackMethod); - _ = cctor.CilInstructions.Add(Newobj, interopReferences.Delegate_ctor(funcType).Import(module)); + _ = cctor.CilInstructions.Add(Newobj, interopReferences.Delegate_ctor(funcType)); _ = cctor.CilInstructions.Add(Stsfld, factoryType.Fields[1]); _ = cctor.CilInstructions.Add(Ret); @@ -142,7 +142,7 @@ public static void Methods( attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: module.CorLibTypeFactory.Object.ToTypeDefOrRef()) { - Interfaces = { new InterfaceImplementation(interopReferences.IObservableMapMethodsImpl2.MakeGenericReferenceType(keyType, valueType).Import(module).ToTypeDefOrRef()) } + Interfaces = { new InterfaceImplementation(interopReferences.IObservableMapMethodsImpl2.MakeGenericReferenceType(keyType, valueType).ToTypeDefOrRef()) } }; module.TopLevelTypes.Add(methodsType); @@ -182,10 +182,10 @@ public static void Methods( name: "MapChanged"u8, attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Static, signature: MethodSignature.CreateStatic( - returnType: eventHandlerEventSourceType.Import(module), + returnType: eventHandlerEventSourceType, parameterTypes: [ - interopReferences.WindowsRuntimeObject.ToReferenceTypeSignature().Import(module), - interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature().Import(module)])) + interopReferences.WindowsRuntimeObject.ToReferenceTypeSignature(), + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature()])) { CilInstructions = { @@ -193,14 +193,14 @@ public static void Methods( { Ldarg_0 }, { Ldsfld, eventSourceFactoryType.GetField("Value"u8) }, { Ldarg_1 }, - { Callvirt, conditionalWeakTableGetOrAddMethod.Import(module) }, + { Callvirt, conditionalWeakTableGetOrAddMethod }, { Ret } } }; // Add and implement the 'IObservableMapMethodsImpl.MapChanged' method methodsType.AddMethodImplementation( - declaration: interopReferences.IObservableMapMethodsImpl2MapChanged(keyType, valueType).Import(module), + declaration: interopReferences.IObservableMapMethodsImpl2MapChanged(keyType, valueType), method: mapChangedMethod); } @@ -357,14 +357,14 @@ public static void InterfaceImpl( attributes: TypeAttributes.Interface | TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: null) { - CustomAttributes = { new CustomAttribute(interopReferences.DynamicInterfaceCastableImplementationAttribute_ctor.Import(module)) }, + CustomAttributes = { new CustomAttribute(interopReferences.DynamicInterfaceCastableImplementationAttribute_ctor) }, Interfaces = { - new InterfaceImplementation(mapType.Import(module).ToTypeDefOrRef()), - new InterfaceImplementation(dictionaryType.Import(module).ToTypeDefOrRef()), - new InterfaceImplementation(collectionType.Import(module).ToTypeDefOrRef()), - new InterfaceImplementation(enumerableType.Import(module).ToTypeDefOrRef()), - new InterfaceImplementation(interopReferences.IEnumerable.Import(module)) + new InterfaceImplementation(mapType.ToTypeDefOrRef()), + new InterfaceImplementation(dictionaryType.ToTypeDefOrRef()), + new InterfaceImplementation(collectionType.ToTypeDefOrRef()), + new InterfaceImplementation(enumerableType.ToTypeDefOrRef()), + new InterfaceImplementation(interopReferences.IEnumerable) } }; @@ -379,7 +379,7 @@ public static void InterfaceImpl( attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceAccessorMethod, signature: MethodSignature.CreateInstance( returnType: module.CorLibTypeFactory.Void, - parameterTypes: [handlerType.Import(module)])) + parameterTypes: [handlerType])) { CilMethodBody = WellKnownCilMethodBodyFactory.DynamicInterfaceCastableImplementation( interfaceType: mapType, @@ -392,7 +392,7 @@ public static void InterfaceImpl( // Add and implement the 'IObservableMap.MapChanged' add accessor method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IObservableMap2add_MapChanged(keyType, valueType).Import(module), + declaration: interopReferences.IObservableMap2add_MapChanged(keyType, valueType), method: add_IObservableMap2MapChangedMethod); // Create the 'IObservableMap.MapChanged' remove method @@ -401,7 +401,7 @@ public static void InterfaceImpl( attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceAccessorMethod, signature: MethodSignature.CreateInstance( returnType: module.CorLibTypeFactory.Void, - parameterTypes: [handlerType.Import(module)])) + parameterTypes: [handlerType])) { CilMethodBody = WellKnownCilMethodBodyFactory.DynamicInterfaceCastableImplementation( interfaceType: mapType, @@ -414,14 +414,14 @@ public static void InterfaceImpl( // Add and implement the 'IObservableMap.MapChanged' remove accessor method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IObservableMap2remove_MapChanged(keyType, valueType).Import(module), + declaration: interopReferences.IObservableMap2remove_MapChanged(keyType, valueType), method: remove_IObservableMap2MapChangedMethod); // Create the 'IObservableMap.MapChanged' event EventDefinition observableMap2MapChangedProperty = new( name: $"Windows.Foundation.Collections.IObservableMap<{keyType.FullName},{valueType.FullName}>.MapChanged", attributes: default, - eventType: handlerType.Import(module).ToTypeDefOrRef()) + eventType: handlerType.ToTypeDefOrRef()) { AddMethod = add_IObservableMap2MapChangedMethod, RemoveMethod = remove_IObservableMap2MapChangedMethod diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IObservableVector1.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IObservableVector1.cs index 215b6a7cc..3d1d38743 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IObservableVector1.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IObservableVector1.cs @@ -58,7 +58,7 @@ public static void EventSourceFactory( interopReferences.VectorChangedEventHandler1EventSource.MakeGenericReferenceType(elementType)); // 'Value' field with the cached factory delegate - factoryType.Fields.Add(new FieldDefinition("Value"u8, FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.InitOnly, funcType.Import(module))); + factoryType.Fields.Add(new FieldDefinition("Value"u8, FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.InitOnly, funcType)); // Add the parameterless constructor factoryType.Methods.Add(MethodDefinition.CreateDefaultConstructor(module)); @@ -78,10 +78,10 @@ public static void EventSourceFactory( name: "Callback"u8, attributes: MethodAttributes.Private | MethodAttributes.HideBySig, signature: MethodSignature.CreateInstance( - returnType: interopReferences.VectorChangedEventHandler1EventSource.MakeGenericReferenceType(elementType).Import(module), + returnType: interopReferences.VectorChangedEventHandler1EventSource.MakeGenericReferenceType(elementType), parameterTypes: [ - interopReferences.WindowsRuntimeObject.ToReferenceTypeSignature().Import(module), - interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature().Import(module)])) + interopReferences.WindowsRuntimeObject.ToReferenceTypeSignature(), + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature()])) { CilInstructions = { @@ -106,7 +106,7 @@ public static void EventSourceFactory( // Create the delegate type and store it in the 'Value' field _ = cctor.CilInstructions.Add(Ldsfld, factoryType.Fields[0]); _ = cctor.CilInstructions.Add(Ldftn, callbackMethod); - _ = cctor.CilInstructions.Add(Newobj, interopReferences.Delegate_ctor(funcType).Import(module)); + _ = cctor.CilInstructions.Add(Newobj, interopReferences.Delegate_ctor(funcType)); _ = cctor.CilInstructions.Add(Stsfld, factoryType.Fields[1]); _ = cctor.CilInstructions.Add(Ret); @@ -140,7 +140,7 @@ public static void Methods( attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: module.CorLibTypeFactory.Object.ToTypeDefOrRef()) { - Interfaces = { new InterfaceImplementation(interopReferences.IObservableVectorMethodsImpl1.MakeGenericReferenceType(elementType).Import(module).ToTypeDefOrRef()) } + Interfaces = { new InterfaceImplementation(interopReferences.IObservableVectorMethodsImpl1.MakeGenericReferenceType(elementType).ToTypeDefOrRef()) } }; module.TopLevelTypes.Add(methodsType); @@ -180,10 +180,10 @@ public static void Methods( name: "VectorChanged"u8, attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Static, signature: MethodSignature.CreateStatic( - returnType: eventHandlerEventSourceType.Import(module), + returnType: eventHandlerEventSourceType, parameterTypes: [ - interopReferences.WindowsRuntimeObject.ToReferenceTypeSignature().Import(module), - interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature().Import(module)])) + interopReferences.WindowsRuntimeObject.ToReferenceTypeSignature(), + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature()])) { CilInstructions = { @@ -191,14 +191,14 @@ public static void Methods( { Ldarg_0 }, { Ldsfld, eventSourceFactoryType.GetField("Value"u8) }, { Ldarg_1 }, - { Callvirt, conditionalWeakTableGetOrAddMethod.Import(module) }, + { Callvirt, conditionalWeakTableGetOrAddMethod }, { Ret } } }; // Add and implement the 'IObservableVectorMethodsImpl.VectorChanged' method methodsType.AddMethodImplementation( - declaration: interopReferences.IObservableVectorMethodsImpl1VectorChanged(elementType).Import(module), + declaration: interopReferences.IObservableVectorMethodsImpl1VectorChanged(elementType), method: vectorChangedMethod); } @@ -345,14 +345,14 @@ public static void InterfaceImpl( attributes: TypeAttributes.Interface | TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: null) { - CustomAttributes = { new CustomAttribute(interopReferences.DynamicInterfaceCastableImplementationAttribute_ctor.Import(module)) }, + CustomAttributes = { new CustomAttribute(interopReferences.DynamicInterfaceCastableImplementationAttribute_ctor) }, Interfaces = { - new InterfaceImplementation(vectorType.Import(module).ToTypeDefOrRef()), - new InterfaceImplementation(interopReferences.IList1.MakeGenericReferenceType(elementType).Import(module).ToTypeDefOrRef()), - new InterfaceImplementation(interopReferences.ICollection1.MakeGenericReferenceType(elementType).Import(module).ToTypeDefOrRef()), - new InterfaceImplementation(interopReferences.IEnumerable1.MakeGenericReferenceType(elementType).Import(module).ToTypeDefOrRef()), - new InterfaceImplementation(interopReferences.IEnumerable.Import(module)) + new InterfaceImplementation(vectorType.ToTypeDefOrRef()), + new InterfaceImplementation(interopReferences.IList1.MakeGenericReferenceType(elementType).ToTypeDefOrRef()), + new InterfaceImplementation(interopReferences.ICollection1.MakeGenericReferenceType(elementType).ToTypeDefOrRef()), + new InterfaceImplementation(interopReferences.IEnumerable1.MakeGenericReferenceType(elementType).ToTypeDefOrRef()), + new InterfaceImplementation(interopReferences.IEnumerable) } }; @@ -367,7 +367,7 @@ public static void InterfaceImpl( attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceAccessorMethod, signature: MethodSignature.CreateInstance( returnType: module.CorLibTypeFactory.Void, - parameterTypes: [handlerType.Import(module)])) + parameterTypes: [handlerType])) { CilMethodBody = WellKnownCilMethodBodyFactory.DynamicInterfaceCastableImplementation( interfaceType: vectorType, @@ -380,7 +380,7 @@ public static void InterfaceImpl( // Add and implement the 'IObservableVector.VectorChanged' add accessor method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IObservableVector1add_VectorChanged(elementType).Import(module), + declaration: interopReferences.IObservableVector1add_VectorChanged(elementType), method: add_IObservableVector1VectorChangedMethod); // Create the 'IObservableVector.VectorChanged' remove method @@ -389,7 +389,7 @@ public static void InterfaceImpl( attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceAccessorMethod, signature: MethodSignature.CreateInstance( returnType: module.CorLibTypeFactory.Void, - parameterTypes: [handlerType.Import(module)])) + parameterTypes: [handlerType])) { CilMethodBody = WellKnownCilMethodBodyFactory.DynamicInterfaceCastableImplementation( interfaceType: vectorType, @@ -402,14 +402,14 @@ public static void InterfaceImpl( // Add and implement the 'IObservableVector.VectorChanged' remove accessor method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IObservableVector1remove_VectorChanged(elementType).Import(module), + declaration: interopReferences.IObservableVector1remove_VectorChanged(elementType), method: remove_IObservableVector1VectorChangedMethod); // Create the 'IObservableVector.VectorChanged' event EventDefinition observableVector1VectorChangedProperty = new( name: $"Windows.Foundation.Collections.IObservableVector<{elementType.FullName}>.VectorChanged", attributes: default, - eventType: handlerType.Import(module).ToTypeDefOrRef()) + eventType: handlerType.ToTypeDefOrRef()) { AddMethod = add_IObservableVector1VectorChangedMethod, RemoveMethod = remove_IObservableVector1VectorChangedMethod diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IReadOnlyDictionary2.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IReadOnlyDictionary2.cs index b99efcaac..52df85441 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IReadOnlyDictionary2.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IReadOnlyDictionary2.cs @@ -107,7 +107,7 @@ public static void IMapViewMethods( attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: module.CorLibTypeFactory.Object.ToTypeDefOrRef()) { - Interfaces = { new InterfaceImplementation(interopReferences.IMapViewMethodsImpl2.MakeGenericReferenceType(keyType, valueType).Import(module).ToTypeDefOrRef()) } + Interfaces = { new InterfaceImplementation(interopReferences.IMapViewMethodsImpl2.MakeGenericReferenceType(keyType, valueType).ToTypeDefOrRef()) } }; module.TopLevelTypes.Add(mapViewMethodsType); @@ -121,13 +121,13 @@ public static void IMapViewMethods( signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Boolean, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), - keyType.Import(module)])) + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), + keyType])) { NoInlining = true }; // Add and implement the 'HasKey' method mapViewMethodsType.AddMethodImplementation( - declaration: interopReferences.IMapViewMethodsImpl2HasKey(keyType, valueType).Import(module), + declaration: interopReferences.IMapViewMethodsImpl2HasKey(keyType, valueType), method: hasKeyMethod); // Create a method body for the 'HasKey' method @@ -143,15 +143,15 @@ public static void IMapViewMethods( name: "Lookup"u8, attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Static, signature: MethodSignature.CreateStatic( - returnType: valueType.Import(module), + returnType: valueType, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), - keyType.Import(module)])) + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), + keyType])) { NoInlining = true }; // Add and implement the 'Lookup' method mapViewMethodsType.AddMethodImplementation( - declaration: interopReferences.IMapViewMethodsImpl2HasKey(keyType, valueType).Import(module), + declaration: interopReferences.IMapViewMethodsImpl2HasKey(keyType, valueType), method: lookupMethod); // Create a method body for the 'Lookup' method @@ -195,10 +195,10 @@ public static void IReadOnlyDictionaryMethods( name: "Item"u8, attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Static, signature: MethodSignature.CreateStatic( - returnType: valueType.Import(module), + returnType: valueType, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), - keyType.Import(module)])); + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), + keyType])); readOnlyDictionaryMethodsType.Methods.Add(get_ItemMethod); @@ -209,7 +209,7 @@ public static void IReadOnlyDictionaryMethods( { { Ldarg_0 }, { Ldarg_1 }, - { Call, interopReferences.IReadOnlyDictionaryMethods2get_Item(keyType, valueType, mapViewMethodsType).Import(module) }, + { Call, interopReferences.IReadOnlyDictionaryMethods2get_Item(keyType, valueType, mapViewMethodsType) }, { Ret } } }; @@ -222,7 +222,7 @@ public static void IReadOnlyDictionaryMethods( attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Static, signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Int32, - parameterTypes: [interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature()])); + parameterTypes: [interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature()])); readOnlyDictionaryMethodsType.Methods.Add(countMethod); @@ -232,7 +232,7 @@ public static void IReadOnlyDictionaryMethods( Instructions = { { Ldarg_0 }, - { Call, interopReferences.IReadOnlyDictionaryMethodsCount.Import(module) }, + { Call, interopReferences.IReadOnlyDictionaryMethodsCount }, { Ret } } }; @@ -246,8 +246,8 @@ public static void IReadOnlyDictionaryMethods( signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Boolean, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), - keyType.Import(module)])); + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), + keyType])); readOnlyDictionaryMethodsType.Methods.Add(containsKeyMethod); @@ -258,7 +258,7 @@ public static void IReadOnlyDictionaryMethods( { { Ldarg_0 }, { Ldarg_1 }, - { Call, interopReferences.IReadOnlyDictionaryMethods2ContainsKey(keyType, valueType, mapViewMethodsType).Import(module) }, + { Call, interopReferences.IReadOnlyDictionaryMethods2ContainsKey(keyType, valueType, mapViewMethodsType) }, { Ret } } }; @@ -272,9 +272,9 @@ public static void IReadOnlyDictionaryMethods( signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Boolean, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), - keyType.Import(module), - valueType.Import(module).MakeByReferenceType()])) + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), + keyType, + valueType.MakeByReferenceType()])) { CilOutParameterIndices = [3] }; readOnlyDictionaryMethodsType.Methods.Add(tryGetValueMethod); @@ -287,7 +287,7 @@ public static void IReadOnlyDictionaryMethods( { Ldarg_0 }, { Ldarg_1 }, { Ldarg_3 }, - { Call, interopReferences.IReadOnlyDictionaryMethods2TryGetValue(keyType, valueType, mapViewMethodsType).Import(module) }, + { Call, interopReferences.IReadOnlyDictionaryMethods2TryGetValue(keyType, valueType, mapViewMethodsType) }, { Ret } } }; @@ -442,11 +442,11 @@ public static void InterfaceImpl( attributes: TypeAttributes.Interface | TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: null) { - CustomAttributes = { new CustomAttribute(interopReferences.DynamicInterfaceCastableImplementationAttribute_ctor.Import(module)) }, + CustomAttributes = { new CustomAttribute(interopReferences.DynamicInterfaceCastableImplementationAttribute_ctor) }, Interfaces = { - new InterfaceImplementation(readOnlyDictionaryType.Import(module).ToTypeDefOrRef()), - new InterfaceImplementation(readOnlyCollectionType.Import(module).ToTypeDefOrRef()) + new InterfaceImplementation(readOnlyDictionaryType.ToTypeDefOrRef()), + new InterfaceImplementation(readOnlyCollectionType.ToTypeDefOrRef()) } }; @@ -456,11 +456,11 @@ public static void InterfaceImpl( MethodDefinition get_ItemMethod = new( name: $"System.Collections.Generic.IReadOnlyDictionary<{keyType.FullName},{valueType.FullName}>.get_Item", attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceAccessorMethod, - signature: MethodSignature.CreateInstance(valueType.Import(module), keyType.Import(module))); + signature: MethodSignature.CreateInstance(valueType, keyType)); // Add and implement the 'get_Item' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IReadOnlyDictionary2get_Item(keyType, valueType).Import(module), + declaration: interopReferences.IReadOnlyDictionary2get_Item(keyType, valueType), method: get_ItemMethod); // Create a body for the 'get_Item' method @@ -484,11 +484,11 @@ public static void InterfaceImpl( MethodDefinition get_KeysMethod = new( name: $"System.Collections.Generic.IReadOnlyDictionary<{keyType.FullName},{valueType.FullName}>.get_Keys", attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceAccessorMethod, - signature: MethodSignature.CreateInstance(interopReferences.IEnumerable1.MakeGenericReferenceType(keyType).Import(module))); + signature: MethodSignature.CreateInstance(interopReferences.IEnumerable1.MakeGenericReferenceType(keyType))); // Add and implement the 'get_Keys' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IReadOnlyDictionary2get_Keys(keyType, valueType).Import(module), + declaration: interopReferences.IReadOnlyDictionary2get_Keys(keyType, valueType), method: get_KeysMethod); // Create a body for the 'get_Keys' method @@ -497,7 +497,7 @@ public static void InterfaceImpl( Instructions = { { Ldarg_0 }, - { Newobj, interopReferences.ReadOnlyDictionaryKeyCollection2_ctor(keyType, valueType).Import(module) }, + { Newobj, interopReferences.ReadOnlyDictionaryKeyCollection2_ctor(keyType, valueType) }, { Ret } } }; @@ -515,11 +515,11 @@ public static void InterfaceImpl( MethodDefinition get_ValuesMethod = new( name: $"System.Collections.Generic.IReadOnlyDictionary<{keyType.FullName},{valueType.FullName}>.get_Values", attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceAccessorMethod, - signature: MethodSignature.CreateInstance(interopReferences.IEnumerable1.MakeGenericReferenceType(valueType).Import(module))); + signature: MethodSignature.CreateInstance(interopReferences.IEnumerable1.MakeGenericReferenceType(valueType))); // Add and implement the 'get_Values' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IReadOnlyDictionary2get_Values(keyType, valueType).Import(module), + declaration: interopReferences.IReadOnlyDictionary2get_Values(keyType, valueType), method: get_ValuesMethod); // Create a body for the 'get_Values' method @@ -528,7 +528,7 @@ public static void InterfaceImpl( Instructions = { { Ldarg_0 }, - { Newobj, interopReferences.ReadOnlyDictionaryValueCollection2_ctor(keyType, valueType).Import(module) }, + { Newobj, interopReferences.ReadOnlyDictionaryValueCollection2_ctor(keyType, valueType) }, { Ret } } }; @@ -548,11 +548,11 @@ public static void InterfaceImpl( attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceMethod, signature: MethodSignature.CreateInstance( returnType: module.CorLibTypeFactory.Boolean, - parameterTypes: [keyType.Import(module)])); + parameterTypes: [keyType])); // Add and implement the 'ContainsKey' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IReadOnlyDictionary2ContainsKey(keyType, valueType).Import(module), + declaration: interopReferences.IReadOnlyDictionary2ContainsKey(keyType, valueType), method: containsKeyMethod); // Create a body for the 'ContainsKey' method @@ -569,12 +569,12 @@ public static void InterfaceImpl( attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceMethod, signature: MethodSignature.CreateInstance( returnType: module.CorLibTypeFactory.Boolean, - parameterTypes: [keyType.Import(module), valueType.Import(module).MakeByReferenceType()])) + parameterTypes: [keyType, valueType.MakeByReferenceType()])) { CilOutParameterIndices = [2] }; // Add and implement the 'TryGetValue' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IReadOnlyDictionary2ContainsKey(keyType, valueType).Import(module), + declaration: interopReferences.IReadOnlyDictionary2ContainsKey(keyType, valueType), method: tryGetValueMethod); // Create a body for the 'TryGetValue' method @@ -593,7 +593,7 @@ public static void InterfaceImpl( // Add and implement the 'get_Count' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IReadOnlyCollection1get_Count(keyValuePairType).Import(module), + declaration: interopReferences.IReadOnlyCollection1get_Count(keyValuePairType), method: get_CountMethod); // Create a body for the 'get_Count' method diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IReadOnlyList1.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IReadOnlyList1.cs index 1a0df72a0..81f939208 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IReadOnlyList1.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.IReadOnlyList1.cs @@ -83,7 +83,7 @@ public static void IVectorViewMethods( attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: module.CorLibTypeFactory.Object.ToTypeDefOrRef()) { - Interfaces = { new InterfaceImplementation(interopReferences.IVectorViewMethods1.MakeGenericReferenceType(elementType).Import(module).ToTypeDefOrRef()) } + Interfaces = { new InterfaceImplementation(interopReferences.IVectorViewMethods1.MakeGenericReferenceType(elementType).ToTypeDefOrRef()) } }; module.TopLevelTypes.Add(vectorViewMethodsType); @@ -101,7 +101,7 @@ public static void IVectorViewMethods( // Add and implement the 'GetAt' method vectorViewMethodsType.AddMethodImplementation( - declaration: interopReferences.IVectorViewMethods1GetAt(elementType).Import(module), + declaration: interopReferences.IVectorViewMethods1GetAt(elementType), method: getAtMethod); } @@ -138,9 +138,9 @@ public static void IReadOnlyListMethods( name: "Item"u8, attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Static, signature: MethodSignature.CreateStatic( - returnType: elementType.Import(module), + returnType: elementType, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), module.CorLibTypeFactory.Int32])); readOnlyListMethodsType.Methods.Add(get_ItemMethod); @@ -152,7 +152,7 @@ public static void IReadOnlyListMethods( { { Ldarg_0 }, { Ldarg_1 }, - { Call, interopReferences.IReadOnlyListMethods1get_Item(elementType, vectorViewMethodsType).Import(module) }, + { Call, interopReferences.IReadOnlyListMethods1get_Item(elementType, vectorViewMethodsType) }, { Ret } } }; @@ -165,7 +165,7 @@ public static void IReadOnlyListMethods( attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Static, signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Int32, - parameterTypes: [interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature()])); + parameterTypes: [interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature()])); readOnlyListMethodsType.Methods.Add(countMethod); @@ -175,7 +175,7 @@ public static void IReadOnlyListMethods( Instructions = { { Ldarg_0 }, - { Call, interopReferences.IReadOnlyListMethodsCount.Import(module) }, + { Call, interopReferences.IReadOnlyListMethodsCount }, { Ret } } }; @@ -328,13 +328,13 @@ public static void InterfaceImpl( attributes: TypeAttributes.Interface | TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: null) { - CustomAttributes = { new CustomAttribute(interopReferences.DynamicInterfaceCastableImplementationAttribute_ctor.Import(module)) }, + CustomAttributes = { new CustomAttribute(interopReferences.DynamicInterfaceCastableImplementationAttribute_ctor) }, Interfaces = { - new InterfaceImplementation(readOnlyListType.Import(module).ToTypeDefOrRef()), - new InterfaceImplementation(readOnlyCollectionType.Import(module).ToTypeDefOrRef()), - new InterfaceImplementation(enumerableType.Import(module).ToTypeDefOrRef()), - new InterfaceImplementation(interopReferences.IEnumerable.Import(module)) + new InterfaceImplementation(readOnlyListType.ToTypeDefOrRef()), + new InterfaceImplementation(readOnlyCollectionType.ToTypeDefOrRef()), + new InterfaceImplementation(enumerableType.ToTypeDefOrRef()), + new InterfaceImplementation(interopReferences.IEnumerable) } }; @@ -344,11 +344,11 @@ public static void InterfaceImpl( MethodDefinition get_ItemMethod = new( name: $"System.Collections.Generic.IReadOnlyList<{elementType.FullName}>.get_Item", attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceAccessorMethod, - signature: MethodSignature.CreateInstance(elementType.Import(module), module.CorLibTypeFactory.Int32)); + signature: MethodSignature.CreateInstance(elementType, module.CorLibTypeFactory.Int32)); // Add and implement the 'get_Item' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IReadOnlyList1get_Item(elementType).Import(module), + declaration: interopReferences.IReadOnlyList1get_Item(elementType), method: get_ItemMethod); // Create a body for the 'get_Item' method @@ -376,7 +376,7 @@ public static void InterfaceImpl( // Add and implement the 'get_Count' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IReadOnlyCollection1get_Count(elementType).Import(module), + declaration: interopReferences.IReadOnlyCollection1get_Count(elementType), method: get_CountMethod); // Create a body for the 'get_Count' method @@ -400,11 +400,11 @@ public static void InterfaceImpl( MethodDefinition enumerable1GetEnumeratorMethod = new( name: $"System.Collections.Generic.IEnumerable<{elementType.FullName}>.GetEnumerator", attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceMethod, - signature: MethodSignature.CreateInstance(interopReferences.IEnumerator1.MakeGenericReferenceType(elementType).Import(module))); + signature: MethodSignature.CreateInstance(interopReferences.IEnumerator1.MakeGenericReferenceType(elementType))); // Add and implement the 'IEnumerable.GetEnumerator' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IEnumerable1GetEnumerator(elementType).Import(module), + declaration: interopReferences.IEnumerable1GetEnumerator(elementType), method: enumerable1GetEnumeratorMethod); // Create a method body for the 'IEnumerable.GetEnumerator' method @@ -419,11 +419,11 @@ public static void InterfaceImpl( MethodDefinition enumerableGetEnumeratorMethod = new( name: "System.Collections.IEnumerable.GetEnumerator"u8, attributes: WellKnownMethodAttributesFactory.ExplicitInterfaceImplementationInstanceMethod, - signature: MethodSignature.CreateInstance(interopReferences.IEnumerator.Import(module).ToReferenceTypeSignature())); + signature: MethodSignature.CreateInstance(interopReferences.IEnumerator.ToReferenceTypeSignature())); // Add and implement the 'IEnumerable.GetEnumerator' method interfaceImplType.AddMethodImplementation( - declaration: interopReferences.IEnumerableGetEnumerator.Import(module), + declaration: interopReferences.IEnumerableGetEnumerator, method: enumerableGetEnumeratorMethod); // Create a method body for the 'IEnumerable.GetEnumerator' method @@ -432,7 +432,7 @@ public static void InterfaceImpl( Instructions = { { Ldarg_0 }, - { Callvirt, interopReferences.IEnumerable1GetEnumerator(elementType).Import(module) }, + { Callvirt, interopReferences.IEnumerable1GetEnumerator(elementType) }, { Ret } } }; diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.KeyValuePair.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.KeyValuePair.cs index 8d6f17008..2d3b161db 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.KeyValuePair.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.KeyValuePair.cs @@ -140,8 +140,8 @@ public static void Marshaller( emitState.TrackTypeDefinition(marshallerType, keyValuePairType, "Marshaller"); // Prepare the external types we need in the implemented methods - TypeSignature typeSignature2 = keyValuePairType.Import(module); - TypeSignature windowsRuntimeObjectReferenceValueType = interopReferences.WindowsRuntimeObjectReferenceValue.Import(module).ToValueTypeSignature(); + TypeSignature typeSignature2 = keyValuePairType; + TypeSignature windowsRuntimeObjectReferenceValueType = interopReferences.WindowsRuntimeObjectReferenceValue.ToValueTypeSignature(); // Determine which 'CreateComInterfaceFlags' flags we use for the marshalled CCW CreateComInterfaceFlags flags = keyValuePairType.IsTrackerSupportRequired(interopReferences) @@ -161,10 +161,10 @@ public static void Marshaller( CilInstructions = { { Ldarg_0 }, - { Box, keyValuePairType.Import(module).ToTypeDefOrRef() }, + { Box, keyValuePairType.ToTypeDefOrRef() }, { CilInstruction.CreateLdcI4((int)flags) }, { Call, get_IidMethod }, - { Call, interopReferences.WindowsRuntimeValueTypeMarshallerConvertToUnmanagedUnsafe.Import(module) }, + { Call, interopReferences.WindowsRuntimeValueTypeMarshallerConvertToUnmanagedUnsafe }, { Ret } } }; @@ -173,7 +173,7 @@ public static void Marshaller( // Declare the local variables: // [0]: '' (for the failure path, initialized to 'default') - CilLocalVariable loc_0_default = new(keyValuePairType.Import(module)); + CilLocalVariable loc_0_default = new(keyValuePairType); // Jump labels CilInstruction ldarg_0_marshal = new(Ldarg_0); @@ -199,7 +199,7 @@ public static void Marshaller( // return default { Ldloca_S, loc_0_default }, - { Initobj, keyValuePairType.Import(module).ToTypeDefOrRef() }, + { Initobj, keyValuePairType.ToTypeDefOrRef() }, { Ldloc_0 }, { Ret }, @@ -208,7 +208,7 @@ public static void Marshaller( { Call, keyAccessorMethod }, { Ldarg_0 }, { Call, valueAccessorMethod }, - { Newobj, interopReferences.KeyValuePair2_ctor(keyValuePairType).Import(module) }, + { Newobj, interopReferences.KeyValuePair2_ctor(keyValuePairType) }, { Ret } } }; diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.SzArray.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.SzArray.cs index c47349485..14b88db97 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.SzArray.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.SzArray.cs @@ -55,9 +55,9 @@ public static void Marshaller( signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Void, parameterTypes: [ - interopReferences.ReadOnlySpan1.MakeGenericValueType(elementType).Import(module), + interopReferences.ReadOnlySpan1.MakeGenericValueType(elementType), module.CorLibTypeFactory.UInt32.MakeByReferenceType(), - elementAbiType.Import(module).MakePointerType().MakeByReferenceType()])) + elementAbiType.MakePointerType().MakeByReferenceType()])) { CilOutParameterIndices = [2, 3], CilInstructions = @@ -76,10 +76,10 @@ public static void Marshaller( name: "ConvertToManaged"u8, attributes: MethodAttributes.Public | MethodAttributes.Static | MethodAttributes.HideBySig, signature: MethodSignature.CreateStatic( - returnType: arrayType.Import(module), + returnType: arrayType, parameterTypes: [ module.CorLibTypeFactory.UInt32, - elementAbiType.Import(module).MakePointerType()])) + elementAbiType.MakePointerType()])) { CilInstructions = { @@ -100,8 +100,8 @@ public static void Marshaller( returnType: module.CorLibTypeFactory.Void, parameterTypes: [ module.CorLibTypeFactory.UInt32, - elementAbiType.Import(module).MakePointerType(), - interopReferences.Span1.MakeGenericValueType(elementType).Import(module)])) + elementAbiType.MakePointerType(), + interopReferences.Span1.MakeGenericValueType(elementType)])) { CilInstructions = { @@ -121,9 +121,9 @@ public static void Marshaller( signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Void, parameterTypes: [ - interopReferences.ReadOnlySpan1.MakeGenericValueType(elementType).Import(module), + interopReferences.ReadOnlySpan1.MakeGenericValueType(elementType), module.CorLibTypeFactory.UInt32, - elementAbiType.Import(module).MakePointerType()])) + elementAbiType.MakePointerType()])) { CilInstructions = { @@ -165,7 +165,7 @@ public static void ComWrappersCallback( attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: module.CorLibTypeFactory.Object.ToTypeDefOrRef()) { - Interfaces = { new InterfaceImplementation(interopReferences.IWindowsRuntimeArrayComWrappersCallback.Import(module)) } + Interfaces = { new InterfaceImplementation(interopReferences.IWindowsRuntimeArrayComWrappersCallback) } }; module.TopLevelTypes.Add(callbackType); @@ -177,7 +177,7 @@ public static void ComWrappersCallback( name: "CreateArray"u8, attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Static, signature: MethodSignature.CreateStatic( - returnType: interopReferences.Array.ToReferenceTypeSignature().Import(module), + returnType: interopReferences.Array.ToReferenceTypeSignature(), parameterTypes: [ module.CorLibTypeFactory.UInt32, module.CorLibTypeFactory.Void.MakePointerType()])) @@ -193,7 +193,7 @@ public static void ComWrappersCallback( // Add and implement 'CreateArray' callbackType.AddMethodImplementation( - declaration: interopReferences.IWindowsRuntimeArrayComWrappersCallbackCreateArray.Import(module), + declaration: interopReferences.IWindowsRuntimeArrayComWrappersCallbackCreateArray, method: createArrayMethod); } @@ -226,7 +226,7 @@ public static void ArrayImpl( parameterTypes: [ module.CorLibTypeFactory.Void.MakePointerType(), module.CorLibTypeFactory.UInt32.MakePointerType(), - arrayType.BaseType.GetAbiType(interopReferences).Import(module).MakePointerType().MakePointerType()])) + arrayType.BaseType.GetAbiType(interopReferences).MakePointerType().MakePointerType()])) { CustomAttributes = { InteropCustomAttributeFactory.UnmanagedCallersOnly(interopReferences, module) } }; @@ -235,14 +235,14 @@ public static void ArrayImpl( CilInstruction ldc_i4_e_pointer = new(Ldc_I4, unchecked((int)0x80004003)); CilInstruction nop_beforeTry = new(Nop); CilInstruction ldarg_0_tryStart = new(Ldarg_0); - CilInstruction call_catchStartMarshalException = new(Call, interopReferences.RestrictedErrorInfoExceptionMarshallerConvertToUnmanaged.Import(module)); + CilInstruction call_catchStartMarshalException = new(Call, interopReferences.RestrictedErrorInfoExceptionMarshallerConvertToUnmanaged); CilInstruction ldloc_0_returnHResult = new(Ldloc_0); // Declare 2 local variables: // [0]: 'int' (the 'HRESULT' to return) // [1]: 'WindowsRuntimeObjectReferenceValue' to use to marshal the delegate CilLocalVariable loc_0_hresult = new(module.CorLibTypeFactory.Int32); - CilLocalVariable loc_1_referenceValue = new(interopReferences.WindowsRuntimeObjectReferenceValue.ToValueTypeSignature().Import(module)); + CilLocalVariable loc_1_referenceValue = new(interopReferences.WindowsRuntimeObjectReferenceValue.ToValueTypeSignature()); // Create a method body for the 'get_Value' method valueMethod.CilMethodBody = new CilMethodBody() @@ -265,8 +265,8 @@ public static void ArrayImpl( // '.try' code { ldarg_0_tryStart }, - { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(arrayType).Import(module) }, - { Newobj, interopReferences.ReadOnlySpan1_ctor(arrayType).Import(module) }, + { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(arrayType) }, + { Newobj, interopReferences.ReadOnlySpan1_ctor(arrayType) }, { Ldarg_1 }, { Ldarg_2 }, { Call, marshallerType.GetMethod("ConvertToUnmanaged"u8) }, @@ -292,7 +292,7 @@ public static void ArrayImpl( TryEnd = call_catchStartMarshalException.CreateLabel(), HandlerStart = call_catchStartMarshalException.CreateLabel(), HandlerEnd = ldloc_0_returnHResult.CreateLabel(), - ExceptionType = interopReferences.Exception.Import(module) + ExceptionType = interopReferences.Exception } } }; @@ -372,7 +372,7 @@ public static void ComWrappersMarshallerAttribute( ns: InteropUtf8NameFactory.TypeNamespace(arrayType), name: InteropUtf8NameFactory.TypeName(arrayType, "ComWrappersMarshallerAttribute"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, - baseType: interopReferences.WindowsRuntimeComWrappersMarshallerAttribute.Import(module)); + baseType: interopReferences.WindowsRuntimeComWrappersMarshallerAttribute); module.TopLevelTypes.Add(marshallerType); @@ -382,7 +382,7 @@ public static void ComWrappersMarshallerAttribute( marshallerType.Methods.Add(ctor); _ = ctor.CilMethodBody!.Instructions.Insert(0, Ldarg_0); - _ = ctor.CilMethodBody!.Instructions.Insert(1, Call, interopReferences.WindowsRuntimeComWrappersMarshallerAttribute_ctor.Import(module)); + _ = ctor.CilMethodBody!.Instructions.Insert(1, Call, interopReferences.WindowsRuntimeComWrappersMarshallerAttribute_ctor); // Determine which 'CreateComInterfaceFlags' flags we use for the marshalled CCW CreateComInterfaceFlags flags = arrayType.IsTrackerSupportRequired(interopReferences) @@ -403,7 +403,7 @@ public static void ComWrappersMarshallerAttribute( { { Ldarg_1 }, { CilInstruction.CreateLdcI4((int)flags) }, - { Call, interopReferences.WindowsRuntimeComWrappersMarshalGetOrCreateComInterfaceForObject.Import(module) }, + { Call, interopReferences.WindowsRuntimeComWrappersMarshalGetOrCreateComInterfaceForObject }, { Ret } } }; @@ -418,7 +418,7 @@ public static void ComWrappersMarshallerAttribute( name: "ComputeVtables"u8, attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Virtual, signature: MethodSignature.CreateInstance( - returnType: interopReferences.ComInterfaceEntry.Import(module).MakePointerType(), + returnType: interopReferences.ComInterfaceEntry.MakePointerType(), parameterTypes: [module.CorLibTypeFactory.Int32.MakeByReferenceType()])) { CilOutParameterIndices = [1], @@ -436,8 +436,8 @@ public static void ComWrappersMarshallerAttribute( marshallerType.Methods.Add(computeVtablesMethod); // Import the 'UnboxToManaged' method for the array - IMethodDescriptor windowsRuntimeArrayMarshallerUnboxToManagedDescriptor = interopReferences.WindowsRuntimeArrayMarshallerUnboxToManaged - .Import(module) + IMethodDescriptor windowsRuntimeArrayMarshallerUnboxToManagedDescriptor = + interopReferences.WindowsRuntimeArrayMarshallerUnboxToManaged .MakeGenericInstanceMethod(arrayComWrappersCallbackType.ToReferenceTypeSignature()); // Define the 'CreateObject' method as follows: @@ -450,7 +450,7 @@ public static void ComWrappersMarshallerAttribute( returnType: module.CorLibTypeFactory.Object, parameterTypes: [ module.CorLibTypeFactory.Void.MakePointerType(), - interopReferences.CreatedWrapperFlags.Import(module).MakeByReferenceType()])) + interopReferences.CreatedWrapperFlags.MakeByReferenceType()])) { CilOutParameterIndices = [2], CilInstructions = diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.UserDefinedType.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.UserDefinedType.cs index 21cfc46d8..b39b244b8 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.UserDefinedType.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.UserDefinedType.cs @@ -197,7 +197,7 @@ public static void ComWrappersMarshallerAttribute( ns: "WindowsRuntime.Interop.UserDefinedTypes"u8, name: InteropUtf8NameFactory.TypeName(userDefinedType, "ComWrappersMarshallerAttribute"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, - baseType: interopReferences.WindowsRuntimeComWrappersMarshallerAttribute.Import(module)); + baseType: interopReferences.WindowsRuntimeComWrappersMarshallerAttribute); module.TopLevelTypes.Add(marshallerType); @@ -207,10 +207,10 @@ public static void ComWrappersMarshallerAttribute( marshallerType.Methods.Add(ctor); _ = ctor.CilMethodBody!.Instructions.Insert(0, Ldarg_0); - _ = ctor.CilMethodBody!.Instructions.Insert(1, Call, interopReferences.WindowsRuntimeComWrappersMarshallerAttribute_ctor.Import(module)); + _ = ctor.CilMethodBody!.Instructions.Insert(1, Call, interopReferences.WindowsRuntimeComWrappersMarshallerAttribute_ctor); // The 'ComputeVtables' method returns the 'ComWrappers.ComInterfaceEntry*' type - PointerTypeSignature computeVtablesReturnType = interopReferences.ComInterfaceEntry.Import(module).MakePointerType(); + PointerTypeSignature computeVtablesReturnType = interopReferences.ComInterfaceEntry.MakePointerType(); // Retrieve the cached COM interface entries type, as we need the number of fields TypeDefinition interfaceEntriesType = interopDefinitions.UserDefinedInterfaceEntries(NumberOfDefaultComInterfaceEntries + vtableTypes.Count); @@ -253,7 +253,7 @@ public static void ComWrappersMarshallerAttribute( { { Ldarg_1 }, { CilInstruction.CreateLdcI4((int)CreateComInterfaceFlags.TrackerSupport) }, - { Call, interopReferences.WindowsRuntimeComWrappersMarshalGetOrCreateComInterfaceForObject.Import(module) }, + { Call, interopReferences.WindowsRuntimeComWrappersMarshalGetOrCreateComInterfaceForObject }, { Ret } } }; @@ -322,14 +322,14 @@ private sealed class WindowsRuntimeInterfaceEntryInfo(IMethodDefOrRef get_IID, I /// public override void LoadIID(CilInstructionCollection instructions, InteropReferences interopReferences, ModuleDefinition module) { - _ = instructions.Add(Call, get_IID.Import(module)); - _ = instructions.Add(Ldobj, interopReferences.Guid.Import(module)); + _ = instructions.Add(Call, get_IID); + _ = instructions.Add(Ldobj, interopReferences.Guid); } /// public override void LoadVtable(CilInstructionCollection instructions, InteropReferences interopReferences, ModuleDefinition module) { - _ = instructions.Add(Call, get_Vtable.Import(module)); + _ = instructions.Add(Call, get_Vtable); } } @@ -342,15 +342,15 @@ private sealed class ComInterfaceEntryInfo(TypeSignature interfaceInformationTyp /// public override void LoadIID(CilInstructionCollection instructions, InteropReferences interopReferences, ModuleDefinition module) { - _ = instructions.Add(Constrained, interfaceInformationType.Import(module).ToTypeDefOrRef()); - _ = instructions.Add(Call, interopReferences.IIUnknownInterfaceTypeget_Iid.Import(module)); + _ = instructions.Add(Constrained, interfaceInformationType.ToTypeDefOrRef()); + _ = instructions.Add(Call, interopReferences.IIUnknownInterfaceTypeget_Iid); } /// public override void LoadVtable(CilInstructionCollection instructions, InteropReferences interopReferences, ModuleDefinition module) { - _ = instructions.Add(Constrained, interfaceInformationType.Import(module).ToTypeDefOrRef()); - _ = instructions.Add(Call, interopReferences.IIUnknownInterfaceTypeget_ManagedVirtualMethodTable.Import(module)); + _ = instructions.Add(Constrained, interfaceInformationType.ToTypeDefOrRef()); + _ = instructions.Add(Call, interopReferences.IIUnknownInterfaceTypeget_ManagedVirtualMethodTable); } } } diff --git a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.cs b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.cs index d6ed1fea0..963eb695a 100644 --- a/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.cs +++ b/src/WinRT.Interop.Generator/Builders/InteropTypeDefinitionBuilder.cs @@ -103,18 +103,18 @@ private static void NativeObject( ns: InteropUtf8NameFactory.TypeNamespace(typeSignature), name: InteropUtf8NameFactory.TypeName(typeSignature, "NativeObject"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, - baseType: nativeObjectBaseType.Import(module).ToTypeDefOrRef()); + baseType: nativeObjectBaseType.ToTypeDefOrRef()); module.TopLevelTypes.Add(nativeObjectType); // Define the constructor - MethodDefinition ctor = MethodDefinition.CreateConstructor(module, interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature()); + MethodDefinition ctor = MethodDefinition.CreateConstructor(module, interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature()); nativeObjectType.Methods.Add(ctor); _ = ctor.CilMethodBody!.Instructions.Insert(0, Ldarg_0); _ = ctor.CilMethodBody!.Instructions.Insert(1, Ldarg_1); - _ = ctor.CilMethodBody!.Instructions.Insert(2, Call, interopReferences.WindowsRuntimeNativeObjectBaseType_ctor(nativeObjectBaseType).Import(module)); + _ = ctor.CilMethodBody!.Instructions.Insert(2, Call, interopReferences.WindowsRuntimeNativeObjectBaseType_ctor(nativeObjectBaseType)); } /// @@ -143,7 +143,7 @@ private static void ComWrappersCallback( attributes: TypeAttributes.AutoLayout | TypeAttributes.Abstract | TypeAttributes.BeforeFieldInit, baseType: module.CorLibTypeFactory.Object.ToTypeDefOrRef()) { - Interfaces = { new InterfaceImplementation(interopReferences.IWindowsRuntimeUnsealedObjectComWrappersCallback.Import(module)) } + Interfaces = { new InterfaceImplementation(interopReferences.IWindowsRuntimeUnsealedObjectComWrappersCallback) } }; module.TopLevelTypes.Add(callbackType); @@ -162,19 +162,19 @@ private static void ComWrappersCallback( returnType: module.CorLibTypeFactory.Boolean, parameterTypes: [ module.CorLibTypeFactory.Void.MakePointerType(), - interopReferences.ReadOnlySpanChar.Import(module), + interopReferences.ReadOnlySpanChar, module.CorLibTypeFactory.Object.MakeByReferenceType(), - interopReferences.CreatedWrapperFlags.Import(module).MakeByReferenceType()])) + interopReferences.CreatedWrapperFlags.MakeByReferenceType()])) { CilOutParameterIndices = [3, 4] }; // Add and implement 'TryCreateObject' callbackType.AddMethodImplementation( - declaration: interopReferences.IWindowsRuntimeUnsealedObjectComWrappersCallbackTryCreateObject.Import(module), + declaration: interopReferences.IWindowsRuntimeUnsealedObjectComWrappersCallbackTryCreateObject, method: tryCreateObjectMethod); // Declare the local variables: // [0]: 'WindowsRuntimeObjectReference' (for 'result') - CilLocalVariable loc_0_result = new(interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature().Import(module)); + CilLocalVariable loc_0_result = new(interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature()); // Jump labels CilInstruction ldarg_3_failure = new(Ldarg_3); @@ -188,15 +188,15 @@ private static void ComWrappersCallback( // Compare the runtime class name for the fast path { Ldarg_1 }, { Ldstr, runtimeClassName }, - { Call, interopReferences.MemoryExtensionsAsSpanCharString.Import(module) }, - { Call, interopReferences.MemoryExtensionsSequenceEqualChar.Import(module) }, + { Call, interopReferences.MemoryExtensionsAsSpanCharString }, + { Call, interopReferences.MemoryExtensionsSequenceEqualChar }, { Brfalse_S, ldarg_3_failure.CreateLabel() }, // Create the 'WindowsRuntimeObjectReference' instance { Ldarg_0 }, { Call, get_IidMethod }, { Ldarg_3 }, - { Call, interopReferences.WindowsRuntimeComWrappersMarshalCreateObjectReferenceUnsafe.Import(module) }, + { Call, interopReferences.WindowsRuntimeComWrappersMarshalCreateObjectReferenceUnsafe }, { Stloc_0 }, // Create and assign the 'NativeObject' instance to return @@ -242,7 +242,7 @@ private static void ComWrappersMarshallerAttribute( ns: InteropUtf8NameFactory.TypeNamespace(typeSignature), name: InteropUtf8NameFactory.TypeName(typeSignature, "ComWrappersMarshallerAttribute"), attributes: TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, - baseType: interopReferences.WindowsRuntimeComWrappersMarshallerAttribute.Import(module)); + baseType: interopReferences.WindowsRuntimeComWrappersMarshallerAttribute); module.TopLevelTypes.Add(marshallerType); @@ -252,7 +252,7 @@ private static void ComWrappersMarshallerAttribute( marshallerType.Methods.Add(ctor); _ = ctor.CilMethodBody!.Instructions.Insert(0, Ldarg_0); - _ = ctor.CilMethodBody!.Instructions.Insert(1, Call, interopReferences.WindowsRuntimeComWrappersMarshallerAttribute_ctor.Import(module)); + _ = ctor.CilMethodBody!.Instructions.Insert(1, Call, interopReferences.WindowsRuntimeComWrappersMarshallerAttribute_ctor); // Define the 'CreateObject' method as follows: // @@ -264,7 +264,7 @@ private static void ComWrappersMarshallerAttribute( returnType: module.CorLibTypeFactory.Object, parameterTypes: [ module.CorLibTypeFactory.Void.MakePointerType(), - interopReferences.CreatedWrapperFlags.Import(module).MakeByReferenceType()])) + interopReferences.CreatedWrapperFlags.MakeByReferenceType()])) { CilOutParameterIndices = [2], CilInstructions = @@ -273,7 +273,7 @@ private static void ComWrappersMarshallerAttribute( { Ldarg_1 }, { Call, get_IidMethod }, { Ldarg_2 }, - { Call, interopReferences.WindowsRuntimeComWrappersMarshalCreateObjectReference.Import(module) }, + { Call, interopReferences.WindowsRuntimeComWrappersMarshalCreateObjectReference }, { Newobj, nativeObjectType.GetMethod(".ctor"u8) }, { Ret }, } @@ -310,8 +310,8 @@ private static void Marshaller( module.TopLevelTypes.Add(marshallerType); // Prepare the external types we need in the implemented methods - TypeSignature typeSignature2 = typeSignature.Import(module); - TypeSignature windowsRuntimeObjectReferenceValueType = interopReferences.WindowsRuntimeObjectReferenceValue.Import(module).ToValueTypeSignature(); + TypeSignature typeSignature2 = typeSignature; + TypeSignature windowsRuntimeObjectReferenceValueType = interopReferences.WindowsRuntimeObjectReferenceValue.ToValueTypeSignature(); // Reference the instantiated 'ConvertToUnmanaged' method for the marshaller MemberReference windowsRuntimeInterfaceMarshallerConvertToUnmanaged = interopReferences.WindowsRuntimeInterfaceMarshallerConvertToUnmanaged(typeSignature); @@ -330,7 +330,7 @@ private static void Marshaller( { { Ldarg_0 }, { Call, get_IidMethod }, - { Call, windowsRuntimeInterfaceMarshallerConvertToUnmanaged.Import(module) }, + { Call, windowsRuntimeInterfaceMarshallerConvertToUnmanaged }, { Ret } } }; @@ -340,7 +340,6 @@ private static void Marshaller( // Construct a descriptor for 'WindowsRuntimeUnsealedObjectMarshaller.ConvertToManaged<>(void*)' IMethodDescriptor windowsRuntimeUnsealedObjectMarshallerConvertToManaged = interopReferences.WindowsRuntimeUnsealedObjectMarshallerConvertToManaged - .Import(module) .MakeGenericInstanceMethod(interfaceComWrappersCallbackType.ToReferenceTypeSignature()); // Define the 'ConvertToManaged' method as follows: @@ -403,7 +402,7 @@ private static void Impl( // private static readonly Vftbl; FieldDefinition vftblField = new("Vftbl"u8, FieldAttributes.Private | FieldAttributes.Static, vftblType.ToValueTypeSignature()) { - CustomAttributes = { new CustomAttribute(interopReferences.FixedAddressValueTypeAttribute_ctor.Import(module)) } + CustomAttributes = { new CustomAttribute(interopReferences.FixedAddressValueTypeAttribute_ctor) } }; implType.Fields.Add(vftblField); @@ -427,13 +426,13 @@ private static void Impl( switch (interfaceType) { case ComInterfaceType.InterfaceIsIUnknown: - _ = cctor.CilMethodBody.Instructions.Add(Call, interopReferences.IUnknownImplget_Vtable.Import(module)); + _ = cctor.CilMethodBody.Instructions.Add(Call, interopReferences.IUnknownImplget_Vtable); _ = cctor.CilMethodBody.Instructions.Add(Ldobj, interopDefinitions.IUnknownVftbl); _ = cctor.CilMethodBody.Instructions.Add(Stobj, interopDefinitions.IUnknownVftbl); vtableOffset = 3; break; case ComInterfaceType.InterfaceIsIInspectable: - _ = cctor.CilMethodBody.Instructions.Add(Call, interopReferences.IInspectableImplget_Vtable.Import(module)); + _ = cctor.CilMethodBody.Instructions.Add(Call, interopReferences.IInspectableImplget_Vtable); _ = cctor.CilMethodBody.Instructions.Add(Ldobj, interopDefinitions.IInspectableVftbl); _ = cctor.CilMethodBody.Instructions.Add(Stobj, interopDefinitions.IInspectableVftbl); vtableOffset = 6; @@ -497,8 +496,8 @@ static void LoadIID( InteropReferences interopReferences, ModuleDefinition module) { - _ = instructions.Add(Call, arg.get_IID.Import(module)); - _ = instructions.Add(Ldobj, interopReferences.Guid.Import(module)); + _ = instructions.Add(Call, arg.get_IID); + _ = instructions.Add(Ldobj, interopReferences.Guid); } // Load the vtable property @@ -508,7 +507,7 @@ static void LoadVtable( InteropReferences interopReferences, ModuleDefinition module) { - _ = instructions.Add(Call, arg.get_Vtable.Import(module)); + _ = instructions.Add(Call, arg.get_Vtable); } InterfaceEntriesImpl( @@ -595,7 +594,7 @@ private static void InterfaceEntriesImpl( // The '[FixedAddressValueType]' attribute allows ILC to pre-initialize the entire vtable (in .rdata). FieldDefinition entriesField = new("Entries"u8, FieldAttributes.Private | FieldAttributes.Static, entriesFieldType.ToValueTypeSignature()) { - CustomAttributes = { new CustomAttribute(interopReferences.FixedAddressValueTypeAttribute_ctor.Import(module)) } + CustomAttributes = { new CustomAttribute(interopReferences.FixedAddressValueTypeAttribute_ctor) } }; implType.Fields.Add(entriesField); @@ -606,8 +605,8 @@ private static void InterfaceEntriesImpl( // Import the target fields (they have to be in the module, or the resulting assembly won't be valid): // - [0]: Guid IID // - [1]: nint Vtable - IFieldDescriptor comInterfaceEntryIIDField = interopReferences.ComInterfaceEntryIID.Import(module); - IFieldDescriptor comInterfaceEntryVtableField = interopReferences.ComInterfaceEntryVtable.Import(module); + IFieldDescriptor comInterfaceEntryIIDField = interopReferences.ComInterfaceEntryIID; + IFieldDescriptor comInterfaceEntryVtableField = interopReferences.ComInterfaceEntryVtable; // We need to create a new method body bound to this constructor CilInstructionCollection cctorInstructions = cctor.CilMethodBody!.Instructions; @@ -642,7 +641,7 @@ private static void InterfaceEntriesImpl( _ = cctorInstructions.Add(Ret); // The 'Vtables' property type has the signature being 'ComWrappers.ComInterfaceEntry*' - PointerTypeSignature vtablesPropertyType = interopReferences.ComInterfaceEntry.Import(module).MakePointerType(); + PointerTypeSignature vtablesPropertyType = interopReferences.ComInterfaceEntry.MakePointerType(); // Create the 'Vtables' property PropertyDefinition vtablesProperty = new( @@ -705,7 +704,7 @@ public static void Proxy( .CreateMemberReference(".ctor", MethodSignature.CreateInstance( returnType: module.CorLibTypeFactory.Void, parameterTypes: [module.CorLibTypeFactory.String])) - .Import(module); + ; // Add the attribute with the name of the runtime class marshallerType.CustomAttributes.Add(new CustomAttribute( @@ -715,7 +714,7 @@ public static void Proxy( value: runtimeClassName)))); // Add the generated marshaller attribute - marshallerType.CustomAttributes.Add(new CustomAttribute(comWrappersMarshallerAttributeType.GetConstructor()!.Import(module))); + marshallerType.CustomAttributes.Add(new CustomAttribute(comWrappersMarshallerAttributeType.GetConstructor()!)); } /// diff --git a/src/WinRT.Interop.Generator/Builders/WindowsRuntimeTypeHierarchyBuilder.cs b/src/WinRT.Interop.Generator/Builders/WindowsRuntimeTypeHierarchyBuilder.cs index acb5ac380..4e1c3664b 100644 --- a/src/WinRT.Interop.Generator/Builders/WindowsRuntimeTypeHierarchyBuilder.cs +++ b/src/WinRT.Interop.Generator/Builders/WindowsRuntimeTypeHierarchyBuilder.cs @@ -224,7 +224,7 @@ private static void ValuesRva( ns: null, name: $"TypeHierarchyLookupValuesRvaData(Size={valuesRvaBuffer.WrittenCount}|Align=2)", attributes: TypeAttributes.NestedAssembly | TypeAttributes.ExplicitLayout | TypeAttributes.Sealed, - baseType: interopReferences.ValueType.Import(module)) + baseType: interopReferences.ValueType) { ClassLayout = new ClassLayout(packingSize: 2, classSize: (uint)valuesRvaBuffer.WrittenCount) }; @@ -379,7 +379,7 @@ private static void KeysRva( ns: null, name: $"TypeHierarchyLookupKeysRvaData(Size={keysRvaBuffer.WrittenCount}|Align=2)", attributes: TypeAttributes.NestedAssembly | TypeAttributes.ExplicitLayout | TypeAttributes.Sealed, - baseType: interopReferences.ValueType.Import(module)) + baseType: interopReferences.ValueType) { ClassLayout = new ClassLayout(packingSize: 2, classSize: (uint)keysRvaBuffer.WrittenCount) }; @@ -430,7 +430,7 @@ private static void BucketsRva( ns: null, name: $"TypeHierarchyLookupBucketsRvaData(Size={bucketsRvaBuffer.WrittenCount}|Align=4)", attributes: TypeAttributes.NestedAssembly | TypeAttributes.ExplicitLayout | TypeAttributes.Sealed, - baseType: interopReferences.ValueType.Import(module)) + baseType: interopReferences.ValueType) { ClassLayout = new ClassLayout(packingSize: 4, classSize: (uint)bucketsRvaBuffer.WrittenCount) }; @@ -483,7 +483,7 @@ private static void WindowsRuntimeTypeHierarchyData( MethodDefinition get_BucketsMethod = new( name: "get_Buckets"u8, attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.Static, - signature: MethodSignature.CreateStatic(interopReferences.ReadOnlySpanInt32.Import(module))) + signature: MethodSignature.CreateStatic(interopReferences.ReadOnlySpanInt32)) { IsAggressiveInlining = true, CilInstructions = @@ -491,7 +491,7 @@ private static void WindowsRuntimeTypeHierarchyData( { Ldsflda, bucketsRvaField }, { Conv_U }, { CilInstruction.CreateLdcI4((int)(bucketsRvaField.Signature!.FieldType.Resolve()!.ClassLayout!.ClassSize / sizeof(int))) }, - { Newobj, interopReferences.ReadOnlySpanInt32_ctor.Import(module) }, + { Newobj, interopReferences.ReadOnlySpanInt32_ctor }, { Ret } } }; @@ -500,7 +500,7 @@ private static void WindowsRuntimeTypeHierarchyData( MethodDefinition get_KeysMethod = new( name: "get_Keys"u8, attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.Static, - signature: MethodSignature.CreateStatic(interopReferences.ReadOnlySpanByte.Import(module))) + signature: MethodSignature.CreateStatic(interopReferences.ReadOnlySpanByte)) { IsAggressiveInlining = true, CilInstructions = @@ -508,7 +508,7 @@ private static void WindowsRuntimeTypeHierarchyData( { Ldsflda, keysRvaField }, { Conv_U }, { CilInstruction.CreateLdcI4((int)keysRvaField.Signature!.FieldType.Resolve()!.ClassLayout!.ClassSize) }, - { Newobj, interopReferences.ReadOnlySpanByte_ctor.Import(module) }, + { Newobj, interopReferences.ReadOnlySpanByte_ctor }, { Ret } } }; @@ -517,7 +517,7 @@ private static void WindowsRuntimeTypeHierarchyData( MethodDefinition get_ValuesMethod = new( name: "get_Values"u8, attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.Static, - signature: MethodSignature.CreateStatic(interopReferences.ReadOnlySpanByte.Import(module))) + signature: MethodSignature.CreateStatic(interopReferences.ReadOnlySpanByte)) { IsAggressiveInlining = true, CilInstructions = @@ -525,7 +525,7 @@ private static void WindowsRuntimeTypeHierarchyData( { Ldsflda, valuesRvaField }, { Conv_U }, { CilInstruction.CreateLdcI4((int)valuesRvaField.Signature!.FieldType.Resolve()!.ClassLayout!.ClassSize) }, - { Newobj, interopReferences.ReadOnlySpanByte_ctor.Import(module) }, + { Newobj, interopReferences.ReadOnlySpanByte_ctor }, { Ret } } }; diff --git a/src/WinRT.Interop.Generator/Extensions/MethodDefinitionExtensions.cs b/src/WinRT.Interop.Generator/Extensions/MethodDefinitionExtensions.cs index da61ffd59..d00d8c099 100644 --- a/src/WinRT.Interop.Generator/Extensions/MethodDefinitionExtensions.cs +++ b/src/WinRT.Interop.Generator/Extensions/MethodDefinitionExtensions.cs @@ -39,7 +39,7 @@ public static MethodDefinition CreateDefaultConstructor(ModuleDefinition module) CilInstructions = { { Ldarg_0 }, - { Call, object_ctor.Import(module) }, + { Call, object_ctor }, { Ret } } }; diff --git a/src/WinRT.Interop.Generator/Factories/InteropCustomAttributeFactory.cs b/src/WinRT.Interop.Generator/Factories/InteropCustomAttributeFactory.cs index 8b2bbf230..fc6dda2c8 100644 --- a/src/WinRT.Interop.Generator/Factories/InteropCustomAttributeFactory.cs +++ b/src/WinRT.Interop.Generator/Factories/InteropCustomAttributeFactory.cs @@ -25,12 +25,12 @@ internal static class InteropCustomAttributeFactory public static CustomAttribute UnmanagedCallersOnly(InteropReferences interopReferences, ModuleDefinition module) { // Get the 'Type[]' signature and reuse it (we need it for both the argument and the element) - TypeSignature typeArraySignature = interopReferences.Type.Import(module).MakeSzArrayType(); + TypeSignature typeArraySignature = interopReferences.Type.MakeSzArrayType(); // Create the following attribute: // // [UnmanagedCallersOnly(CallConvs = [typeof(CallConvMemberFunction)])] - return new(interopReferences.UnmanagedCallersOnlyAttribute_ctor.Import(module), new CustomAttributeSignature( + return new(interopReferences.UnmanagedCallersOnlyAttribute_ctor, new CustomAttributeSignature( fixedArguments: [], namedArguments: [new CustomAttributeNamedArgument( memberType: CustomAttributeArgumentMemberType.Field, @@ -38,7 +38,7 @@ public static CustomAttribute UnmanagedCallersOnly(InteropReferences interopRefe argumentType: typeArraySignature, argument: new CustomAttributeArgument( argumentType: typeArraySignature, - elements: interopReferences.CallConvMemberFunction.Import(module).ToReferenceTypeSignature()))])); + elements: interopReferences.CallConvMemberFunction.ToReferenceTypeSignature()))])); } /// @@ -58,9 +58,9 @@ public static CustomAttribute AttributeUsage( // Create the following attribute: // // [AttributeUsage(, AllowMultiple = )] - return new(interopReferences.AttributeUsageAttribute_ctor_AttributeTargets.Import(module), new CustomAttributeSignature( + return new(interopReferences.AttributeUsageAttribute_ctor_AttributeTargets, new CustomAttributeSignature( fixedArguments: [new CustomAttributeArgument( - argumentType: interopReferences.AttributeTargets.Import(module).ToValueTypeSignature(), + argumentType: interopReferences.AttributeTargets.ToValueTypeSignature(), value: (int)attributeTargets)], namedArguments: [new CustomAttributeNamedArgument( memberType: CustomAttributeArgumentMemberType.Property, @@ -113,17 +113,17 @@ public static CustomAttribute TypeMapWindowsRuntimeComWrappersTypeMapGroup( // Create the following attribute: // // [TypeMap(, , )] - return new(interopReferences.TypeMapAttributeWindowsRuntimeComWrappersTypeMapGroup_ctor_TrimTarget.Import(module), new CustomAttributeSignature( + return new(interopReferences.TypeMapAttributeWindowsRuntimeComWrappersTypeMapGroup_ctor_TrimTarget, new CustomAttributeSignature( fixedArguments: [ new CustomAttributeArgument( argumentType: module.CorLibTypeFactory.String, value: value), new CustomAttributeArgument( - argumentType: interopReferences.Type.Import(module).ToReferenceTypeSignature(), - value: target.Import(module)), + argumentType: interopReferences.Type.ToReferenceTypeSignature(), + value: target), new CustomAttributeArgument( - argumentType: interopReferences.Type.Import(module).ToReferenceTypeSignature(), - value: trimTarget.Import(module))])); + argumentType: interopReferences.Type.ToReferenceTypeSignature(), + value: trimTarget)])); } /// @@ -143,14 +143,14 @@ public static CustomAttribute TypeMapAssociationWindowsRuntimeComWrappersTypeMap // Create the following attribute: // // [TypeMap(, )] - return new(interopReferences.TypeMapAssociationAttributeWindowsRuntimeComWrappersTypeMapGroup_ctor.Import(module), new CustomAttributeSignature( + return new(interopReferences.TypeMapAssociationAttributeWindowsRuntimeComWrappersTypeMapGroup_ctor, new CustomAttributeSignature( fixedArguments: [ new CustomAttributeArgument( - argumentType: interopReferences.Type.Import(module).ToReferenceTypeSignature(), - value: source.Import(module)), + argumentType: interopReferences.Type.ToReferenceTypeSignature(), + value: source), new CustomAttributeArgument( - argumentType: interopReferences.Type.Import(module).ToReferenceTypeSignature(), - value: proxy.Import(module))])); + argumentType: interopReferences.Type.ToReferenceTypeSignature(), + value: proxy)])); } /// @@ -170,13 +170,13 @@ public static CustomAttribute TypeMapAssociationDynamicInterfaceCastableImplemen // Create the following attribute: // // [TypeMap(, )] - return new(interopReferences.TypeMapAssociationAttributeDynamicInterfaceCastableImplementationTypeMapGroup_ctor.Import(module), new CustomAttributeSignature( + return new(interopReferences.TypeMapAssociationAttributeDynamicInterfaceCastableImplementationTypeMapGroup_ctor, new CustomAttributeSignature( fixedArguments: [ new CustomAttributeArgument( - argumentType: interopReferences.Type.Import(module).ToReferenceTypeSignature(), - value: source.Import(module)), + argumentType: interopReferences.Type.ToReferenceTypeSignature(), + value: source), new CustomAttributeArgument( - argumentType: interopReferences.Type.Import(module).ToReferenceTypeSignature(), - value: proxy.Import(module))])); + argumentType: interopReferences.Type.ToReferenceTypeSignature(), + value: proxy)])); } } \ No newline at end of file diff --git a/src/WinRT.Interop.Generator/Factories/InteropMemberDefinitionFactory.cs b/src/WinRT.Interop.Generator/Factories/InteropMemberDefinitionFactory.cs index c9e397c8d..f4d616c05 100644 --- a/src/WinRT.Interop.Generator/Factories/InteropMemberDefinitionFactory.cs +++ b/src/WinRT.Interop.Generator/Factories/InteropMemberDefinitionFactory.cs @@ -43,7 +43,7 @@ public static void LazyVolatileReferenceDefaultConstructorReadOnlyProperty( backingField = new FieldDefinition( name: $"<{propertyName}>k__BackingField", attributes: FieldAttributes.Private | FieldAttributes.Static, - fieldType: propertyType.Import(module)); + fieldType: propertyType); // Define the factory method as follows: // @@ -52,16 +52,16 @@ public static void LazyVolatileReferenceDefaultConstructorReadOnlyProperty( factoryMethod = new MethodDefinition( name: $"g__CreateValue|{index}_0", attributes: MethodAttributes.Private | MethodAttributes.HideBySig | MethodAttributes.Static, - signature: MethodSignature.CreateStatic(propertyType.Import(module))) + signature: MethodSignature.CreateStatic(propertyType)) { NoInlining = true, CilInstructions = { // _ = Interlocked.CompareExchange(ref , value: new(), comparand: null); { Ldsflda, backingField }, - { Newobj, propertyType.ToTypeDefOrRef().CreateConstructorReference(module.CorLibTypeFactory).Import(module) }, + { Newobj, propertyType.ToTypeDefOrRef().CreateConstructorReference(module.CorLibTypeFactory) }, { Ldnull }, - { Call, interopReferences.InterlockedCompareExchange1.MakeGenericInstanceMethod(propertyType).Import(module) }, + { Call, interopReferences.InterlockedCompareExchange1.MakeGenericInstanceMethod(propertyType) }, { Pop }, // return ; @@ -77,7 +77,7 @@ public static void LazyVolatileReferenceDefaultConstructorReadOnlyProperty( getAccessorMethod = new MethodDefinition( name: $"get_{propertyName}", attributes: MethodAttributes.Private | MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.Static, - signature: MethodSignature.CreateStatic(propertyType.Import(module))) + signature: MethodSignature.CreateStatic(propertyType)) { IsAggressiveInlining = true, CilInstructions = diff --git a/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IAsyncActionWithProgress1Impl.cs b/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IAsyncActionWithProgress1Impl.cs index 56aca053d..feffdc835 100644 --- a/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IAsyncActionWithProgress1Impl.cs +++ b/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IAsyncActionWithProgress1Impl.cs @@ -49,7 +49,7 @@ public static MethodDefinition GetResults( // Labels for jumps CilInstruction ldarg_0_tryStart = new(Ldarg_0); CilInstruction ldloc_0_returnHResult = new(Ldloc_0); - CilInstruction call_catchStartMarshalException = new(Call, interopReferences.RestrictedErrorInfoExceptionMarshallerConvertToUnmanaged.Import(module)); + CilInstruction call_catchStartMarshalException = new(Call, interopReferences.RestrictedErrorInfoExceptionMarshallerConvertToUnmanaged); // Declare the local variables: // [0]: 'int' (the 'HRESULT' to return) @@ -63,8 +63,8 @@ public static MethodDefinition GetResults( { // '.try' code { ldarg_0_tryStart }, - { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(actionType).Import(module) }, - { Callvirt, interopReferences.IAsyncActionWithProgress1GetResults(progressType).Import(module) }, + { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(actionType) }, + { Callvirt, interopReferences.IAsyncActionWithProgress1GetResults(progressType) }, { Ldc_I4_0 }, { Stloc_0 }, { Leave_S, ldloc_0_returnHResult.CreateLabel() }, @@ -87,7 +87,7 @@ public static MethodDefinition GetResults( TryEnd = call_catchStartMarshalException.CreateLabel(), HandlerStart = call_catchStartMarshalException.CreateLabel(), HandlerEnd = ldloc_0_returnHResult.CreateLabel(), - ExceptionType = interopReferences.Exception.Import(module) + ExceptionType = interopReferences.Exception } } }; diff --git a/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IAsyncInfoImpl.cs b/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IAsyncInfoImpl.cs index f5612281e..b6cd834ba 100644 --- a/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IAsyncInfoImpl.cs +++ b/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IAsyncInfoImpl.cs @@ -61,13 +61,13 @@ public static MethodDefinition get_Handler( CilInstruction nop_beforeTry = new(Nop); CilInstruction ldarg_1_tryStart = new(Ldarg_1); CilInstruction ldloc_0_returnHResult = new(Ldloc_0); - CilInstruction call_catchStartMarshalException = new(Call, interopReferences.RestrictedErrorInfoExceptionMarshallerConvertToUnmanaged.Import(module)); + CilInstruction call_catchStartMarshalException = new(Call, interopReferences.RestrictedErrorInfoExceptionMarshallerConvertToUnmanaged); // Declare the local variables: // [0]: 'int' (the 'HRESULT' to return) // [1]: 'WindowsRuntimeObjectReferenceValue' (the marshalled async info instance) CilLocalVariable loc_0_hresult = new(module.CorLibTypeFactory.Int32); - CilLocalVariable loc_1_handlerValue = new(interopReferences.WindowsRuntimeObjectReferenceValue.ToValueTypeSignature().Import(module)); + CilLocalVariable loc_1_handlerValue = new(interopReferences.WindowsRuntimeObjectReferenceValue.ToValueTypeSignature()); // Create a method body for the 'get_Current' method handlerMethod.CilMethodBody = new CilMethodBody() @@ -87,12 +87,12 @@ public static MethodDefinition get_Handler( // '.try' code { ldarg_1_tryStart }, { Ldarg_0 }, - { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(asyncInfoType).Import(module) }, - { Callvirt, get_HandlerMethod.Import(module) }, - { Call, convertToUnmanagedMethod.Import(module) }, + { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(asyncInfoType) }, + { Callvirt, get_HandlerMethod }, + { Call, convertToUnmanagedMethod }, { Stloc_1 }, { Ldloca_S, loc_1_handlerValue }, - { Call, interopReferences.WindowsRuntimeObjectReferenceValueDetachThisPtrUnsafe.Import(module) }, + { Call, interopReferences.WindowsRuntimeObjectReferenceValueDetachThisPtrUnsafe }, { Stind_I }, { Ldc_I4_0 }, { Stloc_0 }, @@ -116,7 +116,7 @@ public static MethodDefinition get_Handler( TryEnd = call_catchStartMarshalException.CreateLabel(), HandlerStart = call_catchStartMarshalException.CreateLabel(), HandlerEnd = ldloc_0_returnHResult.CreateLabel(), - ExceptionType = interopReferences.Exception.Import(module) + ExceptionType = interopReferences.Exception } } }; @@ -163,7 +163,7 @@ public static MethodDefinition set_Handler( CilInstruction nop_beforeTry = new(Nop); CilInstruction ldarg_0_tryStart = new(Ldarg_0); CilInstruction ldloc_0_returnHResult = new(Ldloc_0); - CilInstruction call_catchStartMarshalException = new(Call, interopReferences.RestrictedErrorInfoExceptionMarshallerConvertToUnmanaged.Import(module)); + CilInstruction call_catchStartMarshalException = new(Call, interopReferences.RestrictedErrorInfoExceptionMarshallerConvertToUnmanaged); // Declare the local variables: // [0]: 'int' (the 'HRESULT' to return) @@ -186,10 +186,10 @@ public static MethodDefinition set_Handler( // '.try' code { ldarg_0_tryStart }, - { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(asyncInfoType).Import(module) }, + { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(asyncInfoType) }, { Ldarg_1 }, - { Call, convertToManagedMethod.Import(module) }, - { Callvirt, set_HandlerMethod.Import(module) }, + { Call, convertToManagedMethod }, + { Callvirt, set_HandlerMethod }, { Ldc_I4_0 }, { Stloc_0 }, { Leave_S, ldloc_0_returnHResult.CreateLabel() }, @@ -212,7 +212,7 @@ public static MethodDefinition set_Handler( TryEnd = call_catchStartMarshalException.CreateLabel(), HandlerStart = call_catchStartMarshalException.CreateLabel(), HandlerEnd = ldloc_0_returnHResult.CreateLabel(), - ExceptionType = interopReferences.Exception.Import(module) + ExceptionType = interopReferences.Exception } } }; diff --git a/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IAsyncInfoMethods.cs b/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IAsyncInfoMethods.cs index fd06e8ddd..57ebd62d1 100644 --- a/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IAsyncInfoMethods.cs +++ b/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IAsyncInfoMethods.cs @@ -47,8 +47,8 @@ public static MethodDefinition get_Handler( name: methodName, attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Static, signature: MethodSignature.CreateStatic( - returnType: handlerType.Import(module), - parameterTypes: [interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature()])) + returnType: handlerType, + parameterTypes: [interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature()])) { NoInlining = true }; // Declare the local variables: @@ -56,10 +56,10 @@ public static MethodDefinition get_Handler( // [1]: 'void*' (for 'thisPtr') // [2]: 'void*' (the handler pointer that was retrieved) // [3]: '' (the marshalled handler) - CilLocalVariable loc_0_thisValue = new(interopReferences.WindowsRuntimeObjectReferenceValue.ToValueTypeSignature().Import(module)); + CilLocalVariable loc_0_thisValue = new(interopReferences.WindowsRuntimeObjectReferenceValue.ToValueTypeSignature()); CilLocalVariable loc_1_thisPtr = new(module.CorLibTypeFactory.Void.MakePointerType()); CilLocalVariable loc_2_handlerPtr = new(module.CorLibTypeFactory.Void.MakePointerType()); - CilLocalVariable loc_3_handler = new(handlerType.Import(module)); + CilLocalVariable loc_3_handler = new(handlerType); // Jump labels CilInstruction ldloca_s_0_tryStart = new(Ldloca_S, loc_0_thisValue); @@ -77,25 +77,25 @@ public static MethodDefinition get_Handler( { // Initialize 'thisValue' { Ldarg_0 }, - { Callvirt, interopReferences.WindowsRuntimeObjectReferenceAsValue.Import(module) }, + { Callvirt, interopReferences.WindowsRuntimeObjectReferenceAsValue }, { Stloc_0 }, // '.try' code { ldloca_s_0_tryStart }, - { Call, interopReferences.WindowsRuntimeObjectReferenceValueGetThisPtrUnsafe.Import(module) }, + { Call, interopReferences.WindowsRuntimeObjectReferenceValueGetThisPtrUnsafe }, { Stloc_1 }, { Ldloc_1 }, { Ldloca_S, loc_2_handlerPtr }, { Ldloc_1 }, { Ldind_I }, { Ldfld, vftblField }, - { Calli, WellKnownTypeSignatureFactory.get_Handler(interopReferences).Import(module).MakeStandAloneSignature() }, - { Call, interopReferences.RestrictedErrorInfoThrowExceptionForHR.Import(module) }, + { Calli, WellKnownTypeSignatureFactory.get_Handler(interopReferences).MakeStandAloneSignature() }, + { Call, interopReferences.RestrictedErrorInfoThrowExceptionForHR }, { Leave_S, nop_finallyEnd.CreateLabel() }, // '.finally' code { ldloca_s_0_finallyStart }, - { Call, interopReferences.WindowsRuntimeObjectReferenceValueDispose.Import(module) }, + { Call, interopReferences.WindowsRuntimeObjectReferenceValueDispose }, { Endfinally }, { nop_finallyEnd }, @@ -105,7 +105,7 @@ public static MethodDefinition get_Handler( { Stloc_3 }, { Leave_S, ldloc_3_finallyEnd.CreateLabel() }, { ldloc_2_finallyStart }, - { Call, interopReferences.WindowsRuntimeUnknownMarshallerFree.Import(module) }, + { Call, interopReferences.WindowsRuntimeUnknownMarshallerFree }, { Endfinally }, { ldloc_3_finallyEnd }, { Ret } @@ -160,16 +160,16 @@ public static MethodDefinition set_Handler( signature: MethodSignature.CreateStatic( returnType: module.CorLibTypeFactory.Void, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), - handlerType.Import(module)])) + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), + handlerType])) { NoInlining = true }; // Declare the local variables: // [0]: 'WindowsRuntimeObjectReferenceValue' (for 'thisValue') // [1]: 'WindowsRuntimeObjectReferenceValue' (for 'handlerValue') // [2]: 'void*' (for 'thisPtr') - CilLocalVariable loc_0_thisValue = new(interopReferences.WindowsRuntimeObjectReferenceValue.ToValueTypeSignature().Import(module)); - CilLocalVariable loc_1_handlerValue = new(interopReferences.WindowsRuntimeObjectReferenceValue.ToValueTypeSignature().Import(module)); + CilLocalVariable loc_0_thisValue = new(interopReferences.WindowsRuntimeObjectReferenceValue.ToValueTypeSignature()); + CilLocalVariable loc_1_handlerValue = new(interopReferences.WindowsRuntimeObjectReferenceValue.ToValueTypeSignature()); CilLocalVariable loc_2_thisPtr = new(module.CorLibTypeFactory.Void.MakePointerType()); // Jump labels @@ -187,7 +187,7 @@ public static MethodDefinition set_Handler( { // Initialize 'thisValue' { Ldarg_0 }, - { Callvirt, interopReferences.WindowsRuntimeObjectReferenceAsValue.Import(module) }, + { Callvirt, interopReferences.WindowsRuntimeObjectReferenceAsValue }, { Stloc_0 }, // Initialize 'handlerValue' @@ -197,26 +197,26 @@ public static MethodDefinition set_Handler( // '.try' code { ldloca_s_0_tryStart }, - { Call, interopReferences.WindowsRuntimeObjectReferenceValueGetThisPtrUnsafe.Import(module) }, + { Call, interopReferences.WindowsRuntimeObjectReferenceValueGetThisPtrUnsafe }, { Stloc_2 }, { Ldloc_2 }, { Ldloca_S, loc_1_handlerValue }, - { Call, interopReferences.WindowsRuntimeObjectReferenceValueGetThisPtrUnsafe.Import(module) }, + { Call, interopReferences.WindowsRuntimeObjectReferenceValueGetThisPtrUnsafe }, { Ldloc_2 }, { Ldind_I }, { Ldfld, vftblField }, - { Calli, WellKnownTypeSignatureFactory.set_Handler(interopReferences).Import(module).MakeStandAloneSignature() }, - { Call, interopReferences.RestrictedErrorInfoThrowExceptionForHR.Import(module) }, + { Calli, WellKnownTypeSignatureFactory.set_Handler(interopReferences).MakeStandAloneSignature() }, + { Call, interopReferences.RestrictedErrorInfoThrowExceptionForHR }, { Leave_S, ret_finallyEnd.CreateLabel() }, // '.finally' code (for 'handlerValue') { ldloca_s_1_finallyStart }, - { Call, interopReferences.WindowsRuntimeObjectReferenceValueDispose.Import(module) }, + { Call, interopReferences.WindowsRuntimeObjectReferenceValueDispose }, { Endfinally }, // '.finally' code (for 'thisValue') { ldloca_s_0_finallyStart }, - { Call, interopReferences.WindowsRuntimeObjectReferenceValueDispose.Import(module) }, + { Call, interopReferences.WindowsRuntimeObjectReferenceValueDispose }, { Endfinally }, // Return (after both '.finally' blocks) @@ -268,17 +268,17 @@ public static MethodDefinition GetResults( name: "GetResults"u8, attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Static, signature: MethodSignature.CreateStatic( - returnType: resultType.Import(module), - parameterTypes: [interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature()])) + returnType: resultType, + parameterTypes: [interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature()])) { NoInlining = true }; // Declare the local variables: // [0]: 'WindowsRuntimeObjectReferenceValue' (for 'thisValue') // [1]: 'void*' (for 'thisPtr') // [2]: '' (the ABI type for the type argument) - CilLocalVariable loc_0_thisValue = new(interopReferences.WindowsRuntimeObjectReferenceValue.ToValueTypeSignature().Import(module)); + CilLocalVariable loc_0_thisValue = new(interopReferences.WindowsRuntimeObjectReferenceValue.ToValueTypeSignature()); CilLocalVariable loc_1_thisPtr = new(module.CorLibTypeFactory.Void.MakePointerType()); - CilLocalVariable loc_2_resultNative = new(resultType.GetAbiType(interopReferences).Import(module)); + CilLocalVariable loc_2_resultNative = new(resultType.GetAbiType(interopReferences)); // Jump labels CilInstruction ldloca_s_0_tryStart = new(Ldloca_S, loc_0_thisValue); @@ -294,12 +294,12 @@ public static MethodDefinition GetResults( { // Initialize 'thisValue' { Ldarg_0 }, - { Callvirt, interopReferences.WindowsRuntimeObjectReferenceAsValue.Import(module) }, + { Callvirt, interopReferences.WindowsRuntimeObjectReferenceAsValue }, { Stloc_0 }, // '.try' code { ldloca_s_0_tryStart }, - { Call, interopReferences.WindowsRuntimeObjectReferenceValueGetThisPtrUnsafe.Import(module) }, + { Call, interopReferences.WindowsRuntimeObjectReferenceValueGetThisPtrUnsafe }, { Stloc_1 }, { Ldloc_1 }, { Ldarg_1 }, @@ -307,13 +307,13 @@ public static MethodDefinition GetResults( { Ldloc_1 }, { Ldind_I }, { Ldfld, vftblField }, - { Calli, WellKnownTypeSignatureFactory.get_TypedRetVal(resultType.GetAbiType(interopReferences).MakePointerType(), interopReferences).Import(module).MakeStandAloneSignature() }, - { Call, interopReferences.RestrictedErrorInfoThrowExceptionForHR.Import(module) }, + { Calli, WellKnownTypeSignatureFactory.get_TypedRetVal(resultType.GetAbiType(interopReferences).MakePointerType(), interopReferences).MakeStandAloneSignature() }, + { Call, interopReferences.RestrictedErrorInfoThrowExceptionForHR }, { Leave_S, nop_finallyEnd.CreateLabel() }, // '.finally' code { ldloca_s_0_finallyStart }, - { Call, interopReferences.WindowsRuntimeObjectReferenceValueDispose.Import(module) }, + { Call, interopReferences.WindowsRuntimeObjectReferenceValueDispose }, { Endfinally }, { nop_finallyEnd }, { nop_returnValueRewrite } diff --git a/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IAsyncOperation1Impl.cs b/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IAsyncOperation1Impl.cs index 2a6200deb..184a4b703 100644 --- a/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IAsyncOperation1Impl.cs +++ b/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IAsyncOperation1Impl.cs @@ -51,7 +51,7 @@ public static MethodDefinition GetResults( returnType: module.CorLibTypeFactory.Int32, parameterTypes: [ module.CorLibTypeFactory.Void.MakePointerType(), - resultType.GetAbiType(interopReferences).Import(module).MakePointerType()])) + resultType.GetAbiType(interopReferences).MakePointerType()])) { CustomAttributes = { InteropCustomAttributeFactory.UnmanagedCallersOnly(interopReferences, module) } }; @@ -60,7 +60,7 @@ public static MethodDefinition GetResults( CilInstruction nop_beforeTry = new(Nop); CilInstruction ldarg_1_tryStart = new(Ldarg_1); CilInstruction ldloc_0_returnHResult = new(Ldloc_0); - CilInstruction call_catchStartMarshalException = new(Call, interopReferences.RestrictedErrorInfoExceptionMarshallerConvertToUnmanaged.Import(module)); + CilInstruction call_catchStartMarshalException = new(Call, interopReferences.RestrictedErrorInfoExceptionMarshallerConvertToUnmanaged); CilInstruction nop_convertToUnmanaged = new(Nop); // Create a method body for the 'GetResults' method @@ -83,8 +83,8 @@ public static MethodDefinition GetResults( // '.try' code { ldarg_1_tryStart }, { Ldarg_0 }, - { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(operationType).Import(module) }, - { Callvirt, getResultsMethod.Import(module) }, + { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(operationType) }, + { Callvirt, getResultsMethod }, { nop_convertToUnmanaged }, { Ldc_I4_0 }, { Stloc_0 }, @@ -108,7 +108,7 @@ public static MethodDefinition GetResults( TryEnd = call_catchStartMarshalException.CreateLabel(), HandlerStart = call_catchStartMarshalException.CreateLabel(), HandlerEnd = ldloc_0_returnHResult.CreateLabel(), - ExceptionType = interopReferences.Exception.Import(module) + ExceptionType = interopReferences.Exception } } }; diff --git a/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IEnumerable1Impl.cs b/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IEnumerable1Impl.cs index b621ff34b..85a5c534e 100644 --- a/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IEnumerable1Impl.cs +++ b/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IEnumerable1Impl.cs @@ -56,7 +56,7 @@ public static MethodDefinition First( CilInstruction ldarg_1_tryStart = new(Ldarg_1); CilInstruction nop_convertToUnmanaged = new(Nop); CilInstruction ldloc_0_returnHResult = new(Ldloc_0); - CilInstruction call_catchStartMarshalException = new(Call, interopReferences.RestrictedErrorInfoExceptionMarshallerConvertToUnmanaged.Import(module)); + CilInstruction call_catchStartMarshalException = new(Call, interopReferences.RestrictedErrorInfoExceptionMarshallerConvertToUnmanaged); // Declare the local variables: // [0]: 'int' (the 'HRESULT' to return) @@ -80,8 +80,8 @@ public static MethodDefinition First( // '.try' code { ldarg_1_tryStart }, { Ldarg_0 }, - { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(enumerableType).Import(module) }, - { Callvirt, interopReferences.IEnumerable1GetEnumerator(elementType).Import(module) }, + { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(enumerableType) }, + { Callvirt, interopReferences.IEnumerable1GetEnumerator(elementType) }, { nop_convertToUnmanaged }, { Ldc_I4_0 }, { Stloc_0 }, @@ -105,7 +105,7 @@ public static MethodDefinition First( TryEnd = call_catchStartMarshalException.CreateLabel(), HandlerStart = call_catchStartMarshalException.CreateLabel(), HandlerEnd = ldloc_0_returnHResult.CreateLabel(), - ExceptionType = interopReferences.Exception.Import(module) + ExceptionType = interopReferences.Exception } } }; diff --git a/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IEnumerator1Impl.cs b/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IEnumerator1Impl.cs index 23789f3dd..62f120ae7 100644 --- a/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IEnumerator1Impl.cs +++ b/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IEnumerator1Impl.cs @@ -51,7 +51,7 @@ public static MethodDefinition get_Current( returnType: module.CorLibTypeFactory.Int32, parameterTypes: [ module.CorLibTypeFactory.Void.MakePointerType(), - elementType.GetAbiType(interopReferences).Import(module).MakePointerType()])) + elementType.GetAbiType(interopReferences).MakePointerType()])) { CustomAttributes = { InteropCustomAttributeFactory.UnmanagedCallersOnly(interopReferences, module) } }; @@ -60,7 +60,7 @@ public static MethodDefinition get_Current( CilInstruction nop_beforeTry = new(Nop); CilInstruction ldarg_1_tryStart = new(Ldarg_1); CilInstruction ldloc_0_returnHResult = new(Ldloc_0); - CilInstruction call_catchStartMarshalException = new(Call, interopReferences.RestrictedErrorInfoExceptionMarshallerConvertToUnmanaged.Import(module)); + CilInstruction call_catchStartMarshalException = new(Call, interopReferences.RestrictedErrorInfoExceptionMarshallerConvertToUnmanaged); CilInstruction nop_convertToUnmanaged = new(Nop); // Create a method body for the 'get_Current' method @@ -83,9 +83,9 @@ public static MethodDefinition get_Current( // '.try' code { ldarg_1_tryStart }, { Ldarg_0 }, - { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(enumeratorType).Import(module) }, - { Call, interopReferences.IEnumeratorAdapter1GetInstance(elementType).Import(module) }, - { Callvirt, interopReferences.IEnumeratorAdapter1get_Current(elementType).Import(module) }, + { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(enumeratorType) }, + { Call, interopReferences.IEnumeratorAdapter1GetInstance(elementType) }, + { Callvirt, interopReferences.IEnumeratorAdapter1get_Current(elementType) }, { nop_convertToUnmanaged }, { Ldc_I4_0 }, { Stloc_0 }, @@ -109,7 +109,7 @@ public static MethodDefinition get_Current( TryEnd = call_catchStartMarshalException.CreateLabel(), HandlerStart = call_catchStartMarshalException.CreateLabel(), HandlerEnd = ldloc_0_returnHResult.CreateLabel(), - ExceptionType = interopReferences.Exception.Import(module) + ExceptionType = interopReferences.Exception } } }; @@ -163,7 +163,7 @@ public static MethodDefinition HasCurrentOrMoveNext( CilInstruction nop_beforeTry = new(Nop); CilInstruction ldarg_1_tryStart = new(Ldarg_1); CilInstruction ldloc_0_returnHResult = new(Ldloc_0); - CilInstruction call_catchStartMarshalException = new(Call, interopReferences.RestrictedErrorInfoExceptionMarshallerConvertToUnmanaged.Import(module)); + CilInstruction call_catchStartMarshalException = new(Call, interopReferences.RestrictedErrorInfoExceptionMarshallerConvertToUnmanaged); // Create a method body for the 'get_HasCurrent' method boolMethod.CilMethodBody = new CilMethodBody() @@ -185,9 +185,9 @@ public static MethodDefinition HasCurrentOrMoveNext( // '.try' code { ldarg_1_tryStart }, { Ldarg_0 }, - { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(enumeratorType).Import(module) }, - { Call, interopReferences.IEnumeratorAdapter1GetInstance(elementType).Import(module) }, - { Callvirt, adapterMethod.Import(module) }, + { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(enumeratorType) }, + { Call, interopReferences.IEnumeratorAdapter1GetInstance(elementType) }, + { Callvirt, adapterMethod }, { Stind_I1 }, { Ldc_I4_0 }, { Stloc_0 }, @@ -211,7 +211,7 @@ public static MethodDefinition HasCurrentOrMoveNext( TryEnd = call_catchStartMarshalException.CreateLabel(), HandlerStart = call_catchStartMarshalException.CreateLabel(), HandlerEnd = ldloc_0_returnHResult.CreateLabel(), - ExceptionType = interopReferences.Exception.Import(module) + ExceptionType = interopReferences.Exception } } }; @@ -244,7 +244,7 @@ public static MethodDefinition GetMany( parameterTypes: [ module.CorLibTypeFactory.Void.MakePointerType(), module.CorLibTypeFactory.UInt32, - elementType.GetAbiType(interopReferences).Import(module).MakePointerType(), + elementType.GetAbiType(interopReferences).MakePointerType(), module.CorLibTypeFactory.UInt32.MakePointerType()])) { CustomAttributes = { InteropCustomAttributeFactory.UnmanagedCallersOnly(interopReferences, module) } @@ -255,7 +255,7 @@ public static MethodDefinition GetMany( CilInstruction nop_beforeTry = new(Nop); CilInstruction ldarg_0_tryStart = new(Ldarg_0); CilInstruction ldloc_0_returnHResult = new(Ldloc_0); - CilInstruction call_catchStartMarshalException = new(Call, interopReferences.RestrictedErrorInfoExceptionMarshallerConvertToUnmanaged.Import(module)); + CilInstruction call_catchStartMarshalException = new(Call, interopReferences.RestrictedErrorInfoExceptionMarshallerConvertToUnmanaged); CilInstruction nop_implementation = new(Nop); // Create a method body for the 'get_Current' method @@ -267,7 +267,7 @@ public static MethodDefinition GetMany( LocalVariables = { new CilLocalVariable(module.CorLibTypeFactory.Int32), - new CilLocalVariable(interopReferences.IEnumeratorAdapter1.MakeGenericReferenceType(elementType).Import(module)) + new CilLocalVariable(interopReferences.IEnumeratorAdapter1.MakeGenericReferenceType(elementType)) }, Instructions = { @@ -286,8 +286,8 @@ public static MethodDefinition GetMany( // '.try' code { ldarg_0_tryStart }, - { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(enumeratorType).Import(module) }, - { Call, interopReferences.IEnumeratorAdapter1GetInstance(elementType).Import(module) }, + { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(enumeratorType) }, + { Call, interopReferences.IEnumeratorAdapter1GetInstance(elementType) }, { Stloc_1 }, { nop_implementation }, { Ldc_I4_0 }, @@ -312,7 +312,7 @@ public static MethodDefinition GetMany( TryEnd = call_catchStartMarshalException.CreateLabel(), HandlerStart = call_catchStartMarshalException.CreateLabel(), HandlerEnd = ldloc_0_returnHResult.CreateLabel(), - ExceptionType = interopReferences.Exception.Import(module) + ExceptionType = interopReferences.Exception } } }; diff --git a/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IKeyValuePair2Impl.cs b/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IKeyValuePair2Impl.cs index d364a67e9..d01b64ca4 100644 --- a/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IKeyValuePair2Impl.cs +++ b/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IKeyValuePair2Impl.cs @@ -95,14 +95,13 @@ private static MethodDefinition get_KeyOrValue( returnType: module.CorLibTypeFactory.Int32, parameterTypes: [ module.CorLibTypeFactory.Void.MakePointerType(), - keyOrValueType.GetAbiType(interopReferences).Import(module).MakePointerType()])) + keyOrValueType.GetAbiType(interopReferences).MakePointerType()])) { CustomAttributes = { InteropCustomAttributeFactory.UnmanagedCallersOnly(interopReferences, module) } }; // Reference the 'KeyValuePair<,>' accessor method MemberReference get_KeyOrValueAccessorMethod = keyValuePairType - .Import(module) .ToTypeDefOrRef() .CreateMemberReference( memberName: methodName, @@ -114,13 +113,13 @@ private static MethodDefinition get_KeyOrValue( // [0]: 'int' (the 'HRESULT' to return) // [1]: 'KeyValuePair<,>' (the boxed object to get values from) CilLocalVariable loc_0_hresult = new(module.CorLibTypeFactory.Int32); - CilLocalVariable loc_1_keyValuePair = new(keyValuePairType.Import(module)); + CilLocalVariable loc_1_keyValuePair = new(keyValuePairType); // Labels for jumps CilInstruction nop_beforeTry = new(Nop); CilInstruction ldarg_1_tryStart = new(Ldarg_1); CilInstruction ldloc_0_returnHResult = new(Ldloc_0); - CilInstruction call_catchStartMarshalException = new(Call, interopReferences.RestrictedErrorInfoExceptionMarshallerConvertToUnmanaged.Import(module)); + CilInstruction call_catchStartMarshalException = new(Call, interopReferences.RestrictedErrorInfoExceptionMarshallerConvertToUnmanaged); CilInstruction nop_convertToUnmanaged = new(Nop); // Create a method body for the native export method @@ -141,8 +140,8 @@ private static MethodDefinition get_KeyOrValue( // '.try' code { ldarg_1_tryStart }, { Ldarg_0 }, - { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(module.CorLibTypeFactory.Object).Import(module) }, - { Unbox_Any, keyValuePairType.Import(module).ToTypeDefOrRef() }, + { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(module.CorLibTypeFactory.Object) }, + { Unbox_Any, keyValuePairType.ToTypeDefOrRef() }, { Stloc_1 }, { Ldarg_1 }, { Ldloca_S, loc_1_keyValuePair }, @@ -170,7 +169,7 @@ private static MethodDefinition get_KeyOrValue( TryEnd = call_catchStartMarshalException.CreateLabel(), HandlerStart = call_catchStartMarshalException.CreateLabel(), HandlerEnd = ldloc_0_returnHResult.CreateLabel(), - ExceptionType = interopReferences.Exception.Import(module) + ExceptionType = interopReferences.Exception } } }; diff --git a/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IMapChangedEventArgs1Impl.cs b/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IMapChangedEventArgs1Impl.cs index ba1fc64f3..9fa3d93b6 100644 --- a/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IMapChangedEventArgs1Impl.cs +++ b/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IMapChangedEventArgs1Impl.cs @@ -44,7 +44,7 @@ public static MethodDefinition CollectionChanged( returnType: module.CorLibTypeFactory.Int32, parameterTypes: [ module.CorLibTypeFactory.Void.MakePointerType(), - interopReferences.CollectionChange.Import(module).MakePointerType()])) + interopReferences.CollectionChange.MakePointerType()])) { CustomAttributes = { InteropCustomAttributeFactory.UnmanagedCallersOnly(interopReferences, module) } }; @@ -53,7 +53,7 @@ public static MethodDefinition CollectionChanged( CilInstruction nop_beforeTry = new(Nop); CilInstruction ldarg_1_tryStart = new(Ldarg_1); CilInstruction ldloc_0_returnHResult = new(Ldloc_0); - CilInstruction call_catchStartMarshalException = new(Call, interopReferences.RestrictedErrorInfoExceptionMarshallerConvertToUnmanaged.Import(module)); + CilInstruction call_catchStartMarshalException = new(Call, interopReferences.RestrictedErrorInfoExceptionMarshallerConvertToUnmanaged); // Create a method body for the 'get_CollectionChanged' method collectionChangeMethod.CilMethodBody = new CilMethodBody() @@ -75,8 +75,8 @@ public static MethodDefinition CollectionChanged( // '.try' code { ldarg_1_tryStart }, { Ldarg_0 }, - { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(argsType).Import(module) }, - { Callvirt, interopReferences.IMapChangedEventArgs1get_CollectionChange(elementType).Import(module) }, + { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(argsType) }, + { Callvirt, interopReferences.IMapChangedEventArgs1get_CollectionChange(elementType) }, { Stind_I4 }, { Ldc_I4_0 }, { Stloc_0 }, @@ -100,7 +100,7 @@ public static MethodDefinition CollectionChanged( TryEnd = call_catchStartMarshalException.CreateLabel(), HandlerStart = call_catchStartMarshalException.CreateLabel(), HandlerEnd = ldloc_0_returnHResult.CreateLabel(), - ExceptionType = interopReferences.Exception.Import(module) + ExceptionType = interopReferences.Exception } } }; @@ -134,7 +134,7 @@ public static MethodDefinition Key( returnType: module.CorLibTypeFactory.Int32, parameterTypes: [ module.CorLibTypeFactory.Void.MakePointerType(), - keyType.GetAbiType(interopReferences).Import(module).MakePointerType()])) + keyType.GetAbiType(interopReferences).MakePointerType()])) { CustomAttributes = { InteropCustomAttributeFactory.UnmanagedCallersOnly(interopReferences, module) } }; @@ -143,7 +143,7 @@ public static MethodDefinition Key( CilInstruction nop_beforeTry = new(Nop); CilInstruction ldarg_1_tryStart = new(Ldarg_1); CilInstruction ldloc_0_returnHResult = new(Ldloc_0); - CilInstruction call_catchStartMarshalException = new(Call, interopReferences.RestrictedErrorInfoExceptionMarshallerConvertToUnmanaged.Import(module)); + CilInstruction call_catchStartMarshalException = new(Call, interopReferences.RestrictedErrorInfoExceptionMarshallerConvertToUnmanaged); CilInstruction nop_convertToUnmanaged = new(Nop); // Create a method body for the 'get_Current' method @@ -166,8 +166,8 @@ public static MethodDefinition Key( // '.try' code { ldarg_1_tryStart }, { Ldarg_0 }, - { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(argsType).Import(module) }, - { Callvirt, interopReferences.IMapChangedEventArgs1get_Key(keyType).Import(module) }, + { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(argsType) }, + { Callvirt, interopReferences.IMapChangedEventArgs1get_Key(keyType) }, { nop_convertToUnmanaged }, { Ldc_I4_0 }, { Stloc_0 }, @@ -191,7 +191,7 @@ public static MethodDefinition Key( TryEnd = call_catchStartMarshalException.CreateLabel(), HandlerStart = call_catchStartMarshalException.CreateLabel(), HandlerEnd = ldloc_0_returnHResult.CreateLabel(), - ExceptionType = interopReferences.Exception.Import(module) + ExceptionType = interopReferences.Exception } } }; diff --git a/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IObservableMap2Impl.cs b/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IObservableMap2Impl.cs index ce3814123..4eaf62348 100644 --- a/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IObservableMap2Impl.cs +++ b/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IObservableMap2Impl.cs @@ -61,7 +61,7 @@ public static MethodDefinition add_MapChanged( parameterTypes: [ module.CorLibTypeFactory.Void.MakePointerType(), module.CorLibTypeFactory.Void.MakePointerType(), - interopReferences.EventRegistrationToken.MakePointerType().Import(module)])) + interopReferences.EventRegistrationToken.MakePointerType()])) { CustomAttributes = { InteropCustomAttributeFactory.UnmanagedCallersOnly(interopReferences, module) } }; @@ -70,15 +70,15 @@ public static MethodDefinition add_MapChanged( CilInstruction ldc_i4_e_pointer = new(Ldc_I4, unchecked((int)0x80004003)); CilInstruction nop_beforeTry = new(Nop); CilInstruction ldarg_0_tryStart = new(Ldarg_0); - CilInstruction callvirt_catchHResult = new(Callvirt, interopReferences.Exceptionget_HResult.Import(module)); + CilInstruction callvirt_catchHResult = new(Callvirt, interopReferences.Exceptionget_HResult); CilInstruction ldloc_2_returnHResult = new(Ldloc_2); // Declare the local variables: // [0]: '' (the 'unboxedValue' object) // [1]: 'MapChangedEventHandler<, >' (the 'managedHandler' object) // [2]: 'int' (the 'HRESULT' to return) - CilLocalVariable loc_0_unboxedValue = new(mapType.Import(module)); - CilLocalVariable loc_1_managedHandler = new(eventHandlerType.Import(module)); + CilLocalVariable loc_0_unboxedValue = new(mapType); + CilLocalVariable loc_1_managedHandler = new(eventHandlerType); CilLocalVariable loc_2_hresult = new(module.CorLibTypeFactory.Int32); // Create a method body for the 'add_MapChanged' method @@ -102,7 +102,7 @@ public static MethodDefinition add_MapChanged( // '.try' code { ldarg_0_tryStart }, - { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(mapType).Import(module) }, + { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(mapType) }, { Stloc_0 }, { Ldarg_1 }, { Call, emitState.LookupTypeDefinition(eventHandlerType, "Marshaller").GetMethod("ConvertToManaged"u8) }, @@ -112,15 +112,15 @@ public static MethodDefinition add_MapChanged( { Ldarg_2 }, { Call, get_MapChangedTableMethod }, { Ldloc_0 }, - { Callvirt, interopReferences.ConditionalWeakTable2GetOrCreateValue(conditionalWeakTableType).Import(module) }, + { Callvirt, interopReferences.ConditionalWeakTable2GetOrCreateValue(conditionalWeakTableType) }, { Ldloc_1 }, - { Callvirt, interopReferences.EventRegistrationTokenTableAddEventHandler(eventRegistrationTokenTableType).Import(module) }, - { Stobj, interopReferences.EventRegistrationToken.Import(module) }, + { Callvirt, interopReferences.EventRegistrationTokenTableAddEventHandler(eventRegistrationTokenTableType) }, + { Stobj, interopReferences.EventRegistrationToken }, // unboxedValue.MapChanged += managedHandler; { Ldloc_0 }, { Ldloc_1 }, - { Callvirt, interopReferences.IObservableMap2add_MapChanged(keyType, valueType).Import(module) }, + { Callvirt, interopReferences.IObservableMap2add_MapChanged(keyType, valueType) }, { Ldc_I4_0 }, { Stloc_2 }, { Leave_S, ldloc_2_returnHResult.CreateLabel() }, @@ -143,7 +143,7 @@ public static MethodDefinition add_MapChanged( TryEnd = callvirt_catchHResult.CreateLabel(), HandlerStart = callvirt_catchHResult.CreateLabel(), HandlerEnd = ldloc_2_returnHResult.CreateLabel(), - ExceptionType = interopReferences.Exception.Import(module) + ExceptionType = interopReferences.Exception } } }; @@ -187,7 +187,7 @@ public static MethodDefinition remove_MapChanged( returnType: module.CorLibTypeFactory.Int32, parameterTypes: [ module.CorLibTypeFactory.Void.MakePointerType(), - interopReferences.EventRegistrationToken.ToValueTypeSignature().Import(module)])) + interopReferences.EventRegistrationToken.ToValueTypeSignature()])) { CustomAttributes = { InteropCustomAttributeFactory.UnmanagedCallersOnly(interopReferences, module) } }; @@ -195,7 +195,7 @@ public static MethodDefinition remove_MapChanged( // Jump labels CilInstruction ldarg_0_tryStart = new(Ldarg_0); CilInstruction ldc_i4_0_return0 = new(Ldc_I4_0); - CilInstruction callvirt_catchHResult = new(Callvirt, interopReferences.Exceptionget_HResult.Import(module)); + CilInstruction callvirt_catchHResult = new(Callvirt, interopReferences.Exceptionget_HResult); CilInstruction ldloc_3_returnHResult = new(Ldloc_3); // Declare the local variables: @@ -203,9 +203,9 @@ public static MethodDefinition remove_MapChanged( // [1]: 'EventRegistrationTokenTable, >>' (the 'table' object) // [2]: 'MapChangedEventHandler<, >' (the 'managedHandler' object) // [3]: 'int' (the 'HRESULT' to return) - CilLocalVariable loc_0_unboxedValue = new(mapType.Import(module)); - CilLocalVariable loc_1_table = new(eventRegistrationTokenTableType.Import(module)); - CilLocalVariable loc_2_managedHandler = new(eventHandlerType.Import(module)); + CilLocalVariable loc_0_unboxedValue = new(mapType); + CilLocalVariable loc_1_table = new(eventRegistrationTokenTableType); + CilLocalVariable loc_2_managedHandler = new(eventHandlerType); CilLocalVariable loc_3_hresult = new(module.CorLibTypeFactory.Int32); // Create a method body for the 'remove_MapChanged' method @@ -216,7 +216,7 @@ public static MethodDefinition remove_MapChanged( { // '.try' code { ldarg_0_tryStart }, - { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(mapType).Import(module) }, + { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(mapType) }, { Stloc_0 }, // if (unboxedValue != null && MapChangedTable.TryGetValue(unboxedValue, out EventRegistrationTokenTable, >> table)) @@ -225,20 +225,20 @@ public static MethodDefinition remove_MapChanged( { Call, get_MapChangedTableMethod }, { Ldloc_0 }, { Ldloca_S, loc_1_table }, - { Callvirt, interopReferences.ConditionalWeakTable2TryGetValue(conditionalWeakTableType).Import(module) }, + { Callvirt, interopReferences.ConditionalWeakTable2TryGetValue(conditionalWeakTableType) }, { Brfalse_S, ldc_i4_0_return0.CreateLabel() }, // if (table.RemoveEventHandler(token, out MapChangedEventHandler<, > managedHandler)) { Ldloc_1 }, { Ldarg_1 }, { Ldloca_S, loc_2_managedHandler }, - { Callvirt, interopReferences.EventRegistrationTokenTableRemoveEventHandler(eventRegistrationTokenTableType).Import(module) }, + { Callvirt, interopReferences.EventRegistrationTokenTableRemoveEventHandler(eventRegistrationTokenTableType) }, { Brfalse_S, ldc_i4_0_return0.CreateLabel() }, // unboxedValue.MapChanged -= managedHandler; { Ldloc_0 }, { Ldloc_2 }, - { Callvirt, interopReferences.IObservableMap2remove_MapChanged(keyType, valueType).Import(module) }, + { Callvirt, interopReferences.IObservableMap2remove_MapChanged(keyType, valueType) }, // Return S_OK { ldc_i4_0_return0 }, @@ -263,7 +263,7 @@ public static MethodDefinition remove_MapChanged( TryEnd = callvirt_catchHResult.CreateLabel(), HandlerStart = callvirt_catchHResult.CreateLabel(), HandlerEnd = ldloc_3_returnHResult.CreateLabel(), - ExceptionType = interopReferences.Exception.Import(module) + ExceptionType = interopReferences.Exception } } }; diff --git a/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IObservableVector1Impl.cs b/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IObservableVector1Impl.cs index e92c8b4eb..67f362cf9 100644 --- a/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IObservableVector1Impl.cs +++ b/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IObservableVector1Impl.cs @@ -60,7 +60,7 @@ public static MethodDefinition add_VectorChanged( parameterTypes: [ module.CorLibTypeFactory.Void.MakePointerType(), module.CorLibTypeFactory.Void.MakePointerType(), - interopReferences.EventRegistrationToken.MakePointerType().Import(module)])) + interopReferences.EventRegistrationToken.MakePointerType()])) { CustomAttributes = { InteropCustomAttributeFactory.UnmanagedCallersOnly(interopReferences, module) } }; @@ -69,15 +69,15 @@ public static MethodDefinition add_VectorChanged( CilInstruction ldc_i4_e_pointer = new(Ldc_I4, unchecked((int)0x80004003)); CilInstruction nop_beforeTry = new(Nop); CilInstruction ldarg_0_tryStart = new(Ldarg_0); - CilInstruction callvirt_catchHResult = new(Callvirt, interopReferences.Exceptionget_HResult.Import(module)); + CilInstruction callvirt_catchHResult = new(Callvirt, interopReferences.Exceptionget_HResult); CilInstruction ldloc_2_returnHResult = new(Ldloc_2); // Declare the local variables: // [0]: '' (the 'unboxedValue' object) // [1]: 'VectorChangedEventHandler<>' (the 'managedHandler' object) // [2]: 'int' (the 'HRESULT' to return) - CilLocalVariable loc_0_unboxedValue = new(vectorType.Import(module)); - CilLocalVariable loc_1_managedHandler = new(eventHandlerType.Import(module)); + CilLocalVariable loc_0_unboxedValue = new(vectorType); + CilLocalVariable loc_1_managedHandler = new(eventHandlerType); CilLocalVariable loc_2_hresult = new(module.CorLibTypeFactory.Int32); // Create a method body for the 'add_VectorChanged' method @@ -101,7 +101,7 @@ public static MethodDefinition add_VectorChanged( // '.try' code { ldarg_0_tryStart }, - { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(vectorType).Import(module) }, + { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(vectorType) }, { Stloc_0 }, { Ldarg_1 }, { Call, emitState.LookupTypeDefinition(eventHandlerType, "Marshaller").GetMethod("ConvertToManaged"u8) }, @@ -111,15 +111,15 @@ public static MethodDefinition add_VectorChanged( { Ldarg_2 }, { Call, get_VectorChangedTableMethod }, { Ldloc_0 }, - { Callvirt, interopReferences.ConditionalWeakTable2GetOrCreateValue(conditionalWeakTableType).Import(module) }, + { Callvirt, interopReferences.ConditionalWeakTable2GetOrCreateValue(conditionalWeakTableType) }, { Ldloc_1 }, - { Callvirt, interopReferences.EventRegistrationTokenTableAddEventHandler(eventRegistrationTokenTableType).Import(module) }, - { Stobj, interopReferences.EventRegistrationToken.Import(module) }, + { Callvirt, interopReferences.EventRegistrationTokenTableAddEventHandler(eventRegistrationTokenTableType) }, + { Stobj, interopReferences.EventRegistrationToken }, // unboxedValue.VectorChanged += managedHandler; { Ldloc_0 }, { Ldloc_1 }, - { Callvirt, interopReferences.IObservableVector1add_VectorChanged(elementType).Import(module) }, + { Callvirt, interopReferences.IObservableVector1add_VectorChanged(elementType) }, { Ldc_I4_0 }, { Stloc_2 }, { Leave_S, ldloc_2_returnHResult.CreateLabel() }, @@ -142,7 +142,7 @@ public static MethodDefinition add_VectorChanged( TryEnd = callvirt_catchHResult.CreateLabel(), HandlerStart = callvirt_catchHResult.CreateLabel(), HandlerEnd = ldloc_2_returnHResult.CreateLabel(), - ExceptionType = interopReferences.Exception.Import(module) + ExceptionType = interopReferences.Exception } } }; @@ -185,7 +185,7 @@ public static MethodDefinition remove_VectorChanged( returnType: module.CorLibTypeFactory.Int32, parameterTypes: [ module.CorLibTypeFactory.Void.MakePointerType(), - interopReferences.EventRegistrationToken.ToValueTypeSignature().Import(module)])) + interopReferences.EventRegistrationToken.ToValueTypeSignature()])) { CustomAttributes = { InteropCustomAttributeFactory.UnmanagedCallersOnly(interopReferences, module) } }; @@ -193,7 +193,7 @@ public static MethodDefinition remove_VectorChanged( // Jump labels CilInstruction ldarg_0_tryStart = new(Ldarg_0); CilInstruction ldc_i4_0_return0 = new(Ldc_I4_0); - CilInstruction callvirt_catchHResult = new(Callvirt, interopReferences.Exceptionget_HResult.Import(module)); + CilInstruction callvirt_catchHResult = new(Callvirt, interopReferences.Exceptionget_HResult); CilInstruction ldloc_3_returnHResult = new(Ldloc_3); // Declare the local variables: @@ -201,9 +201,9 @@ public static MethodDefinition remove_VectorChanged( // [1]: 'EventRegistrationTokenTable>>' (the 'table' object) // [2]: 'VectorChangedEventHandler<>' (the 'managedHandler' object) // [3]: 'int' (the 'HRESULT' to return) - CilLocalVariable loc_0_unboxedValue = new(vectorType.Import(module)); - CilLocalVariable loc_1_table = new(eventRegistrationTokenTableType.Import(module)); - CilLocalVariable loc_2_managedHandler = new(eventHandlerType.Import(module)); + CilLocalVariable loc_0_unboxedValue = new(vectorType); + CilLocalVariable loc_1_table = new(eventRegistrationTokenTableType); + CilLocalVariable loc_2_managedHandler = new(eventHandlerType); CilLocalVariable loc_3_hresult = new(module.CorLibTypeFactory.Int32); // Create a method body for the 'remove_VectorChanged' method @@ -214,7 +214,7 @@ public static MethodDefinition remove_VectorChanged( { // '.try' code { ldarg_0_tryStart }, - { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(vectorType).Import(module) }, + { Call, interopReferences.ComInterfaceDispatchGetInstance.MakeGenericInstanceMethod(vectorType) }, { Stloc_0 }, // if (unboxedValue != null && VectorChangedTable.TryGetValue(unboxedValue, out EventRegistrationTokenTable>> table)) @@ -223,20 +223,20 @@ public static MethodDefinition remove_VectorChanged( { Call, get_VectorChangedTableMethod }, { Ldloc_0 }, { Ldloca_S, loc_1_table }, - { Callvirt, interopReferences.ConditionalWeakTable2TryGetValue(conditionalWeakTableType).Import(module) }, + { Callvirt, interopReferences.ConditionalWeakTable2TryGetValue(conditionalWeakTableType) }, { Brfalse_S, ldc_i4_0_return0.CreateLabel() }, // if (table.RemoveEventHandler(token, out VectorChangedEventHandler<> managedHandler)) { Ldloc_1 }, { Ldarg_1 }, { Ldloca_S, loc_2_managedHandler }, - { Callvirt, interopReferences.EventRegistrationTokenTableRemoveEventHandler(eventRegistrationTokenTableType).Import(module) }, + { Callvirt, interopReferences.EventRegistrationTokenTableRemoveEventHandler(eventRegistrationTokenTableType) }, { Brfalse_S, ldc_i4_0_return0.CreateLabel() }, // unboxedValue.VectorChanged -= managedHandler; { Ldloc_0 }, { Ldloc_2 }, - { Callvirt, interopReferences.IObservableVector1remove_VectorChanged(elementType).Import(module) }, + { Callvirt, interopReferences.IObservableVector1remove_VectorChanged(elementType) }, // Return S_OK { ldc_i4_0_return0 }, @@ -261,7 +261,7 @@ public static MethodDefinition remove_VectorChanged( TryEnd = callvirt_catchHResult.CreateLabel(), HandlerStart = callvirt_catchHResult.CreateLabel(), HandlerEnd = ldloc_3_returnHResult.CreateLabel(), - ExceptionType = interopReferences.Exception.Import(module) + ExceptionType = interopReferences.Exception } } }; diff --git a/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IVectorViewMethods.cs b/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IVectorViewMethods.cs index 33c7868e1..0dc2f5fee 100644 --- a/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IVectorViewMethods.cs +++ b/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.IVectorViewMethods.cs @@ -47,9 +47,9 @@ public static MethodDefinition GetAt( name: "GetAt"u8, attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Static, signature: MethodSignature.CreateStatic( - returnType: elementType.Import(module), + returnType: elementType, parameterTypes: [ - interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature(), + interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature(), module.CorLibTypeFactory.UInt32])) { NoInlining = true }; @@ -57,9 +57,9 @@ public static MethodDefinition GetAt( // [0]: 'WindowsRuntimeObjectReferenceValue' (for 'thisValue') // [1]: 'void*' (for 'thisPtr') // [2]: '' (the ABI type for the type argument) - CilLocalVariable loc_0_thisValue = new(interopReferences.WindowsRuntimeObjectReferenceValue.ToValueTypeSignature().Import(module)); + CilLocalVariable loc_0_thisValue = new(interopReferences.WindowsRuntimeObjectReferenceValue.ToValueTypeSignature()); CilLocalVariable loc_1_thisPtr = new(module.CorLibTypeFactory.Void.MakePointerType()); - CilLocalVariable loc_2_resultNative = new(elementType.GetAbiType(interopReferences).Import(module)); + CilLocalVariable loc_2_resultNative = new(elementType.GetAbiType(interopReferences)); // Jump labels CilInstruction ldloca_s_0_tryStart = new(Ldloca_S, loc_0_thisValue); @@ -75,12 +75,12 @@ public static MethodDefinition GetAt( { // Initialize 'thisValue' { Ldarg_0 }, - { Callvirt, interopReferences.WindowsRuntimeObjectReferenceAsValue.Import(module) }, + { Callvirt, interopReferences.WindowsRuntimeObjectReferenceAsValue }, { Stloc_0 }, // '.try' code { ldloca_s_0_tryStart }, - { Call, interopReferences.WindowsRuntimeObjectReferenceValueGetThisPtrUnsafe.Import(module) }, + { Call, interopReferences.WindowsRuntimeObjectReferenceValueGetThisPtrUnsafe }, { Stloc_1 }, { Ldloc_1 }, { Ldarg_1 }, @@ -91,13 +91,13 @@ public static MethodDefinition GetAt( // This 'calli' instruction is always using 'IReadOnlyList1GetAtImpl', but the signature for // the vtable slot for 'GetAt' for 'IVector' is identical, so doing so is safe in this case. - { Calli, WellKnownTypeSignatureFactory.IReadOnlyList1GetAtImpl(elementType, interopReferences).Import(module).MakeStandAloneSignature() }, - { Call, interopReferences.RestrictedErrorInfoThrowExceptionForHR.Import(module) }, + { Calli, WellKnownTypeSignatureFactory.IReadOnlyList1GetAtImpl(elementType, interopReferences).MakeStandAloneSignature() }, + { Call, interopReferences.RestrictedErrorInfoThrowExceptionForHR }, { Leave_S, nop_finallyEnd.CreateLabel() }, // '.finally' code { ldloca_s_0_finallyStart }, - { Call, interopReferences.WindowsRuntimeObjectReferenceValueDispose.Import(module) }, + { Call, interopReferences.WindowsRuntimeObjectReferenceValueDispose }, { Endfinally }, { nop_finallyEnd }, { nop_returnValueRewrite } diff --git a/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.KeyValuePairMethods.cs b/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.KeyValuePairMethods.cs index fbf6871ee..a198c3ea2 100644 --- a/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.KeyValuePairMethods.cs +++ b/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.KeyValuePairMethods.cs @@ -51,13 +51,13 @@ public static MethodDefinition get_KeyOrValue( name: accessorMethodName, attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Static, signature: MethodSignature.CreateStatic( - returnType: keyOrValueType.Import(module), + returnType: keyOrValueType, parameterTypes: [module.CorLibTypeFactory.Void.MakePointerType()])) { NoInlining = true }; // Declare the local variables: // [0]: '' (the ABI type for the result type) - CilLocalVariable loc_0_resultNative = new(keyOrValueType.GetAbiType(interopReferences).Import(module)); + CilLocalVariable loc_0_resultNative = new(keyOrValueType.GetAbiType(interopReferences)); // Jump labels CilInstruction nop_returnValueRewrite = new(Nop); @@ -73,8 +73,8 @@ public static MethodDefinition get_KeyOrValue( { Ldarg_0 }, { Ldind_I }, { Ldfld, vftblType.GetField(vftblMethodName) }, - { Calli, WellKnownTypeSignatureFactory.get_UntypedRetVal(interopReferences).Import(module).MakeStandAloneSignature() }, - { Call, interopReferences.RestrictedErrorInfoThrowExceptionForHR.Import(module) }, + { Calli, WellKnownTypeSignatureFactory.get_UntypedRetVal(interopReferences).MakeStandAloneSignature() }, + { Call, interopReferences.RestrictedErrorInfoThrowExceptionForHR }, { nop_returnValueRewrite } } }; diff --git a/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.SzArrayMarshaller.cs b/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.SzArrayMarshaller.cs index a41eb897a..d79ebbfc2 100644 --- a/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.SzArrayMarshaller.cs +++ b/src/WinRT.Interop.Generator/Factories/InteropMethodDefinitionFactory.SzArrayMarshaller.cs @@ -41,7 +41,7 @@ public static MethodDefinition Free( returnType: module.CorLibTypeFactory.Void, parameterTypes: [ module.CorLibTypeFactory.UInt32, - elementType.GetAbiType(interopReferences).Import(module).MakePointerType()])); + elementType.GetAbiType(interopReferences).MakePointerType()])); // For 'string', 'Type', reference types and blittable types, we can reuse the shared stubs from the 'WindowsRuntimeArrayHelpers' // type in WinRT.Runtime.dll, to simplify the code and reduce binary size (as we can reuse all these stubs for multiple types). @@ -53,7 +53,7 @@ public static MethodDefinition Free( { { Ldarg_0 }, { Ldarg_1 }, - { Call, interopReferences.WindowsRuntimeArrayHelpersFreeHStringArrayUnsafe.Import(module) }, + { Call, interopReferences.WindowsRuntimeArrayHelpersFreeHStringArrayUnsafe }, { Ret } } }; @@ -66,7 +66,7 @@ public static MethodDefinition Free( { { Ldarg_0 }, { Ldarg_1 }, - { Call, interopReferences.WindowsRuntimeArrayHelpersFreeTypeArrayUnsafe.Import(module) }, + { Call, interopReferences.WindowsRuntimeArrayHelpersFreeTypeArrayUnsafe }, { Ret } } }; @@ -79,7 +79,7 @@ public static MethodDefinition Free( { { Ldarg_0 }, { Ldarg_1 }, - { Call, interopReferences.WindowsRuntimeArrayHelpersFreeObjectArrayUnsafe.Import(module) }, + { Call, interopReferences.WindowsRuntimeArrayHelpersFreeObjectArrayUnsafe }, { Ret } } }; @@ -92,7 +92,7 @@ public static MethodDefinition Free( { { Ldarg_0 }, { Ldarg_1 }, - { Call, interopReferences.WindowsRuntimeArrayHelpersFreeBlittableArrayUnsafe.Import(module) }, + { Call, interopReferences.WindowsRuntimeArrayHelpersFreeBlittableArrayUnsafe }, { Ret } } }; diff --git a/src/WinRT.Interop.Generator/Factories/InteropMethodRewriteFactory.RetVal.cs b/src/WinRT.Interop.Generator/Factories/InteropMethodRewriteFactory.RetVal.cs index a33b21bd9..3bcb96da7 100644 --- a/src/WinRT.Interop.Generator/Factories/InteropMethodRewriteFactory.RetVal.cs +++ b/src/WinRT.Interop.Generator/Factories/InteropMethodRewriteFactory.RetVal.cs @@ -86,7 +86,7 @@ public static void RewriteMethod( ElementType.R4 => new CilInstruction(Stind_R4), ElementType.R8 => new CilInstruction(Stind_R8), ElementType.ValueType when retValType.Resolve() is { IsClass: true, IsEnum: true } => new CilInstruction(Stind_I4), - _ => new CilInstruction(Stobj, retValType.Import(module).ToTypeDefOrRef()), + _ => new CilInstruction(Stobj, retValType.ToTypeDefOrRef()), }; body.Instructions.ReplaceRange(marker, [storeInstruction]); @@ -138,30 +138,30 @@ public static void RewriteMethod( // Delegate to the marshaller to convert the managed value type on the evaluation stack body.Instructions.ReplaceRange(marker, [ - new CilInstruction(Call, marshallerMethod.Import(module)), - new CilInstruction(Stobj, retValType.GetAbiType(interopReferences).Import(module).ToTypeDefOrRef())]); + new CilInstruction(Call, marshallerMethod), + new CilInstruction(Stobj, retValType.GetAbiType(interopReferences).ToTypeDefOrRef())]); } } else if (retValType.IsTypeOfString()) { // When marshalling 'string' values, we must use 'HStringMarshaller' body.Instructions.ReplaceRange(marker, [ - new CilInstruction(Call, interopReferences.HStringMarshallerConvertToUnmanaged.Import(module)), + new CilInstruction(Call, interopReferences.HStringMarshallerConvertToUnmanaged), new CilInstruction(Stind_I)]); } else if (retValType.IsTypeOfType(interopReferences)) { // 'Type' values also need their own specialized marshaller body.Instructions.ReplaceRange(marker, [ - new CilInstruction(Call, interopReferences.TypeMarshallerConvertToUnmanaged.Import(module)), - new CilInstruction(Stobj, interopReferences.AbiType.Import(module).ToTypeDefOrRef())]); + new CilInstruction(Call, interopReferences.TypeMarshallerConvertToUnmanaged), + new CilInstruction(Stobj, interopReferences.AbiType)]); } else if (retValType.IsTypeOfException(interopReferences)) { // 'Exception' is also special, and needs its own specialized marshaller body.Instructions.ReplaceRange(marker, [ - new CilInstruction(Call, interopReferences.ExceptionMarshallerConvertToUnmanaged.Import(module)), - new CilInstruction(Stobj, interopReferences.AbiException.Import(module).ToTypeDefOrRef())]); + new CilInstruction(Call, interopReferences.ExceptionMarshallerConvertToUnmanaged), + new CilInstruction(Stobj, interopReferences.AbiException)]); } else if (retValType is GenericInstanceTypeSignature) { @@ -208,16 +208,16 @@ private static void RewriteBody( // We need a new local for the 'WindowsRuntimeObjectReferenceValue' returned from the // marshalling methods that the code will invoke. This is because we are going to call // the 'DetachThisPtrUnsafe()' method on it, which needs 'this' by reference. - CilLocalVariable loc_returnValue = new(interopReferences.WindowsRuntimeObjectReferenceValue.Import(module).ToValueTypeSignature()); + CilLocalVariable loc_returnValue = new(interopReferences.WindowsRuntimeObjectReferenceValue.ToValueTypeSignature()); body.LocalVariables.Add(loc_returnValue); // Marshal the value and detach its native pointer before assigning it to the target location body.Instructions.ReplaceRange(marker, [ - new CilInstruction(Call, marshallerMethod.Import(module)), + new CilInstruction(Call, marshallerMethod), CilInstruction.CreateStloc(loc_returnValue, body), new CilInstruction(Ldloca_S, loc_returnValue), - new CilInstruction(Call, interopReferences.WindowsRuntimeObjectReferenceValueDetachThisPtrUnsafe.Import(module)), + new CilInstruction(Call, interopReferences.WindowsRuntimeObjectReferenceValueDetachThisPtrUnsafe), new CilInstruction(Stind_I)]); } } diff --git a/src/WinRT.Interop.Generator/Factories/InteropMethodRewriteFactory.ReturnValue.cs b/src/WinRT.Interop.Generator/Factories/InteropMethodRewriteFactory.ReturnValue.cs index 3bac81fce..f470cb28d 100644 --- a/src/WinRT.Interop.Generator/Factories/InteropMethodRewriteFactory.ReturnValue.cs +++ b/src/WinRT.Interop.Generator/Factories/InteropMethodRewriteFactory.ReturnValue.cs @@ -157,7 +157,7 @@ public static void RewriteMethod( // We can directly call the marshaller and return it, no 'try/finally' complexity is needed body.Instructions.ReplaceRange(marker, [ CilInstruction.CreateLdloc(source, body), - new CilInstruction(Call, marshallerMethod.Import(module)), + new CilInstruction(Call, marshallerMethod), new CilInstruction(Ret)]); } } @@ -190,7 +190,7 @@ public static void RewriteMethod( // 'Exception' is also special, though it's simple: the ABI type is an unmanaged value type body.Instructions.ReplaceRange(marker, [ CilInstruction.CreateLdloc(source, body), - new CilInstruction(Call, interopReferences.ExceptionMarshallerConvertToManaged.Import(module)), + new CilInstruction(Call, interopReferences.ExceptionMarshallerConvertToManaged), new CilInstruction(Ret)]); } else if (returnType is GenericInstanceTypeSignature) @@ -247,7 +247,7 @@ private static void RewriteBody( // Add a new local for the marshalled return value. We need this because it will be // assigned from inside a protected region (a 'try') block, so we can't return the // value directly. Instead, we'll load and return the local after the handler code. - CilLocalVariable loc_returnValue = new(returnType.Import(module)); + CilLocalVariable loc_returnValue = new(returnType); body.LocalVariables.Add(loc_returnValue); @@ -259,11 +259,11 @@ private static void RewriteBody( // Marshal the value and release the original interface pointer, or dispose the ABI value body.Instructions.ReplaceRange(marker, [ ldloc_tryStart, - new CilInstruction(Call, marshallerMethod.Import(module)), + new CilInstruction(Call, marshallerMethod), CilInstruction.CreateStloc(loc_returnValue, body), new CilInstruction(Leave_S, ldloc_finallyEnd.CreateLabel()), ldloc_finallyStart, - new CilInstruction(Call, releaseOrDisposeMethod.Import(module)), + new CilInstruction(Call, releaseOrDisposeMethod), new CilInstruction(Endfinally), ldloc_finallyEnd, new CilInstruction(Ret)]); diff --git a/src/WinRT.Interop.Generator/Factories/WellKnownCilMethodBodyFactory.cs b/src/WinRT.Interop.Generator/Factories/WellKnownCilMethodBodyFactory.cs index fb1296cce..7cd208e78 100644 --- a/src/WinRT.Interop.Generator/Factories/WellKnownCilMethodBodyFactory.cs +++ b/src/WinRT.Interop.Generator/Factories/WellKnownCilMethodBodyFactory.cs @@ -45,11 +45,11 @@ public static CilMethodBody DynamicInterfaceCastableImplementation( // Load 'this', cast to 'WindowsRuntimeObject', and call 'GetObjectReferenceForInterface' // with the 'RuntimeTypeHandle' value that's loaded for the target interface type. { Ldarg_0 }, - { Castclass, interopReferences.WindowsRuntimeObject.Import(module) }, - { Ldtoken, interfaceType.Import(module).ToTypeDefOrRef() }, - { Call, interopReferences.TypeGetTypeFromHandle.Import(module) }, - { Callvirt, interopReferences.Typeget_TypeHandle.Import(module) }, - { Callvirt, interopReferences.WindowsRuntimeObjectGetObjectReferenceForInterface.Import(module) }, + { Castclass, interopReferences.WindowsRuntimeObject }, + { Ldtoken, interfaceType.ToTypeDefOrRef() }, + { Call, interopReferences.TypeGetTypeFromHandle }, + { Callvirt, interopReferences.Typeget_TypeHandle }, + { Callvirt, interopReferences.WindowsRuntimeObjectGetObjectReferenceForInterface }, } }; @@ -101,20 +101,20 @@ public static CilMethodBody DynamicInterfaceCastableImplementation( { LocalVariables = { - new CilLocalVariable(interopReferences.WindowsRuntimeObject.ToReferenceTypeSignature().Import(module)), - new CilLocalVariable(interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature().Import(module)) + new CilLocalVariable(interopReferences.WindowsRuntimeObject.ToReferenceTypeSignature()), + new CilLocalVariable(interopReferences.WindowsRuntimeObjectReference.ToReferenceTypeSignature()) }, Instructions = { // Cast 'this' and resolve the 'WindowsRuntimeObjectReference' instance for the interface { Ldarg_0 }, - { Castclass, interopReferences.WindowsRuntimeObject.Import(module) }, + { Castclass, interopReferences.WindowsRuntimeObject }, { Stloc_0 }, { Ldloc_0 }, - { Ldtoken, interfaceType.Import(module).ToTypeDefOrRef() }, - { Call, interopReferences.TypeGetTypeFromHandle.Import(module) }, - { Callvirt, interopReferences.Typeget_TypeHandle.Import(module) }, - { Callvirt, interopReferences.WindowsRuntimeObjectGetObjectReferenceForInterface.Import(module) }, + { Ldtoken, interfaceType.ToTypeDefOrRef() }, + { Call, interopReferences.TypeGetTypeFromHandle }, + { Callvirt, interopReferences.Typeget_TypeHandle }, + { Callvirt, interopReferences.WindowsRuntimeObjectGetObjectReferenceForInterface }, { Stloc_1 }, // (thisObject, thisReference).(value); @@ -122,7 +122,7 @@ public static CilMethodBody DynamicInterfaceCastableImplementation( { Ldloc_1 }, { Call, eventMethod }, { Ldarg_1 }, - { Callvirt, accessorMethod.Import(module) }, + { Callvirt, accessorMethod }, { Ret } } }; diff --git a/src/WinRT.Interop.Generator/Factories/WellKnownMemberDefinitionFactory.cs b/src/WinRT.Interop.Generator/Factories/WellKnownMemberDefinitionFactory.cs index e9be743bb..878ddb9ca 100644 --- a/src/WinRT.Interop.Generator/Factories/WellKnownMemberDefinitionFactory.cs +++ b/src/WinRT.Interop.Generator/Factories/WellKnownMemberDefinitionFactory.cs @@ -49,7 +49,7 @@ public static void IID( }; // The 'IID' property type has the signature being 'Guid& modreq(InAttribute)' - TypeSignature iidPropertyType = WellKnownTypeSignatureFactory.InGuid(interopReferences).Import(module); + TypeSignature iidPropertyType = WellKnownTypeSignatureFactory.InGuid(interopReferences); // Select the property and accessor name based on 'propertyName' Utf8String effectivePropertyName = $"IID_{propertyName}"; @@ -74,7 +74,7 @@ public static void IID( attributes: PropertyAttributes.None, signature: PropertySignature.FromGetMethod(get_IidMethod)) { - CustomAttributes = { new CustomAttribute(interopReferences.IsReadOnlyAttribute_ctor.Import(module)) }, + CustomAttributes = { new CustomAttribute(interopReferences.IsReadOnlyAttribute_ctor) }, GetMethod = get_IidMethod }; } @@ -95,7 +95,7 @@ public static void IID( out PropertyDefinition iidProperty) { // The 'IID' property type has the signature being 'Guid& modreq(InAttribute)' - TypeSignature iidPropertyType = WellKnownTypeSignatureFactory.InGuid(interopReferences).Import(module); + TypeSignature iidPropertyType = WellKnownTypeSignatureFactory.InGuid(interopReferences); // Create the 'get_IID' getter method get_IidMethod = new MethodDefinition( @@ -117,7 +117,7 @@ public static void IID( attributes: PropertyAttributes.None, signature: PropertySignature.FromGetMethod(get_IidMethod)) { - CustomAttributes = { new CustomAttribute(interopReferences.IsReadOnlyAttribute_ctor.Import(module)) }, + CustomAttributes = { new CustomAttribute(interopReferences.IsReadOnlyAttribute_ctor) }, GetMethod = get_IidMethod }; } diff --git a/src/WinRT.Interop.Generator/Factories/WellKnownTypeDefinitionFactory.IgnoreAccessChecksToAttribute.cs b/src/WinRT.Interop.Generator/Factories/WellKnownTypeDefinitionFactory.IgnoreAccessChecksToAttribute.cs index 4db1750eb..ee0ed8945 100644 --- a/src/WinRT.Interop.Generator/Factories/WellKnownTypeDefinitionFactory.IgnoreAccessChecksToAttribute.cs +++ b/src/WinRT.Interop.Generator/Factories/WellKnownTypeDefinitionFactory.IgnoreAccessChecksToAttribute.cs @@ -27,7 +27,7 @@ public static TypeDefinition IgnoresAccessChecksToAttribute(InteropReferences in ns: "System.Runtime.CompilerServices"u8, name: "IgnoresAccessChecksToAttribute"u8, attributes: TypeAttributes.Public | TypeAttributes.AutoLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, - baseType: interopReferences.Attribute.Import(module)); + baseType: interopReferences.Attribute); // Add the '_assemblyName' field FieldDefinition assemblyNameField = new( @@ -46,7 +46,7 @@ public static TypeDefinition IgnoresAccessChecksToAttribute(InteropReferences in _ = ctor.CilMethodBody!.Instructions.Insert(1, Ldarg_1); _ = ctor.CilMethodBody!.Instructions.Insert(2, Stfld, assemblyNameField); _ = ctor.CilMethodBody!.Instructions.Insert(3, Ldarg_0); - _ = ctor.CilMethodBody!.Instructions.Insert(4, Call, interopReferences.Attribute_ctor.Import(module)); + _ = ctor.CilMethodBody!.Instructions.Insert(4, Call, interopReferences.Attribute_ctor); // Create the 'get_AssemblyName' getter method MethodDefinition get_AssemblyNameMethod = new( diff --git a/src/WinRT.Interop.Generator/Factories/WellKnownTypeDefinitionFactory.cs b/src/WinRT.Interop.Generator/Factories/WellKnownTypeDefinitionFactory.cs index 0a007c5da..67618f809 100644 --- a/src/WinRT.Interop.Generator/Factories/WellKnownTypeDefinitionFactory.cs +++ b/src/WinRT.Interop.Generator/Factories/WellKnownTypeDefinitionFactory.cs @@ -28,7 +28,7 @@ public static TypeDefinition IUnknownVftbl(InteropReferences interopReferences, ns: null, name: ""u8, attributes: TypeAttributes.SequentialLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, - baseType: interopReferences.ValueType.Import(module)); + baseType: interopReferences.ValueType); // Get the 'IUnknown' signatures MethodSignature queryInterfaceType = WellKnownTypeSignatureFactory.QueryInterfaceImpl(interopReferences); @@ -40,9 +40,9 @@ public static TypeDefinition IUnknownVftbl(InteropReferences interopReferences, // public delegate* unmanaged[MemberFunction] QueryInterface; // public delegate* unmanaged[MemberFunction] AddRef; // public delegate* unmanaged[MemberFunction] Release; - vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.Import(module).MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.MakeFunctionPointerType())); return vftblType; } @@ -60,7 +60,7 @@ public static TypeDefinition IInspectableVftbl(InteropReferences interopReferenc ns: null, name: ""u8, attributes: TypeAttributes.SequentialLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, - baseType: interopReferences.ValueType.Import(module)); + baseType: interopReferences.ValueType); // Get the 'IUnknown' signatures MethodSignature queryInterfaceType = WellKnownTypeSignatureFactory.QueryInterfaceImpl(interopReferences); @@ -80,12 +80,12 @@ public static TypeDefinition IInspectableVftbl(InteropReferences interopReferenc // public delegate* unmanaged[MemberFunction] GetIids; // public delegate* unmanaged[MemberFunction] GetRuntimeClassName; // public delegate* unmanaged[MemberFunction] GetTrustLevel; - vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetIids"u8, FieldAttributes.Public, getIidsType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetRuntimeClassName"u8, FieldAttributes.Public, getRuntimeClassNameType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetTrustLevel"u8, FieldAttributes.Public, getTrustLevelType.Import(module).MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetIids"u8, FieldAttributes.Public, getIidsType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetRuntimeClassName"u8, FieldAttributes.Public, getRuntimeClassNameType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetTrustLevel"u8, FieldAttributes.Public, getTrustLevelType.MakeFunctionPointerType())); return vftblType; } @@ -104,7 +104,7 @@ public static TypeDefinition DelegateVftbl(InteropReferences interopReferences, ns: null, name: ""u8, attributes: TypeAttributes.SequentialLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, - baseType: interopReferences.ValueType.Import(module)); + baseType: interopReferences.ValueType); // Get the 'IUnknown' signatures MethodSignature queryInterfaceType = WellKnownTypeSignatureFactory.QueryInterfaceImpl(interopReferences); @@ -120,10 +120,10 @@ public static TypeDefinition DelegateVftbl(InteropReferences interopReferences, // public delegate* unmanaged[MemberFunction] AddRef; // public delegate* unmanaged[MemberFunction] Release; // public delegate* unmanaged[MemberFunction] Invoke; - vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("Invoke"u8, FieldAttributes.Public, invokeType.Import(module).MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("Invoke"u8, FieldAttributes.Public, invokeType.MakeFunctionPointerType())); return vftblType; } @@ -140,7 +140,7 @@ public static TypeDefinition DelegateReferenceVftbl(InteropReferences interopRef ns: null, name: ""u8, attributes: TypeAttributes.SequentialLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, - baseType: interopReferences.ValueType.Import(module)); + baseType: interopReferences.ValueType); // Get the 'IUnknown' signatures MethodSignature queryInterfaceType = WellKnownTypeSignatureFactory.QueryInterfaceImpl(interopReferences); @@ -172,13 +172,13 @@ public static TypeDefinition DelegateReferenceVftbl(InteropReferences interopRef // public delegate* unmanaged[MemberFunction] GetRuntimeClassName; // public delegate* unmanaged[MemberFunction] GetTrustLevel; // public delegate* unmanaged[MemberFunction] get_Value; - vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetIids"u8, FieldAttributes.Public, getIidsType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetRuntimeClassName"u8, FieldAttributes.Public, getRuntimeClassNameType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetTrustLevel"u8, FieldAttributes.Public, getTrustLevelType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("get_Value"u8, FieldAttributes.Public, valueType.Import(module).MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetIids"u8, FieldAttributes.Public, getIidsType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetRuntimeClassName"u8, FieldAttributes.Public, getRuntimeClassNameType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetTrustLevel"u8, FieldAttributes.Public, getTrustLevelType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("get_Value"u8, FieldAttributes.Public, valueType.MakeFunctionPointerType())); return vftblType; } @@ -195,10 +195,10 @@ public static TypeDefinition DelegateInterfaceEntriesType(InteropReferences inte ns: null, name: ""u8, attributes: TypeAttributes.SequentialLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, - baseType: interopReferences.ValueType.Import(module)); + baseType: interopReferences.ValueType); // Get the signature for the 'ComInterfaceEntry' type (this is a bit involved, so cache it) - TypeSignature comInterfaceEntryType = interopReferences.ComInterfaceEntry.Import(module).ToValueTypeSignature(); + TypeSignature comInterfaceEntryType = interopReferences.ComInterfaceEntry.ToValueTypeSignature(); // The type layout looks like this: // @@ -236,7 +236,7 @@ public static TypeDefinition IEnumerator1Vftbl(InteropReferences interopReferenc ns: null, name: ""u8, attributes: TypeAttributes.SequentialLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, - baseType: interopReferences.ValueType.Import(module)); + baseType: interopReferences.ValueType); // Get the 'IUnknown' signatures MethodSignature queryInterfaceType = WellKnownTypeSignatureFactory.QueryInterfaceImpl(interopReferences); @@ -266,16 +266,16 @@ public static TypeDefinition IEnumerator1Vftbl(InteropReferences interopReferenc // public delegate* unmanaged[MemberFunction] get_HasCurrent; // public delegate* unmanaged[MemberFunction] MoveNext; // public delegate* unmanaged[MemberFunction] GetMany; - vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetIids"u8, FieldAttributes.Public, getIidsType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetRuntimeClassName"u8, FieldAttributes.Public, getRuntimeClassNameType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetTrustLevel"u8, FieldAttributes.Public, getTrustLevelType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("get_Current"u8, FieldAttributes.Public, get_CurrentType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("get_HasCurrent"u8, FieldAttributes.Public, get_HasCurrentType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("MoveNext"u8, FieldAttributes.Public, moveNextType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetMany"u8, FieldAttributes.Public, getManyType.Import(module).MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetIids"u8, FieldAttributes.Public, getIidsType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetRuntimeClassName"u8, FieldAttributes.Public, getRuntimeClassNameType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetTrustLevel"u8, FieldAttributes.Public, getTrustLevelType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("get_Current"u8, FieldAttributes.Public, get_CurrentType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("get_HasCurrent"u8, FieldAttributes.Public, get_HasCurrentType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("MoveNext"u8, FieldAttributes.Public, moveNextType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetMany"u8, FieldAttributes.Public, getManyType.MakeFunctionPointerType())); return vftblType; } @@ -292,7 +292,7 @@ public static TypeDefinition IEnumerable1Vftbl(InteropReferences interopReferenc ns: null, name: ""u8, attributes: TypeAttributes.SequentialLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, - baseType: interopReferences.ValueType.Import(module)); + baseType: interopReferences.ValueType); // Get the 'IUnknown' signatures MethodSignature queryInterfaceType = WellKnownTypeSignatureFactory.QueryInterfaceImpl(interopReferences); @@ -316,13 +316,13 @@ public static TypeDefinition IEnumerable1Vftbl(InteropReferences interopReferenc // public delegate* unmanaged[MemberFunction] GetRuntimeClassName; // public delegate* unmanaged[MemberFunction] GetTrustLevel; // public delegate* unmanaged[MemberFunction] First; - vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetIids"u8, FieldAttributes.Public, getIidsType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetRuntimeClassName"u8, FieldAttributes.Public, getRuntimeClassNameType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetTrustLevel"u8, FieldAttributes.Public, getTrustLevelType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("First"u8, FieldAttributes.Public, firstType.Import(module).MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetIids"u8, FieldAttributes.Public, getIidsType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetRuntimeClassName"u8, FieldAttributes.Public, getRuntimeClassNameType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetTrustLevel"u8, FieldAttributes.Public, getTrustLevelType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("First"u8, FieldAttributes.Public, firstType.MakeFunctionPointerType())); return vftblType; } @@ -367,7 +367,7 @@ public static TypeDefinition IReadOnlyList1Vftbl( ns: ns, name: name, attributes: TypeAttributes.SequentialLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, - baseType: interopReferences.ValueType.Import(module)); + baseType: interopReferences.ValueType); // Get the 'IUnknown' signatures MethodSignature queryInterfaceType = WellKnownTypeSignatureFactory.QueryInterfaceImpl(interopReferences); @@ -397,16 +397,16 @@ public static TypeDefinition IReadOnlyList1Vftbl( // public delegate* unmanaged[MemberFunction] get_Size; // public delegate* unmanaged[MemberFunction], uint*, HRESULT> IndexOf; // public delegate* unmanaged[MemberFunction]*, uint*, HRESULT> GetMany; - vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetIids"u8, FieldAttributes.Public, getIidsType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetRuntimeClassName"u8, FieldAttributes.Public, getRuntimeClassNameType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetTrustLevel"u8, FieldAttributes.Public, getTrustLevelType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetAt"u8, FieldAttributes.Public, getAtType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("get_Size"u8, FieldAttributes.Public, get_SizeType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("IndexOf"u8, FieldAttributes.Public, indexOfType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetMany"u8, FieldAttributes.Public, getManyType.Import(module).MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetIids"u8, FieldAttributes.Public, getIidsType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetRuntimeClassName"u8, FieldAttributes.Public, getRuntimeClassNameType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetTrustLevel"u8, FieldAttributes.Public, getTrustLevelType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetAt"u8, FieldAttributes.Public, getAtType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("get_Size"u8, FieldAttributes.Public, get_SizeType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("IndexOf"u8, FieldAttributes.Public, indexOfType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetMany"u8, FieldAttributes.Public, getManyType.MakeFunctionPointerType())); return vftblType; } @@ -451,7 +451,7 @@ public static TypeDefinition IList1Vftbl( ns: ns, name: name, attributes: TypeAttributes.SequentialLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, - baseType: interopReferences.ValueType.Import(module)); + baseType: interopReferences.ValueType); // Get the 'IUnknown' signatures MethodSignature queryInterfaceType = WellKnownTypeSignatureFactory.QueryInterfaceImpl(interopReferences); @@ -498,24 +498,24 @@ public static TypeDefinition IList1Vftbl( // public delegate* unmanaged[MemberFunction] Clear; // public delegate* unmanaged[MemberFunction] GetMany; // public delegate* unmanaged[MemberFunction] ReplaceAll; - vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetIids"u8, FieldAttributes.Public, getIidsType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetRuntimeClassName"u8, FieldAttributes.Public, getRuntimeClassNameType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetTrustLevel"u8, FieldAttributes.Public, getTrustLevelType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetAt"u8, FieldAttributes.Public, getAtType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("get_Size"u8, FieldAttributes.Public, get_SizeType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetView"u8, FieldAttributes.Public, getViewType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("IndexOf"u8, FieldAttributes.Public, indexOfType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("SetAt"u8, FieldAttributes.Public, setAtType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("InsertAt"u8, FieldAttributes.Public, insertAtType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("RemoveAt"u8, FieldAttributes.Public, removeAtType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("Append"u8, FieldAttributes.Public, appendType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("RemoveAtEnd"u8, FieldAttributes.Public, removeAtEndType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("Clear"u8, FieldAttributes.Public, clearType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetMany"u8, FieldAttributes.Public, getManyType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("ReplaceAll"u8, FieldAttributes.Public, replaceAllType.Import(module).MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetIids"u8, FieldAttributes.Public, getIidsType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetRuntimeClassName"u8, FieldAttributes.Public, getRuntimeClassNameType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetTrustLevel"u8, FieldAttributes.Public, getTrustLevelType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetAt"u8, FieldAttributes.Public, getAtType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("get_Size"u8, FieldAttributes.Public, get_SizeType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetView"u8, FieldAttributes.Public, getViewType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("IndexOf"u8, FieldAttributes.Public, indexOfType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("SetAt"u8, FieldAttributes.Public, setAtType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("InsertAt"u8, FieldAttributes.Public, insertAtType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("RemoveAt"u8, FieldAttributes.Public, removeAtType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("Append"u8, FieldAttributes.Public, appendType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("RemoveAtEnd"u8, FieldAttributes.Public, removeAtEndType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("Clear"u8, FieldAttributes.Public, clearType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetMany"u8, FieldAttributes.Public, getManyType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("ReplaceAll"u8, FieldAttributes.Public, replaceAllType.MakeFunctionPointerType())); return vftblType; } @@ -563,7 +563,7 @@ public static TypeDefinition IReadOnlyDictionary2Vftbl( ns: ns, name: name, attributes: TypeAttributes.SequentialLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, - baseType: interopReferences.ValueType.Import(module)); + baseType: interopReferences.ValueType); // Get the 'IUnknown' signatures MethodSignature queryInterfaceType = WellKnownTypeSignatureFactory.QueryInterfaceImpl(interopReferences); @@ -593,16 +593,16 @@ public static TypeDefinition IReadOnlyDictionary2Vftbl( // public delegate* unmanaged[MemberFunction] get_Size; // public delegate* unmanaged[MemberFunction] HasKey; // public delegate* unmanaged[MemberFunction] Split; - vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetIids"u8, FieldAttributes.Public, getIidsType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetRuntimeClassName"u8, FieldAttributes.Public, getRuntimeClassNameType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetTrustLevel"u8, FieldAttributes.Public, getTrustLevelType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("Lookup"u8, FieldAttributes.Public, lookupType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("get_Size"u8, FieldAttributes.Public, get_SizeType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("HasKey"u8, FieldAttributes.Public, hasKeyType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("Split"u8, FieldAttributes.Public, splitType.Import(module).MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetIids"u8, FieldAttributes.Public, getIidsType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetRuntimeClassName"u8, FieldAttributes.Public, getRuntimeClassNameType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetTrustLevel"u8, FieldAttributes.Public, getTrustLevelType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("Lookup"u8, FieldAttributes.Public, lookupType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("get_Size"u8, FieldAttributes.Public, get_SizeType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("HasKey"u8, FieldAttributes.Public, hasKeyType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("Split"u8, FieldAttributes.Public, splitType.MakeFunctionPointerType())); return vftblType; } @@ -650,7 +650,7 @@ public static TypeDefinition IDictionary2Vftbl( ns: ns, name: name, attributes: TypeAttributes.SequentialLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, - baseType: interopReferences.ValueType.Import(module)); + baseType: interopReferences.ValueType); // Get the 'IUnknown' signatures MethodSignature queryInterfaceType = WellKnownTypeSignatureFactory.QueryInterfaceImpl(interopReferences); @@ -686,19 +686,19 @@ public static TypeDefinition IDictionary2Vftbl( // public delegate* unmanaged[MemberFunction] Insert; // public delegate* unmanaged[MemberFunction] Remove; // public delegate* unmanaged[MemberFunction] Clear; - vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetIids"u8, FieldAttributes.Public, getIidsType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetRuntimeClassName"u8, FieldAttributes.Public, getRuntimeClassNameType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetTrustLevel"u8, FieldAttributes.Public, getTrustLevelType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("Lookup"u8, FieldAttributes.Public, lookupType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("get_Size"u8, FieldAttributes.Public, get_SizeType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("HasKey"u8, FieldAttributes.Public, hasKeyType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetView"u8, FieldAttributes.Public, getViewType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("Insert"u8, FieldAttributes.Public, insertType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("Remove"u8, FieldAttributes.Public, removeType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("Clear"u8, FieldAttributes.Public, clearType.Import(module).MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetIids"u8, FieldAttributes.Public, getIidsType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetRuntimeClassName"u8, FieldAttributes.Public, getRuntimeClassNameType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetTrustLevel"u8, FieldAttributes.Public, getTrustLevelType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("Lookup"u8, FieldAttributes.Public, lookupType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("get_Size"u8, FieldAttributes.Public, get_SizeType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("HasKey"u8, FieldAttributes.Public, hasKeyType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetView"u8, FieldAttributes.Public, getViewType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("Insert"u8, FieldAttributes.Public, insertType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("Remove"u8, FieldAttributes.Public, removeType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("Clear"u8, FieldAttributes.Public, clearType.MakeFunctionPointerType())); return vftblType; } @@ -715,7 +715,7 @@ public static TypeDefinition IKeyValuePairVftbl(InteropReferences interopReferen ns: null, name: ""u8, attributes: TypeAttributes.SequentialLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, - baseType: interopReferences.ValueType.Import(module)); + baseType: interopReferences.ValueType); // Get the 'IUnknown' signatures MethodSignature queryInterfaceType = WellKnownTypeSignatureFactory.QueryInterfaceImpl(interopReferences); @@ -748,14 +748,14 @@ public static TypeDefinition IKeyValuePairVftbl(InteropReferences interopReferen // public delegate* unmanaged[MemberFunction] GetTrustLevel; // public delegate* unmanaged[MemberFunction] get_Key; // public delegate* unmanaged[MemberFunction] get_Value; - vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetIids"u8, FieldAttributes.Public, getIidsType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetRuntimeClassName"u8, FieldAttributes.Public, getRuntimeClassNameType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetTrustLevel"u8, FieldAttributes.Public, getTrustLevelType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("get_Key"u8, FieldAttributes.Public, get_KeyOrValueType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("get_Value"u8, FieldAttributes.Public, get_KeyOrValueType.Import(module).MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetIids"u8, FieldAttributes.Public, getIidsType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetRuntimeClassName"u8, FieldAttributes.Public, getRuntimeClassNameType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetTrustLevel"u8, FieldAttributes.Public, getTrustLevelType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("get_Key"u8, FieldAttributes.Public, get_KeyOrValueType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("get_Value"u8, FieldAttributes.Public, get_KeyOrValueType.MakeFunctionPointerType())); return vftblType; } @@ -772,10 +772,10 @@ public static TypeDefinition IKeyValuePairInterfaceEntriesType(InteropReferences ns: null, name: ""u8, attributes: TypeAttributes.SequentialLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, - baseType: interopReferences.ValueType.Import(module)); + baseType: interopReferences.ValueType); // Get the signature for the 'ComInterfaceEntry' type (this is a bit involved, so cache it) - TypeSignature comInterfaceEntryType = interopReferences.ComInterfaceEntry.Import(module).ToValueTypeSignature(); + TypeSignature comInterfaceEntryType = interopReferences.ComInterfaceEntry.ToValueTypeSignature(); // The type layout looks like this: // @@ -809,7 +809,7 @@ public static TypeDefinition IMapChangedEventArgsVftbl(InteropReferences interop ns: null, name: ""u8, attributes: TypeAttributes.SequentialLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, - baseType: interopReferences.ValueType.Import(module)); + baseType: interopReferences.ValueType); // Get the 'IUnknown' signatures MethodSignature queryInterfaceType = WellKnownTypeSignatureFactory.QueryInterfaceImpl(interopReferences); @@ -853,14 +853,14 @@ public static TypeDefinition IMapChangedEventArgsVftbl(InteropReferences interop // public delegate* unmanaged[MemberFunction] GetTrustLevel; // public delegate* unmanaged[MemberFunction] get_CollectionChange; // public delegate* unmanaged[MemberFunction] get_Key; - vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetIids"u8, FieldAttributes.Public, getIidsType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetRuntimeClassName"u8, FieldAttributes.Public, getRuntimeClassNameType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetTrustLevel"u8, FieldAttributes.Public, getTrustLevelType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("get_CollectionChange"u8, FieldAttributes.Public, collectionChangeType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("get_Key"u8, FieldAttributes.Public, keyType.Import(module).MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetIids"u8, FieldAttributes.Public, getIidsType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetRuntimeClassName"u8, FieldAttributes.Public, getRuntimeClassNameType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetTrustLevel"u8, FieldAttributes.Public, getTrustLevelType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("get_CollectionChange"u8, FieldAttributes.Public, collectionChangeType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("get_Key"u8, FieldAttributes.Public, keyType.MakeFunctionPointerType())); return vftblType; } @@ -877,7 +877,7 @@ public static TypeDefinition IObservableVectorVftbl(InteropReferences interopRef ns: null, name: ""u8, attributes: TypeAttributes.SequentialLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, - baseType: interopReferences.ValueType.Import(module)); + baseType: interopReferences.ValueType); // Get the 'IUnknown' signatures MethodSignature queryInterfaceType = WellKnownTypeSignatureFactory.QueryInterfaceImpl(interopReferences); @@ -903,14 +903,14 @@ public static TypeDefinition IObservableVectorVftbl(InteropReferences interopRef // public delegate* unmanaged[MemberFunction] GetTrustLevel; // public delegate* unmanaged[MemberFunction] add_VectorChanged; // public delegate* unmanaged[MemberFunction] remove_VectorChanged; - vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetIids"u8, FieldAttributes.Public, getIidsType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetRuntimeClassName"u8, FieldAttributes.Public, getRuntimeClassNameType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetTrustLevel"u8, FieldAttributes.Public, getTrustLevelType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("add_VectorChanged"u8, FieldAttributes.Public, add_VectorChanged.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("remove_VectorChanged"u8, FieldAttributes.Public, remove_VectorChanged.Import(module).MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetIids"u8, FieldAttributes.Public, getIidsType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetRuntimeClassName"u8, FieldAttributes.Public, getRuntimeClassNameType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetTrustLevel"u8, FieldAttributes.Public, getTrustLevelType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("add_VectorChanged"u8, FieldAttributes.Public, add_VectorChanged.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("remove_VectorChanged"u8, FieldAttributes.Public, remove_VectorChanged.MakeFunctionPointerType())); return vftblType; } @@ -927,7 +927,7 @@ public static TypeDefinition IObservableMapVftbl(InteropReferences interopRefere ns: null, name: ""u8, attributes: TypeAttributes.SequentialLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, - baseType: interopReferences.ValueType.Import(module)); + baseType: interopReferences.ValueType); // Get the 'IUnknown' signatures MethodSignature queryInterfaceType = WellKnownTypeSignatureFactory.QueryInterfaceImpl(interopReferences); @@ -953,14 +953,14 @@ public static TypeDefinition IObservableMapVftbl(InteropReferences interopRefere // public delegate* unmanaged[MemberFunction] GetTrustLevel; // public delegate* unmanaged[MemberFunction] add_MapChanged; // public delegate* unmanaged[MemberFunction] remove_MapChanged; - vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetIids"u8, FieldAttributes.Public, getIidsType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetRuntimeClassName"u8, FieldAttributes.Public, getRuntimeClassNameType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetTrustLevel"u8, FieldAttributes.Public, getTrustLevelType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("add_MapChanged"u8, FieldAttributes.Public, add_MapChanged.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("remove_MapChanged"u8, FieldAttributes.Public, remove_MapChanged.Import(module).MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetIids"u8, FieldAttributes.Public, getIidsType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetRuntimeClassName"u8, FieldAttributes.Public, getRuntimeClassNameType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetTrustLevel"u8, FieldAttributes.Public, getTrustLevelType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("add_MapChanged"u8, FieldAttributes.Public, add_MapChanged.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("remove_MapChanged"u8, FieldAttributes.Public, remove_MapChanged.MakeFunctionPointerType())); return vftblType; } @@ -977,7 +977,7 @@ public static TypeDefinition IAsyncActionWithProgressVftbl(InteropReferences int ns: null, name: ""u8, attributes: TypeAttributes.SequentialLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, - baseType: interopReferences.ValueType.Import(module)); + baseType: interopReferences.ValueType); // Get the 'IUnknown' signatures MethodSignature queryInterfaceType = WellKnownTypeSignatureFactory.QueryInterfaceImpl(interopReferences); @@ -1019,17 +1019,17 @@ public static TypeDefinition IAsyncActionWithProgressVftbl(InteropReferences int // public delegate* unmanaged[MemberFunction] get_Completed; // public delegate* unmanaged[MemberFunction] set_Completed; // public delegate* unmanaged[MemberFunction] GetResults; - vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetIids"u8, FieldAttributes.Public, getIidsType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetRuntimeClassName"u8, FieldAttributes.Public, getRuntimeClassNameType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetTrustLevel"u8, FieldAttributes.Public, getTrustLevelType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("get_Progress"u8, FieldAttributes.Public, get_ProgressType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("set_Progress"u8, FieldAttributes.Public, set_ProgressType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("get_Completed"u8, FieldAttributes.Public, get_CompletedType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("set_Completed"u8, FieldAttributes.Public, set_CompletedType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetResults"u8, FieldAttributes.Public, getResultsType.Import(module).MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetIids"u8, FieldAttributes.Public, getIidsType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetRuntimeClassName"u8, FieldAttributes.Public, getRuntimeClassNameType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetTrustLevel"u8, FieldAttributes.Public, getTrustLevelType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("get_Progress"u8, FieldAttributes.Public, get_ProgressType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("set_Progress"u8, FieldAttributes.Public, set_ProgressType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("get_Completed"u8, FieldAttributes.Public, get_CompletedType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("set_Completed"u8, FieldAttributes.Public, set_CompletedType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetResults"u8, FieldAttributes.Public, getResultsType.MakeFunctionPointerType())); return vftblType; } @@ -1046,7 +1046,7 @@ public static TypeDefinition IAsyncOperationVftbl(InteropReferences interopRefer ns: null, name: ""u8, attributes: TypeAttributes.SequentialLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, - baseType: interopReferences.ValueType.Import(module)); + baseType: interopReferences.ValueType); // Get the 'IUnknown' signatures MethodSignature queryInterfaceType = WellKnownTypeSignatureFactory.QueryInterfaceImpl(interopReferences); @@ -1076,15 +1076,15 @@ public static TypeDefinition IAsyncOperationVftbl(InteropReferences interopRefer // public delegate* unmanaged[MemberFunction] get_Completed; // public delegate* unmanaged[MemberFunction] set_Completed; // public delegate* unmanaged[MemberFunction] GetResults; - vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetIids"u8, FieldAttributes.Public, getIidsType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetRuntimeClassName"u8, FieldAttributes.Public, getRuntimeClassNameType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetTrustLevel"u8, FieldAttributes.Public, getTrustLevelType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("get_Completed"u8, FieldAttributes.Public, get_CompletedType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("set_Completed"u8, FieldAttributes.Public, set_CompletedType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetResults"u8, FieldAttributes.Public, getResultsType.Import(module).MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetIids"u8, FieldAttributes.Public, getIidsType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetRuntimeClassName"u8, FieldAttributes.Public, getRuntimeClassNameType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetTrustLevel"u8, FieldAttributes.Public, getTrustLevelType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("get_Completed"u8, FieldAttributes.Public, get_CompletedType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("set_Completed"u8, FieldAttributes.Public, set_CompletedType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetResults"u8, FieldAttributes.Public, getResultsType.MakeFunctionPointerType())); return vftblType; } @@ -1101,7 +1101,7 @@ public static TypeDefinition IAsyncOperationWithProgressVftbl(InteropReferences ns: null, name: ""u8, attributes: TypeAttributes.SequentialLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, - baseType: interopReferences.ValueType.Import(module)); + baseType: interopReferences.ValueType); // Get the 'IUnknown' signatures MethodSignature queryInterfaceType = WellKnownTypeSignatureFactory.QueryInterfaceImpl(interopReferences); @@ -1137,17 +1137,17 @@ public static TypeDefinition IAsyncOperationWithProgressVftbl(InteropReferences // public delegate* unmanaged[MemberFunction] get_Completed; // public delegate* unmanaged[MemberFunction] set_Completed; // public delegate* unmanaged[MemberFunction] GetResults; - vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetIids"u8, FieldAttributes.Public, getIidsType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetRuntimeClassName"u8, FieldAttributes.Public, getRuntimeClassNameType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetTrustLevel"u8, FieldAttributes.Public, getTrustLevelType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("get_Progress"u8, FieldAttributes.Public, get_ProgressType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("set_Progress"u8, FieldAttributes.Public, set_ProgressType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("get_Completed"u8, FieldAttributes.Public, get_CompletedType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("set_Completed"u8, FieldAttributes.Public, set_CompletedType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetResults"u8, FieldAttributes.Public, getResultsType.Import(module).MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetIids"u8, FieldAttributes.Public, getIidsType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetRuntimeClassName"u8, FieldAttributes.Public, getRuntimeClassNameType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetTrustLevel"u8, FieldAttributes.Public, getTrustLevelType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("get_Progress"u8, FieldAttributes.Public, get_ProgressType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("set_Progress"u8, FieldAttributes.Public, set_ProgressType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("get_Completed"u8, FieldAttributes.Public, get_CompletedType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("set_Completed"u8, FieldAttributes.Public, set_CompletedType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetResults"u8, FieldAttributes.Public, getResultsType.MakeFunctionPointerType())); return vftblType; } @@ -1164,7 +1164,7 @@ public static TypeDefinition ReferenceArrayVftbl(InteropReferences interopRefere ns: null, name: ""u8, attributes: TypeAttributes.SequentialLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, - baseType: interopReferences.ValueType.Import(module)); + baseType: interopReferences.ValueType); // Get the 'IUnknown' signatures MethodSignature queryInterfaceType = WellKnownTypeSignatureFactory.QueryInterfaceImpl(interopReferences); @@ -1197,13 +1197,13 @@ public static TypeDefinition ReferenceArrayVftbl(InteropReferences interopRefere // public delegate* unmanaged[MemberFunction] GetRuntimeClassName; // public delegate* unmanaged[MemberFunction] GetTrustLevel; // public delegate* unmanaged[MemberFunction] get_Value; - vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetIids"u8, FieldAttributes.Public, getIidsType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetRuntimeClassName"u8, FieldAttributes.Public, getRuntimeClassNameType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("GetTrustLevel"u8, FieldAttributes.Public, getTrustLevelType.Import(module).MakeFunctionPointerType())); - vftblType.Fields.Add(new FieldDefinition("get_Value"u8, FieldAttributes.Public, valueType.Import(module).MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("QueryInterface"u8, FieldAttributes.Public, queryInterfaceType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("AddRef"u8, FieldAttributes.Public, addRefType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("Release"u8, FieldAttributes.Public, releaseType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetIids"u8, FieldAttributes.Public, getIidsType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetRuntimeClassName"u8, FieldAttributes.Public, getRuntimeClassNameType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("GetTrustLevel"u8, FieldAttributes.Public, getTrustLevelType.MakeFunctionPointerType())); + vftblType.Fields.Add(new FieldDefinition("get_Value"u8, FieldAttributes.Public, valueType.MakeFunctionPointerType())); return vftblType; } @@ -1220,10 +1220,10 @@ public static TypeDefinition ReferenceArrayInterfaceEntriesType(InteropReference ns: null, name: ""u8, attributes: TypeAttributes.SequentialLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, - baseType: interopReferences.ValueType.Import(module)); + baseType: interopReferences.ValueType); // Get the signature for the 'ComInterfaceEntry' type (this is a bit involved, so cache it) - TypeSignature comInterfaceEntryType = interopReferences.ComInterfaceEntry.Import(module).ToValueTypeSignature(); + TypeSignature comInterfaceEntryType = interopReferences.ComInterfaceEntry.ToValueTypeSignature(); // The type layout looks like this: // @@ -1260,10 +1260,10 @@ public static TypeDefinition UserDefinedInterfaceEntriesType(int numberOfEntries ns: null, name: $"", attributes: TypeAttributes.SequentialLayout | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, - baseType: interopReferences.ValueType.Import(module)); + baseType: interopReferences.ValueType); // Get the signature for the 'ComInterfaceEntry' type - TypeSignature comInterfaceEntryType = interopReferences.ComInterfaceEntry.Import(module).ToValueTypeSignature(); + TypeSignature comInterfaceEntryType = interopReferences.ComInterfaceEntry.ToValueTypeSignature(); // Add a field for each interface entry for (int i = 0; i < numberOfEntries; i++) @@ -1297,7 +1297,7 @@ public static TypeDefinition RvaFields(InteropReferences interopReferences, Modu ns: null, name: "IIDRvaData(Size=16|Align=4)", attributes: TypeAttributes.NestedAssembly | TypeAttributes.ExplicitLayout | TypeAttributes.Sealed, - baseType: interopReferences.ValueType.Import(module)) + baseType: interopReferences.ValueType) { ClassLayout = new ClassLayout(packingSize: 4, classSize: 16) }; diff --git a/src/WinRT.Interop.Generator/Generation/InteropGenerator.Discover.cs b/src/WinRT.Interop.Generator/Generation/InteropGenerator.Discover.cs index a417b9d33..864a902ff 100644 --- a/src/WinRT.Interop.Generator/Generation/InteropGenerator.Discover.cs +++ b/src/WinRT.Interop.Generator/Generation/InteropGenerator.Discover.cs @@ -551,6 +551,6 @@ private static InteropReferences CreateDiscoveryInteropReferences(ModuleDefiniti windowsSdkProjectionAssembly.PublicKeyOrToken = InteropValues.PublicKeyData; windowsSdkProjectionAssembly.HasPublicKey = true; - return new(module.CorLibTypeFactory, windowsRuntimeAssembly.Import(module), windowsSdkProjectionAssembly.Import(module)); + return new(module.CorLibTypeFactory, windowsRuntimeAssembly, windowsSdkProjectionAssembly); } } \ No newline at end of file From 976fc388a419ac9f9c5659db891f422b3a94e511 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Thu, 11 Dec 2025 10:10:53 -0800 Subject: [PATCH 3/7] Import assembly references with DefaultImporter Updated assembly reference creation to use the ImportWith method with DefaultImporter in both InteropGenerator.Discover and InteropReferences. This ensures references are properly imported into the target module context. --- .../Generation/InteropGenerator.Discover.cs | 2 +- src/WinRT.Interop.Generator/References/InteropReferences.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/WinRT.Interop.Generator/Generation/InteropGenerator.Discover.cs b/src/WinRT.Interop.Generator/Generation/InteropGenerator.Discover.cs index 864a902ff..a417b9d33 100644 --- a/src/WinRT.Interop.Generator/Generation/InteropGenerator.Discover.cs +++ b/src/WinRT.Interop.Generator/Generation/InteropGenerator.Discover.cs @@ -551,6 +551,6 @@ private static InteropReferences CreateDiscoveryInteropReferences(ModuleDefiniti windowsSdkProjectionAssembly.PublicKeyOrToken = InteropValues.PublicKeyData; windowsSdkProjectionAssembly.HasPublicKey = true; - return new(module.CorLibTypeFactory, windowsRuntimeAssembly, windowsSdkProjectionAssembly); + return new(module.CorLibTypeFactory, windowsRuntimeAssembly.Import(module), windowsSdkProjectionAssembly.Import(module)); } } \ No newline at end of file diff --git a/src/WinRT.Interop.Generator/References/InteropReferences.cs b/src/WinRT.Interop.Generator/References/InteropReferences.cs index 821893b33..dbb27b0f0 100644 --- a/src/WinRT.Interop.Generator/References/InteropReferences.cs +++ b/src/WinRT.Interop.Generator/References/InteropReferences.cs @@ -68,7 +68,7 @@ public InteropReferences( name: "System.Runtime.InteropServices"u8, version: new Version(10, 0, 0, 0), publicKey: false, - publicKeyOrToken: WellKnownPublicKeyTokens.SystemRuntimeInteropServices); + publicKeyOrToken: WellKnownPublicKeyTokens.SystemRuntimeInteropServices).ImportWith(_corLibTypeFactory.CorLibScope.ContextModule!.DefaultImporter); /// /// Gets the for System.ObjectModel.dll. @@ -77,7 +77,7 @@ public InteropReferences( name: "System.ObjectModel"u8, version: new Version(10, 0, 0, 0), publicKey: false, - publicKeyOrToken: WellKnownPublicKeyTokens.SystemObjectModel); + publicKeyOrToken: WellKnownPublicKeyTokens.SystemObjectModel).ImportWith(_corLibTypeFactory.CorLibScope.ContextModule!.DefaultImporter); /// /// Gets the for System.Memory.dll. @@ -86,7 +86,7 @@ public InteropReferences( name: "System.Memory"u8, version: new Version(10, 0, 0, 0), publicKey: false, - publicKeyOrToken: WellKnownPublicKeyTokens.SystemMemory); + publicKeyOrToken: WellKnownPublicKeyTokens.SystemMemory).ImportWith(_corLibTypeFactory.CorLibScope.ContextModule!.DefaultImporter); /// /// Gets the for . From af8e422da1307bf3fa249f78af40c9678f4c7001 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Fri, 12 Dec 2025 08:52:14 -0800 Subject: [PATCH 4/7] Add Import extension for AssemblyReference with IResolutionScope Introduced a new Import extension method for AssemblyReference that accepts an IResolutionScope, simplifying the import process. Updated InteropReferences to use the new method, improving code clarity and reducing direct dependency on ContextModule.DefaultImporter. --- .../Extensions/ImportExtensions.cs | 11 +++++++++++ .../References/InteropReferences.cs | 6 +++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/WinRT.Interop.Generator/Extensions/ImportExtensions.cs b/src/WinRT.Interop.Generator/Extensions/ImportExtensions.cs index 77a1f99a0..3ec807cd6 100644 --- a/src/WinRT.Interop.Generator/Extensions/ImportExtensions.cs +++ b/src/WinRT.Interop.Generator/Extensions/ImportExtensions.cs @@ -77,6 +77,17 @@ public static AssemblyReference Import(this AssemblyReference assemblyReference, return assemblyReference.ImportWith(module.DefaultImporter); } + /// + /// Imports a member reference into a module using the default reference importer. + /// + /// The instance to import. + /// The scope to import into. + /// The imported . + public static AssemblyReference Import(this AssemblyReference assemblyReference, IResolutionScope scope) + { + return assemblyReference.ImportWith(scope.ContextModule!.DefaultImporter); + } + /// /// Imports a member reference into a module using the default reference importer. /// diff --git a/src/WinRT.Interop.Generator/References/InteropReferences.cs b/src/WinRT.Interop.Generator/References/InteropReferences.cs index dbb27b0f0..470fa39b5 100644 --- a/src/WinRT.Interop.Generator/References/InteropReferences.cs +++ b/src/WinRT.Interop.Generator/References/InteropReferences.cs @@ -68,7 +68,7 @@ public InteropReferences( name: "System.Runtime.InteropServices"u8, version: new Version(10, 0, 0, 0), publicKey: false, - publicKeyOrToken: WellKnownPublicKeyTokens.SystemRuntimeInteropServices).ImportWith(_corLibTypeFactory.CorLibScope.ContextModule!.DefaultImporter); + publicKeyOrToken: WellKnownPublicKeyTokens.SystemRuntimeInteropServices).Import(_corLibTypeFactory.CorLibScope); /// /// Gets the for System.ObjectModel.dll. @@ -77,7 +77,7 @@ public InteropReferences( name: "System.ObjectModel"u8, version: new Version(10, 0, 0, 0), publicKey: false, - publicKeyOrToken: WellKnownPublicKeyTokens.SystemObjectModel).ImportWith(_corLibTypeFactory.CorLibScope.ContextModule!.DefaultImporter); + publicKeyOrToken: WellKnownPublicKeyTokens.SystemObjectModel).Import(_corLibTypeFactory.CorLibScope); /// /// Gets the for System.Memory.dll. @@ -86,7 +86,7 @@ public InteropReferences( name: "System.Memory"u8, version: new Version(10, 0, 0, 0), publicKey: false, - publicKeyOrToken: WellKnownPublicKeyTokens.SystemMemory).ImportWith(_corLibTypeFactory.CorLibScope.ContextModule!.DefaultImporter); + publicKeyOrToken: WellKnownPublicKeyTokens.SystemMemory).Import(_corLibTypeFactory.CorLibScope); /// /// Gets the for . From a734128860c12b6ebaeefb7fd50f87236568bee4 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Fri, 12 Dec 2025 08:54:36 -0800 Subject: [PATCH 5/7] Add remarks for assembly reference scope resolution Added remarks to clarify that assembly references use the same scope as the core library type factory to ensure correct resolution. Also added comments in InteropGenerator.Discover.cs to explain the need for importing both assembly references for accurate signature comparisons during discovery. --- .../Generation/InteropGenerator.Discover.cs | 2 ++ src/WinRT.Interop.Generator/References/InteropReferences.cs | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/WinRT.Interop.Generator/Generation/InteropGenerator.Discover.cs b/src/WinRT.Interop.Generator/Generation/InteropGenerator.Discover.cs index a417b9d33..23910a12b 100644 --- a/src/WinRT.Interop.Generator/Generation/InteropGenerator.Discover.cs +++ b/src/WinRT.Interop.Generator/Generation/InteropGenerator.Discover.cs @@ -551,6 +551,8 @@ private static InteropReferences CreateDiscoveryInteropReferences(ModuleDefiniti windowsSdkProjectionAssembly.PublicKeyOrToken = InteropValues.PublicKeyData; windowsSdkProjectionAssembly.HasPublicKey = true; + // Import both assembly references, so the resolution scope for them is set correctly during discovery. + // This is requires so that all kinds of signature comparisons during discovery actually work correctly. return new(module.CorLibTypeFactory, windowsRuntimeAssembly.Import(module), windowsSdkProjectionAssembly.Import(module)); } } \ No newline at end of file diff --git a/src/WinRT.Interop.Generator/References/InteropReferences.cs b/src/WinRT.Interop.Generator/References/InteropReferences.cs index 470fa39b5..7cfd3e084 100644 --- a/src/WinRT.Interop.Generator/References/InteropReferences.cs +++ b/src/WinRT.Interop.Generator/References/InteropReferences.cs @@ -64,6 +64,9 @@ public InteropReferences( /// /// Gets the for System.Runtime.InteropServices.dll. /// + /// + /// This will use the same scope as , to enable correct resolution. + /// public AssemblyReference SystemRuntimeInteropServices => field ??= new AssemblyReference( name: "System.Runtime.InteropServices"u8, version: new Version(10, 0, 0, 0), @@ -73,6 +76,7 @@ public InteropReferences( /// /// Gets the for System.ObjectModel.dll. /// + /// public AssemblyReference SystemObjectModel => field ??= new AssemblyReference( name: "System.ObjectModel"u8, version: new Version(10, 0, 0, 0), @@ -82,6 +86,7 @@ public InteropReferences( /// /// Gets the for System.Memory.dll. /// + /// public AssemblyReference SystemMemory => field ??= new AssemblyReference( name: "System.Memory"u8, version: new Version(10, 0, 0, 0), From 566810414a3cc46f03d403806b5b16a17a529668 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Fri, 12 Dec 2025 08:56:35 -0800 Subject: [PATCH 6/7] Remove unused import extension methods Deleted several Import extension methods for types, methods, signatures, and member references that are no longer used. This streamlines the ImportExtensions class and removes unnecessary code. --- .../Extensions/ImportExtensions.cs | 78 ------------------- 1 file changed, 78 deletions(-) diff --git a/src/WinRT.Interop.Generator/Extensions/ImportExtensions.cs b/src/WinRT.Interop.Generator/Extensions/ImportExtensions.cs index 3ec807cd6..2f7354e34 100644 --- a/src/WinRT.Interop.Generator/Extensions/ImportExtensions.cs +++ b/src/WinRT.Interop.Generator/Extensions/ImportExtensions.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using AsmResolver.DotNet; -using AsmResolver.DotNet.Signatures; namespace WindowsRuntime.InteropGenerator; @@ -11,61 +10,6 @@ namespace WindowsRuntime.InteropGenerator; /// internal static class ImportExtensions { - /// - /// Imports a type definition or reference into a module using the default reference importer. - /// - /// The instance to import. - /// The module to import into. - /// The imported . - public static ITypeDefOrRef Import(this ITypeDefOrRef typeDefOrRef, ModuleDefinition module) - { - return typeDefOrRef.ImportWith(module.DefaultImporter); - } - - /// - /// Imports a method definition or reference into a module using the default reference importer. - /// - /// The instance to import. - /// The module to import into. - /// The imported . - public static IMethodDefOrRef Import(this IMethodDefOrRef methodDefOrRef, ModuleDefinition module) - { - return (IMethodDefOrRef)methodDefOrRef.ImportWith(module.DefaultImporter); - } - - /// - /// Imports a type signature into a module using the default reference importer. - /// - /// The instance to import. - /// The module to import into. - /// The imported . - public static TypeSignature Import(this TypeSignature typeSignature, ModuleDefinition module) - { - return typeSignature.ImportWith(module.DefaultImporter); - } - - /// - /// Imports a type signature into a module using the default reference importer. - /// - /// The instance to import. - /// The module to import into. - /// The imported . - public static GenericInstanceTypeSignature Import(this GenericInstanceTypeSignature typeSignature, ModuleDefinition module) - { - return (GenericInstanceTypeSignature)typeSignature.ImportWith(module.DefaultImporter); - } - - /// - /// Imports a method signature into a module using the default reference importer. - /// - /// The instance to import. - /// The module to import into. - /// The imported . - public static MethodSignature Import(this MethodSignature methodSignature, ModuleDefinition module) - { - return methodSignature.ImportWith(module.DefaultImporter); - } - /// /// Imports a member reference into a module using the default reference importer. /// @@ -87,26 +31,4 @@ public static AssemblyReference Import(this AssemblyReference assemblyReference, { return assemblyReference.ImportWith(scope.ContextModule!.DefaultImporter); } - - /// - /// Imports a member reference into a module using the default reference importer. - /// - /// The instance to import. - /// The module to import into. - /// The imported . - public static MemberReference Import(this MemberReference memberReference, ModuleDefinition module) - { - return memberReference.ImportWith(module.DefaultImporter); - } - - /// - /// Imports a method specification into a module using the default reference importer. - /// - /// The instance to import. - /// The module to import into. - /// The imported . - public static MethodSpecification Import(this MethodSpecification methodSpecification, ModuleDefinition module) - { - return methodSpecification.ImportWith(module.DefaultImporter); - } } \ No newline at end of file From 421756b4f7a140d0a060e196c166a095295f44a3 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 16 Dec 2025 15:39:49 -0800 Subject: [PATCH 7/7] Update AsmResolver.DotNet package version Bumped AsmResolver.DotNet from 6.0.0-development.317 to 6.0.0-refs-pull-697-merge.322 to incorporate the latest changes and improvements. --- src/Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 66abf3e0d..fda677143 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -3,7 +3,7 @@ true - +