3 instantiations of Result
Microsoft.Maui.Controls.BindingSourceGen (3)
74 references to Result
Microsoft.Maui.Controls.BindingSourceGen (74)
BindingSourceGenerator.cs (26)
71 private static Result<BindingInvocationDescription> GetBindingForGeneration(GeneratorSyntaxContext context, CancellationToken t)
79 var interceptedMethodTypeResult = invocationParser.ParseInvocation(invocation, t);
83 return Result<BindingInvocationDescription>.Failure(interceptedMethodTypeResult.Diagnostics);
89 return Result<BindingInvocationDescription>.Failure(DiagnosticsFactory.UnableToResolvePath(invocation.GetLocation()));
92 var lambdaResult = GetLambda(invocation, interceptedMethodTypeResult.Value);
95 return Result<BindingInvocationDescription>.Failure(lambdaResult.Diagnostics);
98 var lambdaParamTypeResult = GetLambdaParameterType(lambdaResult.Value, context.SemanticModel, t);
101 return Result<BindingInvocationDescription>.Failure(lambdaParamTypeResult.Diagnostics);
104 var lambdaReturnTypeResult = GetLambdaReturnType(lambdaResult.Value, context.SemanticModel, t);
107 return Result<BindingInvocationDescription>.Failure(lambdaReturnTypeResult.Diagnostics);
111 var pathParseResult = pathParser.ParsePath(lambdaResult.Value.ExpressionBody);
114 return Result<BindingInvocationDescription>.Failure(pathParseResult.Diagnostics);
125 return Result<BindingInvocationDescription>.Success(binding);
134 private static Result<LambdaExpressionSyntax> GetLambda(InvocationExpressionSyntax invocation, InterceptedMethodType methodType)
146 return Result<LambdaExpressionSyntax>.Failure(DiagnosticsFactory.GetterIsNotLambda(expression.GetLocation()));
152 return Result<LambdaExpressionSyntax>.Failure(DiagnosticsFactory.LambdaIsNotStatic(lambda.GetLocation()));
155 return Result<LambdaExpressionSyntax>.Success(lambda);
158 private static Result<ITypeSymbol> GetLambdaReturnType(LambdaExpressionSyntax lambda, SemanticModel semanticModel, CancellationToken t)
162 return Result<ITypeSymbol>.Failure(DiagnosticsFactory.GetterLambdaBodyIsNotExpression(lambda.Body.GetLocation()));
168 return Result<ITypeSymbol>.Failure(DiagnosticsFactory.LambdaResultCannotBeResolved(lambdaBody.GetLocation()));
171 return Result<ITypeSymbol>.Success(lambdaResultType);
174 private static Result<ITypeSymbol> GetLambdaParameterType(LambdaExpressionSyntax lambda, SemanticModel semanticModel, CancellationToken t)
178 return Result<ITypeSymbol>.Failure(DiagnosticsFactory.GetterIsNotLambda(lambda.GetLocation()));
184 return Result<ITypeSymbol>.Failure(DiagnosticsFactory.LambdaParameterCannotBeResolved(lambda.GetLocation()));
190 return Result<ITypeSymbol>.Failure(DiagnosticsFactory.UnaccessibleTypeUsedAsLambdaParameter(lambda.GetLocation()));
193 return Result<ITypeSymbol>.Success(lambdaParamType);
PathParser.cs (33)
18 internal Result<List<IPathPart>> ParsePath(CSharpSyntaxNode? expressionSyntax)
22 IdentifierNameSyntax _ => Result<List<IPathPart>>.Success(new List<IPathPart>()),
35 private Result<List<IPathPart>> HandleMemberAccessExpression(MemberAccessExpressionSyntax memberAccess)
37 var result = ParsePath(memberAccess.Expression);
49 return Result<List<IPathPart>>.Failure(DiagnosticsFactory.UnableToResolvePath(memberAccess.GetLocation()));
62 return Result<List<IPathPart>>.Success(result.Value);
65 private Result<List<IPathPart>> HandleElementAccessExpression(ElementAccessExpressionSyntax elementAccess)
67 var result = ParsePath(elementAccess.Expression);
76 var elementAccessResult = CreateIndexAccess(elementAccessSymbol, elementType, elementAccess.ArgumentList.Arguments, elementAccess.GetLocation());
83 return Result<List<IPathPart>>.Success(result.Value);
86 private Result<List<IPathPart>> HandleConditionalAccessExpression(ConditionalAccessExpressionSyntax conditionalAccess)
88 var expressionResult = ParsePath(conditionalAccess.Expression);
94 var whenNotNullResult = ParsePath(conditionalAccess.WhenNotNull);
102 return Result<List<IPathPart>>.Success(expressionResult.Value);
105 private Result<List<IPathPart>> HandleMemberBindingExpression(MemberBindingExpressionSyntax memberBinding)
113 return Result<List<IPathPart>>.Success(new List<IPathPart>([part]));
116 private Result<List<IPathPart>> HandleElementBindingExpression(ElementBindingExpressionSyntax elementBinding)
121 var elementAccessResult = CreateIndexAccess(elementAccessSymbol, elementType, elementBinding.ArgumentList.Arguments, elementBinding.GetLocation());
129 return Result<List<IPathPart>>.Success(elementAccessResult.Value);
132 private Result<List<IPathPart>> HandleBinaryExpression(BinaryExpressionSyntax asExpression)
134 var leftResult = ParsePath(asExpression.Left);
144 return Result<List<IPathPart>>.Failure(DiagnosticsFactory.UnableToResolvePath(castTo.GetLocation()));
149 return Result<List<IPathPart>>.Success(leftResult.Value);
152 private Result<List<IPathPart>> HandleCastExpression(CastExpressionSyntax castExpression)
154 var result = ParsePath(castExpression.Expression);
163 return Result<List<IPathPart>>.Failure(DiagnosticsFactory.UnableToResolvePath(castExpression.GetLocation()));
168 return Result<List<IPathPart>>.Success(result.Value);
171 private Result<List<IPathPart>> HandleDefaultCase()
173 return Result<List<IPathPart>>.Failure(DiagnosticsFactory.UnableToResolvePath(_context.Node.GetLocation()));
176 private Result<List<IPathPart>> CreateIndexAccess(ISymbol? elementAccessSymbol, ITypeSymbol? typeSymbol, SeparatedSyntaxList<ArgumentSyntax> argumentList, Location location)
180 return Result<List<IPathPart>>.Failure(DiagnosticsFactory.UnableToResolvePath(location));
187 return Result<List<IPathPart>>.Failure(DiagnosticsFactory.UnableToResolvePath(indexExpression.GetLocation()));
194 return Result<List<IPathPart>>.Success(new List<IPathPart>([part]));