Skip to content

Commit

Permalink
Rename IAbstractionsContext to ICommonContext and cleaned up XML docs…
Browse files Browse the repository at this point in the history
… for clarity
  • Loading branch information
bradwilson committed Oct 28, 2024
1 parent 2dead6c commit d303131
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,6 @@ protected override XunitContext CreateXunitContext(Compilation compilation) =>
public class V3Analyzer : SerializableClassMustHaveParameterlessConstructor
{
protected override XunitContext CreateXunitContext(Compilation compilation) =>
XunitContext.ForV3Core(compilation);
XunitContext.ForV3(compilation);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

namespace Xunit.Analyzers;

public class EmptyAbstractionsContext : IAbstractionsContext
public class EmptyCommonContext : ICommonContext
{
EmptyAbstractionsContext()
EmptyCommonContext()
{ }

public static EmptyAbstractionsContext Instance { get; } = new();
public static EmptyCommonContext Instance { get; } = new();

public INamedTypeSymbol? IMessageSinkType => null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
namespace Xunit.Analyzers;

/// <summary>
/// Context with information from <c>xunit.abstractions</c> (in v2) or <c>xunit.v3.common</c> or <c>xunit.v3.core</c> (in v3).
/// The types here are the ones common to both.
/// Context for types that that originated in <c>xunit.abstractions</c> in v2, and moved in v3
/// to one of <c>xunit.v3.common</c>, <c>xunit.v3.core</c>, or <c>xunit.v3.runner.common</c>.
/// </summary>
public interface IAbstractionsContext
public interface ICommonContext
{
/// <summary>
/// Gets a reference to type <c>IMessageSink</c>, if available.
Expand Down
2 changes: 1 addition & 1 deletion src/xunit.analyzers/Utility/SerializableTypeSymbols.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public sealed class SerializableTypeSymbols
bigInteger = new(() => TypeSymbolFactory.BigInteger(compilation));
dateOnly = new(() => TypeSymbolFactory.DateOnly(compilation));
dateTimeOffset = new(() => TypeSymbolFactory.DateTimeOffset(compilation));
iXunitSerializable = new(() => xunitContext.Abstractions.IXunitSerializableType);
iXunitSerializable = new(() => xunitContext.Common.IXunitSerializableType);
// For v2 and early versions of v3, the base type is "TheoryData" (non-generic). For later versions
// of v3, it's "TheoryDataBase<TTheoryDataRow, TRawDataRow>". In either case, getting "TheoryData<T>"
// and going up one layer gets us the type we want to be able to search for.
Expand Down
2 changes: 1 addition & 1 deletion src/xunit.analyzers/Utility/V2AbstractionsContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Xunit.Analyzers;

public class V2AbstractionsContext : IAbstractionsContext
public class V2AbstractionsContext : ICommonContext
{
readonly Lazy<INamedTypeSymbol?> lazyIAssemblyInfoType;
readonly Lazy<INamedTypeSymbol?> lazyIAttributeInfoType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

namespace Xunit.Analyzers;

// Technically xunit.abstractions doesn't exist in v3; all the co-existent/updated types are present in xunit.v3.common, instead.

public class V3AbstractionsContext : IAbstractionsContext
public class V3CommonContext : ICommonContext
{
readonly Lazy<INamedTypeSymbol?> lazyIMessageSinkType;
readonly Lazy<INamedTypeSymbol?> lazyISourceInformationProviderType;
Expand All @@ -21,7 +19,7 @@ public class V3AbstractionsContext : IAbstractionsContext
readonly Lazy<INamedTypeSymbol?> lazyITestType;
readonly Lazy<INamedTypeSymbol?> lazyIXunitSerializableType;

V3AbstractionsContext(
V3CommonContext(
Compilation compilation,
Version version)
{
Expand All @@ -42,50 +40,62 @@ public class V3AbstractionsContext : IAbstractionsContext
}

/// <inheritdoc/>
/// <remarks>This type lives in <c>xunit.v3.common</c>.</remarks>
public INamedTypeSymbol? IMessageSinkType =>
lazyIMessageSinkType.Value;

/// <inheritdoc/>
/// <remarks>This type lives in <c>xunit.v3.runner.common</c>.</remarks>
public INamedTypeSymbol? ISourceInformationProviderType =>
lazyISourceInformationProviderType.Value;

/// <inheritdoc/>
/// <remarks>This type lives in <c>xunit.v3.common</c>.</remarks>
public INamedTypeSymbol? ITestAssemblyType =>
lazyITestAssemblyType.Value;

/// <inheritdoc/>
/// <remarks>This type lives in <c>xunit.v3.common</c>.</remarks>
public INamedTypeSymbol? ITestCaseType =>
lazyITestCaseType.Value;

/// <inheritdoc/>
/// <remarks>This type lives in <c>xunit.v3.common</c>.</remarks>
public INamedTypeSymbol? ITestClassType =>
lazyITestClassType.Value;

/// <inheritdoc/>
/// <remarks>This type lives in <c>xunit.v3.common</c>.</remarks>
public INamedTypeSymbol? ITestCollectionType =>
lazyITestCollectionType.Value;

/// <inheritdoc/>
/// <remarks>This type lives in <c>xunit.v3.core</c>.</remarks>
public INamedTypeSymbol? ITestFrameworkDiscovererType =>
lazyITestFrameworkDiscovererType.Value;

/// <inheritdoc/>
/// <remarks>This type lives in <c>xunit.v3.core</c>.</remarks>
public INamedTypeSymbol? ITestFrameworkExecutorType =>
lazyITestFrameworkExecutorType.Value;

/// <inheritdoc/>
/// <remarks>This type lives in <c>xunit.v3.core</c>.</remarks>
public INamedTypeSymbol? ITestFrameworkType =>
lazyITestFrameworkType.Value;

/// <inheritdoc/>
/// <remarks>This type lives in <c>xunit.v3.common</c>.</remarks>
public INamedTypeSymbol? ITestMethodType =>
lazyITestMethodType.Value;

/// <inheritdoc/>
/// <remarks>This type lives in <c>xunit.v3.common</c>.</remarks>
public INamedTypeSymbol? ITestType =>
lazyITestType.Value;

/// <inheritdoc/>
/// <remarks>This type lives in <c>xunit.v3.common</c>.</remarks>
public INamedTypeSymbol? IXunitSerializableType =>
lazyIXunitSerializableType.Value;

Expand All @@ -94,7 +104,7 @@ public class V3AbstractionsContext : IAbstractionsContext
/// </summary>
public Version Version { get; }

public static V3AbstractionsContext? Get(
public static V3CommonContext? Get(
Compilation compilation,
Version? versionOverride = null)
{
Expand Down
Loading

0 comments on commit d303131

Please sign in to comment.