Skip to content

Commit

Permalink
Update types needed in 4.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamTheCoder committed Apr 21, 2024
1 parent 365302e commit 6ed1211
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CodeConverter/CSharp/CommonConversions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ public static ExpressionSyntax ThrowawayParameters(ExpressionSyntax invocable, i
return SyntaxFactory.ParenthesizedLambdaExpression(parameters, SyntaxFactory.InvocationExpression(invocable));
}

public static CSSyntax.ParameterListSyntax CreateParameterList(IEnumerable<SyntaxNode> ps)
public static CSSyntax.ParameterListSyntax CreateParameterList(IEnumerable<CSSyntax.ParameterSyntax> ps)
{
return SyntaxFactory.ParameterList(SyntaxFactory.SeparatedList(ps));
}
Expand Down
2 changes: 1 addition & 1 deletion CodeConverter/CSharp/HandledEventsAnalysis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private PropertyDeclarationSyntax GetDeclarationsForHandlingBaseMembers((EventCo
var prop = (PropertyDeclarationSyntax) _commonConversions.CsSyntaxGenerator.Declaration(basePropertyEventSubscription.PropertyDetails.Property);
var modifiers = prop.Modifiers.RemoveWhere(m => m.IsKind(SyntaxKind.VirtualKeyword)).Add(SyntaxFactory.Token(SyntaxKind.OverrideKeyword));
//TODO Stash away methodwithandles in constructor that don't match any symbol from that type, to match here against base symbols
return GetDeclarationsForFieldBackedProperty(basePropertyEventSubscription.HandledMethods, SyntaxFactory.List<SyntaxNode>(), modifiers,
return GetDeclarationsForFieldBackedProperty(basePropertyEventSubscription.HandledMethods, SyntaxFactory.List<AttributeListSyntax>(), modifiers,
prop.Type, prop.Identifier, SyntaxFactory.MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, SyntaxFactory.BaseExpression(), ValidSyntaxFactory.IdentifierName(prop.Identifier)));
}

Expand Down
2 changes: 1 addition & 1 deletion CodeConverter/CSharp/LambdaConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private async Task<CSharpSyntaxNode> ConvertToFunctionDeclarationOrNullAsync(VBS
// Could do: See if we can improve upon returning "object" for pretty much everything (which is what the symbols say)
// I believe that in general, special VB functions such as MultiplyObject are designed to work the same as integer when given two integers for example.
// If all callers currently pass an integer, perhaps it'd be more idiomatic in C# to specify "int", than to have Operators
var paramsWithTypes = anonFuncOp.Symbol.Parameters.Select(p => CommonConversions.CsSyntaxGenerator.ParameterDeclaration(p));
var paramsWithTypes = anonFuncOp.Symbol.Parameters.Select(p => (ParameterSyntax) CommonConversions.CsSyntaxGenerator.ParameterDeclaration(p));

var paramListWithTypes = param.WithParameters(SyntaxFactory.SeparatedList(paramsWithTypes));
if (potentialAncestorDeclarationOperation is IFieldInitializerOperation fieldInit) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ public override async Task<SyntaxList<StatementSyntax>> VisitForBlock(VBSyntax.F
}


var preLoopStatements = new List<SyntaxNode>();
var preLoopStatements = new List<StatementSyntax>();
var csToValue = await stmt.ToValue.AcceptAsync<ExpressionSyntax>(_expressionVisitor);
csToValue = CommonConversions.TypeConversionAnalyzer.AddExplicitConversion(stmt.ToValue, csToValue?.SkipIntoParens(), forceTargetType: controlVarType);

Expand Down
6 changes: 3 additions & 3 deletions CodeConverter/CSharp/TypeConversionAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,17 +242,17 @@ private CSSyntax.NameSyntax GetCommonDelegateTypeOrNull(VBSyntax.ExpressionSynta
private CSSyntax.NameSyntax CreateCommonDelegateTypeSyntax(IMethodSymbol vbLambda)
{
var parameters = vbLambda.Parameters
.Select(p => _csSyntaxGenerator.TypeExpression(p.Type));
.Select(p => (TypeSyntax) _csSyntaxGenerator.TypeExpression(p.Type));

if (vbLambda.ReturnType.IsSystemVoid()) {
return CreateType("Action", parameters);
}

var typeExpression = _csSyntaxGenerator.TypeExpression(vbLambda.ReturnType);
var typeExpression = (TypeSyntax) _csSyntaxGenerator.TypeExpression(vbLambda.ReturnType);
return CreateType("Func", parameters.Concat(typeExpression));
}

private static CSSyntax.NameSyntax CreateType(string baseTypeName, IEnumerable<SyntaxNode> parameters)
private static CSSyntax.NameSyntax CreateType(string baseTypeName, IEnumerable<TypeSyntax> parameters)
{
var parameterList = SyntaxFactory.TypeArgumentList(SyntaxFactory.SeparatedList(parameters));
if (!parameterList.Arguments.Any()) return ValidSyntaxFactory.IdentifierName(baseTypeName);
Expand Down
2 changes: 1 addition & 1 deletion CodeConverter/VB/NodesVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ public override VisualBasicSyntaxNode VisitEventDeclaration(CSSyntax.EventDeclar
);
} else {
if ((int)LanguageVersion < 14) {
var conditionalStatement = _vbSyntaxGenerator.IfStatement(
var conditionalStatement = (StatementSyntax) _vbSyntaxGenerator.IfStatement(
_vbSyntaxGenerator.ReferenceNotEqualsExpression(eventFieldIdentifier,
_vbSyntaxGenerator.NullLiteralExpression()),
SyntaxFactory.InvocationExpression(
Expand Down

0 comments on commit 6ed1211

Please sign in to comment.