1
0
Fork 0
mirror of https://github.com/VSadov/Satori.git synced 2025-06-08 03:27:04 +09:00

Change how test assemblies opt-in to LibraryImportGenerator usage (#92661)

This commit is contained in:
Jeremy Koritzinsky 2023-09-27 10:56:47 -07:00 committed by GitHub
parent 95fe99c564
commit 5c391f6b6b
Signed by: github
GPG key ID: 4AEE18F83AFDEB23
37 changed files with 21 additions and 43 deletions

View file

@ -8,14 +8,18 @@
<ItemGroup>
<EnabledGenerators Include="LibraryImportGenerator" Condition="'$(EnableLibraryImportGenerator)' == 'true'" />
<!-- If the current project is not System.Private.CoreLib, we enable the LibraryImportGenerator source generator
when the project is a C# source project that:
when the project is a C# source or test project that:
- doesn't target the a TFM that includes LibraryImportGenerator or
- doesn't reference the live targeting pack (i.e. when inbox) and
- references System.Private.CoreLib, or
- references System.Runtime.InteropServices -->
<EnabledGenerators Include="LibraryImportGenerator"
Condition="'$(EnableLibraryImportGenerator)' == '' and
'$(IsSourceProject)' == 'true' and
(
'$(IsSourceProject)' == 'true' or
'$(IsTestProject)' == 'true' or
'$(IsTestSupportProject)' == 'true'
) and
'$(MSBuildProjectExtension)' == '.csproj' and
(
!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0')) or

View file

@ -3,7 +3,6 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-linux;$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-osx</TargetFrameworks>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(CommonTestPath)System\Collections\DictionaryExtensions.cs"

View file

@ -8,7 +8,6 @@
and instead use runtime checks.
-->
<TargetFrameworks>$(NetCoreAppMinimum);$(NetFrameworkMinimum)</TargetFrameworks>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)ILLink.Substitutions.AggressiveTrimming.xml"

View file

@ -2,9 +2,8 @@
<PropertyGroup>
<!-- Use "$(NetCoreAppCurrent)-windows" to avoid PlatformNotSupportedExceptions from ServiceController. -->
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetFrameworkMinimum)</TargetFrameworks>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetFrameworkMinimum)</TargetFrameworks>
<EnableDefaultItems>true</EnableDefaultItems>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
</PropertyGroup>

View file

@ -2,7 +2,6 @@
<PropertyGroup>
<DefineConstants>$(DefineConstants);REGISTRY_ASSEMBLY</DefineConstants>
<TargetFramework>$(NetCoreAppCurrent)-windows</TargetFramework>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>

View file

@ -3,7 +3,6 @@
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetFrameworkMinimum)</TargetFrameworks>
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(CommonPath)Interop\Windows\Interop.Libraries.cs"

View file

@ -3,7 +3,6 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
<TargetFrameworks>$(NetCoreAppCurrent);$(NetCoreAppCurrent)-windows</TargetFrameworks>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
<StringResourcesPath>..\src\Resources\Strings.resx</StringResourcesPath>
</PropertyGroup>
<ItemGroup>

View file

@ -2,7 +2,6 @@
<PropertyGroup>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetFrameworkMinimum)</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
</PropertyGroup>
<ItemGroup>
<Compile Include="EventInstanceTests.cs" />

View file

@ -3,7 +3,6 @@
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IgnoreForCI Condition="'$(TargetOS)' == 'browser'">true</IgnoreForCI>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
</PropertyGroup>
<ItemGroup>
<!-- Checked in test binaries for FileVersionInfoTest -->
@ -28,7 +27,7 @@
<ItemGroup>
<Compile Include="FileVersionInfoTest.cs" />
<Compile Include="AssemblyInfo.cs" />
<Compile Include="$(CommonTestPath)System\IO\ReparsePointUtilities.cs"
<Compile Include="$(CommonTestPath)System\IO\ReparsePointUtilities.cs"
Link="Common\System\IO\ReparsePointUtilities.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'windows'">

View file

@ -4,7 +4,6 @@
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser</TargetFrameworks>
<IgnoreForCI Condition="'$(TargetOS)' == 'browser'">true</IgnoreForCI>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
</PropertyGroup>
<!-- DesignTimeBuild requires all the TargetFramework Derived Properties to not be present in the first property group. -->
<PropertyGroup>

View file

@ -3,7 +3,6 @@
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<StringResourcesPath>$(MSBuildProjectDirectory)\..\src\Resources\Strings.resx</StringResourcesPath>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
</PropertyGroup>
<ItemGroup>

View file

@ -1,6 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser</TargetFrameworks>

View file

@ -4,7 +4,6 @@
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-linux;$(NetCoreAppCurrent)-osx;$(NetCoreAppCurrent)-maccatalyst;$(NetCoreAppCurrent)-freebsd</TargetFrameworks>
<IgnoreForCI Condition="'$(TargetOS)' == 'browser' or '$(TargetOS)' == 'iossimulator' or '$(TargetOS)' == 'ios' or '$(TargetOS)' == 'tvossimulator' or '$(TargetOS)' == 'tvos'">true</IgnoreForCI>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
</PropertyGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />

View file

@ -2,7 +2,6 @@
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
<!-- file locking can't be disabled on Windows -->
<TargetFramework>$(NetCoreAppCurrent)-unix</TargetFramework>

View file

@ -5,7 +5,6 @@
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser</TargetFrameworks>
<WasmXHarnessMonoArgs>--working-dir=/test-dir</WasmXHarnessMonoArgs>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
</PropertyGroup>
<ItemGroup>
<Compile Include="Base\BaseGetSetAttributes.cs" />

View file

@ -3,7 +3,6 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser</TargetFrameworks>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
</PropertyGroup>
<ItemGroup>
<RdXmlFile Include="default.rd.xml" />

View file

@ -4,7 +4,6 @@
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)</TargetFrameworks>
<IgnoreForCI Condition="'$(TargetOS)' == 'browser'">true</IgnoreForCI>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
</PropertyGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />

View file

@ -5,7 +5,6 @@
<StringResourcesPath>../../src/Resources/Strings.resx</StringResourcesPath>
<TargetFramework>$(NetCoreAppCurrent)-windows</TargetFramework>
<DefineConstants>UNITTEST</DefineConstants>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
</PropertyGroup>
<ItemGroup>
<DefaultReferenceExclusion Include="System.Net.Http.WinHttpHandler" />
@ -29,7 +28,7 @@
Link="Common\System\CharArrayHelpers.cs" />
<Compile Include="$(CommonPath)System\StringExtensions.cs"
Link="Common\System\StringExtensions.cs" />
<Compile Include="$(CommonPath)System\Obsoletions.cs"
<Compile Include="$(CommonPath)System\Obsoletions.cs"
Link="Common\System\Obsoletions.cs" />
<Compile Include="$(CommonPath)System\IO\StreamHelpers.CopyValidation.cs"
Link="Common\System\IO\StreamHelpers.CopyValidation.cs" />

View file

@ -7,7 +7,6 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-linux;$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-osx</TargetFrameworks>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
<EnablePreviewFeatures>true</EnablePreviewFeatures>
<EventSourceSupport Condition="'$(TestNativeAot)' == 'true'">true</EventSourceSupport>
</PropertyGroup>

View file

@ -4,7 +4,6 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-osx;$(NetCoreAppCurrent)-maccatalyst;$(NetCoreAppCurrent)-ios;$(NetCoreAppCurrent)-tvos;$(NetCoreAppCurrent)-android</TargetFrameworks>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
</PropertyGroup>
<!-- Do not reference these assemblies from the TargetingPack since we are building part of the source code for tests. -->
<ItemGroup>

View file

@ -2,7 +2,6 @@
<PropertyGroup>
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-osx;$(NetCoreAppCurrent)-ios;$(NetCoreAppCurrent)-android</TargetFrameworks>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<EnablePreviewFeatures>true</EnablePreviewFeatures>
<EventSourceSupport Condition="'$(TestNativeAot)' == 'true'">true</EventSourceSupport>

View file

@ -3,7 +3,6 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<StringResourcesPath>../../src/Resources/Strings.resx</StringResourcesPath>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser</TargetFrameworks>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
</PropertyGroup>
<ItemGroup>
<Compile Include="Base64EncodingTest.cs" />
@ -141,7 +140,7 @@
Link="Common\System\Net\NegotiationInfoClass.cs" />
<Compile Include="$(CommonPath)System\HexConverter.cs"
Link="Common\System\HexConverter.cs" />
<Compile Include="$(CommonPath)System\Obsoletions.cs"
<Compile Include="$(CommonPath)System\Obsoletions.cs"
Link="Common\System\Obsoletions.cs" />
</ItemGroup>
<!-- Unix specific files -->

View file

@ -4,7 +4,6 @@
<StringResourcesPath>../../src/Resources/Strings.resx</StringResourcesPath>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser</TargetFrameworks>
<IgnoreForCI Condition="'$(TargetOS)' == 'browser'">true</IgnoreForCI>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
</PropertyGroup>
<!-- Do not reference these assemblies from the TargetingPack since we are building part of the source code for tests. -->
<ItemGroup>

View file

@ -4,7 +4,6 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
<IgnoreForCI Condition="'$(TargetOS)' == 'browser'">true</IgnoreForCI>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
</PropertyGroup>
<!-- Test APIs introduced after 1.0 -->
<ItemGroup>

View file

@ -3,7 +3,6 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<StringResourcesPath>../../src/Resources/Strings.resx</StringResourcesPath>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser</TargetFrameworks>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
</PropertyGroup>
<PropertyGroup>
<!-- SYSTEM_NET_PRIMITIVES_DLL is required to allow source-level code sharing for types defined within the

View file

@ -4,7 +4,6 @@
<NoWarn>169,649</NoWarn>
<StringResourcesPath>../../src/Resources/Strings.resx</StringResourcesPath>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser</TargetFrameworks>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
</PropertyGroup>
<PropertyGroup>
<!-- SYSTEM_NET_PRIMITIVES_DLL is required to allow source-level code sharing for types defined within the

