Skip to content

Commit b9fc77e

Browse files
committed
Initial change to combined having fewer refs
First steps of #27
1 parent 0d726a6 commit b9fc77e

19 files changed

Lines changed: 82 additions & 7912 deletions

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

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,16 @@
1414
</ItemGroup>
1515

1616
<ItemGroup>
17-
<ProjectReference Include="..\Basic.Reference.Assemblies.Net50\Basic.Reference.Assemblies.Net50.csproj">
18-
<Aliases>RefNet50</Aliases>
17+
<ProjectReference Include="..\Basic.Reference.Assemblies.Net50\Basic.Reference.Assemblies.Net50.csproj" />
18+
<ProjectReference Include="..\Basic.Reference.Assemblies.Net60\Basic.Reference.Assemblies.Net60.csproj" />
19+
<ProjectReference Include="..\Basic.Reference.Assemblies.NetCoreApp31\Basic.Reference.Assemblies.NetCoreApp31.csproj" />
20+
<ProjectReference Include="..\Basic.Reference.Assemblies.NetStandard13\Basic.Reference.Assemblies.NetStandard13.csproj" />
21+
<ProjectReference Include="..\Basic.Reference.Assemblies.NetStandard20\Basic.Reference.Assemblies.NetStandard20.csproj" />
22+
<ProjectReference Include="..\Basic.Reference.Assemblies.Net472\Basic.Reference.Assemblies.Net472.csproj" />
23+
<ProjectReference Include="..\Basic.Reference.Assemblies.Net461\Basic.Reference.Assemblies.Net461.csproj" />
24+
<ProjectReference Include="..\Basic.Reference.Assemblies\Basic.Reference.Assemblies.csproj">
25+
<Aliases>Combined</Aliases>
1926
</ProjectReference>
20-
<ProjectReference Include="..\Basic.Reference.Assemblies.Net60\Basic.Reference.Assemblies.Net60.csproj">
21-
<Aliases>RefNet60</Aliases>
22-
</ProjectReference>
23-
<ProjectReference Include="..\Basic.Reference.Assemblies.NetCoreApp31\Basic.Reference.Assemblies.NetCoreApp31.csproj">
24-
<Aliases>RefNetCoreApp31</Aliases>
25-
</ProjectReference>
26-
<ProjectReference Include="..\Basic.Reference.Assemblies.NetStandard13\Basic.Reference.Assemblies.NetStandard13.csproj">
27-
<Aliases>RefNetStandard13</Aliases>
28-
</ProjectReference>
29-
<ProjectReference Include="..\Basic.Reference.Assemblies.NetStandard20\Basic.Reference.Assemblies.NetStandard20.csproj">
30-
<Aliases>RefNetStandard20</Aliases>
31-
</ProjectReference>
32-
<ProjectReference Include="..\Basic.Reference.Assemblies.Net472\Basic.Reference.Assemblies.Net472.csproj">
33-
<Aliases>RefNet472</Aliases>
34-
</ProjectReference>
35-
<ProjectReference Include="..\Basic.Reference.Assemblies.Net461\Basic.Reference.Assemblies.Net461.csproj">
36-
<Aliases>RefNet461</Aliases>
37-
</ProjectReference>
38-
<ProjectReference Include="..\Basic.Reference.Assemblies\Basic.Reference.Assemblies.csproj" />
3927
</ItemGroup>
4028

4129
</Project>

Basic.Reference.Assemblies.UnitTests/SanityUnitTests.cs

