WebRequestPSCmdlet.Common.cs nullable comments #19162
WebRequestPSCmdlet.Common.cs nullable comments #19162CarloToso wants to merge 45 commits intoPowerShell:masterfrom
Conversation
|
Unrelated test failure |
...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
| if (_followRelLink) | ||
| { | ||
| if (!_relationLink.ContainsKey("next")) | ||
| if (!_relationLink!.ContainsKey("next")) |
There was a problem hiding this comment.
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
| } | ||
|
|
||
| currentUri = new Uri(request.RequestUri, response.Headers.Location); | ||
| currentUri = new Uri(request.RequestUri!, response.Headers.Location); |
There was a problem hiding this comment.
I still haven't found a way to correctly handle this, do you have some guidance?
There was a problem hiding this comment.
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.
Implemented a possible solution, maybe i could have used currentUri = response.Headers.Location;
| [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.
What's the difference between [ValidateNotNullOrEmpty] and [DisallowNull] ?
There was a problem hiding this comment.
First is PowerShell attribute for parameters, second is .Net attribute for nullability annotations.
There was a problem hiding this comment.
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!;|
@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 <darpa@yandex.ru>
|
@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,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.(which runs in a different PS Host).