-
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.
- Loading branch information
1 parent
7670f69
commit 3485768
Showing
16 changed files
with
229 additions
and
135 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,20 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Collections.Immutable; | ||
using Microsoft.CodeAnalysis.CSharp.Syntax; | ||
|
||
namespace Pretender.SourceGenerator.Emitter | ||
{ | ||
internal class GrandEmitter | ||
{ | ||
public GrandEmitter() | ||
private readonly ImmutableArray<PretendEmitter> _pretendEmitters; | ||
|
||
public GrandEmitter(ImmutableArray<PretendEmitter> pretendEmitters) | ||
{ | ||
_pretendEmitters = pretendEmitters; | ||
} | ||
|
||
public CompilationUnitSyntax Emit(CancellationToken cancellationToken) | ||
{ | ||
|
||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
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,10 @@ | ||
using Microsoft.CodeAnalysis; | ||
using Pretender.SourceGenerator.Parser; | ||
|
||
namespace Pretender.SourceGenerator.Fakes | ||
{ | ||
internal interface IKnownFake | ||
{ | ||
bool TryConstruct(INamedTypeSymbol typeSymbol, KnownTypeSymbols knownTypeSymbols, CancellationToken cancellationToken, out ITypeSymbol? fakeType); | ||
} | ||
} |
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,19 @@ | ||
using Microsoft.CodeAnalysis; | ||
using Pretender.SourceGenerator.Parser; | ||
|
||
namespace Pretender.SourceGenerator.Fakes | ||
{ | ||
internal class ILoggerFake : IKnownFake | ||
{ | ||
public bool TryConstruct(INamedTypeSymbol typeSymbol, KnownTypeSymbols knownTypeSymbols, CancellationToken cancellationToken, out ITypeSymbol? fakeType) | ||
{ | ||
fakeType = null; | ||
if (SymbolEqualityComparer.Default.Equals(typeSymbol, knownTypeSymbols.MicrosoftExtensionsLoggingILogger)) | ||
{ | ||
// TODO: Support this | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
} |
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
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,40 @@ | ||
using Microsoft.CodeAnalysis; | ||
using Pretender.Settings; | ||
|
||
namespace Pretender.SourceGenerator | ||
{ | ||
internal class PretenderSettings | ||
{ | ||
public static PretenderSettings Default { get; } = new PretenderSettings( | ||
PretendBehavior.PreferFakes | ||
); | ||
|
||
public static PretenderSettings FromAttribute(AttributeData attributeData) | ||
{ | ||
PretendBehavior? behavior = null; | ||
|
||
foreach (var namedArg in attributeData.NamedArguments) | ||
{ | ||
switch (namedArg.Key) | ||
{ | ||
case nameof(Behavior): | ||
behavior = (PretendBehavior)namedArg.Value.Value!; | ||
break; | ||
default: | ||
throw new InvalidOperationException(); | ||
} | ||
} | ||
|
||
return new PretenderSettings( | ||
behavior.GetValueOrDefault(PretendBehavior.PreferFakes) | ||
); | ||
} | ||
|
||
public PretenderSettings(PretendBehavior behavior) | ||
{ | ||
Behavior = behavior; | ||
} | ||
|
||
public PretendBehavior Behavior { get; } | ||
} | ||
} |
Oops, something went wrong.