-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Detect .NET SDK & VSLANG Custom Language Settings & Apply To MSBuild #8503
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
Merged
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
0f58db2
Add logic to change the encoding and detect .NET SDK and VS language …
nagilson 3a3db4d
Restore the original encoding so msbuild does not impact encoding of …
nagilson e4595a9
Add a unit test for external ui language overrides
nagilson dc17603
Merge remote-tracking branch 'upstream/main' into nagilson-cli-language
nagilson fa715d1
Fix the merge conflict that vscode did not fix (grumpiness)
nagilson cc30ce9
Use langword=null for Sandcastle and VsDocMan
nagilson 1058b59
Respond to feedback. But it's not done yet.
nagilson 01b381b
Limit the scope of the breaking change so windows who dont support ut…
nagilson 8487af6
Remove comment that I didn't hit ctrl S on, automatic encoding restor…
nagilson 747ff0b
Move encoding restorer to a non public API
nagilson 3b3b23d
Use a name instead of _ for the discard variable bc the compiler gets…
nagilson d52714b
Dont use runtimeinfo as its not in net 472 full framework even tho it…
nagilson b20919f
Move the encoding restorer so it's not part of a public api and build…
nagilson 8d0e14b
Consider that full framework must set all culture variables for corre…
nagilson d96551c
Try to make full framework correctly change the culture :(
nagilson 9b1c074
Check to see if the windows version of build machines doesnt support …
nagilson 5a06292
Dont look for vslang because vs can manage the lang settings itself a…
nagilson 60ee6bc
Make the encoding change happen earlier than msbuild use server stuff
nagilson 992fb7e
Code clean up for dotnet cli language feature
nagilson 048bd20
Respond to PR feedback
nagilson 18f34d5
Follow the Microsoft style of using the string alias over System.String
nagilson 881305c
prepare to add encoding change to logs as well
nagilson cfe0c6c
Merge remote-tracking branch 'upstream/main' into nagilson-cli-language
nagilson 45961ed
Get the encoding to change log files as well and move the encoding up…
nagilson 3023308
Merge remote-tracking branch 'upstream/main' into nagilson-cli-language
nagilson 41d9da6
Add environment variable to disable/opt-out of the new feature
nagilson aa5a55b
Move the utf8 encoding change feature flag to the change wave
nagilson 5c2db93
Remove some no-longer-required usings
rainersigwald 28b8bd0
Remove the english language and redirect in the help link
nagilson e61c559
Consider that a user may delete windows registry keys
nagilson 16a0acd
Merge branch 'nagilson-cli-language' of https://github.com/nagilson/m…
nagilson f794639
update test to expect the fallback culture instead of the original cu…
nagilson 86cf4e5
Merge remote-tracking branch 'upstream/main' into nagilson-cli-language
nagilson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// See https://aka.ms/new-console-template for more information | ||
Console.WriteLine("Hello, World!"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.IO; | ||
using System.Runtime.InteropServices; | ||
using System.Security; | ||
using System.Text; | ||
|
||
namespace Microsoft.Build.CommandLine | ||
{ | ||
/// <summary> | ||
/// Ported from https://github.com/dotnet/sdk/blob/bcea1face15458814b8e53e8785b52ba464f6538/src/Cli/dotnet/AutomaticEncodingRestorer.cs. | ||
/// A program can change the encoding of the console which would affect other programs. | ||
/// We would prefer to have a pattern where the program does not affect encoding of other programs. | ||
/// Create this class in a function akin to Main and let it manage the console encoding resources to return it to the state before execution upon destruction. | ||
/// </summary> | ||
public class AutomaticEncodingRestorer : IDisposable | ||
{ | ||
private Encoding? _originalOutputEncoding = null; | ||
private Encoding? _originalInputEncoding = null; | ||
|
||
public AutomaticEncodingRestorer() | ||
{ | ||
try | ||
{ | ||
#if NET7_0_OR_GREATER | ||
nagilson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (OperatingSystem.IsIOS() || OperatingSystem.IsAndroid() || OperatingSystem.IsTvOS()) // Output + Input Encoding are unavailable on these platforms per docs, and they're only available past net 5. | ||
{ | ||
return; | ||
} | ||
#endif | ||
_originalOutputEncoding = Console.OutputEncoding; | ||
|
||
#if NET7_0_OR_GREATER | ||
if (OperatingSystem.IsBrowser()) // Input Encoding is also unavailable in this platform. (No concern for net472 as browser is unavailable.) | ||
{ | ||
return; | ||
} | ||
#endif | ||
_originalInputEncoding = Console.InputEncoding; | ||
} | ||
catch (Exception ex) when (ex is IOException || ex is SecurityException) | ||
{ | ||
// The encoding is unavailable. Do nothing. | ||
} | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
try | ||
{ | ||
if (_originalOutputEncoding != null) | ||
{ | ||
Console.OutputEncoding = _originalOutputEncoding; | ||
} | ||
if (_originalInputEncoding != null) | ||
{ | ||
Console.InputEncoding = _originalInputEncoding; | ||
} | ||
} | ||
catch (Exception ex) when (ex is IOException || ex is SecurityException) | ||
{ | ||
// The encoding is unavailable. Do nothing. | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.