Skip to content

Commit

Permalink
Rename XunitContext.ForV2Core to .ForV2, since this is the standard r…
Browse files Browse the repository at this point in the history
…eferences for v2 test authors
  • Loading branch information
bradwilson committed Nov 3, 2024
1 parent 99947a9 commit c707020
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1482,6 +1482,6 @@ public void TestMethod(int a, params {1}[] b) {{ }}
internal class Analyzer_v2_Pre240 : InlineDataMustMatchTheoryParameters
{
protected override XunitContext CreateXunitContext(Compilation compilation) =>
XunitContext.ForV2Core(compilation, new Version(2, 3, 999));
XunitContext.ForV2(compilation, new Version(2, 3, 999));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ public void TestMethod(int a, string b, string c = "") { }
internal class Analyzer_v2_Pre220 : TheoryMethodCannotHaveDefaultParameter
{
protected override XunitContext CreateXunitContext(Compilation compilation) =>
XunitContext.ForV2Core(compilation, new Version(2, 1, 999));
XunitContext.ForV2(compilation, new Version(2, 1, 999));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ public void TestMethod(int a, string b, string[] c) { }
internal class Analyzer_v2_Pre220 : TheoryMethodCannotHaveParamsArray
{
protected override XunitContext CreateXunitContext(Compilation compilation) =>
XunitContext.ForV2Core(compilation, new Version(2, 1, 999));
XunitContext.ForV2(compilation, new Version(2, 1, 999));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ public void Test1(int x, {|CS1001:{|CS1031:{|xUnit1026:|})|}|}
internal class Analyzer_X1022 : TheoryMethodCannotHaveParamsArray
{
protected override XunitContext CreateXunitContext(Compilation compilation) =>
XunitContext.ForV2Core(compilation, new Version(2, 1, 999));
XunitContext.ForV2(compilation, new Version(2, 1, 999));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ public void TestMethod(int _) { }
internal class Analyzer : TheoryMethodCannotHaveDefaultParameter
{
protected override XunitContext CreateXunitContext(Compilation compilation) =>
XunitContext.ForV2Core(compilation, new Version(2, 1, 999));
XunitContext.ForV2(compilation, new Version(2, 1, 999));
}
}
30 changes: 15 additions & 15 deletions src/xunit.analyzers/Utility/XunitContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,21 @@ public IRunnerUtilityContext RunnerUtility
/// </summary>
public V3RunnerUtilityContext? V3RunnerUtility { get; private set; }

/// <summary>
/// Used to create a context object for testing v2 analyzers and fixers. This includes references
/// to <c>xunit.abstractions</c> (at version 2.0.3) and <c>xunit.core</c>.
/// </summary>
/// <param name="compilation">The Roslyn compilation object used to look up types</param>
/// <param name="versionOverride">The overridden version for <c>xunit.core</c></param>
public static XunitContext ForV2(
Compilation compilation,
Version? versionOverride = null) =>
new()
{
V2Abstractions = V2AbstractionsContext.Get(compilation, v2AbstractionsVersion),
V2Core = V2CoreContext.Get(compilation, versionOverride),
};

/// <summary>
/// Used to create a context object for testing v2 analyzers and fixers. This includes references
/// to <c>xunit.abstactions</c> (at version 2.0.3).
Expand All @@ -192,21 +207,6 @@ public static XunitContext ForV2Assert(
V2Assert = V2AssertContext.Get(compilation, versionOverride),
};

/// <summary>
/// Used to create a context object for testing v2 analyzers and fixers. This includes references
/// to <c>xunit.abstractions</c> (at version 2.0.3) and <c>xunit.core</c>.
/// </summary>
/// <param name="compilation">The Roslyn compilation object used to look up types</param>
/// <param name="versionOverride">The overridden version for <c>xunit.core</c></param>
public static XunitContext ForV2Core(
Compilation compilation,
Version? versionOverride = null) =>
new()
{
V2Abstractions = V2AbstractionsContext.Get(compilation, v2AbstractionsVersion),
V2Core = V2CoreContext.Get(compilation, versionOverride),
};

/// <summary>
/// Used to create a context object for testing v2 analyzers and fixers. This includes references
/// to <c>xunit.abstractions</c> (at version 2.0.3) and <c>xunit.execution</c>.
Expand Down

0 comments on commit c707020

Please sign in to comment.