Skip to content

Commit

Permalink
Net461 support (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredpar authored Aug 30, 2021
1 parent 8102c83 commit 745c190
Show file tree
Hide file tree
Showing 12 changed files with 3,832 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ jobs:
- name: Pack NetStandard20
run: dotnet pack --no-build -p:IncludeSymbols=false -p:RepositoryCommit=${GITHUB_SHA} -p:PackageVersion="${{ github.event.inputs.version }}" -c Release Basic.Reference.Assemblies.NetStandard20/Basic.Reference.Assemblies.NetStandard20.csproj -o .

- name: Pack Net461
run: dotnet pack --no-build -p:IncludeSymbols=false -p:RepositoryCommit=${GITHUB_SHA} -p:PackageVersion="${{ github.event.inputs.version }}" -c Release Basic.Reference.Assemblies.Net461/Basic.Reference.Assemblies.Net461.csproj -o .

- name: Pack Net472
run: dotnet pack --no-build -p:IncludeSymbols=false -p:RepositoryCommit=${GITHUB_SHA} -p:PackageVersion="${{ github.event.inputs.version }}" -c Release Basic.Reference.Assemblies.Net472/Basic.Reference.Assemblies.Net472.csproj -o .


- name: Publish NuPkg Files
run: dotnet nuget push "*.nupkg" -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<IsPackable>true</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net461" Version="1.0.2" IncludeAssets="none" PrivateAssets="all" GeneratePathProperty="true" />
</ItemGroup>

<Import Project="Generated.targets" />

</Project>
1,138 changes: 1,138 additions & 0 deletions Basic.Reference.Assemblies.Net461/Generated.cs

Large diffs are not rendered by default.

736 changes: 736 additions & 0 deletions Basic.Reference.Assemblies.Net461/Generated.targets

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
<ProjectReference Include="..\Basic.Reference.Assemblies.Net472\Basic.Reference.Assemblies.Net472.csproj">
<Aliases>RefNet472</Aliases>
</ProjectReference>
<ProjectReference Include="..\Basic.Reference.Assemblies.Net461\Basic.Reference.Assemblies.Net461.csproj">
<Aliases>RefNet461</Aliases>
</ProjectReference>
<ProjectReference Include="..\Basic.Reference.Assemblies\Basic.Reference.Assemblies.csproj" />
</ItemGroup>

Expand Down
38 changes: 38 additions & 0 deletions Basic.Reference.Assemblies.UnitTests/SpecificSanityUnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
extern alias RefNet50;
extern alias RefNet60;
extern alias RefNetStandard20;
extern alias RefNet461;
extern alias RefNet472;

using Microsoft.CodeAnalysis.CSharp;
Expand All @@ -16,6 +17,7 @@ namespace Basic.Reference.Assemblies.UnitTests
using Net60 = RefNet60::Basic.Reference.Assemblies.Net60;
using NetCoreApp31 = RefNetCoreApp31::Basic.Reference.Assemblies.NetCoreApp31;
using NetStandard20 = RefNetStandard20::Basic.Reference.Assemblies.NetStandard20;
using Net461 = RefNet461::Basic.Reference.Assemblies.Net461;
using Net472 = RefNet472::Basic.Reference.Assemblies.Net472;

public class SpecificSanityUnitTests
Expand Down Expand Up @@ -139,6 +141,42 @@ public void NetStandard20Tests()
Assert.Equal("Basic.Reference.Assemblies.NetStandard20", typeof(NetStandard20).Assembly.GetName().Name);
}

[Fact]
public void Net461Tests()
{
foreach (var portableRef in Net461.All)
{
Assert.NotNull(portableRef);
}
Assert.True(Net461.All.Count() > 50);
Assert.Equal("Basic.Reference.Assemblies.Net461", typeof(Net461).Assembly.GetName().Name);
}

[Fact]
public void Net461Compilation()
{
var source = @"
using System;
class Program
{
static void Main()
{
Console.WriteLine(""Hello World"");
}
}";
var compilation = CSharpCompilation.Create(
"Example",
new[] { CSharpSyntaxTree.ParseText(source) },
references: Net461.All);

Assert.Empty(compilation.GetDiagnostics());
using var stream = new MemoryStream();
var emitResult = compilation.Emit(stream);
Assert.True(emitResult.Success);
Assert.Empty(emitResult.Diagnostics);
}

