|
4 | 4 | using System.Runtime.CompilerServices;
|
5 | 5 | using ApprovalTests;
|
6 | 6 | using GitVersion;
|
| 7 | +using Microsoft.CodeAnalysis; |
| 8 | +using Microsoft.CodeAnalysis.CSharp; |
7 | 9 | using NUnit.Framework;
|
8 |
| -using Roslyn.Compilers; |
9 |
| -using Roslyn.Compilers.CSharp; |
10 | 10 |
|
11 | 11 | [TestFixture]
|
12 | 12 | public class AssemblyInfoBuilderTests
|
@@ -34,11 +34,15 @@ public void VerifyCreatedCode()
|
34 | 34 | };
|
35 | 35 | var assemblyInfoText = assemblyInfoBuilder.GetAssemblyInfoText(new Config());
|
36 | 36 | Approvals.Verify(assemblyInfoText);
|
37 |
| - var syntaxTree = SyntaxTree.ParseText(assemblyInfoText); |
38 |
| - var references = new[] {new MetadataFileReference(typeof(object).Assembly.Location)}; |
39 |
| - var compilation = Compilation.Create("Greeter.dll", new CompilationOptions(OutputKind.NetModule), new[] { syntaxTree }, references); |
| 37 | + |
| 38 | + var compilation = CSharpCompilation.Create("Fake.dll") |
| 39 | + .WithOptions(new CSharpCompilationOptions(OutputKind.NetModule)) |
| 40 | + .AddReferences(MetadataReference.CreateFromFile(typeof(object).Assembly.Location)) |
| 41 | + .AddSyntaxTrees(CSharpSyntaxTree.ParseText(assemblyInfoText)); |
| 42 | + |
| 43 | + |
40 | 44 | var emitResult = compilation.Emit(new MemoryStream());
|
41 |
| - Assert.IsTrue(emitResult.Success, string.Join(Environment.NewLine, emitResult.Diagnostics.Select(x => x.Info))); |
| 45 | + Assert.IsTrue(emitResult.Success, string.Join(Environment.NewLine, emitResult.Diagnostics.Select(x => x.Descriptor))); |
42 | 46 | }
|
43 | 47 |
|
44 | 48 | [Test]
|
@@ -90,10 +94,13 @@ static void VerifyAssemblyVersion(AssemblyVersioningScheme avs)
|
90 | 94 |
|
91 | 95 | var assemblyInfoText = assemblyInfoBuilder.GetAssemblyInfoText(new Config { AssemblyVersioningScheme = avs });
|
92 | 96 | Approvals.Verify(assemblyInfoText);
|
93 |
| - var syntaxTree = SyntaxTree.ParseText(assemblyInfoText); |
94 |
| - var references = new[] { new MetadataFileReference(typeof(object).Assembly.Location)}; |
95 |
| - var compilation = Compilation.Create("Greeter.dll", new CompilationOptions(OutputKind.NetModule), new[] { syntaxTree }, references); |
| 97 | + |
| 98 | + var compilation = CSharpCompilation.Create("Fake.dll") |
| 99 | + .WithOptions(new CSharpCompilationOptions(OutputKind.NetModule)) |
| 100 | + .AddReferences(MetadataReference.CreateFromFile(typeof(object).Assembly.Location)) |
| 101 | + .AddSyntaxTrees(CSharpSyntaxTree.ParseText(assemblyInfoText)); |
| 102 | + |
96 | 103 | var emitResult = compilation.Emit(new MemoryStream());
|
97 |
| - Assert.IsTrue(emitResult.Success, string.Join(Environment.NewLine, emitResult.Diagnostics.Select(x => x.Info))); |
| 104 | + Assert.IsTrue(emitResult.Success, string.Join(Environment.NewLine, emitResult.Diagnostics.Select(x => x.Descriptor))); |
98 | 105 | }
|
99 | 106 | }
|
0 commit comments