From aa78f9c7a43c40e189d10af8af71dd21643247a9 Mon Sep 17 00:00:00 2001 From: Florian Traxler Date: Wed, 1 Apr 2020 17:01:45 +0200 Subject: [PATCH 1/3] updated nugets to use actual versions --- SkiaSharpFiddle/SkiaSharpFiddle.csproj | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/SkiaSharpFiddle/SkiaSharpFiddle.csproj b/SkiaSharpFiddle/SkiaSharpFiddle.csproj index 9332166..1113e7a 100644 --- a/SkiaSharpFiddle/SkiaSharpFiddle.csproj +++ b/SkiaSharpFiddle/SkiaSharpFiddle.csproj @@ -16,12 +16,12 @@ - - + + - - - + + + \ No newline at end of file From c1082cbb740cbbc2caa1e9c5ac0d667c1b4ade8a Mon Sep 17 00:00:00 2001 From: Florian Traxler Date: Wed, 1 Apr 2020 17:42:53 +0200 Subject: [PATCH 2/3] adding SkiaSharp.Extended.Svg support --- SkiaSharpFiddle/Compiler/AssemblyLoader.cs | 41 ++++++++++++++++++++++ SkiaSharpFiddle/Compiler/Compiler.cs | 20 ++--------- SkiaSharpFiddle/SkiaSharpFiddle.csproj | 2 ++ 3 files changed, 46 insertions(+), 17 deletions(-) create mode 100644 SkiaSharpFiddle/Compiler/AssemblyLoader.cs diff --git a/SkiaSharpFiddle/Compiler/AssemblyLoader.cs b/SkiaSharpFiddle/Compiler/AssemblyLoader.cs new file mode 100644 index 0000000..7d13c48 --- /dev/null +++ b/SkiaSharpFiddle/Compiler/AssemblyLoader.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +namespace SkiaSharpFiddle +{ + public class AssemblyLoader + { + private static readonly string[] WhitelistedAssemblies = + { + "netstandard", + "mscorlib", + "System", + "System.Core", + "System.Private.CoreLib", + "System.Runtime", + "SkiaSharp", + "SkiaSharp.Extended", + "SkiaSharp.Extended.Svg", + "System.Xml.ReaderWriter", + "System.Private.Xml", + }; + + public AssemblyLoader() + { + AddExternalAssemblies(); + } + + public IEnumerable GetReferences() => + AppDomain.CurrentDomain + .GetAssemblies() + .Where(a => WhitelistedAssemblies.Any(wl => wl.Equals(a.GetName().Name, StringComparison.OrdinalIgnoreCase))); + + private void AddExternalAssemblies() + { + var skiasharpExtendedReference = SkiaSharp.Extended.SKGeometry.PI; + var skiasharpSvgReference = new SkiaSharp.Extended.Svg.SKSvg(); + } + } +} diff --git a/SkiaSharpFiddle/Compiler/Compiler.cs b/SkiaSharpFiddle/Compiler/Compiler.cs index e55ca97..b457c94 100644 --- a/SkiaSharpFiddle/Compiler/Compiler.cs +++ b/SkiaSharpFiddle/Compiler/Compiler.cs @@ -14,26 +14,17 @@ namespace SkiaSharpFiddle { internal class Compiler { - private static readonly string[] WhitelistedAssemblies = - { - "netstandard", - "mscorlib", - "System", - "System.Core", - "System.Private.CoreLib", - "System.Runtime", - "SkiaSharp", - }; - private readonly CSharpCompilationOptions compilationOptions; private readonly CSharpParseOptions parseOptions; private readonly object referencesLocker = new object(); private Assembly[] assemblyReferences; private MetadataReference[] metadataReferences; + private AssemblyLoader assemblyLoader; public Compiler() { + assemblyLoader = new AssemblyLoader(); compilationOptions = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary); parseOptions = new CSharpParseOptions(LanguageVersion.Latest, kind: SourceCodeKind.Script); } @@ -45,7 +36,7 @@ public async Task CompileAsync(string sourceCode, Cancellatio // load references lock (referencesLocker) { - assemblyReferences = GetReferences().ToArray(); + assemblyReferences = assemblyLoader.GetReferences().ToArray(); metadataReferences = assemblyReferences.Select(a => MetadataReference.CreateFromFile(a.Location)).ToArray(); } @@ -58,11 +49,6 @@ public async Task CompileAsync(string sourceCode, Cancellatio return result; } - private IEnumerable GetReferences() => - AppDomain.CurrentDomain - .GetAssemblies() - .Where(a => WhitelistedAssemblies.Any(wl => wl.Equals(a.GetName().Name, StringComparison.OrdinalIgnoreCase))); - private CompilationResult CompileSourceCode(SourceText sourceCode, CancellationToken cancellationToken = default) { var syntaxTree = SyntaxFactory.ParseSyntaxTree( diff --git a/SkiaSharpFiddle/SkiaSharpFiddle.csproj b/SkiaSharpFiddle/SkiaSharpFiddle.csproj index 1113e7a..f9f3d33 100644 --- a/SkiaSharpFiddle/SkiaSharpFiddle.csproj +++ b/SkiaSharpFiddle/SkiaSharpFiddle.csproj @@ -20,6 +20,8 @@ + + From fe5f6aeff7d7dc163c3a3958aabae162116b2e8a Mon Sep 17 00:00:00 2001 From: Florian Traxler Date: Wed, 1 Apr 2020 18:09:05 +0200 Subject: [PATCH 3/3] changing canvas sizes directly because focus lost does not work when entering the editor --- SkiaSharpFiddle/MainWindow.xaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SkiaSharpFiddle/MainWindow.xaml b/SkiaSharpFiddle/MainWindow.xaml index c6fa324..ed6945d 100644 --- a/SkiaSharpFiddle/MainWindow.xaml +++ b/SkiaSharpFiddle/MainWindow.xaml @@ -85,9 +85,9 @@ ItemsSource="{Binding ColorCombinations}" DisplayMemberPath="Name" />