Use the BannedApiAnalyzer instead of the LinqPoison mechanism to ban Linq in the...
authorJeremy Koritzinsky <jekoritz@microsoft.com>
Wed, 24 May 2023 20:02:50 +0000 (13:02 -0700)
committerGitHub <noreply@github.com>
Wed, 24 May 2023 20:02:50 +0000 (13:02 -0700)
eng/Versions.props
src/coreclr/tools/Common/TypeSystem/Common/LinqPoison.cs [deleted file]
src/coreclr/tools/aot/ILCompiler.TypeSystem/BannedSymbols.txt [new file with mode: 0644]
src/coreclr/tools/aot/ILCompiler.TypeSystem/ILCompiler.TypeSystem.csproj

index e88a638..f9d6f8e 100644 (file)
@@ -70,7 +70,7 @@
     -->
     <MicrosoftCodeAnalysisVersion_LatestVS>4.5.0</MicrosoftCodeAnalysisVersion_LatestVS>
     <!-- Some of the analyzer dependencies used by ILLink project -->
-    <MicrosoftCodeAnalysisBannedApiAnalyzersVersion>3.3.2</MicrosoftCodeAnalysisBannedApiAnalyzersVersion>
+    <MicrosoftCodeAnalysisBannedApiAnalyzersVersion>3.3.5-beta1.23270.2</MicrosoftCodeAnalysisBannedApiAnalyzersVersion>
   </PropertyGroup>
   <!--
     These packages affect the design-time experience in VS, so we update them at the same cadance as the MicrosoftCodeAnalysisVersion_LatestVS version.
diff --git a/src/coreclr/tools/Common/TypeSystem/Common/LinqPoison.cs b/src/coreclr/tools/Common/TypeSystem/Common/LinqPoison.cs
deleted file mode 100644 (file)
index 2473b14..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System
-{
-    //
-    // The type system needs to be low level enough to be usable as
-    // an actual runtime type system.
-    //
-    // LINQ is not low level enough to be allowable in the type system.
-    //
-    // It also has performance characteristics that make it a poor choice
-    // in high performance components such as the type system.
-    //
-    // If you get an error pointing to here, the fix is to remove
-    // "using System.Linq" from your file. Do not modify this file or
-    // remove it from the project.
-    //
-    internal sealed class Linq { }
-}
diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem/BannedSymbols.txt b/src/coreclr/tools/aot/ILCompiler.TypeSystem/BannedSymbols.txt
new file mode 100644 (file)
index 0000000..9e3976e
--- /dev/null
@@ -0,0 +1 @@
+N:System.Linq;The type system needs to be low level enough to be usable as an actual runtime type system. LINQ is not low level enough to be allowable in the type system.
index 5a80cac..23f3ac4 100644 (file)
@@ -27,7 +27,7 @@
   </ItemGroup>
 
   <ItemGroup>
-    <PackageReference Condition = "'$(EnableDiaSymReaderUse)' == 'true'" Include="Microsoft.DiaSymReader">
+    <PackageReference Condition="'$(EnableDiaSymReaderUse)' == 'true'" Include="Microsoft.DiaSymReader">
       <Version>1.4.0</Version>
     </PackageReference>
   </ItemGroup>
     <Compile Include="..\..\Common\TypeSystem\Common\LayoutInt.cs">
       <Link>TypeSystem\Common\LayoutInt.cs</Link>
     </Compile>
-    <Compile Include="..\..\Common\TypeSystem\Common\LinqPoison.cs">
-      <Link>TypeSystem\Common\LinqPoison.cs</Link>
-    </Compile>
     <Compile Include="..\..\Common\TypeSystem\Common\MetadataType.cs">
       <Link>TypeSystem\Common\MetadataType.cs</Link>
     </Compile>
       <Link>TypeSystem\Sorting\TypeSystemComparer.cs</Link>
     </Compile>
   </ItemGroup>
+
+  <ItemGroup>
+    <AdditionalFiles Include="BannedSymbols.txt" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="$(MicrosoftCodeAnalysisBannedApiAnalyzersVersion)" Condition="'$(DotNetBuildFromSource)' != 'true'">
+      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
+      <PrivateAssets>all</PrivateAssets>
+    </PackageReference>
+  </ItemGroup>
 </Project>