Skip to content

Commit 973cb90

Browse files
authored
Created a combined DLL (#4)
This makes the easy case extremely easy to use. The TFM specific assemblies are still there because they're smaller and can be useful for big solutions like Roslyn. Expectation is most customers will use the combined one
1 parent a82c1c6 commit 973cb90

19 files changed

Lines changed: 3620 additions & 72 deletions

.github/workflows/publish.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ jobs:
2424

2525
- name: Build
2626
run: dotnet build -c Release
27+
28+
- name: Pack Combined
29+
run: dotnet pack --no-build -p:IncludeSymbols=false -p:PackageVersion="${{ github.event.inputs.version }}" -c Release Basic.Reference.Assemblies/Basic.Reference.Assemblies.csproj -o .
2730

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

Basic.Reference.Assemblies.Net50/Basic.Reference.Assemblies.Net50.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<IsPackable>true</IsPackable>
66
</PropertyGroup>
77

8-
98
<ItemGroup>
109
<PackageReference Include="Microsoft.NETCore.App.Ref" Version="5.0.0" IncludeAssets="none" PrivateAssets="all" GeneratePathProperty="true" />
1110
</ItemGroup>

Basic.Reference.Assemblies.Net50/Generated.targets

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
<Project>
2-
<ItemGroup>
3-
<Compile Include="..\Shared\ResourceLoader.cs" Link="ResourceLoader.cs" />
4-
</ItemGroup>
5-
62
<ItemGroup>
73
<EmbeddedResource Include="$(NuGetPackageRoot)\microsoft.netcore.app.ref\5.0.0\ref\net5.0\Microsoft.CSharp.dll">
84
<LogicalName>net50.Microsoft.CSharp</LogicalName>

Basic.Reference.Assemblies.NetCoreApp31/Generated.targets

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
<Project>
2-
<ItemGroup>
3-
<Compile Include="..\Shared\ResourceLoader.cs" Link="ResourceLoader.cs" />
4-
</ItemGroup>
5-
62
<ItemGroup>
73
<EmbeddedResource Include="$(NuGetPackageRoot)\microsoft.netcore.app.ref\3.1.0\ref\netcoreapp3.1\Microsoft.CSharp.dll">
84
<LogicalName>netcoreapp31.Microsoft.CSharp</LogicalName>

Basic.Reference.Assemblies.NetStandard20/Generated.targets

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
<Project>
2-
<ItemGroup>
3-
<Compile Include="..\Shared\ResourceLoader.cs" Link="ResourceLoader.cs" />
4-
</ItemGroup>
5-
62
<ItemGroup>
73
<EmbeddedResource Include="$(NuGetPackageRoot)\netstandard.library\2.0.3\build\netstandard2.0\ref\Microsoft.Win32.Primitives.dll">
84
<LogicalName>netstandard20.Microsoft.Win32.Primitives</LogicalName>

Basic.Reference.Assemblies.UnitTests/Basic.Reference.Assemblies.UnitTests.csproj

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>net5.0</TargetFramework>
@@ -14,9 +14,16 @@
1414
</ItemGroup>
1515

1616
<ItemGroup>
17-
<ProjectReference Include="..\Basic.Reference.Assemblies.Net50\Basic.Reference.Assemblies.Net50.csproj" />
18-
<ProjectReference Include="..\Basic.Reference.Assemblies.NetCoreApp31\Basic.Reference.Assemblies.NetCoreApp31.csproj" />
19-
<ProjectReference Include="..\Basic.Reference.Assemblies.NetStandard20\Basic.Reference.Assemblies.NetStandard20.csproj" />
17+
<ProjectReference Include="..\Basic.Reference.Assemblies.Net50\Basic.Reference.Assemblies.Net50.csproj">
18+
<Aliases>RefNet50</Aliases>
19+
</ProjectReference>
20+
<ProjectReference Include="..\Basic.Reference.Assemblies.NetCoreApp31\Basic.Reference.Assemblies.NetCoreApp31.csproj">
21+
<Aliases>RefNetCoreApp31</Aliases>
22+
</ProjectReference>
23+
<ProjectReference Include="..\Basic.Reference.Assemblies.NetStandard20\Basic.Reference.Assemblies.NetStandard20.csproj">
24+
<Aliases>RefNetStandard20</Aliases>
25+
</ProjectReference>
26+
<ProjectReference Include="..\Basic.Reference.Assemblies\Basic.Reference.Assemblies.csproj" />
2027
</ItemGroup>
2128

2229
</Project>
Lines changed: 32 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Microsoft.CodeAnalysis;
12
using Microsoft.CodeAnalysis.CSharp;
23
using System;
34
using System.IO;
@@ -9,83 +10,66 @@ namespace Basic.Reference.Assemblies.UnitTests
910
public class SanityUnitTests
1011
{
1112
[Fact]
12-
public void NetCoreApp31Tests()
13-
{
14-
foreach (var portableRef in NetCoreApp31.All)
15-
{
16-
Assert.NotNull(portableRef);
17-
}
18-
Assert.True(NetCoreApp31.All.Count() > 50);
19-
}
20-
21-
[Fact]
22-
public void NetCoreApp31Compilation()
13+
public void AllCanCompile()
2314
{
2415
var source = @"
2516
using System;
2617
27-
class Program
18+
public class C
2819
{
20+
public Exception Exception;
21+
2922
static void Main()
3023
{
3124
Console.WriteLine(""Hello World"");
3225
}
3326
}";
34-
var compilation = CSharpCompilation.Create(
35-
"Example",
36-
new[] { CSharpSyntaxTree.ParseText(source) },
37-
references: NetCoreApp31.All);
38-
39-
Assert.Empty(compilation.GetDiagnostics());
40-
using var stream = new MemoryStream();
41-
var emitResult = compilation.Emit(stream);
42-
Assert.True(emitResult.Success);
43-
Assert.Empty(emitResult.Diagnostics);
44-
}
4527

46-
[Fact]
47-
public void Net50Tests()
48-
{
49-
foreach (var portableRef in Net50.All)
28+
foreach (var kind in Enum.GetValues<ReferenceAssemblyKind>())
5029
{
51-
Assert.NotNull(portableRef);
30+
var compilation = CSharpCompilation.Create(
31+
"Example",
32+
new[] { CSharpSyntaxTree.ParseText(source) },
33+
references: ReferenceAssemblies.Get(kind));
34+
35+
Assert.Empty(compilation.GetDiagnostics());
36+
using var stream = new MemoryStream();
37+
var emitResult = compilation.Emit(stream);
38+
Assert.True(emitResult.Success);
39+
Assert.Empty(emitResult.Diagnostics);
5240
}
53-
Assert.True(Net50.All.Count() > 50);
5441
}
5542

5643
[Fact]
57-
public void Net50Compilation()
44+
public void AllCanCompile2()
5845
{
5946
var source = @"
6047
using System;
6148
62-
class Program
49+
public class C
6350
{
51+
public Exception Exception;
52+
6453
static void Main()
6554
{
6655
Console.WriteLine(""Hello World"");
6756
}
6857
}";
69-
var compilation = CSharpCompilation.Create(
70-
"Example",
71-
new[] { CSharpSyntaxTree.ParseText(source) },
72-
references: Net50.All);
7358

74-
Assert.Empty(compilation.GetDiagnostics());
75-
using var stream = new MemoryStream();
76-
var emitResult = compilation.Emit(stream);
77-
Assert.True(emitResult.Success);
78-
Assert.Empty(emitResult.Diagnostics);
79-
}
80-
81-
[Fact]
82-
public void NetStandard20Tests()
83-
{
84-
foreach (var portableRef in NetStandard20.All)
59+
foreach (var kind in Enum.GetValues<ReferenceAssemblyKind>())
8560
{
86-
Assert.NotNull(portableRef);
61+
var compilation = CSharpCompilation.Create(
62+
"Example",
63+
new[] { CSharpSyntaxTree.ParseText(source) },
64+
references: Array.Empty<MetadataReference>());
65+
compilation = compilation.WithReferenceAssemblies(kind);
66+
67+
Assert.Empty(compilation.GetDiagnostics());
68+
using var stream = new MemoryStream();
69+
var emitResult = compilation.Emit(stream);
70+
Assert.True(emitResult.Success);
71+
Assert.Empty(emitResult.Diagnostics);
8772
}
88-
Assert.True(NetStandard20.All.Count() > 50);
8973
}
9074
}
9175
}
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
extern alias RefNetCoreApp31;
2+
extern alias RefNet50;
3+
extern alias RefNetStandard20;
4+
5+
using Microsoft.CodeAnalysis.CSharp;
6+
using System;
7+
using System.IO;
8+
using System.Linq;
9+
using Xunit;
10+
11+
namespace Basic.Reference.Assemblies.UnitTests
12+
{
13+
using Net50 = RefNet50::Basic.Reference.Assemblies.Net50;
14+
using NetCoreApp31 = RefNetCoreApp31::Basic.Reference.Assemblies.NetCoreApp31;
15+
using NetStandard20 = RefNetStandard20::Basic.Reference.Assemblies.NetStandard20;
16+
17+
public class SpecificSanityUnitTests
18+
{
19+
[Fact]
20+
public void NetCoreApp31Tests()
21+
{
22+
foreach (var portableRef in NetCoreApp31.All)
23+
{
24+
Assert.NotNull(portableRef);
25+
}
26+
Assert.True(NetCoreApp31.All.Count() > 50);
27+
Assert.Equal("Basic.Reference.Assemblies.NetCoreApp31", typeof(NetCoreApp31).Assembly.GetName().Name);
28+
}
29+
30+
[Fact]
31+
public void NetCoreApp31Compilation()
32+
{
33+
var source = @"
34+
using System;
35+
36+
class Program
37+
{
38+
static void Main()
39+
{
40+
Console.WriteLine(""Hello World"");
41+
}
42+
}";
43+
var compilation = CSharpCompilation.Create(
44+
"Example",
45+
new[] { CSharpSyntaxTree.ParseText(source) },
46+
references: NetCoreApp31.All);
47+
48+
Assert.Empty(compilation.GetDiagnostics());
49+
using var stream = new MemoryStream();
50+
var emitResult = compilation.Emit(stream);
51+
Assert.True(emitResult.Success);
52+
Assert.Empty(emitResult.Diagnostics);
53+
}
54+
55+
[Fact]
56+
public void Net50Tests()
57+
{
58+
foreach (var portableRef in Net50.All)
59+
{
60+
Assert.NotNull(portableRef);
61+
}
62+
Assert.True(Net50.All.Count() > 50);
63+
Assert.Equal("Basic.Reference.Assemblies.Net50", typeof(Net50).Assembly.GetName().Name);
64+
}
65+
66+
[Fact]
67+
public void Net50Compilation()
68+
{
69+
var source = @"
70+
using System;
71+
72+
class Program
73+
{
74+
static void Main()
75+
{
76+
Console.WriteLine(""Hello World"");
77+
}
78+
}";
79+
var compilation = CSharpCompilation.Create(
80+
"Example",
81+
new[] { CSharpSyntaxTree.ParseText(source) },
82+
references: Net50.All);
83+
84+
Assert.Empty(compilation.GetDiagnostics());
85+
using var stream = new MemoryStream();
86+
var emitResult = compilation.Emit(stream);
87+
Assert.True(emitResult.Success);
88+
Assert.Empty(emitResult.Diagnostics);
89+
}
90+
91+
[Fact]
92+
public void NetStandard20Tests()
93+
{
94+
foreach (var portableRef in NetStandard20.All)
95+
{
96+
Assert.NotNull(portableRef);
97+
}
98+
Assert.True(NetStandard20.All.Count() > 50);
99+
Assert.Equal("Basic.Reference.Assemblies.NetStandard20", typeof(NetStandard20).Assembly.GetName().Name);
100+
}
101+
}
102+
}

Basic.Reference.Assemblies.sln

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ VisualStudioVersion = 16.0.30907.101
55
MinimumVisualStudioVersion = 15.0.26124.0
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Basic.Reference.Assemblies.NetCoreApp31", "Basic.Reference.Assemblies.NetCoreApp31\Basic.Reference.Assemblies.NetCoreApp31.csproj", "{23924D94-13B5-48E4-B90D-E55ADB6E5404}"
77
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Basic.Reference.Assemblies.UnitTests", "Basic.Reference.Assemblies.UnitTests\Basic.Reference.Assemblies.UnitTests.csproj", "{DF2FCB24-4D84-46F8-9469-CC48C9AC9CC5}"
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Basic.Reference.Assemblies.UnitTests", "Basic.Reference.Assemblies.UnitTests\Basic.Reference.Assemblies.UnitTests.csproj", "{DF2FCB24-4D84-46F8-9469-CC48C9AC9CC5}"
99
EndProject
10-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Basic.Reference.Assemblies.Net50", "Basic.Reference.Assemblies.Net50\Basic.Reference.Assemblies.Net50.csproj", "{A14B94F6-BC0E-4412-ACDF-9C9640220B03}"
10+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Basic.Reference.Assemblies.Net50", "Basic.Reference.Assemblies.Net50\Basic.Reference.Assemblies.Net50.csproj", "{A14B94F6-BC0E-4412-ACDF-9C9640220B03}"
1111
EndProject
12-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Basic.Reference.Assemblies.NetStandard20", "Basic.Reference.Assemblies.NetStandard20\Basic.Reference.Assemblies.NetStandard20.csproj", "{36D1BA52-3A5E-4680-8B47-26A308DFC889}"
12+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Basic.Reference.Assemblies.NetStandard20", "Basic.Reference.Assemblies.NetStandard20\Basic.Reference.Assemblies.NetStandard20.csproj", "{36D1BA52-3A5E-4680-8B47-26A308DFC889}"
13+
EndProject
14+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Basic.Reference.Assemblies", "Basic.Reference.Assemblies\Basic.Reference.Assemblies.csproj", "{28EA430D-F84C-46DE-B2EC-D60D1C0A437C}"
1315
EndProject
1416
Global
1517
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -69,6 +71,18 @@ Global
6971
{36D1BA52-3A5E-4680-8B47-26A308DFC889}.Release|x64.Build.0 = Release|Any CPU
7072
{36D1BA52-3A5E-4680-8B47-26A308DFC889}.Release|x86.ActiveCfg = Release|Any CPU
7173
{36D1BA52-3A5E-4680-8B47-26A308DFC889}.Release|x86.Build.0 = Release|Any CPU
74+
{28EA430D-F84C-46DE-B2EC-D60D1C0A437C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
75+
{28EA430D-F84C-46DE-B2EC-D60D1C0A437C}.Debug|Any CPU.Build.0 = Debug|Any CPU
76+
{28EA430D-F84C-46DE-B2EC-D60D1C0A437C}.Debug|x64.ActiveCfg = Debug|Any CPU
77+
{28EA430D-F84C-46DE-B2EC-D60D1C0A437C}.Debug|x64.Build.0 = Debug|Any CPU
78+
{28EA430D-F84C-46DE-B2EC-D60D1C0A437C}.Debug|x86.ActiveCfg = Debug|Any CPU
79+
{28EA430D-F84C-46DE-B2EC-D60D1C0A437C}.Debug|x86.Build.0 = Debug|Any CPU
80+
{28EA430D-F84C-46DE-B2EC-D60D1C0A437C}.Release|Any CPU.ActiveCfg = Release|Any CPU
81+
{28EA430D-F84C-46DE-B2EC-D60D1C0A437C}.Release|Any CPU.Build.0 = Release|Any CPU
82+
{28EA430D-F84C-46DE-B2EC-D60D1C0A437C}.Release|x64.ActiveCfg = Release|Any CPU
83+
{28EA430D-F84C-46DE-B2EC-D60D1C0A437C}.Release|x64.Build.0 = Release|Any CPU
84+
{28EA430D-F84C-46DE-B2EC-D60D1C0A437C}.Release|x86.ActiveCfg = Release|Any CPU
85+
{28EA430D-F84C-46DE-B2EC-D60D1C0A437C}.Release|x86.Build.0 = Release|Any CPU
7286
EndGlobalSection
7387
GlobalSection(SolutionProperties) = preSolution
7488
HideSolutionNode = FALSE
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
<IsPackable>true</IsPackable>
6+
</PropertyGroup>
7+
8+
<Import Project="Generated.Net50.targets" />
9+
<Import Project="Generated.NetCoreApp31.targets" />
10+
<Import Project="Generated.NetStandard20.targets" />
11+
</Project>

0 commit comments

Comments
 (0)