Skip to content

Commit

Permalink
Failing test for NRE when NoWarn is empty (happens in default .fsproj…
Browse files Browse the repository at this point in the history
… too)
  • Loading branch information
jnm2 committed Jan 3, 2020
1 parent 8b67de6 commit 0d5297a
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
5 changes: 5 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ test_script:
- git clean -dxf tests
- msbuild /restore tests/RefVersion3.1.0 /warnaserror /nr:false /v:m
- git clean -dxf tests
# No /warnaserror because WarningsNotAsErrors is not respected
- msbuild /restore tests/NoDisabledWarnings /nr:false /v:m
- git clean -dxf tests
- msbuild /restore tests/SingleTFM /p:TestFramework=net35 /warnaserror /nr:false /v:m
- git clean -dxf tests
- msbuild /restore tests/SingleTFM /p:TestFramework=net48 /warnaserror /nr:false /v:m
Expand Down Expand Up @@ -44,6 +47,8 @@ test_script:
- git clean -dxf tests
- dotnet msbuild -restore tests/RefVersion3.1.0 -warnaserror -nr:false -v:m
- git clean -dxf tests
- dotnet msbuild -restore tests/NoDisabledWarnings -warnaserror -nr:false -v:m
- git clean -dxf tests
- dotnet msbuild -restore tests/SingleTFM -p:TestFramework=net35 -warnaserror -nr:false -v:m
- git clean -dxf tests
- dotnet msbuild -restore tests/SingleTFM -p:TestFramework=net48 -warnaserror -nr:false -v:m
Expand Down
19 changes: 19 additions & 0 deletions tests/NoDisabledWarnings/Class1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Diagnostics.CodeAnalysis;

namespace Sample1
{
public class Class1
{
public static void M(SqlConnection connection, [AllowNull] string? x)
{
if (!string.IsNullOrEmpty(x))
{
x.ToString();
}

_ = EqualityComparer<string?>.Default.GetHashCode(x);
}
}
}
32 changes: 32 additions & 0 deletions tests/NoDisabledWarnings/NoDisabledWarnings.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net35;net48;netstandard1.6;netstandard2.0;netstandard2.1;netcoreapp1.0;netcoreapp1.1;netcoreapp2.0;netcoreapp2.1;netcoreapp3.0;netcoreapp3.1</TargetFrameworks>
<LangVersion>8</LangVersion>
<Nullable>enable</Nullable>
<WarningsNotAsErrors>RA1000</WarningsNotAsErrors>
<NoWarn></NoWarn>
</PropertyGroup>

<PropertyGroup>
<!-- NuGet cannot restore packages for netcoreapp1.0: https://github.com/NuGet/Home/issues/7414 -->
<DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp1.0' OR '$(TargetFramework)' == 'netcoreapp1.1'">
<!-- CS1701: Assuming assembly reference "Assembly Name #1" matches "Assembly Name #2", you may need to supply runtime policy -->
<WarningsNotAsErrors>$(WarningsNotAsErrors),CS1701</WarningsNotAsErrors>
</PropertyGroup>

<ItemGroup>
<!-- https://github.com/dotnet/core-sdk/issues/2022 -->
<PackageReference Condition="'$(TargetFramework)' == 'net35'" Include="jnm2.ReferenceAssemblies.net35" Version="1.0.0" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<PackageReference Condition="'$(TargetFramework)' != 'net35'" Include="System.Data.SqlClient" Version="4.8.0" />
<PackageReference Include="TunnelVisionLabs.ReferenceAssemblyAnnotator" Version="1.0.0-alpha.*" PrivateAssets="all" />
<PackageDownload Include="Microsoft.NETCore.App.Ref" Version="[3.0.0]" />
</ItemGroup>

</Project>

0 comments on commit 0d5297a

Please sign in to comment.