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
15 changes: 7 additions & 8 deletions Directory.Packages.Analyzers.props
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
<Project>
<PropertyGroup>
<CodeAnalysisVersionForAnalyzers>3.11.0</CodeAnalysisVersionForAnalyzers>
<CodeAnalysisVersionForAnalyzers>4.14.0</CodeAnalysisVersionForAnalyzers>
</PropertyGroup>
<ItemGroup>
<!-- These versions carefully chosen to support VS 2019 Update 11. -->
<!-- These versions carefully chosen to support VS 2022 Update 14. -->

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation is out of date then:

## Prerequisites
The .NET 8 SDK or Visual Studio 2019 Update 11 (16.11).

Copy link
Member Author

@AArnott AArnott Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this. We should definitely update the 2019 reference.
As for dropping .NET 8 support, ... I wasn't aware it would do that.
@jevansaks I don't remember exactly what prompted this change.... how do you feel about either of us reverting all or part of it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was hitting an issue with assembly version resolution when targeting STJ 9.0.0, but I can put it back and see if I can resolve that a different way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<PackageVersion Update="Microsoft.CodeAnalysis.Common" Version="$(CodeAnalysisVersionForAnalyzers)" />
<PackageVersion Update="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="$(CodeAnalysisVersionForAnalyzers)" />
<PackageVersion Update="Microsoft.CodeAnalysis.CSharp" Version="$(CodeAnalysisVersionForAnalyzers)" />
<PackageVersion Update="System.Collections.Immutable" Version="5.0.0" />
<PackageVersion Update="System.Memory" Version="4.5.4" />
<PackageVersion Update="System.Reflection.Metadata" Version="5.0.0" />
<PackageVersion Update="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
<PackageVersion Include="System.Text.Encodings.Web" Version="4.7.1" />
<PackageVersion Update="System.Text.Json" Version="4.7.2" />
<PackageVersion Update="System.Collections.Immutable" Version="9.0.0" />
<PackageVersion Update="System.Memory" Version="4.5.5" />
<PackageVersion Update="System.Reflection.Metadata" Version="9.0.0" />
<PackageVersion Include="System.Text.Encodings.Web" Version="9.0.0" />
<PackageVersion Update="System.Text.Json" Version="9.0.0" />
</ItemGroup>
</Project>
3 changes: 2 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
<WDKMetadataVersion>0.12.8-experimental</WDKMetadataVersion>
<!-- <DiaMetadataVersion>0.2.185-preview-g7e1e6a442c</DiaMetadataVersion> -->
<ApiDocsVersion>0.1.42-alpha</ApiDocsVersion>
<CodeAnalysisVersion>4.13.0</CodeAnalysisVersion>
<CodeAnalysisVersion>4.14.0</CodeAnalysisVersion>
</PropertyGroup>
<ItemGroup>
<!-- We have to use the MessagePack version used by win32metadata (https://github.com/microsoft/CsWin32/issues/371) -->
<PackageVersion Include="MessagePack" Version="2.2.85" />
<PackageVersion Include="MessagePackAnalyzer" Version="2.5.192" />
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="9.0.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.3.4" />
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="$(CodeAnalysisVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing.XUnit" Version="1.1.3-beta1.24352.1" />
Expand Down
5 changes: 3 additions & 2 deletions Microsoft.Windows.CsWin32.sln
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33110.383
# Visual Studio Version 18
VisualStudioVersion = 18.0.11018.11 main
MinimumVisualStudioVersion = 15.0.26124.0
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1CE9670B-D5FF-46A7-9D00-24E70E6ED48B}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
Directory.Build.props = Directory.Build.props
Directory.Build.targets = Directory.Build.targets
Directory.Packages.Analyzers.props = Directory.Packages.Analyzers.props
Directory.Packages.props = Directory.Packages.props
global.json = global.json
nuget.config = nuget.config
Expand Down
5 changes: 1 addition & 4 deletions azure-pipelines/integration-test.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
jobs:
# Matrix over VS 2019 and VS 2022
# Matrix over VS 2022 (and eventually VS 2026)

