Skip to content

Commit 61a8c87

Browse files
committed
chore: cleanup benchmark test project
1 parent c317f3e commit 61a8c87

File tree

3 files changed

+9
-69
lines changed

3 files changed

+9
-69
lines changed

src/FluentAssertions.Analyzers.BenchmarkTests/FluentAssertionsBenchmarks.cs

+9-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,15 @@ public Task SmallCompilation_MultipleSources_StringAssertions_Analyzing()
4848

4949
private async Task<CompilationWithAnalyzers> CreateCompilationFromAsync(params string[] sources)
5050
{
51-
var project = CsProjectGenerator.CreateProject(sources);
51+
var arguments = new CsProjectArguments
52+
{
53+
Language = LanguageNames.CSharp,
54+
Sources = sources,
55+
TargetFramework = TargetFramework.Net8_0,
56+
PackageReferences = new[] { PackageReference.FluentAssertions_6_12_0, PackageReference.MSTestTestFramework_3_1_1 }
57+
};
58+
var project = CsProjectGenerator.CreateProject(arguments);
59+
5260
var compilation = await project.GetCompilationAsync();
5361

5462
if (compilation is null)

src/FluentAssertions.Analyzers.TestUtils/CsProjectGenerator.cs

-64
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using Microsoft.CodeAnalysis.CSharp;
88
using Microsoft.CodeAnalysis.Text;
99

10-
using XunitAssert = Xunit.Assert;
1110
using System.Net.Http;
1211
using System.Collections.Concurrent;
1312
using System.Collections.ObjectModel;
@@ -16,76 +15,13 @@ namespace FluentAssertions.Analyzers.TestUtils
1615
{
1716
public class CsProjectGenerator
1817
{
19-
static CsProjectGenerator()
20-
{
21-
References = new[]
22-
{
23-
typeof(object), // System.Private.CoreLib
24-
typeof(Console), // System
25-
typeof(Uri), // System.Private.Uri
26-
typeof(Enumerable), // System.Linq
27-
typeof(CSharpCompilation), // Microsoft.CodeAnalysis.CSharp
28-
typeof(Compilation), // Microsoft.CodeAnalysis
29-
typeof(AssertionScope), // FluentAssertions.Core
30-
typeof(AssertionExtensions), // FluentAssertions
31-
typeof(HttpRequestMessage), // System.Net.Http
32-
typeof(ImmutableArray), // System.Collections.Immutable
33-
typeof(ConcurrentBag<>), // System.Collections.Concurrent
34-
typeof(ReadOnlyDictionary<,>), // System.ObjectModel
35-
typeof(Microsoft.VisualStudio.TestTools.UnitTesting.Assert), // MsTest
36-
typeof(XunitAssert), // Xunit
37-
}.Select(type => type.GetTypeInfo().Assembly.Location)
38-
.Append(GetSystemAssemblyPathByName("System.Globalization.dll"))
39-
.Append(GetSystemAssemblyPathByName("System.Text.RegularExpressions.dll"))
40-
.Append(GetSystemAssemblyPathByName("System.Runtime.Extensions.dll"))
41-
.Append(GetSystemAssemblyPathByName("System.Data.Common.dll"))
42-
.Append(GetSystemAssemblyPathByName("System.Threading.Tasks.dll"))
43-
.Append(GetSystemAssemblyPathByName("System.Runtime.dll"))
44-
.Append(GetSystemAssemblyPathByName("System.Reflection.dll"))
45-
.Append(GetSystemAssemblyPathByName("System.Xml.dll"))
46-
.Append(GetSystemAssemblyPathByName("System.Xml.XDocument.dll"))
47-
.Append(GetSystemAssemblyPathByName("System.Private.Xml.Linq.dll"))
48-
.Append(GetSystemAssemblyPathByName("System.Linq.Expressions.dll"))
49-
.Append(GetSystemAssemblyPathByName("System.Collections.dll"))
50-
.Append(GetSystemAssemblyPathByName("netstandard.dll"))
51-
.Append(GetSystemAssemblyPathByName("System.Xml.ReaderWriter.dll"))
52-
.Append(GetSystemAssemblyPathByName("System.Private.Xml.dll"))
53-
.Select(location => (MetadataReference)MetadataReference.CreateFromFile(location))
54-
.ToImmutableArray();
55-
56-
string GetSystemAssemblyPathByName(string assemblyName)
57-
{
58-
var root = System.IO.Path.GetDirectoryName(typeof(object).Assembly.Location);
59-
return System.IO.Path.Combine(root, assemblyName);
60-
}
61-
}
62-
63-
private static readonly ImmutableArray<MetadataReference> References;
64-
6518
private static readonly string DefaultFilePathPrefix = "Test";
6619
private static readonly string CSharpDefaultFileExt = "cs";
6720
private static readonly string VisualBasicDefaultExt = "vb";
6821
private static readonly string TestProjectName = "TestProject";
6922

7023
public static Document CreateDocument(CsProjectArguments arguments) => CreateProject(arguments).Documents.First();
7124

72-
/// <summary>
73-
/// Create a project using the inputted strings as sources.
74-
/// </summary>
75-
/// <param name="sources">Classes in the form of strings</param>
76-
/// <param name="language">The language the source code is in</param>
77-
/// <returns>A Project created out of the Documents created from the source strings</returns>
78-
public static Project CreateProject(string[] sources, string language = LanguageNames.CSharp)
79-
{
80-
var arguments = new CsProjectArguments
81-
{
82-
Language = language,
83-
Sources = sources,
84-
TargetFramework = TargetFramework.Net8_0,
85-
};
86-
return CreateProject(arguments).AddMetadataReferences(References);
87-
}
88-
8925
public static Project CreateProject(CsProjectArguments arguments)
9026
{
9127
string fileNamePrefix = DefaultFilePathPrefix;

src/FluentAssertions.Analyzers.Tests/DiagnosticVerifier.cs

-4
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,6 @@ private static Diagnostic[] GetSortedDiagnosticsFromDocuments(DiagnosticAnalyzer
268268

269269
#endregion
270270

271-
#region Set up compilation and documents
272-
273-
#endregion
274-
275271
#region Verifier wrappers
276272

277273
/// <summary>

0 commit comments

Comments
 (0)