From e2098e15e5527afefb068f7c251b8ce5e3d407b1 Mon Sep 17 00:00:00 2001 From: Jarl Gullberg Date: Fri, 4 Aug 2017 22:21:56 +0200 Subject: [PATCH 01/13] Add CommandLineParser to Generator.Rewrite. --- .../Generator.Rewrite.csproj | 231 +++++++++++++++++- src/Generator.Rewrite/paket.references | 3 +- 2 files changed, 230 insertions(+), 4 deletions(-) diff --git a/src/Generator.Rewrite/Generator.Rewrite.csproj b/src/Generator.Rewrite/Generator.Rewrite.csproj index e03e83b1..3834892e 100644 --- a/src/Generator.Rewrite/Generator.Rewrite.csproj +++ b/src/Generator.Rewrite/Generator.Rewrite.csproj @@ -98,6 +98,35 @@ + + + + + ..\..\packages\CommandLineParser\lib\net40\CommandLine.dll + True + True + + + + + + + ..\..\packages\CommandLineParser\lib\net45\CommandLine.dll + True + True + + + + + + + ..\..\packages\CommandLineParser\lib\netstandard1.5\CommandLine.dll + True + True + + + + @@ -229,6 +258,29 @@ + + + + + True + + + ..\..\packages\System.Console\lib\net46\System.Console.dll + True + True + + + + + + + ..\..\packages\System.Console\ref\netstandard1.3\System.Console.dll + False + True + + + + @@ -310,9 +362,6 @@ - - True - ..\..\packages\System.IO\lib\net462\System.IO.dll True @@ -417,6 +466,82 @@ + + + + + ..\..\packages\System.Linq.Expressions\lib\net463\System.Linq.Expressions.dll + True + True + + + + + + + ..\..\packages\System.Linq.Expressions\ref\netstandard1.0\System.Linq.Expressions.dll + False + True + + + + + + + ..\..\packages\System.Linq.Expressions\ref\netstandard1.3\System.Linq.Expressions.dll + False + True + + + + + + + ..\..\packages\System.Linq.Expressions\lib\netstandard1.6\System.Linq.Expressions.dll + True + True + + + + + + + ..\..\packages\System.Linq.Expressions\ref\netstandard1.6\System.Linq.Expressions.dll + False + True + + + + + + + + + ..\..\packages\System.ObjectModel\ref\netstandard1.0\System.ObjectModel.dll + False + True + + + + + + + ..\..\packages\System.ObjectModel\lib\netstandard1.3\System.ObjectModel.dll + True + True + + + + + + + ..\..\packages\System.ObjectModel\ref\netstandard1.3\System.ObjectModel.dll + False + True + + + + @@ -455,6 +580,77 @@ + + + + + ..\..\packages\System.Reflection.Emit\ref\netstandard1.1\System.Reflection.Emit.dll + False + True + + + + + + + ..\..\packages\System.Reflection.Emit\lib\netstandard1.3\System.Reflection.Emit.dll + True + True + + + + + + + + + ..\..\packages\System.Reflection.Emit.ILGeneration\ref\netstandard1.0\System.Reflection.Emit.ILGeneration.dll + False + True + + + + + + + ..\..\packages\System.Reflection.Emit.ILGeneration\lib\netstandard1.3\System.Reflection.Emit.ILGeneration.dll + True + True + + + + + + + + + ..\..\packages\System.Reflection.Emit.Lightweight\ref\netstandard1.0\System.Reflection.Emit.Lightweight.dll + False + True + + + + + + + ..\..\packages\System.Reflection.Emit.Lightweight\lib\netstandard1.3\System.Reflection.Emit.Lightweight.dll + True + True + + + + + + + + + ..\..\packages\System.Reflection.Extensions\ref\netstandard1.0\System.Reflection.Extensions.dll + False + True + + + + @@ -466,6 +662,35 @@ + + + + + ..\..\packages\System.Reflection.TypeExtensions\lib\net462\System.Reflection.TypeExtensions.dll + True + True + + + + + + + ..\..\packages\System.Reflection.TypeExtensions\lib\netstandard1.5\System.Reflection.TypeExtensions.dll + True + True + + + + + + + ..\..\packages\System.Reflection.TypeExtensions\ref\netstandard1.5\System.Reflection.TypeExtensions.dll + False + True + + + + diff --git a/src/Generator.Rewrite/paket.references b/src/Generator.Rewrite/paket.references index 4af5b75e..73eee677 100644 --- a/src/Generator.Rewrite/paket.references +++ b/src/Generator.Rewrite/paket.references @@ -1,2 +1,3 @@ Mono.Cecil -StyleCop.Analyzers \ No newline at end of file +StyleCop.Analyzers +CommandLineParser \ No newline at end of file From 7d031a81af6defd8f1118652286de2818fde1a03 Mon Sep 17 00:00:00 2001 From: Jarl Gullberg Date: Mon, 26 Jun 2017 20:53:12 +0200 Subject: [PATCH 02/13] Added option class. --- src/Generator.Rewrite/Options.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/Generator.Rewrite/Options.cs diff --git a/src/Generator.Rewrite/Options.cs b/src/Generator.Rewrite/Options.cs new file mode 100644 index 00000000..2519e0cb --- /dev/null +++ b/src/Generator.Rewrite/Options.cs @@ -0,0 +1,23 @@ +using CommandLine; + +namespace OpenTK.Rewrite +{ + public class Options + { + [Option('d', "debug", DefaultValue = false, + HelpText = "Enable calls to GL.GetError(), wrapped around each native call.")] + public bool EnableDebugCalls { get; set; } + + [Option("dllimport", DefaultValue = false, + HelpText = "Force native calls to use DllImport instead of GetProcAddress.")] + public bool UseDLLImport { get; set; } + + [Option('i', "assembly", Required = true, + HelpText = "The path to the target assembly that should be rewritten.")] + public string TargetAssembly { get; set; } + + [Option('k', "signing-key", + HelpText = "The path to the strong name key which should be used to sign or resign the assembly.")] + public string StrongNameKey { get; set; } + } +} \ No newline at end of file From 3cb9c5f833907667e2e6414f0618db9f251c3d80 Mon Sep 17 00:00:00 2001 From: Jarl Gullberg Date: Mon, 26 Jun 2017 21:01:01 +0200 Subject: [PATCH 03/13] Added help option and moved required argument to the top. --- src/Generator.Rewrite/Options.cs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Generator.Rewrite/Options.cs b/src/Generator.Rewrite/Options.cs index 2519e0cb..8a122aa1 100644 --- a/src/Generator.Rewrite/Options.cs +++ b/src/Generator.Rewrite/Options.cs @@ -1,9 +1,18 @@ using CommandLine; +using CommandLine.Text; namespace OpenTK.Rewrite { public class Options { + [Option('i', "assembly", Required = true, + HelpText = "The path to the target assembly that should be rewritten.")] + public string TargetAssembly { get; set; } + + [Option('k', "signing-key", + HelpText = "The path to the strong name key which should be used to sign or resign the assembly.")] + public string StrongNameKey { get; set; } + [Option('d', "debug", DefaultValue = false, HelpText = "Enable calls to GL.GetError(), wrapped around each native call.")] public bool EnableDebugCalls { get; set; } @@ -12,12 +21,10 @@ namespace OpenTK.Rewrite HelpText = "Force native calls to use DllImport instead of GetProcAddress.")] public bool UseDLLImport { get; set; } - [Option('i', "assembly", Required = true, - HelpText = "The path to the target assembly that should be rewritten.")] - public string TargetAssembly { get; set; } - - [Option('k', "signing-key", - HelpText = "The path to the strong name key which should be used to sign or resign the assembly.")] - public string StrongNameKey { get; set; } + [HelpOption] + public string GetUsage() + { + return HelpText.AutoBuild(this, current => HelpText.DefaultParsingErrorsHandler(this, current)); + } } } \ No newline at end of file From 20399f2da7d5987e75690558627c51a13a77649f Mon Sep 17 00:00:00 2001 From: Jarl Gullberg Date: Mon, 26 Jun 2017 21:01:30 +0200 Subject: [PATCH 04/13] Added option parsing to the main program. --- src/Generator.Rewrite/Generator.Rewrite.csproj | 1 + src/Generator.Rewrite/Program.cs | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Generator.Rewrite/Generator.Rewrite.csproj b/src/Generator.Rewrite/Generator.Rewrite.csproj index 3834892e..518e5ae0 100644 --- a/src/Generator.Rewrite/Generator.Rewrite.csproj +++ b/src/Generator.Rewrite/Generator.Rewrite.csproj @@ -59,6 +59,7 @@ + diff --git a/src/Generator.Rewrite/Program.cs b/src/Generator.Rewrite/Program.cs index f028ff37..02c44cb1 100644 --- a/src/Generator.Rewrite/Program.cs +++ b/src/Generator.Rewrite/Program.cs @@ -18,7 +18,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; - +using CommandLine; using Mono.Cecil; using Mono.Cecil.Cil; using Mono.Cecil.Rocks; @@ -29,14 +29,12 @@ namespace OpenTK.Rewrite // with the s IL instructions. internal class Program { + private static readonly Options Options = new Options(); + private static void Main(string[] args) { - if (args.Length == 0) + if (!Parser.Default.ParseArguments(args, Options)) { - Console.WriteLine("Usage: rewrite [file.dll] [file.snk] [options]"); - Console.WriteLine("[options] is:"); - Console.WriteLine(" -debug (enable calls to GL.GetError())"); - Console.WriteLine(" -dllimport (force calls to use DllImport instead of GetProcAddress)"); return; } From fec6c18702d4a8d6dd0a5ae943f52fb61be25edc Mon Sep 17 00:00:00 2001 From: Jarl Gullberg Date: Mon, 26 Jun 2017 21:05:58 +0200 Subject: [PATCH 05/13] Added some early argument verification. --- src/Generator.Rewrite/Program.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Generator.Rewrite/Program.cs b/src/Generator.Rewrite/Program.cs index 02c44cb1..e866b00f 100644 --- a/src/Generator.Rewrite/Program.cs +++ b/src/Generator.Rewrite/Program.cs @@ -38,6 +38,19 @@ namespace OpenTK.Rewrite return; } + // Argument error checking + if (!File.Exists(Options.TargetAssembly)) + { + Console.Error.WriteLine($"Target assembly not found. \n" + + $"Please check the given path ({Options.TargetAssembly})."); + } + + if (!File.Exists(Path.ChangeExtension(Options.TargetAssembly, "pdb"))) + { + Console.Error.WriteLine("Debugging symbols for target assembly not found. \n" + + "Please make sure that debugging symbols are being generated."); + } + var program = new Program(); var file = args[0]; var key = args[1]; From 77ebecb9f78072bec3140e2029ac1e255e596fc9 Mon Sep 17 00:00:00 2001 From: Jarl Gullberg Date: Mon, 26 Jun 2017 21:11:59 +0200 Subject: [PATCH 06/13] Removed passing of options and replaced checks with option object access. --- src/Generator.Rewrite/Program.cs | 42 ++++++++++++-------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/src/Generator.Rewrite/Program.cs b/src/Generator.Rewrite/Program.cs index e866b00f..1a888d21 100644 --- a/src/Generator.Rewrite/Program.cs +++ b/src/Generator.Rewrite/Program.cs @@ -52,10 +52,7 @@ namespace OpenTK.Rewrite } var program = new Program(); - var file = args[0]; - var key = args[1]; - var options = args.Where(a => a.StartsWith("-") || a.StartsWith("/")); - program.Rewrite(file, key, options); + program.Rewrite(); } // mscorlib types @@ -69,13 +66,8 @@ namespace OpenTK.Rewrite // OpenTK.BindingsBase private static TypeDefinition TypeBindingsBase; - private static bool dllimport; - - private void Rewrite(string file, string keyfile, IEnumerable options) + private void Rewrite() { - IEnumerable optionsEnumerated = options as IList ?? options.ToList(); - dllimport = optionsEnumerated.Contains("-dllimport"); - // Specify assembly read and write parameters // We want to keep a valid symbols file (pdb or mdb) var read_params = new ReaderParameters(); @@ -85,11 +77,11 @@ namespace OpenTK.Rewrite read_params.ReadWrite = true; write_params.WriteSymbols = true; - if (!String.IsNullOrEmpty(keyfile) && File.Exists(keyfile)) + if (!String.IsNullOrEmpty(Options.StrongNameKey) && File.Exists(Options.StrongNameKey)) { - keyfile = Path.GetFullPath(keyfile); + string absoluteKeyFilePath = Path.GetFullPath(Options.StrongNameKey); - using (var fs = new FileStream(keyfile, FileMode.Open, FileAccess.Read)) + using (var fs = new FileStream(absoluteKeyFilePath, FileMode.Open, FileAccess.Read)) { var keypair = new System.Reflection.StrongNameKeyPair(fs); write_params.StrongNameKeyPair = keypair; @@ -103,7 +95,7 @@ namespace OpenTK.Rewrite // Load assembly and process all modules try { - using (AssemblyDefinition assembly = AssemblyDefinition.ReadAssembly(file, read_params)) + using (AssemblyDefinition assembly = AssemblyDefinition.ReadAssembly(Options.TargetAssembly, read_params)) { var rewritten = assembly.CustomAttributes.FirstOrDefault(a => a.AttributeType.Name == "RewrittenAttribute"); if (rewritten == null) @@ -143,7 +135,7 @@ namespace OpenTK.Rewrite { foreach (var type in module.Types) { - Rewrite(type, optionsEnumerated); + Rewrite(type); } } } @@ -163,7 +155,7 @@ namespace OpenTK.Rewrite } } - private void Rewrite(TypeDefinition type, IEnumerable options) + private void Rewrite(TypeDefinition type) { var entry_points = type.Fields.FirstOrDefault(f => f.Name == "EntryPoints"); if (entry_points != null) @@ -173,7 +165,7 @@ namespace OpenTK.Rewrite entry_signatures.AddRange(type.Methods .Where(t => t.CustomAttributes.Any(a => a.AttributeType.Name == "SlotAttribute"))); - Rewrite(type, entry_points, entry_signatures, options); + Rewrite(type, entry_points, entry_signatures); RemoveNativeSignatures(type, entry_signatures); } @@ -191,7 +183,7 @@ namespace OpenTK.Rewrite private static int GetSlot(MethodDefinition signature) { // Pretend there is no slots if we want to force everything to work through DllImport (Android & iOS) - if (dllimport) + if (Options.UseDLLImport) { return -1; } @@ -207,14 +199,13 @@ namespace OpenTK.Rewrite } private void Rewrite(TypeDefinition type, FieldDefinition entry_points, - List entry_signatures, IEnumerable options) + List entry_signatures) { // Rewrite all wrapper methods var wrapper_signatures = new List(); wrapper_signatures.AddRange(type.Methods .Where(m => m.IsPublic && m.CustomAttributes.Any(a => a.AttributeType.Name == "AutoGeneratedAttribute"))); - IEnumerable optionsEnumerated = options as IList ?? options.ToList(); foreach (var wrapper in wrapper_signatures) { var autogenerated = wrapper.CustomAttributes @@ -226,7 +217,7 @@ namespace OpenTK.Rewrite var signature = entry_signatures.FirstOrDefault(s => s.Name == signature_name); int slot = GetSlot(signature); - ProcessMethod(wrapper, signature, slot, entry_points, optionsEnumerated); + ProcessMethod(wrapper, signature, slot, entry_points); } } @@ -236,7 +227,7 @@ namespace OpenTK.Rewrite { foreach (var nested_type in type.NestedTypes) { - Rewrite(nested_type, entry_points, entry_signatures, optionsEnumerated); + Rewrite(nested_type, entry_points, entry_signatures); } } } @@ -283,7 +274,7 @@ namespace OpenTK.Rewrite // Create body for method private static void ProcessMethod(MethodDefinition wrapper, MethodDefinition native, int slot, - FieldDefinition entry_points, IEnumerable options) + FieldDefinition entry_points) { var body = wrapper.Body; var il = body.GetILProcessor(); @@ -294,8 +285,7 @@ namespace OpenTK.Rewrite // and push each parameter on the stack DebugVariables vars = null; - IEnumerable optionsEnumerated = options as IList ?? options.ToList(); - if (optionsEnumerated.Contains("-debug")) + if (Options.EnableDebugCalls) { vars = EmitDebugPrologue(wrapper, il); } @@ -333,7 +323,7 @@ namespace OpenTK.Rewrite EmitParameterEpilogues(wrapper, native, body, il, generatedVariables); - if (optionsEnumerated.Contains("-debug")) + if (Options.EnableDebugCalls) { EmitDebugEpilogue(wrapper, il, vars); } From 4184e6a10e409849844007e437d031037d787ebc Mon Sep 17 00:00:00 2001 From: Jarl Gullberg Date: Mon, 26 Jun 2017 21:13:02 +0200 Subject: [PATCH 07/13] Inverted unclear check and changed it check the dllimport option directly. --- src/Generator.Rewrite/Program.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Generator.Rewrite/Program.cs b/src/Generator.Rewrite/Program.cs index 1a888d21..e161a988 100644 --- a/src/Generator.Rewrite/Program.cs +++ b/src/Generator.Rewrite/Program.cs @@ -302,7 +302,12 @@ namespace OpenTK.Rewrite generatedVariables = EmitConvenienceWrapper(wrapper, native, difference, body, il); } - if (slot != -1) + if (Options.UseDLLImport) + { + // issue DllImport call + EmitCall(il, native); + } + else { // push the entry point address on the stack EmitEntryPoint(entry_points, il, slot); @@ -310,11 +315,6 @@ namespace OpenTK.Rewrite // issue calli EmitCalli(il, native); } - else - { - // issue DllImport call - EmitCall(il, native); - } if (wrapper.ReturnType.Name != "Void") { From 3919e5f14f31da9186981e94740c10340c300212 Mon Sep 17 00:00:00 2001 From: Jarl Gullberg Date: Mon, 26 Jun 2017 21:24:32 +0200 Subject: [PATCH 08/13] Updated calls to Rewrite in the OpenTK project. --- src/OpenTK/OpenTK.csproj | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/OpenTK/OpenTK.csproj b/src/OpenTK/OpenTK.csproj index bf4af5e4..cbcc1ddb 100644 --- a/src/OpenTK/OpenTK.csproj +++ b/src/OpenTK/OpenTK.csproj @@ -797,10 +797,18 @@ - - - - + + + + From c0060bc68187ea1353063322327026d457bff912 Mon Sep 17 00:00:00 2001 From: Jarl Gullberg Date: Thu, 20 Jul 2017 22:43:13 +0200 Subject: [PATCH 09/13] Update options to the new v2 API. --- src/Generator.Rewrite/Options.cs | 10 ++-------- src/Generator.Rewrite/Program.cs | 9 ++++----- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/Generator.Rewrite/Options.cs b/src/Generator.Rewrite/Options.cs index 8a122aa1..6e243f92 100644 --- a/src/Generator.Rewrite/Options.cs +++ b/src/Generator.Rewrite/Options.cs @@ -13,18 +13,12 @@ namespace OpenTK.Rewrite HelpText = "The path to the strong name key which should be used to sign or resign the assembly.")] public string StrongNameKey { get; set; } - [Option('d', "debug", DefaultValue = false, + [Option('d', "debug", Default = false, HelpText = "Enable calls to GL.GetError(), wrapped around each native call.")] public bool EnableDebugCalls { get; set; } - [Option("dllimport", DefaultValue = false, + [Option("dllimport", Default = false, HelpText = "Force native calls to use DllImport instead of GetProcAddress.")] public bool UseDLLImport { get; set; } - - [HelpOption] - public string GetUsage() - { - return HelpText.AutoBuild(this, current => HelpText.DefaultParsingErrorsHandler(this, current)); - } } } \ No newline at end of file diff --git a/src/Generator.Rewrite/Program.cs b/src/Generator.Rewrite/Program.cs index e161a988..459198da 100644 --- a/src/Generator.Rewrite/Program.cs +++ b/src/Generator.Rewrite/Program.cs @@ -29,14 +29,13 @@ namespace OpenTK.Rewrite // with the s IL instructions. internal class Program { - private static readonly Options Options = new Options(); + private static Options Options; private static void Main(string[] args) { - if (!Parser.Default.ParseArguments(args, Options)) - { - return; - } + Parser.Default.ParseArguments(args) + .WithParsed(result => Options = result) + .WithNotParsed(error => Environment.Exit(-1)); // Argument error checking if (!File.Exists(Options.TargetAssembly)) From 975dfc32c7382d36da4f8b682eee12102fdfb7f5 Mon Sep 17 00:00:00 2001 From: Jarl Gullberg Date: Fri, 4 Aug 2017 23:32:47 +0200 Subject: [PATCH 10/13] Correct target command line arguments. --- src/Generator.Rewrite/Generator.Rewrite.csproj | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Generator.Rewrite/Generator.Rewrite.csproj b/src/Generator.Rewrite/Generator.Rewrite.csproj index 518e5ae0..f617b96b 100644 --- a/src/Generator.Rewrite/Generator.Rewrite.csproj +++ b/src/Generator.Rewrite/Generator.Rewrite.csproj @@ -27,7 +27,8 @@ bin\Debug\Rewrite.xml prompt 4 - ../../OpenTK/Debug/OpenTK.dll ../../../OpenTK.snk -debug + --assembly ../../OpenTK/Debug/OpenTK.dll --signing-key ../../../OpenTK.snk --debug + -debug AnyCPU @@ -38,7 +39,8 @@ bin\Release\Rewrite.xml prompt 4 - ../../OpenTK/Release/OpenTK.dll ../../../OpenTK.snk + --assembly ../../OpenTK/Release/OpenTK.dll --signing-key ../../../OpenTK + .snk true From d7a6c0f3bd072ea707e331f652c48b4d43a70d08 Mon Sep 17 00:00:00 2001 From: Jarl Gullberg Date: Mon, 28 Aug 2017 16:57:49 +0200 Subject: [PATCH 11/13] Use 'a' instead of 'i' for the short assembly option. --- src/Generator.Rewrite/Options.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Generator.Rewrite/Options.cs b/src/Generator.Rewrite/Options.cs index 6e243f92..eca85326 100644 --- a/src/Generator.Rewrite/Options.cs +++ b/src/Generator.Rewrite/Options.cs @@ -5,7 +5,7 @@ namespace OpenTK.Rewrite { public class Options { - [Option('i', "assembly", Required = true, + [Option('a', "assembly", Required = true, HelpText = "The path to the target assembly that should be rewritten.")] public string TargetAssembly { get; set; } From 6eb77be2817dba2162f911e0efab40026df52066 Mon Sep 17 00:00:00 2001 From: Jarl Gullberg Date: Mon, 28 Aug 2017 16:58:44 +0200 Subject: [PATCH 12/13] Correct odd line breaks and remove duplicate debug option. --- src/Generator.Rewrite/Generator.Rewrite.csproj | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Generator.Rewrite/Generator.Rewrite.csproj b/src/Generator.Rewrite/Generator.Rewrite.csproj index f617b96b..38c3389a 100644 --- a/src/Generator.Rewrite/Generator.Rewrite.csproj +++ b/src/Generator.Rewrite/Generator.Rewrite.csproj @@ -27,8 +27,7 @@ bin\Debug\Rewrite.xml prompt 4 - --assembly ../../OpenTK/Debug/OpenTK.dll --signing-key ../../../OpenTK.snk --debug - -debug + --assembly ../../OpenTK/Debug/OpenTK.dll --signing-key ../../../OpenTK.snk --debug AnyCPU @@ -39,8 +38,7 @@ bin\Release\Rewrite.xml prompt 4 - --assembly ../../OpenTK/Release/OpenTK.dll --signing-key ../../../OpenTK - .snk + --assembly ../../OpenTK/Release/OpenTK.dll --signing-key ../../../OpenTK.snk true From 947162ce6c9ece4f8985604f5251dad7c5ded003 Mon Sep 17 00:00:00 2001 From: Jarl Gullberg Date: Mon, 28 Aug 2017 17:01:05 +0200 Subject: [PATCH 13/13] Correct altered logic. --- src/Generator.Rewrite/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Generator.Rewrite/Program.cs b/src/Generator.Rewrite/Program.cs index 459198da..d48eff74 100644 --- a/src/Generator.Rewrite/Program.cs +++ b/src/Generator.Rewrite/Program.cs @@ -301,7 +301,7 @@ namespace OpenTK.Rewrite generatedVariables = EmitConvenienceWrapper(wrapper, native, difference, body, il); } - if (Options.UseDLLImport) + if (slot == -1 || Options.UseDLLImport) { // issue DllImport call EmitCall(il, native);