Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
<PackageVersion Include="Verify.Xunit" Version="31.12.5" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
<PackageVersion Include="Zomp.MethodCloning" Version="1.0.20-alpha" />
<PackageVersion Include="Zomp.MethodCloning" Version="1.0.24" />
</ItemGroup>
</Project>
20 changes: 10 additions & 10 deletions src/Zomp.SyncMethodGenerator/AsyncToSyncRewriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ BinaryExpressionSyntax CheckNull(ExpressionSyntax expr) => BinaryExpression(
}
else
{
var argumentTypeExpr = ProcessSymbol(funcArgumentType);
var argumentTypeExpr = Qualify(funcArgumentType);

var separated = SeparatedList([MaybeNullableType(argumentTypeExpr), MaybeNullableType(ProcessSymbol(chain[^1].ReturnType))]);
var separated = SeparatedList([MaybeNullableType(argumentTypeExpr), MaybeNullableType(Qualify(chain[^1].ReturnType))]);

var type = TypeArgumentList(separated);
funcExpr = GenericName(
Expand Down Expand Up @@ -203,7 +203,7 @@ BinaryExpressionSyntax CheckNull(ExpressionSyntax expr) => BinaryExpression(
toCheckForNullExpr,
IdentifierName(nameof(Nullable<>.HasValue))))
: CheckNull(toCheckForNullExpr);
var castTo = MaybeNullableType(ProcessSymbol(returnType), returnType.IsValueType);
var castTo = MaybeNullableType(Qualify(returnType), returnType.IsValueType);

var conditional = ConditionalExpression(
condition.AppendSpace(),
Expand All @@ -223,7 +223,7 @@ BinaryExpressionSyntax CheckNull(ExpressionSyntax expr) => BinaryExpression(
statements.Add(ifStatement);

var toCheckForNull = Identifier($"check{i}");
var localType = ProcessSymbol(returnType); // reduced will return generic
var localType = Qualify(returnType); // reduced will return generic

var declarator = VariableDeclarator(toCheckForNull.AppendSpace(), null, EqualsValueClause(unwrappedExpr.PrependSpace()));
var declaration = VariableDeclaration(localType.AppendSpace(), SeparatedList([declarator]));
Expand Down Expand Up @@ -1144,7 +1144,7 @@ bool ShouldRemoveArgumentLocal(ArgumentSyntax arg, int index)
{
for (var i = 0; i < typeArgs.Length - 1; i++)
{
list.Add(ProcessSymbol(typeArgs[i]));
list.Add(Qualify(typeArgs[i]));
}

var originalSeparators = gns.TypeArgumentList.Arguments.GetSeparators();
Expand Down Expand Up @@ -1260,8 +1260,8 @@ bool ShouldRemoveAttribute(AttributeSyntax attributeSyntax)
protected override SimpleNameSyntax? MapSymbol(ISymbol symbol) => symbol switch
{
INamedTypeSymbol { IsEnumerator: true } s
=> GenericName(IEnumerator).WithTypeArgumentList(TypeArgumentList(SeparatedList<TypeSyntax>([ProcessSymbol(s.ContainingType.TypeArguments[0])], []))),
INamedTypeSymbol { IsTaskOrValueTask: true } s => s.IsGenericType ? ProcessSymbol(s.TypeArguments[0]) : IdentifierName("void"),
=> GenericName(IEnumerator).WithTypeArgumentList(TypeArgumentList(SeparatedList<TypeSyntax>([Qualify(s.ContainingType.TypeArguments[0])], []))),
INamedTypeSymbol { IsTaskOrValueTask: true } s => s.IsGenericType ? Qualify(s.TypeArguments[0]) : IdentifierName("void"),
_ => null,
};

Expand Down Expand Up @@ -1684,7 +1684,7 @@ private static List<SyntaxTrivia> RemoveFirstEndIf(SyntaxTriviaList list)

private TypeSyntax GetReturnType(TypeSyntax returnType, INamedTypeSymbol symbol) => (returnType switch
{
IdentifierNameSyntax => ProcessSymbol(symbol),
IdentifierNameSyntax => Qualify(symbol),
_ => returnType,
}).WithTriviaFrom(returnType);

Expand Down Expand Up @@ -1726,7 +1726,7 @@ private static List<SyntaxTrivia> RemoveFirstEndIf(SyntaxTriviaList list)
// Func<something, Task> => Action<something>
for (var i = 0; i < typeArgs.Length - 1; i++)
{
list.Add(ProcessSymbol(typeArgs[i]));
list.Add(Qualify(typeArgs[i]));
}

var originalSeparators = (List<SyntaxToken>)[.. gns.TypeArgumentList.Arguments.GetSeparators()];
Expand Down Expand Up @@ -1853,7 +1853,7 @@ private InvocationExpressionSyntax UnwrapExtension(InvocationExpressionSyntax ie
var newName = reducedFrom.Name;
newName = changeMemoryToSpan ? ReplaceWithSpan(reducedFrom) : RemoveAsync(newName);

var fullyQualifiedName = $"{SyncQueryableContainer(containingType, newName) ?? MakeType(containingType)}.{newName}";
var fullyQualifiedName = $"{SyncQueryableContainer(containingType, newName) ?? FullyQualifiedName(containingType)}.{newName}";

var es = (ies.Expression switch
{
Expand Down
Loading