Multi-platform .NET bindings to the Ultralight project.

add signing functionality

add demo program

begin adding high-level abstractions


Former-commit-id: c1c6fcd95cc23be42a583b8e232c189d135842f9

+47
Directory.Build.props
···
··· 1 + <Project> 2 + <PropertyGroup> 3 + <SolutionDir Condition="'$(SolutionDir)'==''">$(MSBuildThisFileDirectory)</SolutionDir> 4 + <Version>1.2.0-beta</Version> 5 + </PropertyGroup> 6 + 7 + <Target Name="UpdatePackageCacheForDependencies" BeforeTargets="Build" Condition="'@(NuPkgRef->Count())'!='0'"> 8 + <ItemGroup> 9 + <NuPkgRef Update="**"> 10 + <Id>$([System.Text.RegularExpressions.Regex]::Replace('%(NuPkgRef.Filename)', '^(.*?)\.(?:\.?[0-9]+){3,}(?:[-a-z]+)?$', '$1'))</Id> 11 + <Version>$([System.Text.RegularExpressions.Regex]::Replace('%(NuPkgRef.Filename)', '^.*?\.((?:\.?[0-9]+){3,}(?:[-a-z]+)?)$', '$1'))</Version> 12 + </NuPkgRef> 13 + <NuPkgRef Update="**"> 14 + <LowerCaseId>$([System.String]::Copy('%(NuPkgRef.Id)').ToLowerInvariant())</LowerCaseId> 15 + </NuPkgRef> 16 + </ItemGroup> 17 + <Message Importance="high" Text="Updating package cache: %(NuPkgRef.Id) %(NuPkgRef.Version)"/> 18 + <Unzip SourceFiles="%(NuPkgRef.Identity)" 19 + DestinationFolder="$(NuGetPackageRoot)%(NuPkgRef.LowerCaseId)\%(NuPkgRef.Version)\" 20 + SkipUnchangedFiles="true" ContinueOnError="true"> 21 + </Unzip> 22 + </Target> 23 + 24 + <PropertyGroup> 25 + <SignAssembly>True</SignAssembly> 26 + <AssemblyOriginatorKeyFile Condition=" '$(IsOfficial)' == 'True' ">$(SolutionDir)official.snk</AssemblyOriginatorKeyFile> 27 + <AssemblyOriginatorKeyFile Condition=" '$(IsOfficial)' != 'True' AND '$(IsOfficialCompatible)' != 'True' ">$(SolutionDir)unofficial.snk</AssemblyOriginatorKeyFile> 28 + <AssemblyOriginatorKeyFile Condition=" '$(IsOfficial)' != 'True' AND '$(IsOfficialCompatible)' == 'True' ">$(SolutionDir)official-public.snk</AssemblyOriginatorKeyFile> 29 + <PublicSign Condition=" '$(IsOfficial)' == 'True' AND '$(IsOfficialCompatible)' != 'True' ">False</PublicSign> 30 + <PublicSign Condition=" '$(IsOfficial)' != 'True' OR '$(IsOfficialCompatible)' == 'True' ">True</PublicSign> 31 + </PropertyGroup> 32 + 33 + 34 + <PropertyGroup Condition=" '$(IsOfficial)' == 'True' "> 35 + <DefineConstants Condition=" '$(DefineConstants)' != '' ">$(DefineConstants);OFFICIAL</DefineConstants> 36 + <DefineConstants Condition=" '$(DefineConstants)' == '' ">OFFICIAL</DefineConstants> 37 + </PropertyGroup> 38 + 39 + <Target Name="PackageAssemblySigningReport" AfterTargets="Pack" Condition=" '$(IsPackable)' != 'False' "> 40 + <Message Importance="high" Text="IsOfficial: $(IsOfficial)"/> 41 + <Message Importance="high" Text="IsOfficialCompatible: $(IsOfficialCompatible)"/> 42 + <Message Importance="high" Text="SignAssembly: $(SignAssembly)"/> 43 + <Message Importance="high" Text="PublicSign: $(PublicSign)"/> 44 + <Message Importance="high" Text="AssemblyOriginatorKeyFile: $(AssemblyOriginatorKeyFile)"/> 45 + <Message Importance="high" Text="DefineConstants: $(DefineConstants)"/> 46 + </Target> 47 + </Project>
+24
UltralightSharp.Demo/DemoProgram.cs
···
··· 1 + using System; 2 + using Ultralight; 3 + using String = System.String; 4 + 5 + namespace UltralightSharp.Demo { 6 + 7 + public static class DemoProgram { 8 + 9 + public static unsafe void Main(string[] args) { 10 + var cfg = Config.Create(); 11 + var renderer = Renderer.Create(cfg); 12 + var sessionName = Ultralight.String.Create("Demo"); 13 + var session = Session.Create(renderer, false, sessionName); 14 + var view = View.Create(renderer, 640, 480, false, session); 15 + 16 + view->Destroy(); 17 + session->Destroy(); 18 + renderer->Destroy(); 19 + cfg->Destroy(); 20 + } 21 + 22 + } 23 + 24 + }
+16
UltralightSharp.Demo/UltralightSharp.Demo.csproj
···
··· 1 + <Project Sdk="Microsoft.NET.Sdk"> 2 + 3 + <PropertyGroup> 4 + <OutputType>Exe</OutputType> 5 + <TargetFramework>netcoreapp3.1</TargetFramework> 6 + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> 7 + <Platform>x64</Platform> 8 + <PlatformTarget>x64</PlatformTarget> 9 + <RuntimeIdentifier>win-x64</RuntimeIdentifier> 10 + </PropertyGroup> 11 + 12 + <ItemGroup> 13 + <PackageReference Include="ImpromptuNinjas.UltralightSharp" Version="[$(Version)]" /> 14 + </ItemGroup> 15 + 16 + </Project>
+6
UltralightSharp.sln
··· 2 Microsoft Visual Studio Solution File, Format Version 12.00 3 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UltralightSharp", "UltralightSharp\UltralightSharp.csproj", "{96233509-536D-46D0-A206-B8E06F81132D}" 4 EndProject 5 Global 6 GlobalSection(SolutionConfigurationPlatforms) = preSolution 7 Debug|Any CPU = Debug|Any CPU ··· 12 {96233509-536D-46D0-A206-B8E06F81132D}.Debug|Any CPU.Build.0 = Debug|Any CPU 13 {96233509-536D-46D0-A206-B8E06F81132D}.Release|Any CPU.ActiveCfg = Release|Any CPU 14 {96233509-536D-46D0-A206-B8E06F81132D}.Release|Any CPU.Build.0 = Release|Any CPU 15 EndGlobalSection 16 EndGlobal
··· 2 Microsoft Visual Studio Solution File, Format Version 12.00 3 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UltralightSharp", "UltralightSharp\UltralightSharp.csproj", "{96233509-536D-46D0-A206-B8E06F81132D}" 4 EndProject 5 + Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UltralightSharp.Demo", "UltralightSharp.Demo\UltralightSharp.Demo.csproj", "{B02BAE78-39EE-457A-92EC-10AF4220154C}" 6 + EndProject 7 Global 8 GlobalSection(SolutionConfigurationPlatforms) = preSolution 9 Debug|Any CPU = Debug|Any CPU ··· 14 {96233509-536D-46D0-A206-B8E06F81132D}.Debug|Any CPU.Build.0 = Debug|Any CPU 15 {96233509-536D-46D0-A206-B8E06F81132D}.Release|Any CPU.ActiveCfg = Release|Any CPU 16 {96233509-536D-46D0-A206-B8E06F81132D}.Release|Any CPU.Build.0 = Release|Any CPU 17 + {B02BAE78-39EE-457A-92EC-10AF4220154C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 18 + {B02BAE78-39EE-457A-92EC-10AF4220154C}.Debug|Any CPU.Build.0 = Debug|Any CPU 19 + {B02BAE78-39EE-457A-92EC-10AF4220154C}.Release|Any CPU.ActiveCfg = Release|Any CPU 20 + {B02BAE78-39EE-457A-92EC-10AF4220154C}.Release|Any CPU.Build.0 = Release|Any CPU 21 EndGlobalSection 22 EndGlobal
+14
UltralightSharp/Config.cs
··· 1 using JetBrains.Annotations; 2 3 namespace Ultralight { 4 5 [PublicAPI] 6 public readonly ref struct Config { 7 8 } 9
··· 1 + using InlineIL; 2 using JetBrains.Annotations; 3 4 namespace Ultralight { 5 6 [PublicAPI] 7 public readonly ref struct Config { 8 + 9 + public static unsafe Config* Create() 10 + => Ultralight.CreateConfig(); 11 + 12 + } 13 + 14 + public static class ConfigExtensions { 15 + 16 + public static unsafe void Destroy(in this Config _) { 17 + IL.Emit.Ldarg_0(); 18 + IL.Pop(out var p); 19 + Ultralight.DestroyConfig((Config*) p); 20 + } 21 22 } 23
+4
UltralightSharp/FodyWeavers.xml
···
··· 1 + <Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> 2 + <InlineIL /> 3 + <InfoOf /> 4 + </Weavers>
+83
UltralightSharp/FodyWeavers.xsd
···
··· 1 + <?xml version="1.0" encoding="utf-8"?> 2 + <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> 3 + <!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> 4 + <xs:element name="Weavers"> 5 + <xs:complexType> 6 + <xs:all> 7 + <xs:element name="InlineIL" minOccurs="0" maxOccurs="1"> 8 + <xs:complexType> 9 + <xs:attribute name="SequencePoints"> 10 + <xs:annotation> 11 + <xs:documentation>Defines if sequence points should be generated for each emitted IL instruction. Default value: Debug</xs:documentation> 12 + </xs:annotation> 13 + <xs:simpleType> 14 + <xs:restriction base="xs:string"> 15 + <xs:enumeration value="Debug"> 16 + <xs:annotation> 17 + <xs:documentation>Insert sequence points in Debug builds only (this is the default).</xs:documentation> 18 + </xs:annotation> 19 + </xs:enumeration> 20 + <xs:enumeration value="Release"> 21 + <xs:annotation> 22 + <xs:documentation>Insert sequence points in Release builds only.</xs:documentation> 23 + </xs:annotation> 24 + </xs:enumeration> 25 + <xs:enumeration value="True"> 26 + <xs:annotation> 27 + <xs:documentation>Always insert sequence points.</xs:documentation> 28 + </xs:annotation> 29 + </xs:enumeration> 30 + <xs:enumeration value="False"> 31 + <xs:annotation> 32 + <xs:documentation>Never insert sequence points.</xs:documentation> 33 + </xs:annotation> 34 + </xs:enumeration> 35 + </xs:restriction> 36 + </xs:simpleType> 37 + </xs:attribute> 38 + <xs:attribute name="Warnings"> 39 + <xs:annotation> 40 + <xs:documentation>Defines how warnings should be handled. Default value: Warnings</xs:documentation> 41 + </xs:annotation> 42 + <xs:simpleType> 43 + <xs:restriction base="xs:string"> 44 + <xs:enumeration value="Warnings"> 45 + <xs:annotation> 46 + <xs:documentation>Emit build warnings (this is the default).</xs:documentation> 47 + </xs:annotation> 48 + </xs:enumeration> 49 + <xs:enumeration value="Ignore"> 50 + <xs:annotation> 51 + <xs:documentation>Do not emit warnings.</xs:documentation> 52 + </xs:annotation> 53 + </xs:enumeration> 54 + <xs:enumeration value="Errors"> 55 + <xs:annotation> 56 + <xs:documentation>Treat warnings as errors.</xs:documentation> 57 + </xs:annotation> 58 + </xs:enumeration> 59 + </xs:restriction> 60 + </xs:simpleType> 61 + </xs:attribute> 62 + </xs:complexType> 63 + </xs:element> 64 + <xs:element name="InfoOf" minOccurs="0" maxOccurs="1" type="xs:anyType" /> 65 + </xs:all> 66 + <xs:attribute name="VerifyAssembly" type="xs:boolean"> 67 + <xs:annotation> 68 + <xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> 69 + </xs:annotation> 70 + </xs:attribute> 71 + <xs:attribute name="VerifyIgnoreCodes" type="xs:string"> 72 + <xs:annotation> 73 + <xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> 74 + </xs:annotation> 75 + </xs:attribute> 76 + <xs:attribute name="GenerateXsd" type="xs:boolean"> 77 + <xs:annotation> 78 + <xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> 79 + </xs:annotation> 80 + </xs:attribute> 81 + </xs:complexType> 82 + </xs:element> 83 + </xs:schema>
+14
UltralightSharp/Renderer.cs
··· 1 using JetBrains.Annotations; 2 3 namespace Ultralight { 4 5 [PublicAPI] 6 public readonly ref struct Renderer { 7 8 } 9
··· 1 + using InlineIL; 2 using JetBrains.Annotations; 3 4 namespace Ultralight { 5 6 [PublicAPI] 7 public readonly ref struct Renderer { 8 + 9 + public static unsafe Renderer* Create(Config* config) 10 + => Ultralight.CreateRenderer(config); 11 + 12 + } 13 + 14 + public static class RendererExtensions { 15 + 16 + public static unsafe void Destroy(in this Renderer _) { 17 + IL.Emit.Ldarg_0(); 18 + IL.Pop(out var p); 19 + Ultralight.DestroyRenderer((Renderer*) p); 20 + } 21 22 } 23
+14
UltralightSharp/Session.cs
··· 1 using JetBrains.Annotations; 2 3 namespace Ultralight { 4 5 [PublicAPI] 6 public readonly ref struct Session { 7 8 } 9
··· 1 + using InlineIL; 2 using JetBrains.Annotations; 3 4 namespace Ultralight { 5 6 [PublicAPI] 7 public readonly ref struct Session { 8 + 9 + public static unsafe Session* Create(Renderer* renderer, bool isPersistent, String* name) 10 + => Ultralight.CreateSession(renderer, isPersistent, name); 11 + 12 + } 13 + 14 + public static class SessionExtensions { 15 + 16 + public static unsafe void Destroy(in this Session _) { 17 + IL.Emit.Ldarg_0(); 18 + IL.Pop(out var p); 19 + Ultralight.DestroySession((Session*) p); 20 + } 21 22 } 23
+30
UltralightSharp/String.cs
··· 1 using JetBrains.Annotations; 2 3 namespace Ultralight { 4 5 [PublicAPI] 6 public readonly ref struct String { 7 8 } 9
··· 1 + using System; 2 + using InlineIL; 3 using JetBrains.Annotations; 4 5 namespace Ultralight { 6 7 [PublicAPI] 8 public readonly ref struct String { 9 + 10 + public static unsafe String* Create(string str) { 11 + #if NETFRAMEWORK || NETSTANDARD1_1 || NETSTANDARD1_4 || NETSTANDARD2_0 12 + fixed (char* p = str) 13 + return Ultralight.CreateStringUTF16(p, (UIntPtr) (uint) str.Length); 14 + #else 15 + return Create((ReadOnlySpan<char>) str); 16 + #endif 17 + } 18 + 19 + public static unsafe String* Create(ReadOnlySpan<char> utf16) { 20 + fixed (char* p = utf16) 21 + return Ultralight.CreateStringUTF16(p, (UIntPtr) (uint) utf16.Length); 22 + } 23 + 24 + public static unsafe String* Create(ReadOnlySpan<byte> utf8) { 25 + fixed (byte* p = utf8) 26 + return Ultralight.CreateStringUTF8((sbyte*) p, (UIntPtr) (uint) utf8.Length); 27 + } 28 + 29 + } 30 + public static class StringExtensions { 31 + 32 + public static unsafe void Destroy(in this String _) { 33 + IL.Emit.Ldarg_0(); 34 + IL.Pop(out var p); 35 + Ultralight.DestroyString((String*) p); 36 + } 37 38 } 39
+1 -1
UltralightSharp/Ultralight.cs
··· 321 322 [DllImport("Ultralight", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ulCreateStringUTF16", ExactSpelling = true)] 323 [return: NativeTypeName("ULString")] 324 - public static extern String* CreateStringUTF16([NativeTypeName("ULChar16 *")] ushort* str, [NativeTypeName("size_t")] UIntPtr len); 325 326 [DllImport("Ultralight", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ulCreateStringFromCopy", ExactSpelling = true)] 327 [return: NativeTypeName("ULString")]
··· 321 322 [DllImport("Ultralight", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ulCreateStringUTF16", ExactSpelling = true)] 323 [return: NativeTypeName("ULString")] 324 + public static extern String* CreateStringUTF16([NativeTypeName("ULChar16 *")] char* str, [NativeTypeName("size_t")] UIntPtr len); 325 326 [DllImport("Ultralight", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ulCreateStringFromCopy", ExactSpelling = true)] 327 [return: NativeTypeName("ULString")]
+33 -1
UltralightSharp/UltralightSharp.csproj
··· 22 <PackageIcon>icon.png</PackageIcon> 23 <IsPackable>True</IsPackable> 24 <GenerateAssemblyConfigurationAttribute>False</GenerateAssemblyConfigurationAttribute> 25 - <Version>1.2.0-beta</Version> 26 </PropertyGroup> 27 28 <ItemGroup> 29 <PackageReference Include="JetBrains.Annotations" Version="2020.1.0" PrivateAssets="all" /> 30 <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" /> 31 </ItemGroup> 32 33 <Choose> 34 <When Condition="'$(TargetFramework)'=='net45'"> 35 <ItemGroup> 36 <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" /> 37 </ItemGroup> 38 </When> 39 </Choose> 40 41 <ItemGroup>
··· 22 <PackageIcon>icon.png</PackageIcon> 23 <IsPackable>True</IsPackable> 24 <GenerateAssemblyConfigurationAttribute>False</GenerateAssemblyConfigurationAttribute> 25 </PropertyGroup> 26 27 <ItemGroup> 28 <PackageReference Include="JetBrains.Annotations" Version="2020.1.0" PrivateAssets="all" /> 29 <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" /> 30 + <PackageReference Include="Fody" Version="6.2.4" PrivateAssets="All" /> 31 + <PackageReference Include="InlineIL.Fody" Version="1.5.0" PrivateAssets="All" /> 32 + <PackageReference Include="InfoOf.Fody" Version="2.0.1" PrivateAssets="All" /> 33 </ItemGroup> 34 35 <Choose> 36 <When Condition="'$(TargetFramework)'=='net45'"> 37 <ItemGroup> 38 + <PackageReference Include="System.Memory" Version="4.5.4" /> 39 <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" /> 40 </ItemGroup> 41 </When> 42 + <When Condition="$(TargetFramework.StartsWith('netstandard'))"> 43 + <Choose> 44 + <When Condition="$(TargetFramework.EndsWith('2.1'))"> 45 + <ItemGroup> 46 + </ItemGroup> 47 + </When> 48 + <When Condition="$(TargetFramework.EndsWith('2.0'))"> 49 + <ItemGroup> 50 + <PackageReference Include="System.Memory" Version="4.5.4" /> 51 + </ItemGroup> 52 + </When> 53 + <When Condition="$(TargetFramework.EndsWith('1.4'))"> 54 + <PropertyGroup> 55 + <DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences> 56 + </PropertyGroup> 57 + <ItemGroup> 58 + <PackageReference Include="System.Memory" Version="4.5.4" /> 59 + </ItemGroup> 60 + </When> 61 + <When Condition="$(TargetFramework.EndsWith('1.1'))"> 62 + <PropertyGroup> 63 + <DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences> 64 + </PropertyGroup> 65 + <ItemGroup> 66 + <PackageReference Include="System.Memory" Version="4.5.4" /> 67 + </ItemGroup> 68 + </When> 69 + </Choose> 70 + </When> 71 </Choose> 72 73 <ItemGroup>
+8
UltralightSharp/UltralightSharp.csproj.DotSettings
···
··· 1 + <wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> 2 + <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=runtimes/@EntryIndexedValue">True</s:Boolean> 3 + <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=runtimes_005Clinux_002Dx64/@EntryIndexedValue">True</s:Boolean> 4 + <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=runtimes_005Clinux_002Dx64_005Cnative/@EntryIndexedValue">True</s:Boolean> 5 + <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=runtimes_005Cosx_002Dx64/@EntryIndexedValue">True</s:Boolean> 6 + <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=runtimes_005Cosx_002Dx64_005Cnative/@EntryIndexedValue">True</s:Boolean> 7 + <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=runtimes_005Cwin_002Dx64/@EntryIndexedValue">True</s:Boolean> 8 + <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=runtimes_005Cwin_002Dx64_005Cnative/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
+14
UltralightSharp/View.cs
··· 1 using JetBrains.Annotations; 2 3 namespace Ultralight { 4 5 [PublicAPI] 6 public readonly ref struct View { 7 8 } 9
··· 1 + using InlineIL; 2 using JetBrains.Annotations; 3 4 namespace Ultralight { 5 6 [PublicAPI] 7 public readonly ref struct View { 8 + 9 + public static unsafe View* Create(Renderer* renderer, uint width, uint height, bool transparent, Session* session) 10 + => Ultralight.CreateView(renderer, width, height, transparent, session); 11 + 12 + } 13 + 14 + public static class ViewExtensions { 15 + 16 + public static unsafe void Destroy(in this View _) { 17 + IL.Emit.Ldarg_0(); 18 + IL.Pop(out var p); 19 + Ultralight.DestroyView((View*) p); 20 + } 21 22 } 23
+10
nuget.config
···
··· 1 + <?xml version="1.0" encoding="utf-8" ?> 2 + <configuration> 3 + <packageRestore> 4 + <add key="enabled" value="True" /> 5 + <add key="automatic" value="True" /> 6 + </packageRestore> 7 + <packageSources> 8 + <add key="Local" value="./" /> 9 + </packageSources> 10 + </configuration>
official-public.snk

This is a binary file and will not be displayed.

unofficial-public.snk

This is a binary file and will not be displayed.

unofficial.snk

This is a binary file and will not be displayed.