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
22 changes: 16 additions & 6 deletions src/CsWin32Generator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -371,13 +371,23 @@ private GeneratorOptions LoadGeneratorOptions(FileInfo? nativeMethodsJson)
}
}

Platform compilationPlatform = platform switch
Platform compilationPlatform = Platform.AnyCpu;
if (platform.Equals("x86", StringComparison.OrdinalIgnoreCase))
{
"x86" => Platform.X86,
"x64" => Platform.X64,
"arm64" => Platform.Arm64,
_ => Platform.AnyCpu,
};
compilationPlatform = Platform.X86;
}
else if (platform.Equals("x64", StringComparison.OrdinalIgnoreCase))
{
compilationPlatform = Platform.X64;
}
else if (platform.Equals("arm64", StringComparison.OrdinalIgnoreCase))
{
compilationPlatform = Platform.Arm64;
}
else if (platform.Equals("AnyCPU", StringComparison.OrdinalIgnoreCase))
{
compilationPlatform = Platform.AnyCpu;
}

var compilationOptions = new CSharpCompilationOptions(
outputKind: OutputKind.DynamicallyLinkedLibrary,
Expand Down
12 changes: 12 additions & 0 deletions test/CsWin32Generator.Tests/CsWin32GeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,18 @@ public async Task TestGenerateSomethingInWin32System()
await this.InvokeGeneratorAndCompile();
}

[Theory]
[InlineData("x64")]
[InlineData("X64")]
[InlineData("arm64")]
[InlineData("ARM64")]
public async Task TestPlatformCaseSensitivity(string platform)
{
this.platform = platform;
this.nativeMethods.Add("SetWindowLongPtr");
await this.InvokeGeneratorAndCompile();
}

[Theory]
[InlineData("IMFMediaKeySession", "get_KeySystem", "winmdroot.Foundation.BSTR* keySystem")]
[InlineData("AddPrinterW", "AddPrinter", "winmdroot.Foundation.PWSTR pName, uint Level, Span<byte> pPrinter")]
Expand Down
3 changes: 2 additions & 1 deletion test/CsWin32Generator.Tests/CsWin32GeneratorTestsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public partial class CsWin32GeneratorTestsBase : GeneratorTestBase
protected List<string> additionalReferences = new();
protected string assemblyName = "TestAssembly";
protected string? keyFile;
protected string platform = "x64";

public CsWin32GeneratorTestsBase(ITestOutputHelper logger)
: base(logger)
Expand Down Expand Up @@ -98,7 +99,7 @@ protected async Task InvokeGenerator(string outputPath, string testCase, TestOpt
args.AddRange(["--native-methods-txt", nativeMethodsTxtPath]);
args.AddRange(["--metadata-paths", win32winmd]);
args.AddRange(["--output-path", outputPath]);
args.AddRange(["--platform", "x64"]);
args.AddRange(["--platform", this.platform]);
if (this.nativeMethodsJson is string)
{
string nativeMethodsJsonPath = Path.Combine(Path.GetDirectoryName(typeof(CsWin32GeneratorTests).Assembly.Location)!, "TestContent", this.nativeMethodsJson);
Expand Down
Loading