-
Notifications
You must be signed in to change notification settings - Fork 7.6k
WebRequestPSCmdlet.Common.cs nullable comments #19162
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
base: master
Are you sure you want to change the base?
Conversation
Unrelated test failure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't comment all issues but only demonstrate my thoughts.
...t.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs
Outdated
Show resolved
Hide resolved
...t.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs
Outdated
Show resolved
Hide resolved
...t.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs
Outdated
Show resolved
Hide resolved
...t.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs
Outdated
Show resolved
Hide resolved
...t.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs
Outdated
Show resolved
Hide resolved
@@ -653,7 +654,7 @@ protected override void ProcessRecord() | |||
|
|||
if (_followRelLink) | |||
{ | |||
if (!_relationLink.ContainsKey("next")) | |||
if (!_relationLink!.ContainsKey("next")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we could set [MemberNotNull(nameof(_relationLink))] on ParseLinkHeader() method.
...t.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs
Outdated
Show resolved
Hide resolved
...t.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs
Outdated
Show resolved
Hide resolved
@@ -1251,7 +1252,7 @@ internal virtual HttpResponseMessage GetResponse(HttpClient client, HttpRequestM | |||
CustomMethod = string.Empty; | |||
} | |||
|
|||
currentUri = new Uri(request.RequestUri, response.Headers.Location); | |||
currentUri = new Uri(request.RequestUri!, response.Headers.Location); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still haven't found a way to correctly handle this, do you have some guidance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't use BaseAddress it is ok
https://source.dot.net/#System.Net.Http/System/Net/Http/HttpClient.cs,751
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented a possible solution, maybe i could have used currentUri = response.Headers.Location;
@@ -144,7 +146,7 @@ public abstract class WebRequestPSCmdlet : PSCmdlet | |||
/// </summary> | |||
[Parameter(Position = 0, Mandatory = true)] | |||
[ValidateNotNullOrEmpty] | |||
public virtual Uri Uri { get; set; } | |||
public virtual Uri? Uri { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider [DisallowNull]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the difference between [ValidateNotNullOrEmpty] and [DisallowNull] ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First is PowerShell attribute for parameters, second is .Net attribute for nullability annotations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking more I believe this could be non-nullable because it is mandatory and not null or empty. Also there are not intentions to create an object of the class directly - only PowerShell Engine creates live cmdlets.
Maybe try:
[DisallowNull]
public virtual Uri Uri { get; set; } = null!;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@iSazonov is the solution I chose for WebSession correct and admissable? |
@iSazonov I think I addressed all the problems except 2 |
...t.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs
Outdated
Show resolved
Hide resolved
@CarloToso Since we merged large PR today I suggest to continue the work beginning with lowest level types like WebRequestSession and then move upwards. |
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
...t.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs
Outdated
Show resolved
Hide resolved
…Cmdlet/Common/WebRequestPSCmdlet.Common.cs Co-authored-by: Ilya <[email protected]>
@iSazonov could you help me fix the 2 remaining errors? |
Probably on Wednesday. |
These CIs fails come from #19330 ( |
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
PR Summary
Enable nullable annotations in WebRequestPSCmdlet.Common.cs, please review carefully.
PR Context
Discussed with @iSazonov in #19128
After #19249
After #19359
PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.(which runs in a different PS Host).