View file

@ -4,7 +4,6 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-osx;$(NetCoreAppCurrent)-ios</TargetFrameworks>
<IgnoreForCI Condition="'$(TargetOS)' == 'browser'">true</IgnoreForCI>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
<EnablePreviewFeatures>true</EnablePreviewFeatures>
<EventSourceSupport Condition="'$(TestNativeAot)' == 'true'">true</EventSourceSupport>
</PropertyGroup>

View file

@ -12,7 +12,6 @@
<NoWarn>$(NoWarn);3021</NoWarn>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-osx;$(NetCoreAppCurrent)-ios;$(NetCoreAppCurrent)-android</TargetFrameworks>
<IgnoreForCI Condition="'$(TargetOS)' == 'browser'">true</IgnoreForCI>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
</PropertyGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
@ -82,7 +81,7 @@
Link="ProductionCode\Common\System\Net\TlsFrameHelper.cs" />
<Compile Include="$(CommonPath)Interop\Windows\SChannel\Interop.Alerts.cs"
Link="Common\Interop\Windows\SChannel\Interop.Alerts.cs" />
<Compile Include="$(CommonPath)System\Obsoletions.cs"
<Compile Include="$(CommonPath)System\Obsoletions.cs"
Link="Common\System\Obsoletions.cs" />
<!-- IP parser -->
<Compile Include="$(CommonPath)System\Net\IPv4AddressHelper.Common.cs"

View file

@ -17,6 +17,10 @@ namespace System.Runtime.InteropServices
#if SYSTEM_PRIVATE_CORELIB
public
#else
#pragma warning disable CS0436 // Type conflicts with imported type
// Some assemblies that target downlevel have InternalsVisibleTo to their test assembiles.
// As this is only used in this repo and isn't a problem in shipping code,
// just disable the duplicate type warning.
internal
#endif
sealed class LibraryImportAttribute : Attribute

View file

@ -7,8 +7,7 @@
SYSLIB0037: AssemblyName members HashAlgorithm, ProcessorArchitecture, and VersionCompatibility are obsolete. -->
<NoWarn>$(NoWarn);436;SYSLIB0037</NoWarn>
<TargetFrameworks>$(NetCoreAppCurrent);$(NetFrameworkMinimum)</TargetFrameworks>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
<DefineConstants Condition="'$(TargetOS)' == 'browser'">$(DefineConstants);TARGET_BROWSER</DefineConstants>
<DefineConstants Condition="'$(TargetOS)' == 'browser'">$(DefineConstants);TARGET_BROWSER</DefineConstants>
</PropertyGroup>
<ItemGroup>

View file

@ -3,7 +3,6 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TestRuntime>true</TestRuntime>
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser</TargetFrameworks>
<!-- some tests require full ICU data, force it -->

View file

@ -1,7 +1,6 @@
<Project>
<Import Project="..\Directory.Build.props" />
<PropertyGroup>
<EnableLibraryImportGenerator>false</EnableLibraryImportGenerator>
<EnableDefaultItems>true</EnableDefaultItems>
<CLSCompliant>false</CLSCompliant>

View file

@ -2,8 +2,6 @@
<PropertyGroup>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
<IncludeLibraryImportGeneratorSources>false</IncludeLibraryImportGeneratorSources>
<ReferencesNativeExports>true</ReferencesNativeExports>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<!-- Declare InteropCompilerGeneratedFilesOutputPath to put generated files in a single repo to easily view diffs -->

View file

@ -6,6 +6,11 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>UseSeparateAssemblyNamespace;HideTypesWithoutSerializableAttribute</DefineConstants>
<NoWarn>$(NoWarn);169;414</NoWarn>
<!--
This assembly does not have any P/Invokes and there are tests that depend on the specific number of enum types in this assembly.
Disable LibraryImportGenerator to avoid including any of the polyfill sources in this assembly.
-->
<EnableLibraryImportGenerator>false</EnableLibraryImportGenerator>
</PropertyGroup>
<ItemGroup>

View file

@ -4,7 +4,6 @@
<!-- The library is not supported on mobile platforms (PNSE) -->
<IgnoreForCI Condition="'$(TargetOS)' == 'android' or '$(TargetOS)' == 'ios' or '$(TargetOS)' == 'tvos'">true</IgnoreForCI>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
</PropertyGroup>
<ItemGroup>
<Compile Include="EcDsaOpenSslTests.cs" />

View file

@ -5,7 +5,6 @@
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
<NoWarn>$(NoWarn);SYSLIB0021;SYSLIB0026;SYSLIB0027;SYSLIB0028</NoWarn>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
</PropertyGroup>
<ItemGroup>
<RdXmlFile Include="default.rd.xml" />

View file

@ -3,7 +3,6 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<OutputType>Exe</OutputType>
<TargetFrameworks>$(NetCoreAppCurrent);$(NetFrameworkMinimum)</TargetFrameworks>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
</PropertyGroup>
<ItemGroup>
<Compile Include="Helpers.cs" />