Skip to content

Commit a4ef366

Browse files
authored
Update win32metadata version to 65.0.8-preview (#1469)
* Update win32metadata version * Fix IPropertyValue issue
1 parent 5335f61 commit a4ef366

7 files changed

Lines changed: 27 additions & 5 deletions

File tree

Directory.Packages.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
77

88
<MicroBuildVersion>2.0.201</MicroBuildVersion>
9-
<MetadataVersion>61.0.15-preview</MetadataVersion>
10-
<WDKMetadataVersion>0.12.8-experimental</WDKMetadataVersion>
9+
<MetadataVersion>65.0.8-preview</MetadataVersion>
10+
<WDKMetadataVersion>0.13.25-experimental</WDKMetadataVersion>
1111
<!-- <DiaMetadataVersion>0.2.185-preview-g7e1e6a442c</DiaMetadataVersion> -->
1212
<ApiDocsVersion>0.1.42-alpha</ApiDocsVersion>
1313
<CodeAnalysisVersion>4.14.0</CodeAnalysisVersion>

src/Microsoft.Windows.CsWin32/Generator.Features.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public partial class Generator
1414
private readonly bool canUseUnsafeSkipInit;
1515
private readonly bool canUseUnmanagedCallersOnlyAttribute;
1616
private readonly bool canUseSetLastPInvokeError;
17+
private readonly bool canUseIPropertyValue;
1718
private readonly bool overloadResolutionPriorityAttributePredefined;
1819
private readonly bool unscopedRefAttributePredefined;
1920
private readonly INamedTypeSymbol? runtimeFeatureClass;
@@ -22,6 +23,8 @@ public partial class Generator
2223
private readonly bool generateDefaultDllImportSearchPathsAttribute;
2324
private readonly Dictionary<Feature, bool> supportedFeatures = new();
2425

26+
internal bool CanUseIPropertyValue => this.canUseIPropertyValue;
27+
2528
private void DeclareOverloadResolutionPriorityAttributeIfNecessary()
2629
{
2730
// This attribute may only be applied for C# 13 and later, or else C# errors out.

src/Microsoft.Windows.CsWin32/Generator.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ public Generator(string metadataLibraryPath, Docs? docs, IEnumerable<string> add
120120
this.comIIDInterfacePredefined = this.FindTypeSymbolIfAlreadyAvailable($"{this.Namespace}.{IComIIDGuidInterfaceName}") is not null;
121121
this.getDelegateForFunctionPointerGenericExists = this.compilation?.GetTypeByMetadataName(typeof(Marshal).FullName)?.GetMembers(nameof(Marshal.GetDelegateForFunctionPointer)).Any(m => m is IMethodSymbol { IsGenericMethod: true }) is true;
122122
this.generateDefaultDllImportSearchPathsAttribute = this.compilation?.GetTypeByMetadataName(typeof(DefaultDllImportSearchPathsAttribute).FullName) is object;
123+
this.canUseIPropertyValue = this.compilation?.GetTypeByMetadataName("Windows.Foundation.IPropertyValue")?.DeclaredAccessibility == Accessibility.Public;
123124
if (this.FindTypeSymbolIfAlreadyAvailable("System.Runtime.Versioning.SupportedOSPlatformAttribute") is { } attribute)
124125
{
125126
this.generateSupportedOSPlatformAttributes = true;

src/Microsoft.Windows.CsWin32/HandleTypeHandleInfo.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ internal override TypeSyntaxAndMarshaling ToTypeSyntax(TypeSyntaxSettings inputs
158158
return new TypeSyntaxAndMarshaling(IdentifierName(specialName));
159159
}
160160
}
161+
else if (inputs.Generator?.CanUseIPropertyValue != true && simpleName is "IPropertyValue")
162+
{
163+
marshalAs = new MarshalAsAttribute(UnmanagedType.Interface);
164+
return new TypeSyntaxAndMarshaling(PredefinedType(Token(SyntaxKind.ObjectKeyword)), marshalAs, null);
165+
}
161166
else if (TryMarshalAsObject(inputs, simpleName, out marshalAs))
162167
{
163168
return new TypeSyntaxAndMarshaling(PredefinedType(Token(SyntaxKind.ObjectKeyword)), marshalAs, null);

test/Microsoft.Windows.CsWin32.Tests/COMTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ public void CreateDispatcherQueueController_CreatesWinRTCustomMarshaler()
4141
Assert.Single(this.FindGeneratedType(WinRTCustomMarshalerClass));
4242
}
4343

44+
[Fact]
45+
public void IGraphicsEffectD2D1Interop_ProjectsIPropertyValueParameter()
46+
{
47+
this.GenerateApi("IGraphicsEffectD2D1Interop");
48+
InterfaceDeclarationSyntax iface = (InterfaceDeclarationSyntax)this.FindGeneratedType("IGraphicsEffectD2D1Interop").Single();
49+
MethodDeclarationSyntax getPropertyMember = (MethodDeclarationSyntax)iface.Members[3];
50+
ParameterSyntax iPropertyValueParameter = getPropertyMember.ParameterList.Parameters[1];
51+
Assert.Equal("global::Windows.Foundation.IPropertyValue", iPropertyValueParameter.Type?.ToString());
52+
}
53+
4454
[Fact]
4555
public void IInpectableDerivedInterface()
4656
{

test/Microsoft.Windows.CsWin32.Tests/GeneratorTests.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,16 +226,19 @@ public void InterestingAPIs(
226226
"ID3D12Resource", // COM interface with base types
227227
"OpenTrace", // the CloseTrace method called by the SafeHandle returns WIN32_ERROR. The handle is ALWAYS 64-bits.
228228
"QueryTraceProcessingHandle", // uses a handle that is always 64-bits, even in 32-bit processes
229-
"ID2D1RectangleGeometry")] // COM interface with base types
229+
"ID2D1RectangleGeometry", // COM interface with base types
230+
"IGraphicsEffectD2D1Interop")] // COM interface that refers to C#/WinRT types
230231
string api,
232+
[CombinatorialValues("netstandard2.0", "net9.0")]
233+
string tfm,
231234
bool allowMarshaling)
232235
{
233236
var options = DefaultTestGeneratorOptions with
234237
{
235238
WideCharOnly = false,
236239
AllowMarshaling = allowMarshaling,
237240
};
238-
this.compilation = this.compilation.WithOptions(this.compilation.Options.WithPlatform(Platform.X64));
241+
this.compilation = this.starterCompilations[tfm].WithOptions(this.compilation.Options.WithPlatform(Platform.X64));
239242
this.generator = this.CreateGenerator(options);
240243
Assert.True(this.generator.TryGenerate(api, CancellationToken.None));
241244
this.CollectGeneratedCode(this.generator);

test/Microsoft.Windows.CsWin32.Tests/MyReferenceAssemblies.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ internal static class MyReferenceAssemblies
1616
];
1717

1818
private static readonly ImmutableArray<PackageIdentity> AdditionalLegacyPackagesNET = [
19-
new PackageIdentity("Microsoft.Windows.SDK.NET.Ref", "10.0.22621.57"),
19+
new PackageIdentity("Microsoft.Windows.SDK.NET.Ref", "10.0.26100.57"),
2020
];
2121

2222
internal static readonly ReferenceAssemblies NetStandard20 = ReferenceAssemblies.NetStandard.NetStandard20.AddPackages([.. AdditionalLegacyPackagesNetFX, .. AdditionalModernPackages]);

0 commit comments

Comments
 (0)