-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[wasm] Introduce <InvariantTimezone> build flag #87284
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
10 commits
Select commit
Hold shift + click to select a range
cda65db
wip
pavelsavara 7544998
fix
pavelsavara 37b89ac
Merge branch 'main' into wasm_invariant_timezone
pavelsavara 75a14d1
WBT
pavelsavara d6aa491
Merge branch 'main' into wasm_invariant_timezone
pavelsavara 670b513
feedback
pavelsavara d0ae247
fix native build
pavelsavara d717645
feedback
pavelsavara 28bdd49
Merge branch 'main' into wasm_invariant_timezone
pavelsavara 30fc179
whitespace
pavelsavara 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,16 @@ | ||
| # Timezone Invariant Mode | ||
|
|
||
| Author: [Pavel Savara](https://github.com/pavelsavara) | ||
|
|
||
| It's currently only available for Browser OS. | ||
| The timezone database is not part of the browser environment (as opposed to other operating systems). | ||
| Therefore dotnet bundles the timezone database as binary as part of the runtime. | ||
| That makes download size larger and application startup slower. | ||
| If your application doesn't need to work with time zone information, you could use this feature to make the runtime about 200KB smaller. | ||
|
|
||
| You enable it in project file: | ||
| ```xml | ||
| <PropertyGroup> | ||
| <InvariantTimezone>true</InvariantTimezone> | ||
| </PropertyGroup> | ||
| ``` |
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
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,73 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Collections.Generic; | ||
| using System.IO; | ||
| using Xunit; | ||
| using Xunit.Abstractions; | ||
|
|
||
| #nullable enable | ||
|
|
||
| namespace Wasm.Build.Tests | ||
| { | ||
| public class InvariantTimezoneTests : BuildTestBase | ||
| { | ||
| public InvariantTimezoneTests(ITestOutputHelper output, SharedBuildPerTestClassFixture buildContext) | ||
| : base(output, buildContext) | ||
| { | ||
| } | ||
|
|
||
| public static IEnumerable<object?[]> InvariantTimezoneTestData(bool aot, RunHost host) | ||
| => ConfigWithAOTData(aot) | ||
| .Multiply( | ||
| new object?[] { null }, | ||
| new object?[] { false }, | ||
| new object?[] { true }) | ||
| .WithRunHosts(host) | ||
| .UnwrapItemsAsArrays(); | ||
|
|
||
| [Theory] | ||
| [MemberData(nameof(InvariantTimezoneTestData), parameters: new object[] { /*aot*/ false, RunHost.All })] | ||
| [MemberData(nameof(InvariantTimezoneTestData), parameters: new object[] { /*aot*/ true, RunHost.All })] | ||
| public void AOT_InvariantTimezone(BuildArgs buildArgs, bool? invariantTimezone, RunHost host, string id) | ||
| => TestInvariantTimezone(buildArgs, invariantTimezone, host, id); | ||
|
|
||
| [Theory] | ||
| [MemberData(nameof(InvariantTimezoneTestData), parameters: new object[] { /*aot*/ false, RunHost.All })] | ||
| public void RelinkingWithoutAOT(BuildArgs buildArgs, bool? invariantTimezone, RunHost host, string id) | ||
| => TestInvariantTimezone(buildArgs, invariantTimezone, host, id, | ||
| extraProperties: "<WasmBuildNative>true</WasmBuildNative>", | ||
| dotnetWasmFromRuntimePack: false); | ||
|
|
||
| private void TestInvariantTimezone(BuildArgs buildArgs, bool? invariantTimezone, | ||
| RunHost host, string id, string extraProperties="", bool? dotnetWasmFromRuntimePack=null) | ||
| { | ||
| string projectName = $"invariant_{invariantTimezone?.ToString() ?? "unset"}"; | ||
pavelsavara marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (invariantTimezone != null) | ||
| extraProperties = $"{extraProperties}<InvariantTimezone>{invariantTimezone}</InvariantTimezone>"; | ||
|
|
||
| buildArgs = buildArgs with { ProjectName = projectName }; | ||
| buildArgs = ExpandBuildArgs(buildArgs, extraProperties); | ||
|
|
||
| if (dotnetWasmFromRuntimePack == null) | ||
| dotnetWasmFromRuntimePack = !(buildArgs.AOT || buildArgs.Config == "Release"); | ||
|
|
||
| BuildProject(buildArgs, | ||
| id: id, | ||
| new BuildProjectOptions( | ||
| InitProject: () => File.Copy(Path.Combine(BuildEnvironment.TestAssetsPath, "Wasm.Buid.Tests.Programs", "InvariantTimezone.cs"), Path.Combine(_projectDir!, "Program.cs")), | ||
| DotnetWasmFromRuntimePack: dotnetWasmFromRuntimePack)); | ||
|
|
||
| string output = RunAndTestWasmApp(buildArgs, expectedExitCode: 42, host: host, id: id); | ||
| Assert.Contains("UTC BaseUtcOffset is 0", output); | ||
| if (invariantTimezone == true) | ||
| { | ||
| Assert.Contains("Could not find Asia/Tokyo", output); | ||
| } | ||
| else | ||
| { | ||
| Assert.Contains("Asia/Tokyo BaseUtcOffset is 09:00:00", output); | ||
| } | ||
| } | ||
| } | ||
| } | ||
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.