aspnetcore icon indicating copy to clipboard operation
aspnetcore copied to clipboard

CreatedResult should accept null location

Open singh733 opened this issue 3 years ago • 2 comments

Task #39454

CreatedResult should accept null location

Description The primary resource created by the request is identified by either a Location header field in the response or, if no Location field is received, by the effective request URI.

singh733 avatar Jul 05 '22 10:07 singh733

Thanks for your PR, @singh733. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

ghost avatar Jul 05 '22 10:07 ghost

One more thing. There were also a bunch of Created() overloads in the approved API that this should add.

halter73 avatar Jul 07 '22 00:07 halter73

/azp run

captainsafia avatar Dec 06 '22 23:12 captainsafia

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Dec 06 '22 23:12 azure-pipelines[bot]

Triage: Need to follow-up on the PublicAPI.txt issues that are blocking this. Let's see about merging with override if there are no other issues in this PR.

captainsafia avatar Dec 06 '22 23:12 captainsafia

@captainsafia Do you need any change from my side ?

singh733 avatar Dec 07 '22 15:12 singh733

@singh733 Thanks for offering to continue updating this after all this time! I appreciate you sticking with it.

I think I managed to massage the PublicAPI.Unshipped.txt files to get the build passing. I thought we were going to have to resort to changing a PublicAPI.Shipped.txt to get the nullability change to the Location property through, but it seems it's alright with claiming the setter is unchanged. Sometimes the analyzer doesn't capture enough information to notice API changes. See https://github.com/dotnet/roslyn-analyzers/issues/3047 and https://github.com/dotnet/roslyn-analyzers/issues/3901. While I was at it, I rebased your changes on main.

Because this didn't make it for .NET 7, I removed the changes that removed Created(string uri) and Created(Uri uri) from TypedResults now that it's shipped API.

I also reverted the change that caused Results to always return Created<object> even when given a null value like TypedResults do. I like always returning the same runtime type from a given method in principle, but now I don't think it's worth breaking code that might depend on the Results returning Created instead of Created<TValue> in the null value case. Hopefully code that cares about the runtime types of these things will use TypedResults instead.

halter73 avatar Dec 08 '22 00:12 halter73

Thanks again @singh733!

halter73 avatar Dec 08 '22 22:12 halter73