diff --git a/Source/Bind/Structures/Function.cs b/Source/Bind/Structures/Function.cs index 6308bffa..47813f6a 100644 --- a/Source/Bind/Structures/Function.cs +++ b/Source/Bind/Structures/Function.cs @@ -531,7 +531,7 @@ namespace Bind.Structures if (f.ReturnType.CurrentType.ToLower().Contains("void")) f.Body.Add(String.Format("{0};", method_call)); else if (ReturnType.CurrentType.ToLower().Contains("string")) - f.Body.Add(String.Format("{0} {1} = Marshal.PtrToStringAnsi({2});", + f.Body.Add(String.Format("{0} {1} = null; unsafe {{ {1} = new string((sbyte*){2}); }}", ReturnType.QualifiedType, "retval", method_call)); else f.Body.Add(String.Format("{0} {1} = {2};", f.ReturnType.QualifiedType, "retval", method_call)); @@ -551,7 +551,7 @@ namespace Bind.Structures if (f.ReturnType.CurrentType.ToLower().Contains("void")) f.Body.Add(String.Format("{0};", f.CallString())); else if (ReturnType.CurrentType.ToLower().Contains("string")) - f.Body.Add(String.Format("return System.Runtime.InteropServices.Marshal.PtrToStringAnsi({0});", + f.Body.Add(String.Format("unsafe {{ return new string((sbyte*){0}); }}", f.CallString())); else f.Body.Add(String.Format("return {0};", f.CallString())); diff --git a/Source/OpenTK/Graphics/ES10/ES.cs b/Source/OpenTK/Graphics/ES10/ES.cs index 8ede4550..92460400 100644 --- a/Source/OpenTK/Graphics/ES10/ES.cs +++ b/Source/OpenTK/Graphics/ES10/ES.cs @@ -2599,7 +2599,7 @@ namespace OpenTK.Graphics.ES10 using (new ErrorHelper(GraphicsContext.CurrentContext)) { #endif - return System.Runtime.InteropServices.Marshal.PtrToStringAnsi(Delegates.glGetString((OpenTK.Graphics.ES10.All)name)); + unsafe { return new string((sbyte*)Delegates.glGetString((OpenTK.Graphics.ES10.All)name)); } #if DEBUG } #endif diff --git a/Source/OpenTK/Graphics/ES11/ES.cs b/Source/OpenTK/Graphics/ES11/ES.cs index 3c0d6bfd..3a56bc6e 100644 --- a/Source/OpenTK/Graphics/ES11/ES.cs +++ b/Source/OpenTK/Graphics/ES11/ES.cs @@ -5018,7 +5018,7 @@ namespace OpenTK.Graphics.ES11 using (new ErrorHelper(GraphicsContext.CurrentContext)) { #endif - return System.Runtime.InteropServices.Marshal.PtrToStringAnsi(Delegates.glGetString((OpenTK.Graphics.ES11.All)name)); + unsafe { return new string((sbyte*)Delegates.glGetString((OpenTK.Graphics.ES11.All)name)); } #if DEBUG } #endif diff --git a/Source/OpenTK/Graphics/ES20/ES.cs b/Source/OpenTK/Graphics/ES20/ES.cs index 7ca68d4d..f3d26c14 100644 --- a/Source/OpenTK/Graphics/ES20/ES.cs +++ b/Source/OpenTK/Graphics/ES20/ES.cs @@ -8202,7 +8202,7 @@ namespace OpenTK.Graphics.ES20 using (new ErrorHelper(GraphicsContext.CurrentContext)) { #endif - return System.Runtime.InteropServices.Marshal.PtrToStringAnsi(Delegates.glGetString((OpenTK.Graphics.ES20.StringName)name)); + unsafe { return new string((sbyte*)Delegates.glGetString((OpenTK.Graphics.ES20.StringName)name)); } #if DEBUG } #endif diff --git a/Source/OpenTK/Graphics/OpenGL/GL.cs b/Source/OpenTK/Graphics/OpenGL/GL.cs index 7e2b18d5..7daffdf8 100644 --- a/Source/OpenTK/Graphics/OpenGL/GL.cs +++ b/Source/OpenTK/Graphics/OpenGL/GL.cs @@ -49901,7 +49901,7 @@ namespace OpenTK.Graphics.OpenGL using (new ErrorHelper(GraphicsContext.CurrentContext)) { #endif - return System.Runtime.InteropServices.Marshal.PtrToStringAnsi(Delegates.glGetString((OpenTK.Graphics.OpenGL.StringName)name)); + unsafe { return new string((sbyte*)Delegates.glGetString((OpenTK.Graphics.OpenGL.StringName)name)); } #if DEBUG } #endif @@ -49924,7 +49924,7 @@ namespace OpenTK.Graphics.OpenGL using (new ErrorHelper(GraphicsContext.CurrentContext)) { #endif - return System.Runtime.InteropServices.Marshal.PtrToStringAnsi(Delegates.glGetStringi((OpenTK.Graphics.OpenGL.StringName)name, (UInt32)index)); + unsafe { return new string((sbyte*)Delegates.glGetStringi((OpenTK.Graphics.OpenGL.StringName)name, (UInt32)index)); } #if DEBUG } #endif @@ -49948,7 +49948,7 @@ namespace OpenTK.Graphics.OpenGL using (new ErrorHelper(GraphicsContext.CurrentContext)) { #endif - return System.Runtime.InteropServices.Marshal.PtrToStringAnsi(Delegates.glGetStringi((OpenTK.Graphics.OpenGL.StringName)name, (UInt32)index)); + unsafe { return new string((sbyte*)Delegates.glGetStringi((OpenTK.Graphics.OpenGL.StringName)name, (UInt32)index)); } #if DEBUG } #endif