Lines changed: 34 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Microsoft.CodeAnalysis;
22
using Microsoft.CodeAnalysis.CSharp;
33
using System;
4+
using System.Collections.Generic;
45
using System.IO;
56
using System.Linq;
67
using Xunit;
@@ -9,8 +10,9 @@ namespace Basic.Reference.Assemblies.UnitTests
910
{
1011
public class SanityUnitTests
1112
{
12-
[Fact]
13-
public void AllCanCompile()
13+
[Theory]
14+
[MemberData(nameof(TestData.ApplicationReferences), MemberType = typeof(TestData))]
15+
public void AllAppCanCompile(string targetFramework, IEnumerable<MetadataReference> references)
1416
{
1517
var source = @"
1618
using System;
@@ -25,30 +27,22 @@ static void Main()
2527
}
2628
}";
2729

28-
foreach (var kind in Enum.GetValues<ReferenceAssemblyKind>())
29-
{
30-
var compilation = CSharpCompilation.Create(
31-
"Example",
32-
new[] { CSharpSyntaxTree.ParseText(source) },
33-
references: ReferenceAssemblies.Get(kind));
34-
35-
// NetStandard1.3 comes with several no warn options we need here
36-
if (kind == ReferenceAssemblyKind.NetStandard13)
37-
{
38-
compilation = NoWarn(compilation, "CS1702");
39-
compilation = NoWarn(compilation, "CS1701");
40-
}
30+
var compilation = CSharpCompilation.Create(
31+
"Example",
32+
new[] { CSharpSyntaxTree.ParseText(source) },
33+
references: references);
4134

42-
Assert.Empty(compilation.GetDiagnostics());
43-
using var stream = new MemoryStream();
44-
var emitResult = compilation.Emit(stream);
45-
Assert.True(emitResult.Success);
46-
Assert.Empty(emitResult.Diagnostics);
47-
}
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);
40+
Assert.NotEmpty(targetFramework);
4841
}
4942

50-
[Fact]
51-
public void AllCanCompile2()
43+
[Theory]
44+
[MemberData(nameof(TestData.AllReferences), MemberType = typeof(TestData))]
45+
public void AllLibraryCanCompile(string targetFramework, IEnumerable<MetadataReference> references)
5246
{
5347
var source = @"
5448
using System;
@@ -63,27 +57,25 @@ static void Main()
6357
}
6458
}";
6559

66-
foreach (var kind in Enum.GetValues<ReferenceAssemblyKind>())
67-
{
68-
var compilation = CSharpCompilation.Create(
69-
"Example",
70-
new[] { CSharpSyntaxTree.ParseText(source) },
71-
references: Array.Empty<MetadataReference>());
72-
compilation = compilation.WithReferenceAssemblies(kind);
60+
var options = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary);
61+
var compilation = CSharpCompilation.Create(
62+
"Example",
63+
new[] { CSharpSyntaxTree.ParseText(source) },
64+
options: options,
65+
references: references);
7366

74-
// NetStandard1.3 comes with several no warn options we need here
75-
if (kind == ReferenceAssemblyKind.NetStandard13)
76-
{
77-
compilation = NoWarn(compilation, "CS1702");
78-
compilation = NoWarn(compilation, "CS1701");
79-
}
80-
81-
Assert.Empty(compilation.GetDiagnostics());
82-
using var stream = new MemoryStream();
83-
var emitResult = compilation.Emit(stream);
84-
Assert.True(emitResult.Success);
85-
Assert.Empty(emitResult.Diagnostics);
67+
// NetStandard1.3 comes with several no warn options we need here
68+
if (targetFramework == "netstandard1.3")
69+
{
70+
compilation = NoWarn(compilation, "CS1702");
71+
compilation = NoWarn(compilation, "CS1701");
8672
}
73+
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);
8779
}
8880

8981
private static CSharpCompilation NoWarn(CSharpCompilation compilation, string id)

Basic.Reference.Assemblies.UnitTests/SpecificSanityUnitTests.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
extern alias RefNetCoreApp31;
2-
extern alias RefNet50;
3-
extern alias RefNet60;
4-
extern alias RefNetStandard13;
5-
extern alias RefNetStandard20;
6-
extern alias RefNet461;
7-
extern alias RefNet472;
8-
91
using Microsoft.CodeAnalysis;
102
using Microsoft.CodeAnalysis.CSharp;
113
using Microsoft.CodeAnalysis.CSharp.Syntax;
@@ -16,14 +8,6 @@
168

