-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
UriBuilder does not update the port number when scheme changes in Powershell 7 #40680
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Tagging subscribers to this area: @dotnet/ncl |
Are you sure? This behavior is the same going back to Framework 2.0 (maybe even earlier). |
Even so, I do think the behavior is very confusing, because it depends on the order in which you access properties. For example, consider the following code: var builder = new UriBuilder { Host = "me.com" };
Console.WriteLine(builder.Port);
Console.WriteLine(builder.Uri);
Console.WriteLine(builder.Port); Its output is:
I definitely wouldn't expect that accessing the Does the current behavior have to be kept for backwards compatibility? If not, I think it should be changed. If it does have to be kept, I think it should at least be clearly documented (the current documentation is fairly sparse). |
Description
In PS7 - the URI port does not reset the port to reflect change to scheme change.
Repro steps
$builder = New-Object UriBuilder
$builder.GetType().Assembly.FullName
System.Private.Uri, Version=4.0.6.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
$builder.Host = "me.com"
$builder
Fragment :
Host : me.com
Password :
Path : /
Port : -1
Query :
Scheme : http
Uri : http://me.com/
UserName :
$builder.Scheme = [Uri]::UriSchemeHttps
$builder
Fragment :
Host : me.com
Password :
Path : /
Port : 80
Query :
Scheme : https
Uri : https://me.com:80/
UserName :
Expected behavior: The port should be 443 when scheme is assigned HTTPS
Actual Behavior: The port for HTTPS is reported as 80, and not 443.
Configuration
$PSVersionTable
Name Value
PSVersion 7.0.3
PSEdition Core
GitCommitId 7.0.3
OS Microsoft Windows 10.0.19041
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Regression?
Other information
Does not repro in PS5.1
The text was updated successfully, but these errors were encountered: