Skip to content

Commit

Permalink
fix merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Meir017 committed Nov 6, 2023
1 parent 434e70e commit 1a9e36f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 61 deletions.
4 changes: 2 additions & 2 deletions FluentAssertions.Analyzers.sln
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionIt
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FluentAssertions.Analyzers", "src\FluentAssertions.Analyzers\FluentAssertions.Analyzers.csproj", "{3BA672F7-00D8-4E77-89A0-D46DD99D35AA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentAssertions.Analyzers.TestUtils", "FluentAssertions.Analyzers.TestUtils\FluentAssertions.Analyzers.TestUtils.csproj", "{BD9FC8CC-C23D-4ECC-A926-4BE35C78D338}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentAssertions.Analyzers.TestUtils", "src\FluentAssertions.Analyzers.TestUtils\FluentAssertions.Analyzers.TestUtils.csproj", "{BD9FC8CC-C23D-4ECC-A926-4BE35C78D338}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentAssertions.Analyzers.BenchmarkTests", "FluentAssertions.Analyzers.BenchmarkTests\FluentAssertions.Analyzers.BenchmarkTests.csproj", "{FE6D8A05-1383-4BCD-AD65-2EF741E48F44}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentAssertions.Analyzers.BenchmarkTests", "src\FluentAssertions.Analyzers.BenchmarkTests\FluentAssertions.Analyzers.BenchmarkTests.csproj", "{FE6D8A05-1383-4BCD-AD65-2EF741E48F44}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
using Microsoft.CodeAnalysis.Text;

using XunitAssert = Xunit.Assert;
using System.Net.Http;
using System.Collections.Concurrent;
using System.Collections.ObjectModel;

namespace FluentAssertions.Analyzers.TestUtils
{
Expand All @@ -19,11 +22,16 @@ static CsProjectGenerator()
{
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)
Expand Down
61 changes: 2 additions & 59 deletions src/FluentAssertions.Analyzers.Tests/DiagnosticVerifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using FluentAssertions.Execution;
using FluentAssertions.Analyzers.TestUtils;
using System;
using System.Collections.Immutable;
using Microsoft.CodeAnalysis.CodeActions;
Expand All @@ -15,9 +16,6 @@
using System.Reflection;

using XunitAssert = Xunit.Assert;
using System.Net.Http;
using System.Collections.Concurrent;
using System.Collections.ObjectModel;

namespace FluentAssertions.Analyzers.Tests
{
Expand All @@ -26,68 +24,13 @@ namespace FluentAssertions.Analyzers.Tests
/// </summary>
public static class DiagnosticVerifier
{
static DiagnosticVerifier()
{
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();

DefaultFilePathPrefix = "Test";
CSharpDefaultFileExt = "cs";
VisualBasicDefaultExt = "vb";
TestProjectName = "TestProject";

string GetSystemAssemblyPathByName(string assemblyName)
{
var root = System.IO.Path.GetDirectoryName(typeof(object).Assembly.Location);
return System.IO.Path.Combine(root, assemblyName);
}
}
// based on http://code.fitness/post/2017/02/using-csharpscript-with-netstandard.html
public static 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<MetadataReference> References;

private static readonly string DefaultFilePathPrefix;
private static readonly string CSharpDefaultFileExt;
private static readonly string VisualBasicDefaultExt;
private static readonly string TestProjectName;

#region CodeFixVerifier

public static void VerifyCSharpFix<TCodeFixProvider, TDiagnosticAnalyzer>(string oldSource, string newSource, int? codeFixIndex = null, bool allowNewCompilerDiagnostics = false)
Expand Down Expand Up @@ -398,7 +341,7 @@ public static void VerifyCSharpDiagnosticUsingAllAnalyzers(string source, params

public static void VerifyCSharpDiagnosticUsingAllAnalyzers(string[] sources, params DiagnosticResult[] expected)
{
var analyzers = CreateAllAnalyzers();
var analyzers = CodeAnalyzersUtils.GetAllAnalyzers();
var diagnostics = GetSortedDiagnostics(sources, LanguageNames.CSharp, analyzers);
VerifyDiagnosticResults(diagnostics, analyzers, expected);
}
Expand Down

0 comments on commit 1a9e36f

Please sign in to comment.