diff --git a/src/FluentAssertions.Analyzers.BenchmarkTests/FluentAssertionsBenchmarks.cs b/src/FluentAssertions.Analyzers.BenchmarkTests/FluentAssertionsBenchmarks.cs index 76ff988f..2dd4ddda 100644 --- a/src/FluentAssertions.Analyzers.BenchmarkTests/FluentAssertionsBenchmarks.cs +++ b/src/FluentAssertions.Analyzers.BenchmarkTests/FluentAssertionsBenchmarks.cs @@ -48,7 +48,15 @@ public Task SmallCompilation_MultipleSources_StringAssertions_Analyzing() private async Task CreateCompilationFromAsync(params string[] sources) { - var project = CsProjectGenerator.CreateProject(sources); + var arguments = new CsProjectArguments + { + Language = LanguageNames.CSharp, + Sources = sources, + TargetFramework = TargetFramework.Net8_0, + PackageReferences = new[] { PackageReference.FluentAssertions_6_12_0, PackageReference.MSTestTestFramework_3_1_1 } + }; + var project = CsProjectGenerator.CreateProject(arguments); + var compilation = await project.GetCompilationAsync(); if (compilation is null) diff --git a/src/FluentAssertions.Analyzers.TestUtils/CsProjectGenerator.cs b/src/FluentAssertions.Analyzers.TestUtils/CsProjectGenerator.cs index 5d7e0741..cb887acc 100644 --- a/src/FluentAssertions.Analyzers.TestUtils/CsProjectGenerator.cs +++ b/src/FluentAssertions.Analyzers.TestUtils/CsProjectGenerator.cs @@ -7,7 +7,6 @@ using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Text; -using XunitAssert = Xunit.Assert; using System.Net.Http; using System.Collections.Concurrent; using System.Collections.ObjectModel; @@ -16,52 +15,6 @@ namespace FluentAssertions.Analyzers.TestUtils { public class CsProjectGenerator { - static CsProjectGenerator() - { - References = new[] - { - typeof(object), // System.Private.CoreLib - typeof(Console), // System - typeof(Uri), // System.Private.Uri - typeof(Enumerable), // System.Linq - typeof(CSharpCompilation), // Microsoft.CodeAnalysis.CSharp - typeof(Compilation), // Microsoft.CodeAnalysis - typeof(AssertionScope), // FluentAssertions.Core - typeof(AssertionExtensions), // FluentAssertions - typeof(HttpRequestMessage), // System.Net.Http - typeof(ImmutableArray), // System.Collections.Immutable - typeof(ConcurrentBag<>), // System.Collections.Concurrent - typeof(ReadOnlyDictionary<,>), // System.ObjectModel - typeof(Microsoft.VisualStudio.TestTools.UnitTesting.Assert), // MsTest - typeof(XunitAssert), // Xunit - }.Select(type => type.GetTypeInfo().Assembly.Location) - .Append(GetSystemAssemblyPathByName("System.Globalization.dll")) - .Append(GetSystemAssemblyPathByName("System.Text.RegularExpressions.dll")) - .Append(GetSystemAssemblyPathByName("System.Runtime.Extensions.dll")) - .Append(GetSystemAssemblyPathByName("System.Data.Common.dll")) - .Append(GetSystemAssemblyPathByName("System.Threading.Tasks.dll")) - .Append(GetSystemAssemblyPathByName("System.Runtime.dll")) - .Append(GetSystemAssemblyPathByName("System.Reflection.dll")) - .Append(GetSystemAssemblyPathByName("System.Xml.dll")) - .Append(GetSystemAssemblyPathByName("System.Xml.XDocument.dll")) - .Append(GetSystemAssemblyPathByName("System.Private.Xml.Linq.dll")) - .Append(GetSystemAssemblyPathByName("System.Linq.Expressions.dll")) - .Append(GetSystemAssemblyPathByName("System.Collections.dll")) - .Append(GetSystemAssemblyPathByName("netstandard.dll")) - .Append(GetSystemAssemblyPathByName("System.Xml.ReaderWriter.dll")) - .Append(GetSystemAssemblyPathByName("System.Private.Xml.dll")) - .Select(location => (MetadataReference)MetadataReference.CreateFromFile(location)) - .ToImmutableArray(); - - string GetSystemAssemblyPathByName(string assemblyName) - { - var root = System.IO.Path.GetDirectoryName(typeof(object).Assembly.Location); - return System.IO.Path.Combine(root, assemblyName); - } - } - - private static readonly ImmutableArray References; - private static readonly string DefaultFilePathPrefix = "Test"; private static readonly string CSharpDefaultFileExt = "cs"; private static readonly string VisualBasicDefaultExt = "vb"; @@ -69,23 +22,6 @@ string GetSystemAssemblyPathByName(string assemblyName) public static Document CreateDocument(CsProjectArguments arguments) => CreateProject(arguments).Documents.First(); - /// - /// Create a project using the inputted strings as sources. - /// - /// Classes in the form of strings - /// The language the source code is in - /// A Project created out of the Documents created from the source strings - public static Project CreateProject(string[] sources, string language = LanguageNames.CSharp) - { - var arguments = new CsProjectArguments - { - Language = language, - Sources = sources, - TargetFramework = TargetFramework.Net8_0, - }; - return CreateProject(arguments).AddMetadataReferences(References); - } - public static Project CreateProject(CsProjectArguments arguments) { string fileNamePrefix = DefaultFilePathPrefix; diff --git a/src/FluentAssertions.Analyzers.Tests/DiagnosticVerifier.cs b/src/FluentAssertions.Analyzers.Tests/DiagnosticVerifier.cs index 7714f0e7..17e5a3b3 100644 --- a/src/FluentAssertions.Analyzers.Tests/DiagnosticVerifier.cs +++ b/src/FluentAssertions.Analyzers.Tests/DiagnosticVerifier.cs @@ -268,10 +268,6 @@ private static Diagnostic[] GetSortedDiagnosticsFromDocuments(DiagnosticAnalyzer #endregion - #region Set up compilation and documents - - #endregion - #region Verifier wrappers ///