-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
48 changed files
with
1,972 additions
and
907 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.5.002.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example", "Example.csproj", "{2FBB56BB-D9CA-4D6F-95DB-9096E555B136}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{2FBB56BB-D9CA-4D6F-95DB-9096E555B136}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{2FBB56BB-D9CA-4D6F-95DB-9096E555B136}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{2FBB56BB-D9CA-4D6F-95DB-9096E555B136}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{2FBB56BB-D9CA-4D6F-95DB-9096E555B136}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {75D71B61-4537-4257-BCDB-BB11AA0B1EF6} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.CSharp; | ||
using Microsoft.CodeAnalysis.CSharp.Syntax; | ||
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; | ||
|
||
namespace Pretender.SourceGenerator.Emitter | ||
{ | ||
internal static class CommonSyntax | ||
{ | ||
// General | ||
public static PredefinedTypeSyntax VoidType { get; } = PredefinedType(Token(SyntaxKind.VoidKeyword)); | ||
public static TypeSyntax VarType { get; } = ParseTypeName("var"); | ||
public static GenericNameSyntax GenericPretendType { get; } = GenericName("Pretend"); | ||
public static UsingDirectiveSyntax UsingSystem { get; } = UsingDirective(ParseName("System")); | ||
public static UsingDirectiveSyntax UsingSystemThreadingTasks { get; } = UsingDirective(ParseName("System.Threading.Tasks")); | ||
|
||
// Verify | ||
public static SyntaxToken SetupIdentifier { get; } = Identifier("setup"); | ||
public static SyntaxToken CalledIdentifier { get; } = Identifier("called"); | ||
public static ParameterSyntax CalledParameter { get; } = Parameter(CalledIdentifier) | ||
.WithType(ParseTypeName("Called")); | ||
|
||
public static CompilationUnitSyntax CreateVerifyCompilationUnit(MethodDeclarationSyntax[] verifyMethods) | ||
{ | ||
var classDeclaration = ClassDeclaration("VerifyInterceptors") | ||
.AddModifiers(Token(SyntaxKind.FileKeyword), Token(SyntaxKind.StaticKeyword)) | ||
.AddMembers(verifyMethods); | ||
|
||
var namespaceDeclaration = NamespaceDeclaration(ParseName("Pretender.SourceGeneration")) | ||
.AddMembers(classDeclaration) | ||
.AddUsings(UsingSystem, KnownBlocks.CompilerServicesUsing, UsingSystemThreadingTasks, KnownBlocks.PretenderUsing, KnownBlocks.PretenderInternalsUsing); | ||
|
||
return CompilationUnit() | ||
.AddMembers(KnownBlocks.InterceptsLocationAttribute, namespaceDeclaration) | ||
.NormalizeWhitespace(); | ||
} | ||
} | ||
} |
Oops, something went wrong.