- job: integrationtest
displayName: 🧪 Integration tests
strategy:
matrix:
vs2019:
vmImage: windows-2019
currentSdk: false
vs2022:
vmImage: windows-2022
currentSdk: true
Expand Down
4 changes: 3 additions & 1 deletion src/Microsoft.Windows.CsWin32/AnalyzerReleases.Unshipped.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ PInvoke004 | Functionality | Warning | SourceGenerator
PInvoke005 | Functionality | Warning | SourceGenerator
PInvoke006 | Configuration | Warning | SourceGenerator
PInvoke007 | Functionality | Error | SourceGenerator
PInvoke008 | Configuration | Error | SourceGenerator
PInvoke008 | Configuration | Error | SourceGenerator
PInvoke009 | Configuration | Warning | SourceGenerator
PInvoke010 | Configuration | Error | SourceGenerator
2 changes: 2 additions & 0 deletions src/Microsoft.Windows.CsWin32/BindingRedirects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ internal static class BindingRedirects

static BindingRedirects()
{
#pragma warning disable RS1035 // Do not use APIs banned for analyzers
LocalAssemblies = new Lazy<Dictionary<string, string>>(
() => Directory.GetFiles(SourceGeneratorAssemblyDirectory, "*.dll").ToDictionary(Path.GetFileNameWithoutExtension, StringComparer.OrdinalIgnoreCase));
#pragma warning restore RS1035 // Do not use APIs banned for analyzers
}

private static bool IsNetFramework => RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework", StringComparison.OrdinalIgnoreCase);
Expand Down
2 changes: 2 additions & 0 deletions src/Microsoft.Windows.CsWin32/Docs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ public static Docs Get(string docsPath)
}
}

#pragma warning disable RS1035 // Do not use APIs banned for analyzers
using FileStream docsStream = File.OpenRead(docsPath);
#pragma warning restore RS1035 // Do not use APIs banned for analyzers
Dictionary<string, ApiDetails>? data = MessagePackSerializer.Deserialize<Dictionary<string, ApiDetails>>(docsStream, MsgPackOptions);
var docs = new Docs(data);

Expand Down
2 changes: 2 additions & 0 deletions src/Microsoft.Windows.CsWin32/MetadataCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ internal MetadataFile GetMetadataFile(string path)
lock (this.metadataFiles)
{
MetadataFile? metadataFile;
#pragma warning disable RS1035 // Do not use APIs banned for analyzers
DateTime lastWriteTimeUtc = File.GetLastWriteTimeUtc(path);
#pragma warning restore RS1035 // Do not use APIs banned for analyzers
if (this.metadataFiles.TryGetValue(path, out metadataFile))
{
if (metadataFile.LastWriteTimeUtc == lastWriteTimeUtc)
Expand Down
2 changes: 2 additions & 0 deletions src/Microsoft.Windows.CsWin32/MetadataFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ internal class MetadataFile : IDisposable
internal MetadataFile(string path)
{
this.Path = path;
#pragma warning disable RS1035 // Do not use APIs banned for analyzers
this.LastWriteTimeUtc = File.GetLastWriteTimeUtc(path);
#pragma warning restore RS1035 // Do not use APIs banned for analyzers

// When using FileShare.Delete, the OS will allow the file to be deleted, but it does not disrupt
// our ability to read the file while our handle is open.
Expand Down
2 changes: 2 additions & 0 deletions src/Microsoft.Windows.CsWin32/MetadataIndex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ namespace Microsoft.Windows.CsWin32;
[DebuggerDisplay("{" + nameof(DebuggerDisplay) + ",nq}")]
internal class MetadataIndex
{
#pragma warning disable RS1035 // Do not use APIs banned for analyzers
private static readonly int MaxPooledObjectCount = Math.Max(Environment.ProcessorCount, 4);
#pragma warning restore RS1035 // Do not use APIs banned for analyzers

private readonly MetadataFile metadataFile;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<NoWarn>$(NoWarn);NU5128;NU5127;NU5104</NoWarn>
<NuSpecFile>Microsoft.Windows.CsWin32.nuspec</NuSpecFile>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
</PropertyGroup>

<ItemGroup>
Expand All @@ -26,8 +27,6 @@
</ItemGroup>

<ItemGroup>
<AdditionalFiles Include="AnalyzerReleases.Shipped.md" />
<AdditionalFiles Include="AnalyzerReleases.Unshipped.md" />
<AdditionalFiles Include="BannedSymbols.txt" />
</ItemGroup>

Expand All @@ -50,7 +49,6 @@
<PackageReference Include="Microsoft.Windows.SDK.Win32Docs" GeneratePathProperty="true" PrivateAssets="none" />
<PackageReference Include="Microsoft.Windows.WDK.Win32Metadata" GeneratePathProperty="true" PrivateAssets="none" />
<PackageReference Include="System.Memory" PrivateAssets="none" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" PrivateAssets="none" />
<PackageReference Include="System.Reflection.Metadata" />
<PackageReference Include="System.Text.Encodings.Web" />
<PackageReference Include="System.Text.Json" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
<TfmSpecificPackageFile Include="@(ReferencePath)" PackagePath="analyzers\cs\" Condition=" '%(FileName)%(Extension)' == 'System.Threading.Tasks.Extensions.dll' " />
<TfmSpecificPackageFile Include="@(ReferencePath)" PackagePath="analyzers\cs\" Condition=" '%(FileName)%(Extension)' == 'System.Memory.dll' " />
<TfmSpecificPackageFile Include="@(ReferencePath)" PackagePath="analyzers\cs\" Condition=" '%(FileName)%(Extension)' == 'System.Buffers.dll' " />
<TfmSpecificPackageFile Include="@(ReferencePath)" PackagePath="analyzers\cs\" Condition=" '%(FileName)%(Extension)' == 'System.Runtime.CompilerServices.Unsafe.dll' " />
<TfmSpecificPackageFile Include="@(SatelliteDllsProjectOutputGroupDependency)" PackagePath="analyzers\cs\%(SatelliteDllsProjectOutputGroupDependency.DestinationSubDirectory)" Condition=" '%(SatelliteDllsProjectOutputGroupDependency.DestinationSubDirectory)' != '' " />
<TfmSpecificPackageFile Include="@(SatelliteDllsProjectOutputGroupOutput->'%(FinalOutputPath)')" PackagePath="analyzers\cs\%(SatelliteDllsProjectOutputGroupOutput.Culture)\" />
<TfmSpecificPackageFile Include="%(_ResolvedProjectReferencePaths.Identity)" PackagePath="analyzers\cs\" />
Expand Down
7 changes: 5 additions & 2 deletions src/Microsoft.Windows.CsWin32/SourceGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#pragma warning disable RS1035 // Do not use APIs banned for analyzers (old style source generator)
#pragma warning disable RS1042 // Deprecated interface

using System.Text.Json;
using Microsoft.CodeAnalysis.Text;

Expand Down Expand Up @@ -172,15 +175,15 @@ public void Execute(GeneratorExecutionContext context)
return;
}

GeneratorOptions options;
GeneratorOptions? options;
AdditionalText? nativeMethodsJsonFile = context.AdditionalFiles
.FirstOrDefault(af => string.Equals(Path.GetFileName(af.Path), NativeMethodsJsonAdditionalFileName, StringComparison.OrdinalIgnoreCase));
if (nativeMethodsJsonFile is object)
{
string optionsJson = nativeMethodsJsonFile.GetText(context.CancellationToken)!.ToString();
try
{
options = JsonSerializer.Deserialize<GeneratorOptions>(optionsJson, JsonOptions);
options = JsonSerializer.Deserialize<GeneratorOptions>(optionsJson, JsonOptions) ?? new();
}
catch (JsonException ex)
{
Expand Down
Loading