Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="AsmResolver.DotNet" Version="6.0.0-development.282" />
<PackageVersion Include="AsmResolver.DotNet" Version="6.0.0-development.317" />
<PackageVersion Include="Basic.Reference.Assemblies.Net100" Version="1.8.3" />
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
<PackageVersion Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.14.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -176,15 +176,15 @@ 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);

_ = 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:
//
Expand All @@ -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 =
{
Expand All @@ -206,7 +206,7 @@ private static void DerivedEventSource(

// Add and implement the 'ConvertToUnmanaged' method
eventSourceType.AddMethodImplementation(
declaration: baseEventSourceConvertToUnmanaged.Import(module),
declaration: baseEventSourceConvertToUnmanaged,
method: convertToUnmanagedMethod);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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<T>' instance to native
Expand All @@ -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<T>' instance to managed
Expand All @@ -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<T>' instance to native
Expand All @@ -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:
Expand All @@ -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);
}

Expand Down Expand Up @@ -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)
}
};

Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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<T>' instance to native
Expand All @@ -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:
Expand All @@ -95,7 +95,7 @@ public static void Methods(
module: module);

operationMethodsType.AddMethodImplementation(
declaration: interopReferences.IAsyncOperationMethodsImpl1GetResults(resultType).Import(module),
declaration: interopReferences.IAsyncOperationMethodsImpl1GetResults(resultType),
method: getResultsMethod);
}

Expand Down Expand Up @@ -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)
}
};

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Loading
Loading