Skip to content

Log CurrentUICulture in binlog.#5426

Merged
rainersigwald merged 1 commit into
dotnet:masterfrom
KirillOsenkov:dev/kirillo/culture
Jun 24, 2020
Merged

Log CurrentUICulture in binlog.#5426
rainersigwald merged 1 commit into
dotnet:masterfrom
KirillOsenkov:dev/kirillo/culture

Conversation

@KirillOsenkov
Copy link
Copy Markdown
Member

@KirillOsenkov KirillOsenkov commented Jun 14, 2020

This will be useful to be able to open localized binlogs. If we know the culture of the log we can fetch the right resources from the MSBuild .dlls.

@KirillOsenkov
Copy link
Copy Markdown
Member Author

image

@Nirmal4G
Copy link
Copy Markdown
Contributor

If we are going to have CurrentUICulture, why not have CurrentCulture too?

@KirillOsenkov
Copy link
Copy Markdown
Member Author

Honestly I don’t know enough about this to know what’s the difference. Do you have a specific usage in mind where knowing CurrentCulture is required?

@Nirmal4G
Copy link
Copy Markdown
Contributor

Same as yours but what happens if the CurrentUICulture is not found, we have to fall back to some sensible default. We also have DefaultThread* props but those are bit overkill. So, falling back to CurrentCulture may not be a bad idea.

Really what my answer boils down to is consistency and completeness!!

@KirillOsenkov
Copy link
Copy Markdown
Member Author

In my opinion we should be logging enough and just enough. Logging needs a purpose. We've been aggressively trying to log less to reduce binlog sizes and cognitive load. I realize it's a small thing, but I'd say let's add this when we need it. For now I need the CurrentUICulture to know the language of the binlog so I can properly interpret localized binlogs.

@Nirmal4G
Copy link
Copy Markdown
Contributor

So, will you have en-US as the default instead of CurrentCulture?

@KirillOsenkov
Copy link
Copy Markdown
Member Author

I'm sorry, perhaps I'm misunderstanding. I have no plans to use CurrentCulture. I only need CurrentUICulture for my purposes.

If you feel like I'm missing your point could you please explain in more detail? What scenario will not work as desired?

@Nirmal4G
Copy link
Copy Markdown
Contributor

What I'm asking is, Will CurrentUICulture change depending on OS (Windows Display) language settings. For Example, I have mine in ta-IN, but there are no resources for ta-IN. So, you have to load en-US/en by default, right?

@KirillOsenkov
Copy link
Copy Markdown
Member Author

Yes, if the logged culture is not among those supported by MSBuild I will fall back to en-US, because I assume that's what MSBuild would do.

@KirillOsenkov
Copy link
Copy Markdown
Member Author

And yes, the CurrentUICulture updates based on your OS language, and MSBuild uses it to retrieve the resources in that locale:
https://source.dot.net/#Microsoft.Build/Resources/AssemblyResources.cs,76

@Nirmal4G
Copy link
Copy Markdown
Contributor

Nirmal4G commented Jun 15, 2020