179
namespace Basic.Reference.Assemblies.UnitTests
1810
{
19-
using Net50 = RefNet50::Basic.Reference.Assemblies.Net50;
20-
using Net60 = RefNet60::Basic.Reference.Assemblies.Net60;
21-
using NetCoreApp31 = RefNetCoreApp31::Basic.Reference.Assemblies.NetCoreApp31;
22-
using NetStandard13 = RefNetStandard13::Basic.Reference.Assemblies.NetStandard13;
23-
using NetStandard20 = RefNetStandard20::Basic.Reference.Assemblies.NetStandard20;
24-
using Net461 = RefNet461::Basic.Reference.Assemblies.Net461;
25-
using Net472 = RefNet472::Basic.Reference.Assemblies.Net472;
26-
2711
public class SpecificSanityUnitTests
2812
{
2913
[Fact]
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace Basic.Reference.Assemblies.UnitTests
8+
{
9+
public static class TestData
10+
{
11+
public static IEnumerable<object[]> ApplicationReferences
12+
{
13+
get
14+
{
15+
return new object[][]
16+
{
17+
new object[] { "net461", Net461.All },
18+
};
19+
}
20+
}
21+
22+
public static IEnumerable<object[]> LibraryReferences
23+
{
24+
get
25+
{
26+
return new object[][]
27+
{
28+
new object[] { "netstandard1.3", NetStandard13.All },
29+
new object[] { "netstandard2.0", NetStandard20.All },
30+
};
31+
}
32+
}
33+
34+
public static IEnumerable<object[]> AllReferences
35+
{
36+
get => LibraryReferences.Concat(ApplicationReferences);
37+
}
38+
}
39+
}

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

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

8-
<Import Project="Generated.Net50.targets" />
98
<Import Project="Generated.Net60.targets" />
10-
<Import Project="Generated.Net70.targets" />
11-
<Import Project="Generated.NetCoreApp31.targets" />
12-
<Import Project="Generated.NetStandard13.targets" />
139
<Import Project="Generated.NetStandard20.targets" />
14-
<Import Project="Generated.Net461.targets" />
1510
<Import Project="Generated.Net472.targets" />
1611
</Project>

Basic.Reference.Assemblies/BasicReferenceAssemblies.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,23 @@ namespace Basic.Reference.Assemblies
88
{
99
public static class ReferenceAssemblies
1010
{
11-
public static IEnumerable<PortableExecutableReference> NetCoreApp31 => Basic.Reference.Assemblies.NetCoreApp31.All;
12-
public static IEnumerable<PortableExecutableReference> Net50 => Basic.Reference.Assemblies.Net50.All;
1311
public static IEnumerable<PortableExecutableReference> Net60 => Basic.Reference.Assemblies.Net60.All;
14-
public static IEnumerable<PortableExecutableReference> NetStandard13 => Basic.Reference.Assemblies.NetStandard13.All;
1512
public static IEnumerable<PortableExecutableReference> NetStandard20 => Basic.Reference.Assemblies.NetStandard20.All;
16-
public static IEnumerable<PortableExecutableReference> Net461 => Basic.Reference.Assemblies.Net461.All;
1713
public static IEnumerable<PortableExecutableReference> Net472 => Basic.Reference.Assemblies.Net472.All;
1814

1915
public static IEnumerable<PortableExecutableReference> Get(ReferenceAssemblyKind kind) => kind switch
2016
{
21-
ReferenceAssemblyKind.NetCoreApp31 => NetCoreApp31,
22-
ReferenceAssemblyKind.Net50 => Net50,
2317
ReferenceAssemblyKind.Net60 => Net60,
24-
ReferenceAssemblyKind.NetStandard13 => NetStandard13,
2518
ReferenceAssemblyKind.NetStandard20 => NetStandard20,
26-
ReferenceAssemblyKind.Net461 => Net461,
2719
ReferenceAssemblyKind.Net472 => Net472,
2820
_ => throw new Exception($"Invalid kind: {kind}")
2921
};
3022
}
3123

3224
public enum ReferenceAssemblyKind
3325
{
34-
NetCoreApp31,
35-
Net50,
3626
Net60,
3727
NetStandard20,
38-
NetStandard13,
39-
Net461,
4028
Net472,
4129
}
4230

0 commit comments

Comments
 (0)