Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boolean operators and TryGet method #45

Merged
merged 3 commits into from Feb 20, 2024

Conversation

Paxol
Copy link
Contributor

@Paxol Paxol commented Feb 15, 2024

Implementation of true/false operators, boolean implicit conversion and TryGet method to extract the content of a successful Result

Closes #44

Copy link
Owner

@marcominerva marcominerva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you provide a sample of the usage of this feature? You can update the samples included in the project.

@Paxol
Copy link
Contributor Author

Paxol commented Feb 16, 2024

I've added the example, but there is a runtime error. I will look more into this later.

fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
      An unhandled exception has occurred while executing the request.
      System.MissingMethodException: Method not found: 'Boolean OperationResults.Result`1.op_Implicit(OperationResults.Result`1<!0>)'.
         at OperationResults.Sample.BusinessLayer.Services.PeopleService.GetWithImageAsync(Guid id)
         at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
         at OperationResults.Sample.BusinessLayer.Services.PeopleService.GetWithImageAsync(Guid id)
         at Program.<>c.<<<Main>$>b__0_4>d.MoveNext() in /home/mirko/tmp/OperationResults/samples/MinimalApis/OperationResults.Sample/Program.cs:line 80
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Http.RequestDelegateFactory.ExecuteTaskResult[T](Task`1 task, HttpContext httpContext)
         at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
         at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
         at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)

@Paxol Paxol marked this pull request as draft February 16, 2024 10:53
@Paxol
Copy link
Contributor Author

Paxol commented Feb 16, 2024

I found what the problem is. Basically some references problem present both in the minimal api sample and in the controller sample.

The main project references OperationResults.Sample.BusinessLayer.csproj and OperationResults.AspNetCore.Http.csproj.
While the BusinessLayer references the local OperationResults.csproj, the OperationResults.AspNetCore.Http.csproj references the OperationResultTools nuget package.

This causes some problems to the runtime that searches the method to use in the wrong assembly.

I found that going into the OperationResults.AspNetCore.Http.csproj project and referencing the local OperationResults.csproj "solves" the issue (or makes it more ugly).

So I thing that the solution to this exception goes bejond the scope of this PR.

@marcominerva marcominerva marked this pull request as ready for review February 20, 2024 10:34
@marcominerva marcominerva merged commit 9c0fa86 into marcominerva:develop Feb 20, 2024
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants