Skip to content

Commit

Permalink
SuppressTfmSupportBuildWarnings in generated projects.
Browse files Browse the repository at this point in the history
Updated MultipleFrameworks tests.
  • Loading branch information
timcassell committed Jan 21, 2025
1 parent d71b626 commit df29aba
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

<Nullable>annotations</Nullable>
<!-- Lets supress the "System.Collections.Immutable 8.0.0 doesn't support netcoreapp3.1" warning -->
<!-- Suppress "System.Collections.Immutable 8.0.0 doesn't support netcoreapp3.1" warning -->
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/BenchmarkDotNet/BenchmarkDotNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="3.1.8" PrivateAssets="contentfiles;analyzers" />
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="3.1.6" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" />
<PackageReference Include="System.Management" Version="8.0.0" />
<PackageReference Include="System.Management" Version="6.0.0" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
Expand Down
2 changes: 2 additions & 0 deletions src/BenchmarkDotNet/Templates/CsProj.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
<!-- fix for NETSDK1150: https://docs.microsoft.com/en-us/dotnet/core/compatibility/sdk/5.0/referencing-executable-generates-error -->
<ValidateExecutableReferencesMatchSelfContained>false</ValidateExecutableReferencesMatchSelfContained>
<!-- fix System.Runtime.CompilerServices.Unsafe doesn't support netcoreapp2.0 -->
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
<StartupObject>BenchmarkDotNet.Autogenerated.UniqueProgramName</StartupObject>
</PropertyGroup>

Expand Down
2 changes: 2 additions & 0 deletions src/BenchmarkDotNet/Templates/MonoAOTLLVMCsProj.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<StartupObject>BenchmarkDotNet.Autogenerated.UniqueProgramName</StartupObject>
<SelfContained>true</SelfContained>
<!-- fix System.Runtime.CompilerServices.Unsafe doesn't support netcoreapp2.0 -->
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/BenchmarkDotNet/Templates/WasmCsProj.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
<ValidateExecutableReferencesMatchSelfContained>false</ValidateExecutableReferencesMatchSelfContained>
<EnableDefaultWasmAssembliesToBundle>false</EnableDefaultWasmAssembliesToBundle>
<!-- fix System.Runtime.CompilerServices.Unsafe doesn't support netcoreapp2.0 -->
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
<StartupObject>BenchmarkDotNet.Autogenerated.UniqueProgramName</StartupObject>
</PropertyGroup>

Expand Down
1 change: 1 addition & 0 deletions src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ private string GenerateProjectForNuGetBuild(BuildPartition buildPartition, Artif
<EnsureNETCoreAppRuntime>false</EnsureNETCoreAppRuntime> <!-- workaround for 'This runtime may not be supported by.NET Core.' error -->
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles> <!-- workaround for 'Found multiple publish output files with the same relative path.' error -->
<ValidateExecutableReferencesMatchSelfContained>false</ValidateExecutableReferencesMatchSelfContained>
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings> <!-- fix System.Runtime.CompilerServices.Unsafe doesn't support netcoreapp2.0 -->
{GetInstructionSetSettings(buildPartition)}
</PropertyGroup>
{GetRuntimeSettings(buildPartition.RepresentativeBenchmarkCase.Job.Environment.Gc, buildPartition.Resolver)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,10 @@
<PropertyGroup>
<AssemblyTitle>BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks</AssemblyTitle>
<!-- We test the oldest frameworks supported by BDN (net461 and netcoreapp2.0), as well as newer versions of those frameworks. -->
<TargetFrameworks>net461;net48;netcoreapp2.0;net8.0</TargetFrameworks>
<!-- Deprecated runtime and vulnerabilities from old runtime, just in case any are found in the future. -->
<NoWarn>$(NoWarn);NETSDK1138;NU1901;NU1902;NU1903;NU1904</NoWarn>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<!-- Using netcoreapp2.0 and net461 as one of the target frameworks leads to the following problems:-->
<!-- * NU1903: Package 'Microsoft.NETCore.App' 2.0.0 has a known high severity vulnerability -->
<!-- * Incompability with xunit.runner.visualstudio 2.4.2+ -->
<!-- Therefore, we don't use it explicitly in the source code base to avoid persistent warnings -->
<!-- If you need it for local backward compatibility experiments, do the following: -->
<!-- 1. Add 'netcoreapp2.0;net461' in the list of TargetFrameworks -->
<!-- 2. Add '<NoWarn>$(NoWarn);NU1903</NoWarn>' -->
<!-- 3. Downgrade the xunit.runner.visualstudio NuGet package to v2.4.1 -->
<!-- Please, do not commit these changes to the repository -->
<TargetFrameworks>net462;net48;net8.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AssemblyName>BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks</AssemblyName>
<PackageId>BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks</PackageId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Extensions;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Portability;
using Xunit;

namespace BenchmarkDotNet.IntegrationTests.ManualRunning
{
// Note: To properly test this locally, modify
// BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks.csproj,
// following the comments in that file.
public class MultipleFrameworksTest : BenchmarkTestExecutor
{
private const string TfmEnvVarName = "TfmEnvVarName";
Expand Down Expand Up @@ -60,7 +56,7 @@ public void ThrowWhenWrong()
{
if (Environment.GetEnvironmentVariable(TfmEnvVarName) != moniker.ToString())
{
throw new InvalidOperationException($"Has not been recompiled, the value was {Environment.GetEnvironmentVariable(TfmEnvVarName)}");
throw new InvalidOperationException($"Has not been recompiled, the value was {moniker}, expected {Environment.GetEnvironmentVariable(TfmEnvVarName)}");
}
}
}
Expand Down

0 comments on commit df29aba

Please sign in to comment.