From: Jean-Philippe Bruyère Date: Fri, 22 May 2020 01:33:37 +0000 (+0200) Subject: use DllMapCore for native dll path resolutions X-Git-Tag: v0.9.5-beta~113^2~24 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=d46cbe601a9d5d4437f256a496f29a3fe6881da8;p=jp%2Fcrow.git use DllMapCore for native dll path resolutions --- diff --git a/Crow.sln b/Crow.sln index d8a144c8..159a127b 100644 --- a/Crow.sln +++ b/Crow.sln @@ -22,7 +22,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "unitTests", "unitTests\unit EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BasicTests", "Samples\BasicTests\BasicTests.csproj", "{7AEB6DD5-916E-4415-84E1-78EC6E5881CE}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PerfTests", "PerfTests\PerfTests.csproj", "{18EBB41F-815E-4BF5-B80F-C9E2FAB2993A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PerfTests", "Samples\PerfTests\PerfTests.csproj", "{18EBB41F-815E-4BF5-B80F-C9E2FAB2993A}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -65,6 +65,7 @@ Global {56329D48-D382-4850-93DE-59C453894E8A} = {B2C7855A-2878-47FD-AD32-9A83DB4AB8C6} {91F1CE07-EECE-4F1D-A3EE-7239B563654A} = {B2C7855A-2878-47FD-AD32-9A83DB4AB8C6} {7AEB6DD5-916E-4415-84E1-78EC6E5881CE} = {B2C7855A-2878-47FD-AD32-9A83DB4AB8C6} + {18EBB41F-815E-4BF5-B80F-C9E2FAB2993A} = {B2C7855A-2878-47FD-AD32-9A83DB4AB8C6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {00D4E149-7131-49F4-BAAD-559AA961A78E} @@ -105,6 +106,5 @@ Global $6.LineAlign = 0 $6.Wrap = False description = @C.R.O.W. c# Rapid Open Widgets\n\nCrow is a pure c# widget toolkit with XML definition of interface, bindings, styling...\n - version = 0.8.0 EndGlobalSection EndGlobal diff --git a/Crow/App.config b/Crow/App.config new file mode 100644 index 00000000..6651a783 --- /dev/null +++ b/Crow/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/Crow/Crow.csproj b/Crow/Crow.csproj index 2e1911d7..587ca78c 100644 --- a/Crow/Crow.csproj +++ b/Crow/Crow.csproj @@ -4,7 +4,6 @@ netstandard2.0 $(CrowVersion) - $(CrowVersion) $(CrowPackageVersion) C# Rapid Open Widget Toolkit @@ -29,6 +28,7 @@ _DESIGN_MODE false false + App.config full diff --git a/PerfTests/PerfTests.csproj b/PerfTests/PerfTests.csproj deleted file mode 100644 index dc735db5..00000000 --- a/PerfTests/PerfTests.csproj +++ /dev/null @@ -1,34 +0,0 @@ - - - - net472 - Exe - 0.8.0 - - - - - - - - PreserveNewest - Interfaces\%(RecursiveDir)%(Filename)%(Extension) - - - ui.%(Filename)%(Extension) - Templates\%(Filename)%(Extension) - - - - images.%(Filename)%(Extension) - Images\%(Filename)%(Extension) - - - Icons.%(Filename)%(Extension) - Icons\%(Filename)%(Extension) - - - - - - \ No newline at end of file diff --git a/PerfTests/Program.cs b/PerfTests/Program.cs deleted file mode 100644 index 68d8c73e..00000000 --- a/PerfTests/Program.cs +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) 2013-2020 Jean-Philippe Bruyère -// -// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) -using System; -using System.CodeDom.Compiler; -using System.Diagnostics; -using System.IO; -using Crow; - -namespace PerfTests -{ - class TestInterface : Interface - { - public TestInterface (int width = 800, int height = 600) - : base (width, height, false, false) - { - surf = new Crow.Cairo.ImageSurface (Crow.Cairo.Format.Argb32, ClientRectangle.Width, ClientRectangle.Height); - Init (); - } - - long Test (string path, out long min, out long max, int count = 10) - { - min = long.MaxValue; - max = long.MinValue; - - long total = 0; - - Stopwatch sw = new Stopwatch (); - - for (int i = 0; i < count; i++) { - sw.Restart (); - - - Load (path); - while (LayoutingQueue.Count > 0) - Update (); - - sw.Stop (); - - if (sw.ElapsedTicks < min) - min = sw.ElapsedMilliseconds; - if (sw.ElapsedTicks > max) - max = sw.ElapsedMilliseconds; - total += sw.ElapsedMilliseconds; - - } - - return total / count; - } - - void testDir (string dirPath, int level = 0) - { - Console.WriteLine ($"{new string (' ', level * 4)}- {dirPath}"); - level++; - - foreach (string d in Directory.GetDirectories (dirPath)) - testDir (d, level); - - foreach (string f in Directory.GetFiles (dirPath)) { - try { - long mean = Test (f, out long min, out long max); - Console.WriteLine ($"{new string (' ', level * 4)}{ Path.GetFileName (f),-30}|{min,5}|{mean,5}|{max,5}"); - } catch (Exception ex) { - Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine ($"- {ex.Message}"); - Console.ResetColor (); - } - } - } - - - public static void Main (string [] args) - { - Console.WriteLine ($"git:{ThisAssembly.Git.Commit} {ThisAssembly.Git.Branch} {ThisAssembly.Git.SemVer.Major}.{ThisAssembly.Git.SemVer.Minor}.{ThisAssembly.Git.SemVer.Patch} {ThisAssembly.Git.SemVer.Label}"); - //IndentedTextWriter w = new IndentedTextWriter() - using (TestInterface iface = new TestInterface ()) { - iface.testDir ("Interfaces"); - } - } - } -} diff --git a/Samples/BasicTests/BasicTests.cs b/Samples/BasicTests/BasicTests.cs index b0d99ccc..fba4b70a 100644 --- a/Samples/BasicTests/BasicTests.cs +++ b/Samples/BasicTests/BasicTests.cs @@ -10,9 +10,11 @@ namespace tests { public class BasicTests : SampleBase { - [STAThread] static void Main () { +#if NETCOREAPP3_1 + DllMapCore.Resolve.Enable (true); +#endif using (BasicTests app = new BasicTests ()) { app.Run (); } @@ -96,7 +98,7 @@ namespace tests else if (idx < 0) idx = testFiles.Length - 1; - Console.WriteLine ($"Loading {testFiles [idx]}."); + Console.WriteLine ($"Loading {testFiles [idx]}. {AppDomain.CurrentDomain.MonitoringSurvivedMemorySize}"); Load (testFiles [idx]).DataSource = this; } catch (Exception ex) { diff --git a/Samples/ControlLib/ControlLib.csproj b/Samples/ControlLib/ControlLib.csproj index c82431e8..e9d01df9 100644 --- a/Samples/ControlLib/ControlLib.csproj +++ b/Samples/ControlLib/ControlLib.csproj @@ -2,7 +2,6 @@ net472;netstandard2.0 false - 0.8.0 diff --git a/Samples/Directory.Build.props b/Samples/Directory.Build.props index d3e9d668..d2f140e7 100644 --- a/Samples/Directory.Build.props +++ b/Samples/Directory.Build.props @@ -15,10 +15,10 @@ false $(SolutionDir)Samples\ - - + + diff --git a/Samples/HelloWorld/main.cs b/Samples/HelloWorld/main.cs index 44ec3fb8..743419ee 100644 --- a/Samples/HelloWorld/main.cs +++ b/Samples/HelloWorld/main.cs @@ -5,6 +5,9 @@ namespace HelloWorld { class Program { static void Main (string[] args) { +#if NETCOREAPP3_1 + DllMapCore.Resolve.Enable (true); +#endif using (Interface app = new Interface ()) { app.Initialized += (sender, e) => (sender as Interface).Load ("#HelloWorld.helloworld.crow"); app.Run (); diff --git a/Samples/PerfTests/PerfTests.csproj b/Samples/PerfTests/PerfTests.csproj new file mode 100644 index 00000000..982bd359 --- /dev/null +++ b/Samples/PerfTests/PerfTests.csproj @@ -0,0 +1,26 @@ + + + + + + + + \ No newline at end of file diff --git a/Samples/PerfTests/Program.cs b/Samples/PerfTests/Program.cs new file mode 100644 index 00000000..68d8c73e --- /dev/null +++ b/Samples/PerfTests/Program.cs @@ -0,0 +1,81 @@ +// Copyright (c) 2013-2020 Jean-Philippe Bruyère +// +// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) +using System; +using System.CodeDom.Compiler; +using System.Diagnostics; +using System.IO; +using Crow; + +namespace PerfTests +{ + class TestInterface : Interface + { + public TestInterface (int width = 800, int height = 600) + : base (width, height, false, false) + { + surf = new Crow.Cairo.ImageSurface (Crow.Cairo.Format.Argb32, ClientRectangle.Width, ClientRectangle.Height); + Init (); + } + + long Test (string path, out long min, out long max, int count = 10) + { + min = long.MaxValue; + max = long.MinValue; + + long total = 0; + + Stopwatch sw = new Stopwatch (); + + for (int i = 0; i < count; i++) { + sw.Restart (); + + + Load (path); + while (LayoutingQueue.Count > 0) + Update (); + + sw.Stop (); + + if (sw.ElapsedTicks < min) + min = sw.ElapsedMilliseconds; + if (sw.ElapsedTicks > max) + max = sw.ElapsedMilliseconds; + total += sw.ElapsedMilliseconds; + + } + + return total / count; + } + + void testDir (string dirPath, int level = 0) + { + Console.WriteLine ($"{new string (' ', level * 4)}- {dirPath}"); + level++; + + foreach (string d in Directory.GetDirectories (dirPath)) + testDir (d, level); + + foreach (string f in Directory.GetFiles (dirPath)) { + try { + long mean = Test (f, out long min, out long max); + Console.WriteLine ($"{new string (' ', level * 4)}{ Path.GetFileName (f),-30}|{min,5}|{mean,5}|{max,5}"); + } catch (Exception ex) { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine ($"- {ex.Message}"); + Console.ResetColor (); + } + } + } + + + public static void Main (string [] args) + { + Console.WriteLine ($"git:{ThisAssembly.Git.Commit} {ThisAssembly.Git.Branch} {ThisAssembly.Git.SemVer.Major}.{ThisAssembly.Git.SemVer.Minor}.{ThisAssembly.Git.SemVer.Patch} {ThisAssembly.Git.SemVer.Label}"); + //IndentedTextWriter w = new IndentedTextWriter() + using (TestInterface iface = new TestInterface ()) { + iface.testDir ("Interfaces"); + } + } + } +} diff --git a/Samples/ShowCase/ShowCase.cs b/Samples/ShowCase/ShowCase.cs new file mode 100644 index 00000000..10da3683 --- /dev/null +++ b/Samples/ShowCase/ShowCase.cs @@ -0,0 +1,115 @@ +// Copyright (c) 2013-2019 Bruyère Jean-Philippe +// +// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + +using System; +using Crow; +using System.IO; +using System.Text; +using Crow.IML; + +namespace ShowCase +{ + class Showcase : Interface + { + + static void Main () + { +#if NETCOREAPP3_1 + DllMapCore.Resolve.Enable (true); +#endif + using (Showcase app = new Showcase ()) + app.Run (); + } + + public Container crowContainer; + + protected override void OnInitialized () + { + Widget g = Load ("#ShowCase.showcase.crow"); + g.DataSource = this; + crowContainer = g.FindByName ("CrowContainer") as Container; + //I set an empty object as datasource at this level to force update when new + //widgets are added to the interface + crowContainer.DataSource = new object (); + hideError (); + } + + static void App_KeyboardKeyDown (object sender, KeyEventArgs e) + { +#if DEBUG_LOG + switch (e.Key) { + case Key.F2: + DebugLog.save (sender as Interface); + break; + } +#endif + } + + public Showcase () + : base (1024, 800) + { + } + + + void Dv_SelectedItemChanged (object sender, SelectionChangeEventArgs e) + { + FileSystemInfo fi = e.NewValue as FileSystemInfo; + if (fi == null) + return; + if (fi is DirectoryInfo) + return; + hideError (); + lock (UpdateMutex) { + try { + Widget g = CreateInstance (fi.FullName); + crowContainer.SetChild (g); + g.DataSource = this; + } catch (Exception ex) { + Console.WriteLine (ex.ToString ()); + showError (ex); + } + } + + string source = ""; + using (Stream s = new FileStream (fi.FullName, FileMode.Open)) { + using (StreamReader sr = new StreamReader (s)) { + source = sr.ReadToEnd (); + } + } + NotifyValueChanged ("source", source); + } + + void showError (Exception ex) + { + NotifyValueChanged ("ErrorMessage", ex.Message); + NotifyValueChanged ("ShowError", true); + } + void hideError () + { + NotifyValueChanged ("ShowError", false); + } + + void Tb_TextChanged (object sender, TextChangeEventArgs e) + { + hideError (); + Widget g = null; + try { + lock (UpdateMutex) { + Instantiator inst = null; + using (MemoryStream ms = new MemoryStream (Encoding.UTF8.GetBytes (e.Text))) { + inst = new Instantiator (this, ms); + } + g = inst.CreateInstance (); + crowContainer.SetChild (g); + g.DataSource = this; + } + } catch (Exception ex) { + Console.WriteLine (ex.ToString ()); + showError ((Exception)ex); + } + } + + + } +} \ No newline at end of file diff --git a/Samples/ShowCase/ShowCase.csproj b/Samples/ShowCase/ShowCase.csproj index fe311b56..ad2019cb 100644 --- a/Samples/ShowCase/ShowCase.csproj +++ b/Samples/ShowCase/ShowCase.csproj @@ -1,6 +1,5 @@ - ShowCase.%(Filename)%(Extension) @@ -8,5 +7,5 @@ - + \ No newline at end of file diff --git a/Samples/ShowCase/main.cs b/Samples/ShowCase/main.cs deleted file mode 100644 index b65f3dfe..00000000 --- a/Samples/ShowCase/main.cs +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright (c) 2013-2019 Bruyère Jean-Philippe -// -// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) - -using System; -using Crow; -using System.IO; -using System.Collections.Generic; -using System.Reflection; -using System.Linq; -using System.Text; -using Crow.IML; - -namespace tests -{ - class Showcase : Interface - { - public Container crowContainer; - - [STAThread] - static void Main () - { - using (Showcase app = new Showcase ()) { - //app.Keyboard.KeyDown += App_KeyboardKeyDown; - - app.Run (); - - } - } - - protected override void OnInitialized () - { - Widget g = Load ("#ShowCase.showcase.crow"); - g.DataSource = this; - crowContainer = g.FindByName ("CrowContainer") as Container; - //I set an empty object as datasource at this level to force update when new - //widgets are added to the interface - crowContainer.DataSource = new object (); - hideError (); - } - - static void App_KeyboardKeyDown (object sender, KeyEventArgs e) - { -#if DEBUG_LOG - switch (e.Key) { - case Key.F2: - DebugLog.save (sender as Interface); - break; - } -#endif - } - - public Showcase () - : base (1024, 800) - { - } - - - void Dv_SelectedItemChanged (object sender, SelectionChangeEventArgs e) - { - FileSystemInfo fi = e.NewValue as FileSystemInfo; - if (fi == null) - return; - if (fi is DirectoryInfo) - return; - hideError (); - lock (UpdateMutex) { - try { - Widget g = CreateInstance (fi.FullName); - crowContainer.SetChild (g); - g.DataSource = this; - } catch (Exception ex) { - Console.WriteLine (ex.ToString ()); - showError (ex); - } - } - - string source = ""; - using (Stream s = new FileStream (fi.FullName, FileMode.Open)) { - using (StreamReader sr = new StreamReader (s)) { - source = sr.ReadToEnd (); - } - } - NotifyValueChanged ("source", source); - } - - void showError (Exception ex) - { - NotifyValueChanged ("ErrorMessage", ex.Message); - NotifyValueChanged ("ShowError", true); - } - void hideError () - { - NotifyValueChanged ("ShowError", false); - } - - void Tb_TextChanged (object sender, TextChangeEventArgs e) - { - hideError (); - Widget g = null; - try { - lock (UpdateMutex) { - Instantiator inst = null; - using (MemoryStream ms = new MemoryStream (Encoding.UTF8.GetBytes (e.Text))) { - inst = new Instantiator (this, ms); - } - g = inst.CreateInstance (); - crowContainer.SetChild (g); - g.DataSource = this; - } - } catch (Exception ex) { - Console.WriteLine (ex.ToString ()); - showError ((Exception)ex); - } - } - - - } -} \ No newline at end of file diff --git a/Samples/common/SampleBase.cs b/Samples/common/SampleBase.cs index 8ee0c151..6800e9ef 100644 --- a/Samples/common/SampleBase.cs +++ b/Samples/common/SampleBase.cs @@ -8,7 +8,7 @@ using Crow; namespace Crow { - public class SampleBase : Interface { + public class SampleBase : Interface { public Version CrowVersion => Assembly.GetAssembly (typeof (Widget)).GetName ().Version; #region Test values for Binding diff --git a/unitTests/unitTests.csproj b/unitTests/unitTests.csproj index c3d6dc97..d5f74c99 100644 --- a/unitTests/unitTests.csproj +++ b/unitTests/unitTests.csproj @@ -1,10 +1,6 @@ net472 - 0.8.0 - - - full