Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependency Verify.Xunit to v22.11.1 #1730

Merged
merged 3 commits into from
Dec 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
<PackageVersion Include="xunit" Version="2.6.4" />
<PackageVersion Include="xunit.analyzers" Version="1.8.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.6" />
<PackageVersion Include="Verify.Xunit" Version="22.10.2" />
<PackageVersion Include="Verify.Xunit" Version="22.11.1" />
<PackageVersion Include="Verify.NodaTime" Version="2.1.0" />
<PackageVersion Include="Verify.SourceGenerators" Version="2.2.0" />
</ItemGroup>
Expand Down
50 changes: 28 additions & 22 deletions test/Analyzers.Tests/ModuleInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ static string GetTypeName(Type type)

// ReSharper disable once RedundantAssignment
var path = Path.Combine(Path.GetDirectoryName(sourceFile)!, "snapshots");
#if !ROSLYN_CURRENT
#if !ROSLYN_CURRENT
path = Path.Combine(Path.GetDirectoryName(sourceFile)!, "../Analyzers.Tests", "snapshots");
#endif
#endif
return new(path, typeName, method.Name);
}
);
Expand All @@ -60,23 +60,24 @@ private static ConversionResult Convert(GenerationTestResults target, IReadOnlyD
targets.AddRange(item.Value.SyntaxTrees.Select(Selector));
}

return new(new { target.ResultDiagnostics, Results = target.Results.ToDictionary(z => z.Key.FullName!, z => z.Value.Diagnostics) }, targets);
return new(new { target.ResultDiagnostics, Results = target.Results.ToDictionary(z => z.Key.FullName!, z => z.Value.Diagnostics), }, targets);
}

private static Target Selector(SyntaxTree source)
{
var hintPath = source.FilePath
.Replace("\\", "/", StringComparison.OrdinalIgnoreCase)
.Replace(".roslyn4.0", string.Empty, StringComparison.OrdinalIgnoreCase)
.Replace(".roslyn4.4", string.Empty, StringComparison.OrdinalIgnoreCase);
var hintPath = source
.FilePath
.Replace("\\", "/", StringComparison.OrdinalIgnoreCase)
.Replace(".roslyn4.0", string.Empty, StringComparison.OrdinalIgnoreCase)
.Replace(".roslyn4.4", string.Empty, StringComparison.OrdinalIgnoreCase);
var data = $@"//HintName: {hintPath}
{source.GetText()}";
return new("cs.txt", data.Replace("\r", string.Empty, StringComparison.OrdinalIgnoreCase));
return new("cs", data.Replace("\r", string.Empty, StringComparison.OrdinalIgnoreCase));
}

private static ConversionResult Convert(GenerationTestResult target, IReadOnlyDictionary<string, object> context)
{
return new(new { target.Diagnostics }, target.SyntaxTrees.Select(Selector));
return new(new { target.Diagnostics, }, target.SyntaxTrees.Select(Selector));
}


Expand All @@ -91,9 +92,10 @@ private static ConversionResult Convert(GeneratorDriverRunResult target, IReadOn
exceptions.Add(result.Exception);
}

var collection = result.GeneratedSources
.OrderBy(x => x.HintName)
.Select(SourceToTarget);
var collection = result
.GeneratedSources
.OrderBy(x => x.HintName)
.Select(SourceToTarget);
targets.AddRange(collection);
}

Expand All @@ -110,9 +112,9 @@ private static ConversionResult Convert(GeneratorDriverRunResult target, IReadOn
if (target.Diagnostics.Any())
{
var info = new
{
target.Diagnostics
};
{
target.Diagnostics,
};
return new(info, targets);
}

Expand All @@ -121,9 +123,10 @@ private static ConversionResult Convert(GeneratorDriverRunResult target, IReadOn

private static Target SourceToTarget(GeneratedSourceResult source)
{
var hintName = source.HintName
.Replace(".roslyn4.0", string.Empty, StringComparison.OrdinalIgnoreCase)
.Replace(".roslyn4.4", string.Empty, StringComparison.OrdinalIgnoreCase);
var hintName = source
.HintName
.Replace(".roslyn4.0", string.Empty, StringComparison.OrdinalIgnoreCase)
.Replace(".roslyn4.4", string.Empty, StringComparison.OrdinalIgnoreCase);
var data = $@"//HintName: {hintName}
{source.SourceText}";
return new("cs", data, Path.GetFileNameWithoutExtension(hintName));
Expand Down Expand Up @@ -181,9 +184,12 @@ public override void Write(VerifyJsonWriter writer, GeneratedSourceResult value)
{
writer.WriteStartObject();
writer.WriteMember(
value, value.HintName
.Replace(".roslyn4.0", string.Empty, StringComparison.OrdinalIgnoreCase)
.Replace(".roslyn4.4", string.Empty, StringComparison.OrdinalIgnoreCase), "HintName"
value,
value
.HintName
.Replace(".roslyn4.0", string.Empty, StringComparison.OrdinalIgnoreCase)
.Replace(".roslyn4.4", string.Empty, StringComparison.OrdinalIgnoreCase),
"HintName"
);
writer.WriteMember(value, value.SourceText, "Source");
writer.WriteEndObject();
Expand Down Expand Up @@ -217,4 +223,4 @@ public override void Write(VerifyJsonWriter writer, SourceText value)
writer.WriteValue(value.ToString());
}
}
}
}
Loading