The CurrentCulture is guaranteed to be available even if UI is not, since full windows language packages are available for those that msbuild also supports (correct me if I'm wrong). So can you fall-back to CurrentCulture instead of just en-US?

That's (mostly) why I've asked for the CurrentCulture to be added as a fall-back.

@KirillOsenkov
Copy link
Copy Markdown
Member Author

I think maybe you're misunderstanding what I'm logging this property for. I don't need to know what CurrentCulture was set to in the MSBuild process. I only need to know what CurrentUICulture was set to, if anything. I'm not interested in any fallbacks. I'm not going to show any UI myself.

The only purpose that I need this information for is what language the strings are in the .binlog. They can only be in one of the languages supported by MSBuild and that's what I care about.

@Nirmal4G
Copy link
Copy Markdown
Contributor

Nirmal4G commented Jun 15, 2020

I see. Then what about opening the binlogs in systems where the specified UI language resource was not available?

MSBuild will return the default language which would be en-US. This clears it up. Now I understand.

@KirillOsenkov
Copy link
Copy Markdown
Member Author

MSBuild always ships with a fixed set of languages, on all systems. It doesn't matter on which OS the log viewer is running, it will always have all languages supported by MSBuild available, for example for de you will always have the German resources.dll, regardless of the OS:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\de\Microsoft.Build.resources.dll

@Nirmal4G
Copy link
Copy Markdown
Contributor

We have an internal fork which has en, ta and other indic languages.

Copy link
Copy Markdown
Contributor

@Forgind Forgind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you've tested the behavior if CurrentUICulture isn't defined? I'm fine with defaulting to either en or CurrentCulture, but it shouldn't crash.

@KirillOsenkov
Copy link
Copy Markdown
Member Author

@Forgind I'm not sure how to test it but according to https://referencesource.microsoft.com/#mscorlib/system/globalization/cultureinfo.cs,811 it can't be null.

@Forgind
Copy link
Copy Markdown
Contributor

Forgind commented Jun 16, 2020

I was thinking of trying to set it to a language MSBuild doesn't recognize and seeing what happens, but that's convincing enough for me.

Copy link
Copy Markdown
Member

@rainersigwald rainersigwald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. #5439 should fix the tests; we'll rerun after merging it.

@rainersigwald rainersigwald added the merge-when-branch-open PRs that are approved, except that there is a problem that means we are not merging stuff right now. label Jun 18, 2020
@rainersigwald
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@rainersigwald rainersigwald merged commit 9c58e75 into dotnet:master Jun 24, 2020
@ghost ghost added this to the current-release milestone Jun 24, 2020
@KirillOsenkov KirillOsenkov deleted the dev/kirillo/culture branch June 25, 2020 00:29
Forgind added a commit to Forgind/msbuild that referenced this pull request Jun 29, 2020
Second part

Part 1 of not checking byte

parent d86a1e168bdf295aa777d47ee1a4b988b8913889
author Nathan Mytelka <Forgind@users.noreply.github.com> 1591730709 -0700
committer Nathan Mytelka <Forgind@users.noreply.github.com> 1593461702 -0700

Remove outdated comment

Part 2 of unmasking first byte

Part 3

Part 4

Part 5

Part 6

Reenabled administrator privilege and cleanup

Add test

Improve RemoveDependenciesFromEntryIfMissing (dotnet#5392)

Fixes dotnet#5180

The fix is a straightforward cache of files that have been detected to exist already, preventing duplicate file system checks on files we already know exist.

There will be a future issue and PR addressing ConstructDependencyTable mentioned in a comment on the original issue.

Testing on my machine shows an improvement in RemoveDependenciesFromEntryIfMissing of ~850ms down to 30~35ms.

Spruce up ObjectModelHelpers assertions

These fired while I was writing a new test but didn't have much useful information.

Keep AssertItems from throwing an ArgumentOutOfRangeException on mismatched lengths,
and give a clue or two about mismatched lengths in AssertItemHasMetadata.

Regression tests for dotnet#5445

Ensure that Update and Remove operations done at evaluation time that use
item functions pay attention to the item function and don't apply to all
items of the same type.

Respect item functions in lazy Update/Remove

Fixes dotnet#5445 by checking to see if an item function is invoked (the captured
expression has subcaptures) before optimizing operations on same-item
captures.

Rename short-circuit-lazy-item-update check method

The question this method answers is 'can I just remove/update every item in the group, or do I need to expand the value to match against existing items?'

Renamed it for a bit more clarity there.

Log CurrentUICulture in binlog (dotnet#5426)

This will be useful to be able to open localized binlogs. If we know the culture of the log we can fetch the right resources from the MSBuild .dlls.

Properly parse version

Part 7
Forgind added a commit that referenced this pull request Jul 22, 2020
* First step

Second part

Part 1 of not checking byte

parent d86a1e168bdf295aa777d47ee1a4b988b8913889
author Nathan Mytelka <Forgind@users.noreply.github.com> 1591730709 -0700
committer Nathan Mytelka <Forgind@users.noreply.github.com> 1593461702 -0700

Remove outdated comment

Part 2 of unmasking first byte

Part 3

Part 4

Part 5

Part 6

Reenabled administrator privilege and cleanup

Add test

Improve RemoveDependenciesFromEntryIfMissing (#5392)

Fixes #5180

The fix is a straightforward cache of files that have been detected to exist already, preventing duplicate file system checks on files we already know exist.

There will be a future issue and PR addressing ConstructDependencyTable mentioned in a comment on the original issue.

Testing on my machine shows an improvement in RemoveDependenciesFromEntryIfMissing of ~850ms down to 30~35ms.

Spruce up ObjectModelHelpers assertions

These fired while I was writing a new test but didn't have much useful information.

Keep AssertItems from throwing an ArgumentOutOfRangeException on mismatched lengths,
and give a clue or two about mismatched lengths in AssertItemHasMetadata.

Regression tests for #5445

Ensure that Update and Remove operations done at evaluation time that use
item functions pay attention to the item function and don't apply to all
items of the same type.

Respect item functions in lazy Update/Remove

Fixes #5445 by checking to see if an item function is invoked (the captured
expression has subcaptures) before optimizing operations on same-item
captures.

Rename short-circuit-lazy-item-update check method

The question this method answers is 'can I just remove/update every item in the group, or do I need to expand the value to match against existing items?'

Renamed it for a bit more clarity there.

Log CurrentUICulture in binlog (#5426)

This will be useful to be able to open localized binlogs. If we know the culture of the log we can fetch the right resources from the MSBuild .dlls.

Properly parse version

Part 7

* Moved user check

* Moved Handshake

* Fixed build

* Refactoring

* Move fire byte calculation into loop

* Save before committing 😃

* Catch uncaught exception

* PR feedback

* Correct off-by-one error
Forgind added a commit that referenced this pull request Jul 27, 2020
* First step

Second part

Part 1 of not checking byte

parent d86a1e168bdf295aa777d47ee1a4b988b8913889
author Nathan Mytelka <Forgind@users.noreply.github.com> 1591730709 -0700
committer Nathan Mytelka <Forgind@users.noreply.github.com> 1593461702 -0700

Remove outdated comment

Part 2 of unmasking first byte

Part 3

Part 4

Part 5

Part 6

Reenabled administrator privilege and cleanup

Add test

Improve RemoveDependenciesFromEntryIfMissing (#5392)

Fixes #5180

The fix is a straightforward cache of files that have been detected to exist already, preventing duplicate file system checks on files we already know exist.

There will be a future issue and PR addressing ConstructDependencyTable mentioned in a comment on the original issue.

Testing on my machine shows an improvement in RemoveDependenciesFromEntryIfMissing of ~850ms down to 30~35ms.

Spruce up ObjectModelHelpers assertions

These fired while I was writing a new test but didn't have much useful information.

Keep AssertItems from throwing an ArgumentOutOfRangeException on mismatched lengths,
and give a clue or two about mismatched lengths in AssertItemHasMetadata.

Regression tests for #5445

Ensure that Update and Remove operations done at evaluation time that use
item functions pay attention to the item function and don't apply to all
items of the same type.

Respect item functions in lazy Update/Remove

Fixes #5445 by checking to see if an item function is invoked (the captured
expression has subcaptures) before optimizing operations on same-item
captures.

Rename short-circuit-lazy-item-update check method

The question this method answers is 'can I just remove/update every item in the group, or do I need to expand the value to match against existing items?'

Renamed it for a bit more clarity there.

Log CurrentUICulture in binlog (#5426)

This will be useful to be able to open localized binlogs. If we know the culture of the log we can fetch the right resources from the MSBuild .dlls.

Properly parse version

Part 7

* Moved user check

* Moved Handshake

* Fixed build

* Refactoring

* Move fire byte calculation into loop

* Save before committing 😃

* Catch uncaught exception

* PR feedback

* Correct off-by-one error

* Make handshake version explicit

* PR comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-when-branch-open PRs that are approved, except that there is a problem that means we are not merging stuff right now.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants