-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Nullability annotation missing on CacheControlHeaderValue.TryParse #74061
Comments
Tagging subscribers to this area: @dotnet/ncl Issue DetailsDescriptionIn the namespace System.Net.Http.Headers are many very specific header classes which all have their own TryParse method. For the following classes TryParse was annotated: It seems like Reproduction StepsThis does not compile without a null-forgiving operator. #nullable enable
CacheControlHeaderValue ParseHeaderOrThrow(string candidate)
=> CacheControlHeaderValue.TryParse(candidate, out var result)
? result
: throw Exception("parse failed"); Expected behaviorCacheControlHeaderValue.TryParse should have correct nullability annotations like the others, to avoid the unnecessary null-forgiving operator. Actual behaviorNo nullability annotations. Regression?No response Known WorkaroundsNo response ConfigurationNo response Other informationNo response
|
Triage: it is most possibly an oversight, but it is possible there was a reason for it. Nice to have, seems to be the first complaint since introducing nullability annotations. Moving to Future. |
Most header values support only a single value via One side-effect (I don't know whether it was intentional) is that this header will allow parsing empty values. So I think there are a few ways of looking at this. Either:
Adding back the |
Triage: |
This should be fairly straightforward to do. It is not important for any release, but we would take a contribution. |
Hey @karelz, since this issue is not important and not in a rush, can I take this one as first issue to start contributing? |
Great, thanks! Assigning to you @pierrebelin |
@pierrebelin in my experience, VS sometimes struggles with the runtime repo, but as long as it builds without errors you should be fine. If there are build errors, can you post the log here so we can have a better idea how to help you? Edit: I assume you have read the contributing guide and followed the steps for building libraries |
The last BUILD: Error: line says it all, Visual Studio 2019 or 2022 with C++ tools are required. Did you try importing the .vsconfig in the Visual Studio Installer? Not sure if this thing requires a reboot. |
Yes, that's why I deleted my post... I think it's too early to open correctly my eyes. I'm gonna grab a coffee |
* Add nullability annotation on CacheControlHeaderValue Add nullability annotation on CacheControlHeaderValue.TryParse inside System.Net.Http Fix #74061 * Returns empty value instead of null * Parsing returns empty values instead of null * Remove useless tests + null-forgiving operator * Remove null-forgiving and add nullable return type
Description
In the namespace System.Net.Http.Headers are many very specific header classes which all have their own TryParse method.
For the following classes TryParse was annotated:
AuthenticationHeaderValue
,ContentDispositionHeaderValue
,ContentRangeHeaderValue
,EntityTagHeaderValue
,MediaTypeHeaderValue
,MediaTypeWithQualityHeaderValue
,NameValueHeaderValue
,NameValueWithParametersHeaderValue
,ProductHeaderValue
,ProductInfoHeaderValue
,RangeConditionHeaderValue
,RangeHeaderValue
,RetryConditionHeaderValue
,StringWithQualityHeaderValue
,TransferCodingHeaderValue
,TransferCodingWithQualityHeaderValue
,ViaHeaderValue
,WarningHeaderValue
It seems like
CacheControlHeaderValue
was overlooked.Reproduction Steps
This does not compile without a null-forgiving operator.
Expected behavior
CacheControlHeaderValue.TryParse
should have correct nullability annotations like the others, to avoid the unnecessary null-forgiving operator.Actual behavior
No nullability annotations.
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: