CreatedResult should accept null location
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.
Thanks for your PR, @singh733. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.
One more thing. There were also a bunch of Created() overloads in the approved API that this should add.
/azp run
Azure Pipelines successfully started running 3 pipeline(s).
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 Do you need any change from my side ?
@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.
Thanks again @singh733!