Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Apr 6, 2021
1 parent e9cf486 commit 0ebe8ad
Show file tree
Hide file tree
Showing 8 changed files with 368 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Bug50757/Bug50757.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30709.64
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bug50757", "Bug50757\Bug50757.csproj", "{744FF869-BFA0-4D69-89B2-DBC9AFE1DF2A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{744FF869-BFA0-4D69-89B2-DBC9AFE1DF2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{744FF869-BFA0-4D69-89B2-DBC9AFE1DF2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{744FF869-BFA0-4D69-89B2-DBC9AFE1DF2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{744FF869-BFA0-4D69-89B2-DBC9AFE1DF2A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A5ADCCFE-043A-4C65-921C-AA5496CF24AB}
EndGlobalSection
EndGlobal
20 changes: 20 additions & 0 deletions Bug50757/Bug50757/Bug50757.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<StartupObject />
<WasmShellMonoRuntimeExecutionMode>InterpreterAndAOT</WasmShellMonoRuntimeExecutionMode>
<WasmShellEnableEmccProfiling>true</WasmShellEnableEmccProfiling>
</PropertyGroup>

<ItemGroup>
<LinkerDescriptor Include="Linker.xml" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Uno.Wasm.Bootstrap" Version="2.1.0-dev.45" />
<PackageReference Include="Uno.Wasm.Bootstrap.DevServer" Version="2.1.0-dev.45" />
</ItemGroup>
</Project>
3 changes: 3 additions & 0 deletions Bug50757/Bug50757/Linker.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<linker>
<assembly fullname="Bug50757"/>
</linker>
91 changes: 91 additions & 0 deletions Bug50757/Bug50757/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
using System;
using System.Diagnostics;

namespace Uno.Wasm.Sample
{
public static class Program
{
static void Main(string[] args)
{
TestRegisterColor();
TestRegisterOther();
}

private static void TestRegisterColor()
{
var sw = Stopwatch.StartNew();
int value = 0;
for (int i = 0; i < 10000000; i++)
{
RegisterColor(null, c => value++);
}
sw.Stop();
Console.WriteLine($"Color: {sw.ElapsedMilliseconds}");
}

private static void TestRegisterOther()
{
var sw = Stopwatch.StartNew();
int value = 0;
for (int i = 0; i < 10000000; i++)
{
RegisterOther(null, c => value++);
}
sw.Stop();
Console.WriteLine($"Other: {sw.ElapsedMilliseconds}");
}

private static void RegisterColor(object o, Action<Color> action)
{
action(new Color());
}

private static void RegisterOther(object o, Action<IDisposable> action)
{
action(null);
}
}

public partial struct Color : IFormattable
{
public byte A { get; set; }

public byte B { get; set; }

public byte G { get; set; }

public byte R { get; set; }

internal bool IsTransparent => A == 0;

public static Color FromArgb(byte a, byte r, byte g, byte b) => new Color(a, r, g, b);

private Color(byte a, byte r, byte g, byte b)
{
A = a;
R = r;
G = g;
B = b;
}

public override bool Equals(object o) => o is Color color && Equals(color);

public bool Equals(Color color) =>
color.A == A
&& color.R == R
&& color.G == G
&& color.B == B;

public override int GetHashCode() => (A << 8) ^ (R << 6) ^ (G << 4) ^ B;

public override string ToString() => $"[Color: {A:X8};{R:X8};{G:X8};{B:X8}]";

public string ToString(string format, IFormatProvider provider) => ToString();

public static bool operator ==(Color color1, Color color2) => color1.Equals(color2);

public static bool operator !=(Color color1, Color color2) => !color1.Equals(color2);

internal Color WithOpacity(double opacity) => new Color((byte)(A * opacity), R, G, B);
}
}
27 changes: 27 additions & 0 deletions Bug50757/Bug50757/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:49943/",
"sslPort": 44344
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Bug44269": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:5000"
}
}
}
7 changes: 7 additions & 0 deletions Bug50757/Bug50757/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Repro for issue https://github.com/dotnet/runtime/issues/50757

Reproducing this requires .NET 5 RC1 or later, mono and ninja installed.

Build with `dotnet build`

The SDK files are located in %TMP/dotnet-runtime-wasm-XXX
72 changes: 72 additions & 0 deletions Bug50757/Bug50757/Resources/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

123 changes: 123 additions & 0 deletions Bug50757/Bug50757/Resources/Strings.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="MyDefaultString" xml:space="preserve">
<value>test en-US</value>
</data>
</root>

0 comments on commit 0ebe8ad

Please sign in to comment.