Skip to content

Commit dc7f357

Browse files
Polyfill clean up and source package organization (#12977)
This pull request represents a bit of clean up and should have no product impact. - a342950: I noticed that the `StringSyntaxAttribute` polyfill is declared in the wrong namespace. This attribute is only for IDE tooling support and probably doesn't actually work in non-.NET, since it was declared in the `System` namespace rather than `System.Diagnostics.CodeAnalysis`. I've fixed the polyfill and updated all of the files that had used conditional compilation gymnastics to deal with the incorrect namespace. - df61bee: Small changes to the `CallerArgumentExpressionAttribute` polyfill to match best practices. - 68b8bf2: Update links to the Compile and Content items in the `Microsoft.CodeAnalysis.*` source packages to display the items in separate folders rather than dumping them into the project root. This separates them in the Solution Explorer. <img width="300" height="620" alt="image" src="https://github.com/user-attachments/assets/012c9d54-db85-49bb-8eb5-266b20704741" />
1 parent 0a54973 commit dc7f357

18 files changed

+52
-33
lines changed

src/Build/Microsoft.Build.csproj

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,36 @@
3838

3939
<PackageReference Include="Microsoft.IO.Redist" Condition="'$(FeatureMSIORedist)' == 'true'" />
4040

41-
<PackageReference Include="Microsoft.CodeAnalysis.Collections" PrivateAssets="all" />
42-
<PackageReference Include="Microsoft.CodeAnalysis.PooledObjects" PrivateAssets="all" />
4341
<PackageReference Include="Microsoft.BuildXL.Processes" Condition="'$(FeatureReportFileAccesses)' == 'true'" PrivateAssets="all" />
4442
<!-- Remove the direct NETStandard.Library dependency when Microsoft.BuildXL.Processes stops bringing in netstandard1.x dependencies
4543
or when a .NET 10 SDK is used (NuGet Package Pruning eliminates netstandard1.x dependencies). -->
4644
<PackageReference Include="NETStandard.Library" VersionOverride="2.0.3" PrivateAssets="all" Condition="'$(FeatureReportFileAccesses)' == 'true'" />
4745
</ItemGroup>
4846

47+
<ItemGroup>
48+
<PackageReference Include="Microsoft.CodeAnalysis.Collections" PrivateAssets="all" />
49+
50+
<!-- Display files included by the Microsoft.CodeAnalysis.Collections source package in a 'SourcePackages\Collections' folder -->
51+
<Content Update="@(Content)">
52+
<Link Condition="'%(NuGetPackageId)' == 'Microsoft.CodeAnalysis.Collections'">SourcePackages\Collections\%(Link)</Link>
53+
</Content>
54+
<Compile Update="@(Compile)">
55+
<Link Condition="'%(NuGetPackageId)' == 'Microsoft.CodeAnalysis.Collections'">SourcePackages\Collections\%(Link)</Link>
56+
</Compile>
57+
</ItemGroup>
58+
59+
<ItemGroup>
60+
<PackageReference Include="Microsoft.CodeAnalysis.PooledObjects" PrivateAssets="all" />
61+
62+
<!-- Display files included by the Microsoft.CodeAnalysis.PooledObjects source package in a 'SourcePackages\PooledObjects' folder -->
63+
<Content Update="@(Content)">
64+
<Link Condition="'%(NuGetPackageId)' == 'Microsoft.CodeAnalysis.PooledObjects'">SourcePackages\PooledObjects\%(Link)</Link>
65+
</Content>
66+
<Compile Update="@(Compile)">
67+
<Link Condition="'%(NuGetPackageId)' == 'Microsoft.CodeAnalysis.PooledObjects'">SourcePackages\PooledObjects\%(Link)</Link>
68+
</Compile>
69+
</ItemGroup>
70+
4971
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' and '$(DotNetBuildSourceOnly)' != 'true'">
5072
<PackageReference Include="Microsoft.VisualStudio.Setup.Configuration.Interop" PrivateAssets="all" />
5173
</ItemGroup>

src/Framework/BuildErrorEventArgs.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System;
5-
#if NET
65
using System.Diagnostics.CodeAnalysis;
7-
#endif
86
using System.IO;
97
using Microsoft.Build.Shared;
108

src/Framework/BuildMessageEventArgs.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System;
5-
#if NET
65
using System.Diagnostics.CodeAnalysis;
7-
#endif
86
using System.IO;
97
using System.Runtime.Serialization;
108
using Microsoft.Build.Shared;

src/Framework/BuildWarningEventArgs.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System;
5-
#if NET
65
using System.Diagnostics.CodeAnalysis;
7-
#endif
86
using System.IO;
97
using Microsoft.Build.Shared;
108

src/Framework/CriticalBuildMessageEventArgs.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System;
5-
#if NET
65
using System.Diagnostics.CodeAnalysis;
7-
#endif
86

97
#nullable disable
108

src/Framework/CustomBuildEventArgs.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System;
5-
#if NET
65
using System.Diagnostics.CodeAnalysis;
7-
#endif
86

97
#nullable disable
108

src/Framework/ExtendedBuildErrorEventArgs.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
using System;
55
using System.Collections.Generic;
6-
#if NET
76
using System.Diagnostics.CodeAnalysis;
8-
#endif
97
using System.IO;
108
using Microsoft.Build.Shared;
119

src/Framework/ExtendedBuildWarningEventArgs.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
using System;
55
using System.Collections.Generic;
6-
#if NET
76
using System.Diagnostics.CodeAnalysis;
8-
#endif
97
using System.IO;
108
using Microsoft.Build.Shared;
119

src/Framework/LazyFormattedBuildEventArgs.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System;
5-
#if NET
65
using System.Diagnostics.CodeAnalysis;
7-
#endif
86
using System.Globalization;
97
using System.IO;
108

src/Framework/Microsoft.Build.Framework.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@
1616

1717
<ItemGroup>
1818
<PackageReference Include="Microsoft.CodeAnalysis.Contracts" PrivateAssets="all" />
19+
20+
<!-- Display files included by the Microsoft.CodeAnalysis.Contracts source package in a 'SourcePackages\Contracts' folder -->
21+
<Content Update="@(Content)">
22+
<Link Condition="'%(NuGetPackageId)' == 'Microsoft.CodeAnalysis.Contracts'">SourcePackages\Contracts\%(Link)</Link>
23+
</Content>
24+
<Compile Update="@(Compile)">
25+
<Link Condition="'%(NuGetPackageId)' == 'Microsoft.CodeAnalysis.Contracts'">SourcePackages\Contracts\%(Link)</Link>
26+
</Compile>
1927
</ItemGroup>
2028

2129
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">

0 commit comments

Comments
 (0)