[Fact]
public void Net472Tests()
{
Expand Down
14 changes: 14 additions & 0 deletions Basic.Reference.Assemblies.sln
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Basic.Reference.Assemblies.Net60", "Basic.Reference.Assemblies.Net60\Basic.Reference.Assemblies.Net60.csproj", "{E2269796-09B5-40C8-85ED-476B5E71B29D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Basic.Reference.Assemblies.Net461", "Basic.Reference.Assemblies.Net461\Basic.Reference.Assemblies.Net461.csproj", "{214260A9-1E3C-400C-A0D1-2BD099F60AD7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -116,6 +118,18 @@ Global
{E2269796-09B5-40C8-85ED-476B5E71B29D}.Release|x64.Build.0 = Release|Any CPU
{E2269796-09B5-40C8-85ED-476B5E71B29D}.Release|x86.ActiveCfg = Release|Any CPU
{E2269796-09B5-40C8-85ED-476B5E71B29D}.Release|x86.Build.0 = Release|Any CPU
{214260A9-1E3C-400C-A0D1-2BD099F60AD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{214260A9-1E3C-400C-A0D1-2BD099F60AD7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{214260A9-1E3C-400C-A0D1-2BD099F60AD7}.Debug|x64.ActiveCfg = Debug|Any CPU
{214260A9-1E3C-400C-A0D1-2BD099F60AD7}.Debug|x64.Build.0 = Debug|Any CPU
{214260A9-1E3C-400C-A0D1-2BD099F60AD7}.Debug|x86.ActiveCfg = Debug|Any CPU
{214260A9-1E3C-400C-A0D1-2BD099F60AD7}.Debug|x86.Build.0 = Debug|Any CPU
{214260A9-1E3C-400C-A0D1-2BD099F60AD7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{214260A9-1E3C-400C-A0D1-2BD099F60AD7}.Release|Any CPU.Build.0 = Release|Any CPU
{214260A9-1E3C-400C-A0D1-2BD099F60AD7}.Release|x64.ActiveCfg = Release|Any CPU
{214260A9-1E3C-400C-A0D1-2BD099F60AD7}.Release|x64.Build.0 = Release|Any CPU
{214260A9-1E3C-400C-A0D1-2BD099F60AD7}.Release|x86.ActiveCfg = Release|Any CPU
{214260A9-1E3C-400C-A0D1-2BD099F60AD7}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
<Import Project="Generated.Net60.targets" />
<Import Project="Generated.NetCoreApp31.targets" />
<Import Project="Generated.NetStandard20.targets" />
<Import Project="Generated.Net461.targets" />
<Import Project="Generated.Net472.targets" />
</Project>
3 changes: 3 additions & 0 deletions Basic.Reference.Assemblies/BasicReferenceAssemblies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public static class ReferenceAssemblies
public static IEnumerable<PortableExecutableReference> Net50 => Basic.Reference.Assemblies.Net50.All;
public static IEnumerable<PortableExecutableReference> Net60 => Basic.Reference.Assemblies.Net60.All;
public static IEnumerable<PortableExecutableReference> NetStandard20 => Basic.Reference.Assemblies.NetStandard20.All;
public static IEnumerable<PortableExecutableReference> Net461 => Basic.Reference.Assemblies.Net461.All;
public static IEnumerable<PortableExecutableReference> Net472 => Basic.Reference.Assemblies.Net472.All;

public static IEnumerable<PortableExecutableReference> Get(ReferenceAssemblyKind kind) => kind switch
Expand All @@ -20,6 +21,7 @@ public static class ReferenceAssemblies
ReferenceAssemblyKind.Net50 => Net50,
ReferenceAssemblyKind.Net60 => Net60,
ReferenceAssemblyKind.NetStandard20 => NetStandard20,
ReferenceAssemblyKind.Net461 => Net461,
ReferenceAssemblyKind.Net472 => Net472,
_ => throw new Exception($"Invalid kind: {kind}")
};
Expand All @@ -31,6 +33,7 @@ public enum ReferenceAssemblyKind
Net50,
Net60,
NetStandard20,
Net461,
Net472,
}

Expand Down
Loading

0 comments on commit 745c190

Please sign in to comment.