diff --git a/Microsoft.Windows.CsWin32.sln b/Microsoft.Windows.CsWin32.sln
index 7ca7b762..c7c3a843 100644
--- a/Microsoft.Windows.CsWin32.sln
+++ b/Microsoft.Windows.CsWin32.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 16
-VisualStudioVersion = 16.0.29322.22
+# Visual Studio Version 17
+VisualStudioVersion = 17.0.31601.41
MinimumVisualStudioVersion = 15.0.26124.0
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1CE9670B-D5FF-46A7-9D00-24E70E6ED48B}"
ProjectSection(SolutionItems) = preProject
@@ -29,7 +29,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{36CCE840-6
test\Directory.Build.targets = test\Directory.Build.targets
EndProjectSection
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Windows.CsWin32", "src\Microsoft.Windows.CsWin32\Microsoft.Windows.CsWin32.csproj", "{E3E96466-44B6-41AF-BBC8-9D30183ED8A9}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Windows.CsWin32.Roslyn38", "src\Microsoft.Windows.CsWin32\Roslyn38\Microsoft.Windows.CsWin32.Roslyn38.csproj", "{E3E96466-44B6-41AF-BBC8-9D30183ED8A9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Windows.CsWin32.Tests", "test\Microsoft.Windows.CsWin32.Tests\Microsoft.Windows.CsWin32.Tests.csproj", "{0129FE6E-3480-408A-BF40-9E6343CDB06C}"
EndProject
@@ -41,7 +41,18 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SpellChecker", "test\SpellC
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinRTInteropTest", "test\WinRTInteropTest\WinRTInteropTest.csproj", "{0E067B66-C2EC-4106-87D2-5310CFCDC5B8}"
EndProject
+Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Microsoft.Windows.CsWin32.Shared", "src\Microsoft.Windows.CsWin32.Shared\Microsoft.Windows.CsWin32.Shared.shproj", "{D820AF8C-46E2-4AE4-B045-0D70B81BDF7E}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Windows.CsWin32.Package", "src\Microsoft.Windows.CsWin32.Package\Microsoft.Windows.CsWin32.Package.csproj", "{F8CE8211-C0C0-440C-904D-7C5444A29933}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Windows.CsWin32.Roslyn40", "src\Microsoft.Windows.CsWin32\Roslyn40\Microsoft.Windows.CsWin32.Roslyn40.csproj", "{11AC1BA1-614A-4332-9448-1DD6E1B75D48}"
+EndProject
Global
+ GlobalSection(SharedMSBuildProjectFiles) = preSolution
+ src\Microsoft.Windows.CsWin32.Shared\Microsoft.Windows.CsWin32.Shared.projitems*{11ac1ba1-614a-4332-9448-1dd6e1b75d48}*SharedItemsImports = 5
+ src\Microsoft.Windows.CsWin32.Shared\Microsoft.Windows.CsWin32.Shared.projitems*{d820af8c-46e2-4ae4-b045-0d70b81bdf7e}*SharedItemsImports = 13
+ src\Microsoft.Windows.CsWin32.Shared\Microsoft.Windows.CsWin32.Shared.projitems*{e3e96466-44b6-41af-bbc8-9d30183ed8a9}*SharedItemsImports = 5
+ EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|NonWindows = Debug|NonWindows
@@ -95,6 +106,22 @@ Global
{0E067B66-C2EC-4106-87D2-5310CFCDC5B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0E067B66-C2EC-4106-87D2-5310CFCDC5B8}.Release|Any CPU.Build.0 = Release|Any CPU
{0E067B66-C2EC-4106-87D2-5310CFCDC5B8}.Release|NonWindows.ActiveCfg = Release|Any CPU
+ {F8CE8211-C0C0-440C-904D-7C5444A29933}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F8CE8211-C0C0-440C-904D-7C5444A29933}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F8CE8211-C0C0-440C-904D-7C5444A29933}.Debug|NonWindows.ActiveCfg = Debug|Any CPU
+ {F8CE8211-C0C0-440C-904D-7C5444A29933}.Debug|NonWindows.Build.0 = Debug|Any CPU
+ {F8CE8211-C0C0-440C-904D-7C5444A29933}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F8CE8211-C0C0-440C-904D-7C5444A29933}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F8CE8211-C0C0-440C-904D-7C5444A29933}.Release|NonWindows.ActiveCfg = Release|Any CPU
+ {F8CE8211-C0C0-440C-904D-7C5444A29933}.Release|NonWindows.Build.0 = Release|Any CPU
+ {11AC1BA1-614A-4332-9448-1DD6E1B75D48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {11AC1BA1-614A-4332-9448-1DD6E1B75D48}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {11AC1BA1-614A-4332-9448-1DD6E1B75D48}.Debug|NonWindows.ActiveCfg = Debug|Any CPU
+ {11AC1BA1-614A-4332-9448-1DD6E1B75D48}.Debug|NonWindows.Build.0 = Debug|Any CPU
+ {11AC1BA1-614A-4332-9448-1DD6E1B75D48}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {11AC1BA1-614A-4332-9448-1DD6E1B75D48}.Release|Any CPU.Build.0 = Release|Any CPU
+ {11AC1BA1-614A-4332-9448-1DD6E1B75D48}.Release|NonWindows.ActiveCfg = Release|Any CPU
+ {11AC1BA1-614A-4332-9448-1DD6E1B75D48}.Release|NonWindows.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -106,6 +133,9 @@ Global
{7E8A5179-F94C-410F-8BBE-FDAAA95A19C3} = {36CCE840-6FE5-4DB9-A8D5-8CF3CB6D342A}
{744BE74F-8C4A-49E8-9683-52D987224285} = {36CCE840-6FE5-4DB9-A8D5-8CF3CB6D342A}
{0E067B66-C2EC-4106-87D2-5310CFCDC5B8} = {36CCE840-6FE5-4DB9-A8D5-8CF3CB6D342A}
+ {D820AF8C-46E2-4AE4-B045-0D70B81BDF7E} = {9E154A29-1796-4B85-BD81-B6A385D8FF71}
+ {F8CE8211-C0C0-440C-904D-7C5444A29933} = {9E154A29-1796-4B85-BD81-B6A385D8FF71}
+ {11AC1BA1-614A-4332-9448-1DD6E1B75D48} = {9E154A29-1796-4B85-BD81-B6A385D8FF71}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E3944F6A-384B-4B0F-B93F-3BD513DC57BD}
diff --git a/src/Microsoft.Windows.CsWin32.Package/Microsoft.Windows.CsWin32.Package.csproj b/src/Microsoft.Windows.CsWin32.Package/Microsoft.Windows.CsWin32.Package.csproj
new file mode 100644
index 00000000..e1657caf
--- /dev/null
+++ b/src/Microsoft.Windows.CsWin32.Package/Microsoft.Windows.CsWin32.Package.csproj
@@ -0,0 +1,31 @@
+
+
+
+ netstandard2.0
+ true
+ true
+
+
+ false
+ false
+ $(NoWarn);NU5128;NU5127
+
+
+
+ Microsoft.Windows.CsWin32.nuspec
+
+ Microsoft.Windows.CsWin32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Microsoft.Windows.CsWin32/Microsoft.Windows.CsWin32.targets b/src/Microsoft.Windows.CsWin32.Package/Microsoft.Windows.CsWin32.Package.targets
similarity index 85%
rename from src/Microsoft.Windows.CsWin32/Microsoft.Windows.CsWin32.targets
rename to src/Microsoft.Windows.CsWin32.Package/Microsoft.Windows.CsWin32.Package.targets
index bb04f231..79fad106 100644
--- a/src/Microsoft.Windows.CsWin32/Microsoft.Windows.CsWin32.targets
+++ b/src/Microsoft.Windows.CsWin32.Package/Microsoft.Windows.CsWin32.Package.targets
@@ -5,7 +5,9 @@
- $(NuspecProperties);Version=$(Version);BaseOutputPath=$(OutputPath);MetadataVersion=$(MetadataVersion);ApiDocsVersion=$(ApiDocsVersion);PackageReleaseNotes=$(PackageReleaseNotes);commit=$(GitCommitId);
+ $(RepoRootPath)bin\Microsoft.Windows.CsWin32.Roslyn38\$(Configuration)\netstandard2.0\
+ $(RepoRootPath)bin\Microsoft.Windows.CsWin32.Roslyn40\$(Configuration)\netstandard2.0\
+ $(NuspecProperties);Version=$(Version);BaseOutputPath=$(OutputPath);BaseOutputPath38=$(OutputPath38);BaseOutputPath40=$(OutputPath40);MetadataVersion=$(MetadataVersion);ApiDocsVersion=$(ApiDocsVersion);PackageReleaseNotes=$(PackageReleaseNotes);commit=$(GitCommitId);
diff --git a/src/Microsoft.Windows.CsWin32.Package/Microsoft.Windows.CsWin32.nuspec b/src/Microsoft.Windows.CsWin32.Package/Microsoft.Windows.CsWin32.nuspec
new file mode 100644
index 00000000..ac292658
--- /dev/null
+++ b/src/Microsoft.Windows.CsWin32.Package/Microsoft.Windows.CsWin32.nuspec
@@ -0,0 +1,70 @@
+
+
+
+ Microsoft.Windows.CsWin32
+ $version$
+ Microsoft
+ true
+ false
+ MIT
+ https://licenses.nuget.org/MIT
+ https://github.com/Microsoft/CsWin32
+ Microsoft Windows SDK Win32 API Source Generator
+ $PackageReleaseNotes$
+ README.md
+ © Microsoft Corporation. All rights reserved.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Microsoft.Windows.CsWin32/build/Microsoft.Windows.CsWin32.props b/src/Microsoft.Windows.CsWin32.Package/build/Microsoft.Windows.CsWin32.props
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/build/Microsoft.Windows.CsWin32.props
rename to src/Microsoft.Windows.CsWin32.Package/build/Microsoft.Windows.CsWin32.props
diff --git a/src/Microsoft.Windows.CsWin32.Package/build/Microsoft.Windows.CsWin32.targets b/src/Microsoft.Windows.CsWin32.Package/build/Microsoft.Windows.CsWin32.targets
new file mode 100644
index 00000000..eafc0234
--- /dev/null
+++ b/src/Microsoft.Windows.CsWin32.Package/build/Microsoft.Windows.CsWin32.targets
@@ -0,0 +1,21 @@
+
+
+
+
+ <_CsWin32Analyzer Include="@(Analyzer)" Condition="'%(Analyzer.NuGetPackageId)' == 'Microsoft.Windows.CsWin32'" />
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Microsoft.Windows.CsWin32/build/net20/Microsoft.Windows.CsWin32.props b/src/Microsoft.Windows.CsWin32.Package/build/net20/Microsoft.Windows.CsWin32.props
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/build/net20/Microsoft.Windows.CsWin32.props
rename to src/Microsoft.Windows.CsWin32.Package/build/net20/Microsoft.Windows.CsWin32.props
diff --git a/src/Microsoft.Windows.CsWin32/build/netstandard1.0/Microsoft.Windows.CsWin32.props b/src/Microsoft.Windows.CsWin32.Package/build/net20/Microsoft.Windows.CsWin32.targets
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/build/netstandard1.0/Microsoft.Windows.CsWin32.props
rename to src/Microsoft.Windows.CsWin32.Package/build/net20/Microsoft.Windows.CsWin32.targets
diff --git a/src/Microsoft.Windows.CsWin32.Package/build/netstandard1.0/Microsoft.Windows.CsWin32.props b/src/Microsoft.Windows.CsWin32.Package/build/netstandard1.0/Microsoft.Windows.CsWin32.props
new file mode 100644
index 00000000..3bf8261e
--- /dev/null
+++ b/src/Microsoft.Windows.CsWin32.Package/build/netstandard1.0/Microsoft.Windows.CsWin32.props
@@ -0,0 +1,3 @@
+
+
+
diff --git a/src/Microsoft.Windows.CsWin32.Package/build/netstandard1.0/Microsoft.Windows.CsWin32.targets b/src/Microsoft.Windows.CsWin32.Package/build/netstandard1.0/Microsoft.Windows.CsWin32.targets
new file mode 100644
index 00000000..3bf8261e
--- /dev/null
+++ b/src/Microsoft.Windows.CsWin32.Package/build/netstandard1.0/Microsoft.Windows.CsWin32.targets
@@ -0,0 +1,3 @@
+
+
+
diff --git a/src/Microsoft.Windows.CsWin32/readme.txt b/src/Microsoft.Windows.CsWin32.Package/readme.txt
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/readme.txt
rename to src/Microsoft.Windows.CsWin32.Package/readme.txt
diff --git a/src/Microsoft.Windows.CsWin32/tools/install.ps1 b/src/Microsoft.Windows.CsWin32.Package/tools/install.ps1
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/tools/install.ps1
rename to src/Microsoft.Windows.CsWin32.Package/tools/install.ps1
diff --git a/src/Microsoft.Windows.CsWin32/tools/uninstall.ps1 b/src/Microsoft.Windows.CsWin32.Package/tools/uninstall.ps1
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/tools/uninstall.ps1
rename to src/Microsoft.Windows.CsWin32.Package/tools/uninstall.ps1
diff --git a/src/Microsoft.Windows.CsWin32/AnalyzerReleases.Shipped.md b/src/Microsoft.Windows.CsWin32.Shared/AnalyzerReleases.Shipped.md
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/AnalyzerReleases.Shipped.md
rename to src/Microsoft.Windows.CsWin32.Shared/AnalyzerReleases.Shipped.md
diff --git a/src/Microsoft.Windows.CsWin32/AnalyzerReleases.Unshipped.md b/src/Microsoft.Windows.CsWin32.Shared/AnalyzerReleases.Unshipped.md
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/AnalyzerReleases.Unshipped.md
rename to src/Microsoft.Windows.CsWin32.Shared/AnalyzerReleases.Unshipped.md
diff --git a/src/Microsoft.Windows.CsWin32/ArrayTypeHandleInfo.cs b/src/Microsoft.Windows.CsWin32.Shared/ArrayTypeHandleInfo.cs
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/ArrayTypeHandleInfo.cs
rename to src/Microsoft.Windows.CsWin32.Shared/ArrayTypeHandleInfo.cs
diff --git a/src/Microsoft.Windows.CsWin32/BannedSymbols.txt b/src/Microsoft.Windows.CsWin32.Shared/BannedSymbols.txt
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/BannedSymbols.txt
rename to src/Microsoft.Windows.CsWin32.Shared/BannedSymbols.txt
diff --git a/src/Microsoft.Windows.CsWin32/BindingRedirects.cs b/src/Microsoft.Windows.CsWin32.Shared/BindingRedirects.cs
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/BindingRedirects.cs
rename to src/Microsoft.Windows.CsWin32.Shared/BindingRedirects.cs
diff --git a/src/Microsoft.Windows.CsWin32/CustomAttributeTypeProvider.cs b/src/Microsoft.Windows.CsWin32.Shared/CustomAttributeTypeProvider.cs
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/CustomAttributeTypeProvider.cs
rename to src/Microsoft.Windows.CsWin32.Shared/CustomAttributeTypeProvider.cs
diff --git a/src/Microsoft.Windows.CsWin32/Docs.cs b/src/Microsoft.Windows.CsWin32.Shared/Docs.cs
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/Docs.cs
rename to src/Microsoft.Windows.CsWin32.Shared/Docs.cs
diff --git a/src/Microsoft.Windows.CsWin32/FastSyntaxFactory.cs b/src/Microsoft.Windows.CsWin32.Shared/FastSyntaxFactory.cs
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/FastSyntaxFactory.cs
rename to src/Microsoft.Windows.CsWin32.Shared/FastSyntaxFactory.cs
diff --git a/src/Microsoft.Windows.CsWin32/GenerationFailedException.cs b/src/Microsoft.Windows.CsWin32.Shared/GenerationFailedException.cs
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/GenerationFailedException.cs
rename to src/Microsoft.Windows.CsWin32.Shared/GenerationFailedException.cs
diff --git a/src/Microsoft.Windows.CsWin32/Generator.cs b/src/Microsoft.Windows.CsWin32.Shared/Generator.cs
similarity index 99%
rename from src/Microsoft.Windows.CsWin32/Generator.cs
rename to src/Microsoft.Windows.CsWin32.Shared/Generator.cs
index 030bb07d..4066a7bb 100644
--- a/src/Microsoft.Windows.CsWin32/Generator.cs
+++ b/src/Microsoft.Windows.CsWin32.Shared/Generator.cs
@@ -294,7 +294,7 @@ public class Generator : IDisposable
private readonly GeneratorOptions options;
private readonly CSharpCompilation? compilation;
- private readonly CSharpParseOptions? parseOptions;
+ private readonly LanguageVersion? languageVersion;
private readonly bool canUseSpan;
private readonly bool canCallCreateSpan;
private readonly bool getDelegateForFunctionPointerGenericExists;
@@ -313,8 +313,8 @@ public class Generator : IDisposable
/// The API docs to include in the generated code.
/// Options that influence the result of generation.
/// The compilation that the generated code will be added to.
- /// The parse options that will be used for the generated code.
- public Generator(string metadataLibraryPath, Docs? docs, GeneratorOptions options, CSharpCompilation? compilation = null, CSharpParseOptions? parseOptions = null)
+ /// The language version that will be used for the generated code.
+ public Generator(string metadataLibraryPath, Docs? docs, GeneratorOptions options, CSharpCompilation? compilation = null, LanguageVersion? languageVersion = null)
{
this.InputAssemblyName = Path.GetFileNameWithoutExtension(metadataLibraryPath);
this.MetadataIndex = MetadataIndex.Get(metadataLibraryPath, compilation?.Options.Platform);
@@ -323,7 +323,7 @@ public Generator(string metadataLibraryPath, Docs? docs, GeneratorOptions option
this.options = options;
this.options.Validate();
this.compilation = compilation;
- this.parseOptions = parseOptions;
+ this.languageVersion = languageVersion;
this.volatileCode = new(this.committedCode);
this.canUseSpan = this.compilation?.GetTypeByMetadataName(typeof(Span<>).FullName) is not null;
@@ -390,7 +390,7 @@ private enum FriendlyOverloadOf
internal MetadataReader Reader => this.MetadataIndex.Reader;
- internal LanguageVersion LanguageVersion => this.parseOptions?.LanguageVersion ?? LanguageVersion.CSharp9;
+ internal LanguageVersion LanguageVersion => this.languageVersion ?? LanguageVersion.CSharp9;
private bool WideCharOnly => this.options.WideCharOnly;
diff --git a/src/Microsoft.Windows.CsWin32/GeneratorOptions.cs b/src/Microsoft.Windows.CsWin32.Shared/GeneratorOptions.cs
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/GeneratorOptions.cs
rename to src/Microsoft.Windows.CsWin32.Shared/GeneratorOptions.cs
diff --git a/src/Microsoft.Windows.CsWin32/HandleTypeHandleInfo.cs b/src/Microsoft.Windows.CsWin32.Shared/HandleTypeHandleInfo.cs
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/HandleTypeHandleInfo.cs
rename to src/Microsoft.Windows.CsWin32.Shared/HandleTypeHandleInfo.cs
diff --git a/src/Microsoft.Windows.CsWin32/ITypeHandleContainer.cs b/src/Microsoft.Windows.CsWin32.Shared/ITypeHandleContainer.cs
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/ITypeHandleContainer.cs
rename to src/Microsoft.Windows.CsWin32.Shared/ITypeHandleContainer.cs
diff --git a/src/Microsoft.Windows.CsWin32/IsExternalInit.cs b/src/Microsoft.Windows.CsWin32.Shared/IsExternalInit.cs
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/IsExternalInit.cs
rename to src/Microsoft.Windows.CsWin32.Shared/IsExternalInit.cs
diff --git a/src/Microsoft.Windows.CsWin32/MetadataIndex.cs b/src/Microsoft.Windows.CsWin32.Shared/MetadataIndex.cs
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/MetadataIndex.cs
rename to src/Microsoft.Windows.CsWin32.Shared/MetadataIndex.cs
diff --git a/src/Microsoft.Windows.CsWin32/MetadataQualifiedTokens.cs b/src/Microsoft.Windows.CsWin32.Shared/MetadataQualifiedTokens.cs
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/MetadataQualifiedTokens.cs
rename to src/Microsoft.Windows.CsWin32.Shared/MetadataQualifiedTokens.cs
diff --git a/src/Microsoft.Windows.CsWin32/MetadataUtilities.cs b/src/Microsoft.Windows.CsWin32.Shared/MetadataUtilities.cs
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/MetadataUtilities.cs
rename to src/Microsoft.Windows.CsWin32.Shared/MetadataUtilities.cs
diff --git a/src/Microsoft.Windows.CsWin32.Shared/Microsoft.Windows.CsWin32.Shared.projitems b/src/Microsoft.Windows.CsWin32.Shared/Microsoft.Windows.CsWin32.Shared.projitems
new file mode 100644
index 00000000..23bd0371
--- /dev/null
+++ b/src/Microsoft.Windows.CsWin32.Shared/Microsoft.Windows.CsWin32.Shared.projitems
@@ -0,0 +1,55 @@
+
+
+
+ $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
+ true
+ d820af8c-46e2-4ae4-b045-0d70b81bdf7e
+
+
+ Microsoft.Windows.CsWin32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Microsoft.Windows.CsWin32.Shared/Microsoft.Windows.CsWin32.Shared.shproj b/src/Microsoft.Windows.CsWin32.Shared/Microsoft.Windows.CsWin32.Shared.shproj
new file mode 100644
index 00000000..c78b038c
--- /dev/null
+++ b/src/Microsoft.Windows.CsWin32.Shared/Microsoft.Windows.CsWin32.Shared.shproj
@@ -0,0 +1,13 @@
+
+
+
+ d820af8c-46e2-4ae4-b045-0d70b81bdf7e
+ 14.0
+
+
+
+
+
+
+
+
diff --git a/src/Microsoft.Windows.CsWin32/ModuleInitializerAttribute.cs b/src/Microsoft.Windows.CsWin32.Shared/ModuleInitializerAttribute.cs
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/ModuleInitializerAttribute.cs
rename to src/Microsoft.Windows.CsWin32.Shared/ModuleInitializerAttribute.cs
diff --git a/src/Microsoft.Windows.CsWin32/NamespaceMetadata.cs b/src/Microsoft.Windows.CsWin32.Shared/NamespaceMetadata.cs
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/NamespaceMetadata.cs
rename to src/Microsoft.Windows.CsWin32.Shared/NamespaceMetadata.cs
diff --git a/src/Microsoft.Windows.CsWin32/PlatformIncompatibleException.cs b/src/Microsoft.Windows.CsWin32.Shared/PlatformIncompatibleException.cs
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/PlatformIncompatibleException.cs
rename to src/Microsoft.Windows.CsWin32.Shared/PlatformIncompatibleException.cs
diff --git a/src/Microsoft.Windows.CsWin32/PointerTypeHandleInfo.cs b/src/Microsoft.Windows.CsWin32.Shared/PointerTypeHandleInfo.cs
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/PointerTypeHandleInfo.cs
rename to src/Microsoft.Windows.CsWin32.Shared/PointerTypeHandleInfo.cs
diff --git a/src/Microsoft.Windows.CsWin32/PrimitiveTypeHandleInfo.cs b/src/Microsoft.Windows.CsWin32.Shared/PrimitiveTypeHandleInfo.cs
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/PrimitiveTypeHandleInfo.cs
rename to src/Microsoft.Windows.CsWin32.Shared/PrimitiveTypeHandleInfo.cs
diff --git a/src/Microsoft.Windows.CsWin32/SignatureHandleProvider.cs b/src/Microsoft.Windows.CsWin32.Shared/SignatureHandleProvider.cs
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/SignatureHandleProvider.cs
rename to src/Microsoft.Windows.CsWin32.Shared/SignatureHandleProvider.cs
diff --git a/src/Microsoft.Windows.CsWin32/SourceGenerator.cs b/src/Microsoft.Windows.CsWin32.Shared/SourceGenerator.cs
similarity index 61%
rename from src/Microsoft.Windows.CsWin32/SourceGenerator.cs
rename to src/Microsoft.Windows.CsWin32.Shared/SourceGenerator.cs
index 1559239b..865c7cff 100644
--- a/src/Microsoft.Windows.CsWin32/SourceGenerator.cs
+++ b/src/Microsoft.Windows.CsWin32.Shared/SourceGenerator.cs
@@ -5,19 +5,26 @@ namespace Microsoft.Windows.CsWin32
{
using System;
using System.Collections.Generic;
+ using System.Collections.Immutable;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.Json;
+ using System.Threading;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
+ using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Text;
///
/// Generates the source code for the p/invoke methods and supporting types into some C# project.
///
[Generator]
+#if ROSLYN4_0
+ public class SourceGenerator : IIncrementalGenerator
+#else
public class SourceGenerator : ISourceGenerator
+#endif
{
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public static readonly DiagnosticDescriptor InternalError = new DiagnosticDescriptor(
@@ -31,7 +38,7 @@ public class SourceGenerator : ISourceGenerator
public static readonly DiagnosticDescriptor NoMatchingMethodOrType = new DiagnosticDescriptor(
"PInvoke001",
"No matching method, type or constant found",
- "Method, type or constant \"{0}\" not found.",
+ "Method, type or constant \"{0}\" not found",
"Functionality",
DiagnosticSeverity.Warning,
isEnabledByDefault: true);
@@ -39,7 +46,9 @@ public class SourceGenerator : ISourceGenerator
public static readonly DiagnosticDescriptor NoMatchingMethodOrTypeWithSuggestions = new DiagnosticDescriptor(
"PInvoke001",
"No matching method, type or constant found",
+#pragma warning disable RS1032 // Define diagnostic message correctly
"Method, type or constant \"{0}\" not found. Did you mean {1}?",
+#pragma warning restore RS1032 // Define diagnostic message correctly
"Functionality",
DiagnosticSeverity.Warning,
isEnabledByDefault: true);
@@ -47,7 +56,7 @@ public class SourceGenerator : ISourceGenerator
public static readonly DiagnosticDescriptor NoMethodsForModule = new DiagnosticDescriptor(
"PInvoke001",
"No module found",
- "No methods found under module \"{0}\".",
+ "No methods found under module \"{0}\"",
"Functionality",
DiagnosticSeverity.Warning,
isEnabledByDefault: true);
@@ -64,7 +73,7 @@ public class SourceGenerator : ISourceGenerator
public static readonly DiagnosticDescriptor BannedApi = new DiagnosticDescriptor(
"PInvoke003",
"BannedAPI",
- "This API will not be generated. {0}",
+ "This API will not be generated: {0}",
"Functionality",
DiagnosticSeverity.Warning,
isEnabledByDefault: true);
@@ -97,7 +106,7 @@ public class SourceGenerator : ISourceGenerator
public static readonly DiagnosticDescriptor AmbiguousMatchError = new DiagnosticDescriptor(
"PInvoke007",
"AmbiguousMatch",
- "The API \"{0}\" is ambiguous.",
+ "The API \"{0}\" is ambiguous",
"Functionality",
DiagnosticSeverity.Error,
isEnabledByDefault: true);
@@ -105,7 +114,9 @@ public class SourceGenerator : ISourceGenerator
public static readonly DiagnosticDescriptor AmbiguousMatchErrorWithSuggestions = new DiagnosticDescriptor(
"PInvoke007",
"AmbiguousMatch",
+#pragma warning disable RS1032 // Define diagnostic message correctly
"The API \"{0}\" is ambiguous. Please specify one of: {1}",
+#pragma warning restore RS1032 // Define diagnostic message correctly
"Functionality",
DiagnosticSeverity.Error,
isEnabledByDefault: true);
@@ -122,6 +133,57 @@ public class SourceGenerator : ISourceGenerator
private const string NativeMethodsTxtAdditionalFileName = "NativeMethods.txt";
private const string NativeMethodsJsonAdditionalFileName = "NativeMethods.json";
+#if ROSLYN4_0
+
+ ///
+ public void Initialize(IncrementalGeneratorInitializationContext context)
+ {
+ var configFiles = context.AdditionalTextsProvider.Collect().Select(
+ static (additionalFiles, cancellationToken) =>
+ {
+ AdditionalText? nativeMethodsJsonFile = GetNativeMethodsJsonFile(additionalFiles);
+ AdditionalText? nativeMethodsTxtFile = GetNativeMethodsTxtFile(additionalFiles);
+
+ return (nativeMethodsJsonFile, nativeMethodsTxtFile);
+ });
+
+ var globalConfig = context.AnalyzerConfigOptionsProvider.Select(
+ static (analyzerConfigOptions, cancellationToken) =>
+ {
+ string? inputMetadataPaths = TryGetInputMetadataPaths(analyzerConfigOptions);
+ string? inputDocPaths = TryGetInputDocPaths(analyzerConfigOptions);
+
+ return (inputMetadataPaths, inputDocPaths);
+ });
+
+ var languageVersion = context.ParseOptionsProvider.Select((parseOptions, _) => (parseOptions as CSharpParseOptions)?.LanguageVersion);
+
+ var inputs = context.CompilationProvider
+ .Combine(languageVersion)
+ .Combine(configFiles)
+ .Combine(globalConfig)
+ .Select((data, cancellationToken) => (compilation: data.Left.Left.Left, languageVersion: data.Left.Left.Right, additionalFiles: data.Left.Right, analyzerConfigOptions: data.Right));
+
+ context.RegisterSourceOutput(
+ inputs,
+ (context, collectedValues) =>
+ {
+ Execute(
+ context,
+ static (context, diagnostic) => context.ReportDiagnostic(diagnostic),
+ static (context, hintName, source) => context.AddSource(hintName, source),
+ (CSharpCompilation)collectedValues.compilation,
+ collectedValues.languageVersion,
+ collectedValues.additionalFiles.nativeMethodsJsonFile,
+ collectedValues.additionalFiles.nativeMethodsTxtFile,
+ collectedValues.analyzerConfigOptions.inputMetadataPaths,
+ collectedValues.analyzerConfigOptions.inputDocPaths,
+ context.CancellationToken);
+ });
+ }
+
+#else
+
///
public void Initialize(GeneratorInitializationContext context)
{
@@ -130,17 +192,64 @@ public void Initialize(GeneratorInitializationContext context)
///
public void Execute(GeneratorExecutionContext context)
{
- if (context.Compilation is not CSharpCompilation compilation)
- {
- return;
- }
+ AdditionalText? nativeMethodsJsonFile = GetNativeMethodsJsonFile(context.AdditionalFiles);
+ AdditionalText? nativeMethodsTxtFile = GetNativeMethodsTxtFile(context.AdditionalFiles);
+ string? inputMetadataPaths = TryGetInputMetadataPaths(context.AnalyzerConfigOptions);
+ string? inputDocPaths = TryGetInputDocPaths(context.AnalyzerConfigOptions);
+
+ Execute(
+ context,
+ static (context, diagnostic) => context.ReportDiagnostic(diagnostic),
+ static (context, hintName, source) => context.AddSource(hintName, source),
+ (CSharpCompilation)context.Compilation,
+ (context.ParseOptions as CSharpParseOptions)?.LanguageVersion,
+ nativeMethodsJsonFile,
+ nativeMethodsTxtFile,
+ inputMetadataPaths,
+ inputDocPaths,
+ context.CancellationToken);
+ }
+
+#endif
+
+ private static AdditionalText? GetNativeMethodsJsonFile(ImmutableArray additionalFiles)
+ {
+ return additionalFiles.FirstOrDefault(af => string.Equals(Path.GetFileName(af.Path), NativeMethodsJsonAdditionalFileName, StringComparison.OrdinalIgnoreCase));
+ }
+
+ private static AdditionalText? GetNativeMethodsTxtFile(ImmutableArray additionalFiles)
+ {
+ return additionalFiles.FirstOrDefault(af => string.Equals(Path.GetFileName(af.Path), NativeMethodsTxtAdditionalFileName, StringComparison.OrdinalIgnoreCase));
+ }
- GeneratorOptions options;
- AdditionalText? nativeMethodsJsonFile = context.AdditionalFiles
- .FirstOrDefault(af => string.Equals(Path.GetFileName(af.Path), NativeMethodsJsonAdditionalFileName, StringComparison.OrdinalIgnoreCase));
+ private static string? TryGetInputMetadataPaths(AnalyzerConfigOptionsProvider analyzerConfigOptions)
+ {
+ analyzerConfigOptions.GlobalOptions.TryGetValue("build_property.CsWin32InputMetadataPaths", out string? inputMetadataPaths);
+ return inputMetadataPaths;
+ }
+
+ private static string? TryGetInputDocPaths(AnalyzerConfigOptionsProvider analyzerConfigOptions)
+ {
+ analyzerConfigOptions.GlobalOptions.TryGetValue("build_property.CsWin32InputDocPaths", out string? inputDocPaths);
+ return inputDocPaths;
+ }
+
+ private static void Execute(
+ TContext context,
+ Action reportDiagnostic,
+ Action addSource,
+ CSharpCompilation compilation,
+ LanguageVersion? languageVersion,
+ AdditionalText? nativeMethodsJsonFile,
+ AdditionalText? nativeMethodsTxtFile,
+ string? inputMetadataPaths,
+ string? inputDocPaths,
+ CancellationToken cancellationToken)
+ {
+ GeneratorOptions? options = null;
if (nativeMethodsJsonFile is object)
{
- string optionsJson = nativeMethodsJsonFile.GetText(context.CancellationToken)!.ToString();
+ string optionsJson = nativeMethodsJsonFile.GetText(cancellationToken)!.ToString();
try
{
options = JsonSerializer.Deserialize(optionsJson, new JsonSerializerOptions
@@ -152,7 +261,7 @@ public void Execute(GeneratorExecutionContext context)
}
catch (JsonException ex)
{
- context.ReportDiagnostic(Diagnostic.Create(OptionsParsingError, location: null, nativeMethodsJsonFile.Path, ex.Message));
+ reportDiagnostic(context, Diagnostic.Create(OptionsParsingError, location: null, nativeMethodsJsonFile.Path, ex.Message));
return;
}
}
@@ -161,26 +270,22 @@ public void Execute(GeneratorExecutionContext context)
options = new GeneratorOptions();
}
- AdditionalText? nativeMethodsTxtFile = context.AdditionalFiles
- .FirstOrDefault(af => string.Equals(Path.GetFileName(af.Path), NativeMethodsTxtAdditionalFileName, StringComparison.OrdinalIgnoreCase));
if (nativeMethodsTxtFile is null)
{
return;
}
- var parseOptions = (CSharpParseOptions)context.ParseOptions;
-
if (!compilation.Options.AllowUnsafe)
{
- context.ReportDiagnostic(Diagnostic.Create(UnsafeCodeRequired, location: null));
+ reportDiagnostic(context, Diagnostic.Create(UnsafeCodeRequired, location: null));
}
- Docs? docs = ParseDocs(context);
- IReadOnlyList generators = CollectMetadataPaths(context).Select(path => new Generator(path, docs, options, compilation, parseOptions)).ToList();
+ Docs? docs = ParseDocs(context, reportDiagnostic, inputDocPaths);
+ IReadOnlyList generators = CollectMetadataPaths(inputMetadataPaths).Select(path => new Generator(path, docs, options, compilation, languageVersion)).ToList();
try
{
SuperGenerator.Combine(generators);
- SourceText? nativeMethodsTxt = nativeMethodsTxtFile.GetText(context.CancellationToken);
+ SourceText? nativeMethodsTxt = nativeMethodsTxtFile.GetText(cancellationToken);
if (nativeMethodsTxt is null)
{
return;
@@ -188,7 +293,7 @@ public void Execute(GeneratorExecutionContext context)
foreach (TextLine line in nativeMethodsTxt.Lines)
{
- context.CancellationToken.ThrowIfCancellationRequested();
+ cancellationToken.ThrowIfCancellationRequested();
string name = line.ToString();
if (string.IsNullOrWhiteSpace(name) || name.StartsWith("//", StringComparison.InvariantCulture))
{
@@ -201,7 +306,7 @@ public void Execute(GeneratorExecutionContext context)
{
if (Generator.GetBannedAPIs(options).TryGetValue(name, out string? reason))
{
- context.ReportDiagnostic(Diagnostic.Create(BannedApi, location, reason));
+ reportDiagnostic(context, Diagnostic.Create(BannedApi, location, reason));
continue;
}
@@ -211,7 +316,7 @@ public void Execute(GeneratorExecutionContext context)
int matches = 0;
foreach (Generator generator in generators)
{
- if (generator.TryGenerateAllExternMethods(moduleName, context.CancellationToken))
+ if (generator.TryGenerateAllExternMethods(moduleName, cancellationToken))
{
matches++;
}
@@ -220,10 +325,10 @@ public void Execute(GeneratorExecutionContext context)
switch (matches)
{
case 0:
- context.ReportDiagnostic(Diagnostic.Create(NoMethodsForModule, location, moduleName));
+ reportDiagnostic(context, Diagnostic.Create(NoMethodsForModule, location, moduleName));
break;
case > 1:
- context.ReportDiagnostic(Diagnostic.Create(AmbiguousMatchError, location, moduleName));
+ reportDiagnostic(context, Diagnostic.Create(AmbiguousMatchError, location, moduleName));
break;
}
@@ -233,7 +338,7 @@ public void Execute(GeneratorExecutionContext context)
List matchingApis = new();
foreach (Generator generator in generators)
{
- if (generator.TryGenerate(name, out IReadOnlyList preciseApi, context.CancellationToken))
+ if (generator.TryGenerate(name, out IReadOnlyList preciseApi, cancellationToken))
{
matchingApis.AddRange(preciseApi);
continue;
@@ -242,8 +347,8 @@ public void Execute(GeneratorExecutionContext context)
matchingApis.AddRange(preciseApi);
if (generator.TryGetEnumName(name, out string? declaringEnum))
{
- context.ReportDiagnostic(Diagnostic.Create(UseEnumValueDeclaringType, location, declaringEnum));
- generator.TryGenerate(declaringEnum, out preciseApi, context.CancellationToken);
+ reportDiagnostic(context, Diagnostic.Create(UseEnumValueDeclaringType, location, declaringEnum));
+ generator.TryGenerate(declaringEnum, out preciseApi, cancellationToken);
matchingApis.AddRange(preciseApi);
}
}
@@ -254,7 +359,7 @@ public void Execute(GeneratorExecutionContext context)
ReportNoMatch(location, name);
break;
case > 1:
- context.ReportDiagnostic(Diagnostic.Create(AmbiguousMatchErrorWithSuggestions, location, name, ConcatSuggestions(matchingApis)));
+ reportDiagnostic(context, Diagnostic.Create(AmbiguousMatchErrorWithSuggestions, location, name, ConcatSuggestions(matchingApis)));
break;
}
}
@@ -262,24 +367,24 @@ public void Execute(GeneratorExecutionContext context)
{
if (Generator.IsPlatformCompatibleException(ex))
{
- context.ReportDiagnostic(Diagnostic.Create(CpuArchitectureIncompatibility, location));
+ reportDiagnostic(context, Diagnostic.Create(CpuArchitectureIncompatibility, location));
}
else
{
// Build up a complete error message.
- context.ReportDiagnostic(Diagnostic.Create(InternalError, location, AssembleFullExceptionMessage(ex)));
+ reportDiagnostic(context, Diagnostic.Create(InternalError, location, AssembleFullExceptionMessage(ex)));
}
}
}
foreach (Generator generator in generators)
{
- var compilationUnits = generator.GetCompilationUnits(context.CancellationToken)
+ var compilationUnits = generator.GetCompilationUnits(cancellationToken)
.OrderBy(pair => pair.Key, StringComparer.OrdinalIgnoreCase)
.ThenBy(pair => pair.Key, StringComparer.Ordinal);
foreach (var unit in compilationUnits)
{
- context.AddSource($"{generator.InputAssemblyName}.{unit.Key}", unit.Value.ToFullString());
+ addSource(context, $"{generator.InputAssemblyName}.{unit.Key}", unit.Value.ToFullString());
}
}
@@ -311,11 +416,11 @@ void ReportNoMatch(Location? location, string failedAttempt)
if (suggestions.Count > 0)
{
- context.ReportDiagnostic(Diagnostic.Create(NoMatchingMethodOrTypeWithSuggestions, location, failedAttempt, ConcatSuggestions(suggestions)));
+ reportDiagnostic(context, Diagnostic.Create(NoMatchingMethodOrTypeWithSuggestions, location, failedAttempt, ConcatSuggestions(suggestions)));
}
else
{
- context.ReportDiagnostic(Diagnostic.Create(NoMatchingMethodOrType, location, failedAttempt));
+ reportDiagnostic(context, Diagnostic.Create(NoMatchingMethodOrType, location, failedAttempt));
}
}
}
@@ -348,23 +453,21 @@ private static string AssembleFullExceptionMessage(Exception ex)
return sb.ToString();
}
- private static IReadOnlyList CollectMetadataPaths(GeneratorExecutionContext context)
+ private static IReadOnlyList CollectMetadataPaths(string? delimitedMetadataBasePaths)
{
- if (!context.AnalyzerConfigOptions.GlobalOptions.TryGetValue("build_property.CsWin32InputMetadataPaths", out string? delimitedMetadataBasePaths) ||
- string.IsNullOrWhiteSpace(delimitedMetadataBasePaths))
+ if (string.IsNullOrWhiteSpace(delimitedMetadataBasePaths))
{
return Array.Empty();
}
- string[] metadataBasePaths = delimitedMetadataBasePaths.Split('|');
+ string[] metadataBasePaths = delimitedMetadataBasePaths!.Split('|');
return metadataBasePaths;
}
- private static Docs? ParseDocs(GeneratorExecutionContext context)
+ private static Docs? ParseDocs(TContext context, Action reportDiagnostic, string? delimitedApiDocsPaths)
{
Docs? docs = null;
- if (context.AnalyzerConfigOptions.GlobalOptions.TryGetValue("build_property.CsWin32InputDocPaths", out string? delimitedApiDocsPaths) &&
- !string.IsNullOrWhiteSpace(delimitedApiDocsPaths))
+ if (!string.IsNullOrWhiteSpace(delimitedApiDocsPaths))
{
string[] apiDocsPaths = delimitedApiDocsPaths!.Split('|');
if (apiDocsPaths.Length > 0)
@@ -378,7 +481,7 @@ private static IReadOnlyList CollectMetadataPaths(GeneratorExecutionCont
}
catch (Exception e)
{
- context.ReportDiagnostic(Diagnostic.Create(DocParsingError, null, path, e.Message));
+ reportDiagnostic(context, Diagnostic.Create(DocParsingError, null, path, e.Message));
}
}
diff --git a/src/Microsoft.Windows.CsWin32/SuperGenerator.cs b/src/Microsoft.Windows.CsWin32.Shared/SuperGenerator.cs
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/SuperGenerator.cs
rename to src/Microsoft.Windows.CsWin32.Shared/SuperGenerator.cs
diff --git a/src/Microsoft.Windows.CsWin32/TypeHandleInfo.cs b/src/Microsoft.Windows.CsWin32.Shared/TypeHandleInfo.cs
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/TypeHandleInfo.cs
rename to src/Microsoft.Windows.CsWin32.Shared/TypeHandleInfo.cs
diff --git a/src/Microsoft.Windows.CsWin32/TypeSyntaxAndMarshaling.cs b/src/Microsoft.Windows.CsWin32.Shared/TypeSyntaxAndMarshaling.cs
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/TypeSyntaxAndMarshaling.cs
rename to src/Microsoft.Windows.CsWin32.Shared/TypeSyntaxAndMarshaling.cs
diff --git a/src/Microsoft.Windows.CsWin32/TypeSyntaxSettings.cs b/src/Microsoft.Windows.CsWin32.Shared/TypeSyntaxSettings.cs
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/TypeSyntaxSettings.cs
rename to src/Microsoft.Windows.CsWin32.Shared/TypeSyntaxSettings.cs
diff --git a/src/Microsoft.Windows.CsWin32/templates/.editorconfig b/src/Microsoft.Windows.CsWin32.Shared/templates/.editorconfig
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/templates/.editorconfig
rename to src/Microsoft.Windows.CsWin32.Shared/templates/.editorconfig
diff --git a/src/Microsoft.Windows.CsWin32/templates/HRESULT.cs b/src/Microsoft.Windows.CsWin32.Shared/templates/HRESULT.cs
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/templates/HRESULT.cs
rename to src/Microsoft.Windows.CsWin32.Shared/templates/HRESULT.cs
diff --git a/src/Microsoft.Windows.CsWin32/templates/NTSTATUS.cs b/src/Microsoft.Windows.CsWin32.Shared/templates/NTSTATUS.cs
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/templates/NTSTATUS.cs
rename to src/Microsoft.Windows.CsWin32.Shared/templates/NTSTATUS.cs
diff --git a/src/Microsoft.Windows.CsWin32/templates/PCSTR.cs b/src/Microsoft.Windows.CsWin32.Shared/templates/PCSTR.cs
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/templates/PCSTR.cs
rename to src/Microsoft.Windows.CsWin32.Shared/templates/PCSTR.cs
diff --git a/src/Microsoft.Windows.CsWin32/templates/PCWSTR.cs b/src/Microsoft.Windows.CsWin32.Shared/templates/PCWSTR.cs
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/templates/PCWSTR.cs
rename to src/Microsoft.Windows.CsWin32.Shared/templates/PCWSTR.cs
diff --git a/src/Microsoft.Windows.CsWin32/templates/WinRTCustomMarshaler.cs b/src/Microsoft.Windows.CsWin32.Shared/templates/WinRTCustomMarshaler.cs
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/templates/WinRTCustomMarshaler.cs
rename to src/Microsoft.Windows.CsWin32.Shared/templates/WinRTCustomMarshaler.cs
diff --git a/src/Microsoft.Windows.CsWin32/templates/marshaling/CoCreateInstance.cs b/src/Microsoft.Windows.CsWin32.Shared/templates/marshaling/CoCreateInstance.cs
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/templates/marshaling/CoCreateInstance.cs
rename to src/Microsoft.Windows.CsWin32.Shared/templates/marshaling/CoCreateInstance.cs
diff --git a/src/Microsoft.Windows.CsWin32/templates/no_marshaling/CoCreateInstance.cs b/src/Microsoft.Windows.CsWin32.Shared/templates/no_marshaling/CoCreateInstance.cs
similarity index 100%
rename from src/Microsoft.Windows.CsWin32/templates/no_marshaling/CoCreateInstance.cs
rename to src/Microsoft.Windows.CsWin32.Shared/templates/no_marshaling/CoCreateInstance.cs
diff --git a/src/Microsoft.Windows.CsWin32/Microsoft.Windows.CsWin32.csproj b/src/Microsoft.Windows.CsWin32/Microsoft.Windows.CsWin32.csproj
deleted file mode 100644
index 7cfa1424..00000000
--- a/src/Microsoft.Windows.CsWin32/Microsoft.Windows.CsWin32.csproj
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
- true
- netstandard2.0
- enable
-
-
- false
- false
- true
- $(NoWarn);NU5128;NU5127
- Microsoft.Windows.CsWin32.nuspec
-
-
-
-
-
-
-
-
-
- true
- build\
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- all
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Microsoft.Windows.CsWin32/Microsoft.Windows.CsWin32.nuspec b/src/Microsoft.Windows.CsWin32/Microsoft.Windows.CsWin32.nuspec
deleted file mode 100644
index 69f86e9b..00000000
--- a/src/Microsoft.Windows.CsWin32/Microsoft.Windows.CsWin32.nuspec
+++ /dev/null
@@ -1,53 +0,0 @@
-
-
-
- Microsoft.Windows.CsWin32
- $version$
- Microsoft
- true
- false
- MIT
- https://licenses.nuget.org/MIT
- https://github.com/Microsoft/CsWin32
- Microsoft Windows SDK Win32 API Source Generator
- $PackageReleaseNotes$
- README.md
- © Microsoft Corporation. All rights reserved.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Microsoft.Windows.CsWin32/Roslyn38/Microsoft.Windows.CsWin32.Roslyn38.csproj b/src/Microsoft.Windows.CsWin32/Roslyn38/Microsoft.Windows.CsWin32.Roslyn38.csproj
new file mode 100644
index 00000000..036e3547
--- /dev/null
+++ b/src/Microsoft.Windows.CsWin32/Roslyn38/Microsoft.Windows.CsWin32.Roslyn38.csproj
@@ -0,0 +1,29 @@
+
+
+
+ false
+ netstandard2.0
+ enable
+
+
+ true
+
+
+ *$(MSBuildProjectFile)*
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Microsoft.Windows.CsWin32/Roslyn40/Microsoft.Windows.CsWin32.Roslyn40.csproj b/src/Microsoft.Windows.CsWin32/Roslyn40/Microsoft.Windows.CsWin32.Roslyn40.csproj
new file mode 100644
index 00000000..2bbf3662
--- /dev/null
+++ b/src/Microsoft.Windows.CsWin32/Roslyn40/Microsoft.Windows.CsWin32.Roslyn40.csproj
@@ -0,0 +1,30 @@
+
+
+
+ false
+ netstandard2.0
+ enable
+ $(DefineConstants);ROSLYN4_0
+
+
+ true
+
+
+ *$(MSBuildProjectFile)*
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Win32MetaGeneration/Program.cs b/src/Win32MetaGeneration/Program.cs
index 90ea2b88..50252e23 100644
--- a/src/Win32MetaGeneration/Program.cs
+++ b/src/Win32MetaGeneration/Program.cs
@@ -53,7 +53,7 @@ private static void Main(string[] args)
WideCharOnly = true,
EmitSingleFile = true,
},
- parseOptions: CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp9));
+ languageVersion: LanguageVersion.CSharp9);
Console.WriteLine("Generating code... (press Ctrl+C to cancel)");
if (args.Length > 0)
{
diff --git a/src/Win32MetaGeneration/Win32MetaGeneration.csproj b/src/Win32MetaGeneration/Win32MetaGeneration.csproj
index 2923782e..a10b0e54 100644
--- a/src/Win32MetaGeneration/Win32MetaGeneration.csproj
+++ b/src/Win32MetaGeneration/Win32MetaGeneration.csproj
@@ -10,7 +10,7 @@
-
+
diff --git a/test/GenerationSandbox.Tests/GenerationSandbox.Tests.csproj b/test/GenerationSandbox.Tests/GenerationSandbox.Tests.csproj
index 21156de6..f0781176 100644
--- a/test/GenerationSandbox.Tests/GenerationSandbox.Tests.csproj
+++ b/test/GenerationSandbox.Tests/GenerationSandbox.Tests.csproj
@@ -1,5 +1,5 @@
-
+
net5.0-windows7.0;netcoreapp3.1;net472
@@ -7,13 +7,13 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/test/Microsoft.Windows.CsWin32.Tests/GeneratorTests.cs b/test/Microsoft.Windows.CsWin32.Tests/GeneratorTests.cs
index 0c56104f..e4886cbc 100644
--- a/test/Microsoft.Windows.CsWin32.Tests/GeneratorTests.cs
+++ b/test/Microsoft.Windows.CsWin32.Tests/GeneratorTests.cs
@@ -2638,7 +2638,7 @@ private async Task CreateCompilationAsync(ReferenceAssemblies
private Generator CreateGenerator(GeneratorOptions? options = null, CSharpCompilation? compilation = null) => this.CreateGenerator(MetadataPath, options, compilation);
- private Generator CreateGenerator(string path, GeneratorOptions? options = null, CSharpCompilation? compilation = null) => new Generator(path, Docs.Get(ApiDocsPath), options ?? DefaultTestGeneratorOptions, compilation ?? this.compilation, this.parseOptions);
+ private Generator CreateGenerator(string path, GeneratorOptions? options = null, CSharpCompilation? compilation = null) => new Generator(path, Docs.Get(ApiDocsPath), options ?? DefaultTestGeneratorOptions, compilation ?? this.compilation, this.parseOptions.LanguageVersion);
private static class MyReferenceAssemblies
{
diff --git a/test/Microsoft.Windows.CsWin32.Tests/Microsoft.Windows.CsWin32.Tests.csproj b/test/Microsoft.Windows.CsWin32.Tests/Microsoft.Windows.CsWin32.Tests.csproj
index 36bfec83..27cbb29b 100644
--- a/test/Microsoft.Windows.CsWin32.Tests/Microsoft.Windows.CsWin32.Tests.csproj
+++ b/test/Microsoft.Windows.CsWin32.Tests/Microsoft.Windows.CsWin32.Tests.csproj
@@ -27,7 +27,7 @@
-
+
diff --git a/test/SpellChecker/SpellChecker.csproj b/test/SpellChecker/SpellChecker.csproj
index b606617a..7731a1e4 100644
--- a/test/SpellChecker/SpellChecker.csproj
+++ b/test/SpellChecker/SpellChecker.csproj
@@ -1,5 +1,5 @@
-
+
Exe
@@ -7,13 +7,13 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/test/WinRTInteropTest/WinRTInteropTest.csproj b/test/WinRTInteropTest/WinRTInteropTest.csproj
index 4bad82c5..1a8ec166 100644
--- a/test/WinRTInteropTest/WinRTInteropTest.csproj
+++ b/test/WinRTInteropTest/WinRTInteropTest.csproj
@@ -1,5 +1,5 @@
-
+
WinExe
@@ -8,13 +8,13 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+