Skip to content
Merged
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
4 changes: 2 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>

<MicroBuildVersion>2.0.201</MicroBuildVersion>
<MetadataVersion>61.0.15-preview</MetadataVersion>
<WDKMetadataVersion>0.12.8-experimental</WDKMetadataVersion>
<MetadataVersion>65.0.8-preview</MetadataVersion>
<WDKMetadataVersion>0.13.25-experimental</WDKMetadataVersion>
<!-- <DiaMetadataVersion>0.2.185-preview-g7e1e6a442c</DiaMetadataVersion> -->
<ApiDocsVersion>0.1.42-alpha</ApiDocsVersion>
<CodeAnalysisVersion>4.14.0</CodeAnalysisVersion>
Expand Down
3 changes: 3 additions & 0 deletions src/Microsoft.Windows.CsWin32/Generator.Features.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public partial class Generator
private readonly bool canUseUnsafeSkipInit;
private readonly bool canUseUnmanagedCallersOnlyAttribute;
private readonly bool canUseSetLastPInvokeError;
private readonly bool canUseIPropertyValue;
private readonly bool overloadResolutionPriorityAttributePredefined;
private readonly bool unscopedRefAttributePredefined;
private readonly INamedTypeSymbol? runtimeFeatureClass;
Expand All @@ -22,6 +23,8 @@ public partial class Generator
private readonly bool generateDefaultDllImportSearchPathsAttribute;
private readonly Dictionary<Feature, bool> supportedFeatures = new();

internal bool CanUseIPropertyValue => this.canUseIPropertyValue;

private void DeclareOverloadResolutionPriorityAttributeIfNecessary()
{
// This attribute may only be applied for C# 13 and later, or else C# errors out.
Expand Down
1 change: 1 addition & 0 deletions src/Microsoft.Windows.CsWin32/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public Generator(string metadataLibraryPath, Docs? docs, IEnumerable<string> add
this.comIIDInterfacePredefined = this.FindTypeSymbolIfAlreadyAvailable($"{this.Namespace}.{IComIIDGuidInterfaceName}") is not null;
this.getDelegateForFunctionPointerGenericExists = this.compilation?.GetTypeByMetadataName(typeof(Marshal).FullName)?.GetMembers(nameof(Marshal.GetDelegateForFunctionPointer)).Any(m => m is IMethodSymbol { IsGenericMethod: true }) is true;
this.generateDefaultDllImportSearchPathsAttribute = this.compilation?.GetTypeByMetadataName(typeof(DefaultDllImportSearchPathsAttribute).FullName) is object;
this.canUseIPropertyValue = this.compilation?.GetTypeByMetadataName("Windows.Foundation.IPropertyValue")?.DeclaredAccessibility == Accessibility.Public;
if (this.FindTypeSymbolIfAlreadyAvailable("System.Runtime.Versioning.SupportedOSPlatformAttribute") is { } attribute)
{
this.generateSupportedOSPlatformAttributes = true;
Expand Down
5 changes: 5 additions & 0 deletions src/Microsoft.Windows.CsWin32/HandleTypeHandleInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ internal override TypeSyntaxAndMarshaling ToTypeSyntax(TypeSyntaxSettings inputs
return new TypeSyntaxAndMarshaling(IdentifierName(specialName));
}
}
else if (inputs.Generator?.CanUseIPropertyValue != true && simpleName is "IPropertyValue")
{
marshalAs = new MarshalAsAttribute(UnmanagedType.Interface);
return new TypeSyntaxAndMarshaling(PredefinedType(Token(SyntaxKind.ObjectKeyword)), marshalAs, null);
}
else if (TryMarshalAsObject(inputs, simpleName, out marshalAs))
{
return new TypeSyntaxAndMarshaling(PredefinedType(Token(SyntaxKind.ObjectKeyword)), marshalAs, null);
Expand Down
10 changes: 10 additions & 0 deletions test/Microsoft.Windows.CsWin32.Tests/COMTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ public void CreateDispatcherQueueController_CreatesWinRTCustomMarshaler()
Assert.Single(this.FindGeneratedType(WinRTCustomMarshalerClass));
}

[Fact]
public void IGraphicsEffectD2D1Interop_ProjectsIPropertyValueParameter()
{
this.GenerateApi("IGraphicsEffectD2D1Interop");
InterfaceDeclarationSyntax iface = (InterfaceDeclarationSyntax)this.FindGeneratedType("IGraphicsEffectD2D1Interop").Single();
MethodDeclarationSyntax getPropertyMember = (MethodDeclarationSyntax)iface.Members[3];
ParameterSyntax iPropertyValueParameter = getPropertyMember.ParameterList.Parameters[1];
Assert.Equal("global::Windows.Foundation.IPropertyValue", iPropertyValueParameter.Type?.ToString());
}

[Fact]
public void IInpectableDerivedInterface()
{
Expand Down
7 changes: 5 additions & 2 deletions test/Microsoft.Windows.CsWin32.Tests/GeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,16 +226,19 @@ public void InterestingAPIs(
"ID3D12Resource", // COM interface with base types
"OpenTrace", // the CloseTrace method called by the SafeHandle returns WIN32_ERROR. The handle is ALWAYS 64-bits.
"QueryTraceProcessingHandle", // uses a handle that is always 64-bits, even in 32-bit processes
"ID2D1RectangleGeometry")] // COM interface with base types
"ID2D1RectangleGeometry", // COM interface with base types
"IGraphicsEffectD2D1Interop")] // COM interface that refers to C#/WinRT types
string api,
[CombinatorialValues("netstandard2.0", "net9.0")]
string tfm,
bool allowMarshaling)
{
var options = DefaultTestGeneratorOptions with
{
WideCharOnly = false,
AllowMarshaling = allowMarshaling,
};
this.compilation = this.compilation.WithOptions(this.compilation.Options.WithPlatform(Platform.X64));
this.compilation = this.starterCompilations[tfm].WithOptions(this.compilation.Options.WithPlatform(Platform.X64));
this.generator = this.CreateGenerator(options);
Assert.True(this.generator.TryGenerate(api, CancellationToken.None));
this.CollectGeneratedCode(this.generator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal static class MyReferenceAssemblies
];

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

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