Skip to content

Commit

Permalink
Merge pull request #62 from jnm2/fix_ref_package_path
Browse files Browse the repository at this point in the history
Fix missing annotations when using Microsoft.NETCore.App.Ref 3.1.0
  • Loading branch information
sharwell authored Dec 31, 2019
2 parents 819b787 + 11eddda commit 496869e
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<PropertyGroup>
<AnnotateReferenceAssembliesDependsOn>
ResolveAnnotatedReferenceAssemblies;
ResolveAvailableReferenceAssemblies;
ResolveOutputReferenceAssemblies
</AnnotateReferenceAssembliesDependsOn>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,21 @@
<AddStandardAssembliesForAnnotationDependsOn>ResolveTargetingPackAssets</AddStandardAssembliesForAnnotationDependsOn>
</PropertyGroup>

<PropertyGroup>
<AnnotatedReferenceAssemblyDirectory Condition="'$(AnnotatedReferenceAssemblyDirectory)' == ''">$(NuGetPackageRoot)\microsoft.netcore.app.ref\$(AnnotatedReferenceAssemblyVersion)\ref\netcoreapp3.0\</AnnotatedReferenceAssemblyDirectory>
</PropertyGroup>
<Target Name="ResolveAnnotatedReferenceAssemblies">
<ItemGroup Condition="'$(AnnotatedReferenceAssemblyDirectory)' == ''">
<_AnnotatedReferenceAssemblyDirectoryContents Include="$(NuGetPackageRoot)\microsoft.netcore.app.ref\$(AnnotatedReferenceAssemblyVersion)\ref\*\*.dll" />
<_AnnotatedReferenceAssemblyDirectoryItem Include="@(_AnnotatedReferenceAssemblyDirectoryContents->'%(RelativeDir)')" />
</ItemGroup>

<ItemGroup>
<AnnotatedReferenceAssembly Include="$(AnnotatedReferenceAssemblyDirectory)*.dll" />
</ItemGroup>
<PropertyGroup Condition="'$(AnnotatedReferenceAssemblyDirectory)' == ''">
<!-- Take last item -->
<AnnotatedReferenceAssemblyDirectory>%(_AnnotatedReferenceAssemblyDirectoryItem.Identity)</AnnotatedReferenceAssemblyDirectory>
</PropertyGroup>

<ItemGroup>
<AnnotatedReferenceAssembly Include="$(AnnotatedReferenceAssemblyDirectory)*.dll" />
</ItemGroup>
</Target>

<Target Name="ResolveAvailableReferenceAssemblies"
DependsOnTargets="GetReferenceAssemblyPaths">
Expand Down
5 changes: 5 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ test_script:
- git clean -dxf tests
- msbuild /restore tests/MultiTFM /warnaserror /v:m
- git clean -dxf tests
- msbuild /restore tests/RefVersion3.1.0 /warnaserror /v:m
- git clean -dxf tests
- msbuild /restore tests/SingleTFM /p:TestFramework=net35 /warnaserror /v:m
- git clean -dxf tests
- msbuild /restore tests/SingleTFM /p:TestFramework=net48 /warnaserror /v:m
Expand All @@ -41,6 +43,9 @@ test_script:
- dotnet msbuild -restore tests/MultiTFM -warnaserror -v:m
- taskkill /im dotnet.exe /f
- git clean -dxf tests
- dotnet msbuild -restore tests/RefVersion3.1.0 -warnaserror -v:m
- taskkill /im dotnet.exe /f
- git clean -dxf tests
- dotnet msbuild -restore tests/SingleTFM -p:TestFramework=net35 -warnaserror -v:m
- taskkill /im dotnet.exe /f
- git clean -dxf tests
Expand Down
19 changes: 19 additions & 0 deletions tests/RefVersion3.1.0/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/RefVersion3.1.0/RefVersion3.1.0.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>
<AnnotatedReferenceAssemblyVersion>3.1.0</AnnotatedReferenceAssemblyVersion>
<NoWarn>RA1000</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 -->
<NoWarn>$(NoWarn),CS1701</NoWarn>
</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="[$(AnnotatedReferenceAssemblyVersion)]" />
</ItemGroup>

</Project>

0 comments on commit 496869e

Please sign in to comment.