Skip to content

Commit

Permalink
Remove Unused Code & Update Baseline
Browse files Browse the repository at this point in the history
  • Loading branch information
justindbaur committed Dec 26, 2023
1 parent d867156 commit 400ffe1
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 135 deletions.
12 changes: 2 additions & 10 deletions src/Pretender.SourceGenerator/DiagnosticDescriptors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,16 @@ namespace Pretender.SourceGenerator
{
internal static class DiagnosticDescriptors
{
public static DiagnosticDescriptor UnsupportedLanguageVersion { get; } = new(
"PRTND001",
"Unsupported language version",
"",
"Usage",
DiagnosticSeverity.Error,
isEnabledByDefault: true);

public static DiagnosticDescriptor UnableToPretendSealedType { get; } = new(
"PRTND002",
"PRTND001",
"Unable to Pretend Sealed Types",
"Sealed types cannot be Pretended, did you mean to use an interface?",
"Usage",
DiagnosticSeverity.Error,
isEnabledByDefault: true);

public static DiagnosticDescriptor InvalidSetupArgument { get; } = new(
"PRTND003",
"PRTND002",
"Invalid Setup Argument",
"We don't support operation type {0} as a setup argument.",
"Usage",
Expand Down
22 changes: 0 additions & 22 deletions src/Pretender.SourceGenerator/InterceptsLocationInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,5 @@ public InterceptsLocationInfo(IInvocationOperation invocationOperation)
public string FilePath { get; }
public int LineNumber { get; }
public int CharacterNumber { get; }

public AttributeSyntax ToAttributeSyntax()
{
return Attribute(IdentifierName("InterceptsLocation"))
.WithArgumentList(AttributeArgumentList(SeparatedList(new[]
{
AttributeArgument(
LiteralExpression(
SyntaxKind.StringLiteralExpression,
Literal(FilePath))),

AttributeArgument(
LiteralExpression(
SyntaxKind.NumericLiteralExpression,
Literal(LineNumber))),

AttributeArgument(
LiteralExpression(
SyntaxKind.NumericLiteralExpression,
Literal(CharacterNumber))),
})));
}
}
}
48 changes: 0 additions & 48 deletions src/Pretender.SourceGenerator/InvocationOperationExtensions.cs

This file was deleted.

37 changes: 0 additions & 37 deletions src/Pretender.SourceGenerator/KnownBlocks.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.Reflection;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;

namespace Pretender.SourceGenerator
{
Expand All @@ -25,39 +22,5 @@ public InterceptsLocationAttribute(string filePath, int line, int column)
}
}
""";

public static MemberAccessExpressionSyntax TaskCompletedTask = MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
IdentifierName("Task"),
IdentifierName("CompletedTask")
);

public static MemberAccessExpressionSyntax ValueTaskCompletedTask = MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
IdentifierName("ValueTask"),
IdentifierName("CompletedTask")
);

public static InvocationExpressionSyntax TaskFromResult(TypeSyntax resultType, ExpressionSyntax resultValue) => InvocationExpression(
MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression,
IdentifierName("Task"),
GenericName("FromResult")
.AddTypeArgumentListArguments(resultType))
)
.AddArgumentListArguments(Argument(resultValue));

public static InvocationExpressionSyntax ValueTaskFromResult(TypeSyntax resultType, ExpressionSyntax resultValue)
{
// ValueTask.FromResult<T>
var memberAccess = MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression,
IdentifierName("ValueTask"),
GenericName("FromResult")
.AddTypeArgumentListArguments(resultType));

// ValueTask.FromResult<T>(value)
return InvocationExpression(memberAccess,
ArgumentList(
SingletonSeparatedList(Argument(resultValue))));
}
}
}
17 changes: 0 additions & 17 deletions src/Pretender.SourceGenerator/SyntaxNodeExtensions.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
// <auto-generated>

#nullable enable annotations
#nullable disable warnings

// Suppress warnings about [Obsolete] member usage in generated code.
#pragma warning disable CS0612, CS0618

namespace System.Runtime.CompilerServices
{
using System;
Expand Down
2 changes: 1 addition & 1 deletion test/SourceGeneratorTests/TestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public async Task RunAndCompareAsync(string source, [CallerMemberName] string? t
private void CompareAgainstBaseline(GeneratedSourceResult result, string? testMethodName = null)
{
var normalizedName = result.HintName[..^3].Replace('.', '_') + ".cs";
#if !GENERATE_SOURCE
#if GENERATE_SOURCE
var resultFileName = result.HintName.Replace('.', '_');
var baseLineName = $"{GetType().Name}.{testMethodName}.{normalizedName}";
var resourceName = Assert.Single(typeof(TestBase).Assembly.GetManifestResourceNames()
Expand Down

0 comments on commit 400ffe1

Please sign in to comment.