diff --git a/Directory.Build.props b/Directory.Build.props
index febdafd9..34f58a15 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -28,8 +28,9 @@
true
snupkg
- 10.2.118-preview
- 0.1.4-alpha
+ 10.2.179-preview-g98239ddf1d
+ 0.2.185-preview-g7e1e6a442c
+ 0.1.5-alpha-g83f1525e8f
diff --git a/src/Microsoft.Windows.CsWin32/Generator.cs b/src/Microsoft.Windows.CsWin32/Generator.cs
index fb1f3081..c7c9bb9e 100644
--- a/src/Microsoft.Windows.CsWin32/Generator.cs
+++ b/src/Microsoft.Windows.CsWin32/Generator.cs
@@ -368,7 +368,7 @@ private enum FriendlyOverloadOf
private bool GroupByModule => string.IsNullOrEmpty(this.options.ClassName);
- private string Namespace => this.options.Namespace;
+ private string Namespace => this.InputAssemblyName;
private string SingleClassName => this.options.ClassName ?? throw new InvalidOperationException("Not in one-class mode.");
@@ -1000,7 +1000,7 @@ nsContents.Key is object
usingDirectives.Add(UsingDirective(ParseName(GlobalNamespacePrefix + "System.Runtime.Versioning")));
}
- usingDirectives.Add(UsingDirective(NameEquals(GlobalWin32NamespaceAlias), ParseName(GlobalNamespacePrefix + this.Namespace)));
+ usingDirectives.Add(UsingDirective(NameEquals(GlobalWin32NamespaceAlias), ParseName(GlobalNamespacePrefix + CommonNamespace)));
var normalizedResults = new Dictionary(StringComparer.OrdinalIgnoreCase);
results.AsParallel().WithCancellation(cancellationToken).ForAll(kv =>
diff --git a/src/Microsoft.Windows.CsWin32/GeneratorOptions.cs b/src/Microsoft.Windows.CsWin32/GeneratorOptions.cs
index 933dab8d..578b7476 100644
--- a/src/Microsoft.Windows.CsWin32/GeneratorOptions.cs
+++ b/src/Microsoft.Windows.CsWin32/GeneratorOptions.cs
@@ -23,12 +23,6 @@ public record GeneratorOptions
/// The default value is "PInvoke".
public string? ClassName { get; init; } = "PInvoke";
- ///
- /// Gets the namespace for generated code.
- ///
- /// The default value is "Windows.Win32". Must be non-empty.
- public string Namespace { get; init; } = "Windows.Win32";
-
///
/// Gets a value indicating whether to emit a single source file as opposed to types spread across many files.
///
@@ -57,10 +51,6 @@ public record GeneratorOptions
/// Thrown when some setting is invalid.
public void Validate()
{
- if (string.IsNullOrWhiteSpace(this.Namespace))
- {
- throw new InvalidOperationException("The namespace must be set.");
- }
}
///
diff --git a/src/Microsoft.Windows.CsWin32/SourceGenerator.cs b/src/Microsoft.Windows.CsWin32/SourceGenerator.cs
index 68dfa33d..82eec0f8 100644
--- a/src/Microsoft.Windows.CsWin32/SourceGenerator.cs
+++ b/src/Microsoft.Windows.CsWin32/SourceGenerator.cs
@@ -263,7 +263,7 @@ public void Execute(GeneratorExecutionContext context)
.ThenBy(pair => pair.Key, StringComparer.Ordinal);
foreach (var unit in compilationUnits)
{
- context.AddSource(unit.Key, unit.Value.ToFullString());
+ context.AddSource($"{generator.InputAssemblyName}.{unit.Key}", unit.Value.ToFullString());
}
}
diff --git a/test/GenerationSandbox.Tests/BasicTests.cs b/test/GenerationSandbox.Tests/BasicTests.cs
index 5c453103..07b63ed7 100644
--- a/test/GenerationSandbox.Tests/BasicTests.cs
+++ b/test/GenerationSandbox.Tests/BasicTests.cs
@@ -41,6 +41,12 @@ public void DISPLAYCONFIG_VIDEO_SIGNAL_INFO_Test()
// TODO: write code that sets/gets memory on the inner struct (e.g. videoStandard).
}
+ [Fact]
+ public void E_PDB_LIMIT()
+ {
+ Assert.Equal(-2140340211, global::Microsoft.Dia.Constants.E_PDB_LIMIT.Value);
+ }
+
[Fact]
public void Bool()
{
diff --git a/test/GenerationSandbox.Tests/GenerationSandbox.Tests.csproj b/test/GenerationSandbox.Tests/GenerationSandbox.Tests.csproj
index 666938a7..c219909f 100644
--- a/test/GenerationSandbox.Tests/GenerationSandbox.Tests.csproj
+++ b/test/GenerationSandbox.Tests/GenerationSandbox.Tests.csproj
@@ -22,6 +22,7 @@
+
diff --git a/test/GenerationSandbox.Tests/NativeMethods.txt b/test/GenerationSandbox.Tests/NativeMethods.txt
index f4580594..622917b8 100644
--- a/test/GenerationSandbox.Tests/NativeMethods.txt
+++ b/test/GenerationSandbox.Tests/NativeMethods.txt
@@ -10,3 +10,4 @@ EnumWindows
GetWindowTextLength
GetWindowText
WPARAM
+E_PDB_LIMIT
diff --git a/test/Microsoft.Windows.CsWin32.Tests/GeneratorOptionsTests.cs b/test/Microsoft.Windows.CsWin32.Tests/GeneratorOptionsTests.cs
index 30d87e96..7cecd1a6 100644
--- a/test/Microsoft.Windows.CsWin32.Tests/GeneratorOptionsTests.cs
+++ b/test/Microsoft.Windows.CsWin32.Tests/GeneratorOptionsTests.cs
@@ -12,10 +12,4 @@ public void Validate_Default()
{
new GeneratorOptions().Validate();
}
-
- [Fact]
- public void Validate_EmptyNamespace()
- {
- Assert.Throws(() => new GeneratorOptions { Namespace = string.Empty }.Validate());
- }
}
diff --git a/test/Microsoft.Windows.CsWin32.Tests/GeneratorTests.cs b/test/Microsoft.Windows.CsWin32.Tests/GeneratorTests.cs
index 2c60cdb5..01633093 100644
--- a/test/Microsoft.Windows.CsWin32.Tests/GeneratorTests.cs
+++ b/test/Microsoft.Windows.CsWin32.Tests/GeneratorTests.cs
@@ -871,7 +871,7 @@ public async Task TestSimpleStructure()
},
GeneratedSources =
{
- (typeof(SourceGenerator), "BOOL.g.cs", @"// ------------------------------------------------------------------------------
+ (typeof(SourceGenerator), "Windows.Win32.BOOL.g.cs", @"// ------------------------------------------------------------------------------
//
// This code was generated by a tool.
//
@@ -932,7 +932,7 @@ public async Task TestSimpleEnum()
},
GeneratedSources =
{
- (typeof(SourceGenerator), "DISPLAYCONFIG_SCANLINE_ORDERING.g.cs", @"// ------------------------------------------------------------------------------
+ (typeof(SourceGenerator), "Windows.Win32.DISPLAYCONFIG_SCANLINE_ORDERING.g.cs", @"// ------------------------------------------------------------------------------
//
// This code was generated by a tool.
//
@@ -997,7 +997,7 @@ public async Task TestSimpleEnumWithoutDocs()
},
GeneratedSources =
{
- (typeof(SourceGenerator), "DISPLAYCONFIG_SCANLINE_ORDERING.g.cs", @"// ------------------------------------------------------------------------------
+ (typeof(SourceGenerator), "Windows.Win32.DISPLAYCONFIG_SCANLINE_ORDERING.g.cs", @"// ------------------------------------------------------------------------------
//
// This code was generated by a tool.
//
@@ -1052,7 +1052,7 @@ public async Task TestFlagsEnum()
},
GeneratedSources =
{
- (typeof(SourceGenerator), "FILE_ACCESS_FLAGS.g.cs", @"// ------------------------------------------------------------------------------
+ (typeof(SourceGenerator), "Windows.Win32.FILE_ACCESS_FLAGS.g.cs", @"// ------------------------------------------------------------------------------
//
// This code was generated by a tool.
//
@@ -1128,7 +1128,7 @@ public async Task TestSimpleDelegate()
},
GeneratedSources =
{
- (typeof(SourceGenerator), "BOOL.g.cs", @"// ------------------------------------------------------------------------------
+ (typeof(SourceGenerator), "Windows.Win32.BOOL.g.cs", @"// ------------------------------------------------------------------------------
//
// This code was generated by a tool.
//
@@ -1166,7 +1166,7 @@ public static implicit operator bool(BOOL value)
}
}
".Replace("\r\n", "\n")),
- (typeof(SourceGenerator), "Delegates.g.cs", @"// ------------------------------------------------------------------------------
+ (typeof(SourceGenerator), "Windows.Win32.Delegates.g.cs", @"// ------------------------------------------------------------------------------
//
// This code was generated by a tool.
//
@@ -1191,7 +1191,7 @@ namespace UI.WindowsAndMessaging
}
}
".Replace("\r\n", "\n")),
- (typeof(SourceGenerator), "HWND.g.cs", @"// ------------------------------------------------------------------------------
+ (typeof(SourceGenerator), "Windows.Win32.HWND.g.cs", @"// ------------------------------------------------------------------------------
//
// This code was generated by a tool.
//
@@ -1231,7 +1231,7 @@ internal readonly partial struct HWND
}
}
".Replace("\r\n", "\n")),
- (typeof(SourceGenerator), "LPARAM.g.cs", @"// ------------------------------------------------------------------------------
+ (typeof(SourceGenerator), "Windows.Win32.LPARAM.g.cs", @"// ------------------------------------------------------------------------------
//
// This code was generated by a tool.
//
@@ -1294,7 +1294,7 @@ public async Task TestSimpleMethod()
},
GeneratedSources =
{
- (typeof(SourceGenerator), "HDC.g.cs", @"// ------------------------------------------------------------------------------
+ (typeof(SourceGenerator), "Windows.Win32.HDC.g.cs", @"// ------------------------------------------------------------------------------
//
// This code was generated by a tool.
//
@@ -1336,7 +1336,7 @@ internal readonly partial struct HDC
}
}
".Replace("\r\n", "\n")),
- (typeof(SourceGenerator), "HWND.g.cs", @"// ------------------------------------------------------------------------------
+ (typeof(SourceGenerator), "Windows.Win32.HWND.g.cs", @"// ------------------------------------------------------------------------------
//
// This code was generated by a tool.
//
@@ -1376,7 +1376,7 @@ internal readonly partial struct HWND
}
}
".Replace("\r\n", "\n")),
- (typeof(SourceGenerator), "PInvoke.User32.g.cs", @"// ------------------------------------------------------------------------------
+ (typeof(SourceGenerator), "Windows.Win32.PInvoke.User32.g.cs", @"// ------------------------------------------------------------------------------
//
// This code was generated by a tool.
//
@@ -1438,7 +1438,7 @@ public async Task TestMethodWithOverloads()
},
GeneratedSources =
{
- (typeof(SourceGenerator), "BOOL.g.cs", @"// ------------------------------------------------------------------------------
+ (typeof(SourceGenerator), "Windows.Win32.BOOL.g.cs", @"// ------------------------------------------------------------------------------
//
// This code was generated by a tool.
//
@@ -1476,7 +1476,7 @@ public static implicit operator bool(BOOL value)
}
}
".Replace("\r\n", "\n")),
- (typeof(SourceGenerator), "FILE_ACCESS_FLAGS.g.cs", @"// ------------------------------------------------------------------------------
+ (typeof(SourceGenerator), "Windows.Win32.FILE_ACCESS_FLAGS.g.cs", @"// ------------------------------------------------------------------------------
//
// This code was generated by a tool.
//
@@ -1529,7 +1529,7 @@ internal enum FILE_ACCESS_FLAGS : uint
}
}
".Replace("\r\n", "\n")),
- (typeof(SourceGenerator), "FILE_CREATION_DISPOSITION.g.cs", @"// ------------------------------------------------------------------------------
+ (typeof(SourceGenerator), "Windows.Win32.FILE_CREATION_DISPOSITION.g.cs", @"// ------------------------------------------------------------------------------
//
// This code was generated by a tool.
//
@@ -1560,7 +1560,7 @@ internal enum FILE_CREATION_DISPOSITION : uint
}
}
".Replace("\r\n", "\n")),
- (typeof(SourceGenerator), "FILE_FLAGS_AND_ATTRIBUTES.g.cs", @"// ------------------------------------------------------------------------------
+ (typeof(SourceGenerator), "Windows.Win32.FILE_FLAGS_AND_ATTRIBUTES.g.cs", @"// ------------------------------------------------------------------------------
//
// This code was generated by a tool.
//
@@ -1629,7 +1629,7 @@ internal enum FILE_FLAGS_AND_ATTRIBUTES : uint
}
}
".Replace("\r\n", "\n")),
- (typeof(SourceGenerator), "FILE_SHARE_MODE.g.cs", @"// ------------------------------------------------------------------------------
+ (typeof(SourceGenerator), "Windows.Win32.FILE_SHARE_MODE.g.cs", @"// ------------------------------------------------------------------------------
//
// This code was generated by a tool.
//
@@ -1660,7 +1660,7 @@ internal enum FILE_SHARE_MODE : uint
}
}
".Replace("\r\n", "\n")),
- (typeof(SourceGenerator), "HANDLE.g.cs", @"// ------------------------------------------------------------------------------
+ (typeof(SourceGenerator), "Windows.Win32.HANDLE.g.cs", @"// ------------------------------------------------------------------------------
//
// This code was generated by a tool.
//
@@ -1702,7 +1702,7 @@ internal readonly partial struct HANDLE
}
}
".Replace("\r\n", "\n")),
- (typeof(SourceGenerator), "PCWSTR.g.cs", @"// ------------------------------------------------------------------------------
+ (typeof(SourceGenerator), "Windows.Win32.PCWSTR.g.cs", @"// ------------------------------------------------------------------------------
//
// This code was generated by a tool.
//
@@ -1780,7 +1780,7 @@ internal int Length
}
}
".Replace("\r\n", "\n")),
- (typeof(SourceGenerator), "PInvoke.Kernel32.g.cs", @"// ------------------------------------------------------------------------------
+ (typeof(SourceGenerator), "Windows.Win32.PInvoke.Kernel32.g.cs", @"// ------------------------------------------------------------------------------
//
// This code was generated by a tool.
//
@@ -1886,7 +1886,7 @@ internal static unsafe Microsoft.Win32.SafeHandles.SafeFileHandle CreateFile(str
}
}
".Replace("\r\n", "\n")),
- (typeof(SourceGenerator), "PWSTR.g.cs", @"// ------------------------------------------------------------------------------
+ (typeof(SourceGenerator), "Windows.Win32.PWSTR.g.cs", @"// ------------------------------------------------------------------------------
//
// This code was generated by a tool.
//
@@ -1943,7 +1943,7 @@ internal int Length
}
}
".Replace("\r\n", "\n")),
- (typeof(SourceGenerator), "SECURITY_ATTRIBUTES.g.cs", @"// ------------------------------------------------------------------------------
+ (typeof(SourceGenerator), "Windows.Win32.SECURITY_ATTRIBUTES.g.cs", @"// ------------------------------------------------------------------------------
//
// This code was generated by a tool.
//