From 0307acadab021f79de5d5ac160b22e0002a86e6d Mon Sep 17 00:00:00 2001 From: triton Date: Wed, 17 Jul 2013 21:06:03 +0100 Subject: [PATCH] Simplify library/symbols handling in the C# backend. --- src/Generator/Generators/CSharp/CSharpTextTemplate.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs index ac1980d8..b7db10c1 100644 --- a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs +++ b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs @@ -629,10 +629,10 @@ namespace CppSharp.Generators.CSharp if (!Driver.LibrarySymbols.FindLibraryBySymbol(symbol, out nativeLib)) goto Out; - library = nativeLib.FileName; + library = Path.GetFileNameWithoutExtension(nativeLib.FileName); Out: - return Tuple.Create(Path.GetFileNameWithoutExtension(library), symbol); + return Tuple.Create(library, symbol); } private void GeneratePropertySetter(T decl, Class @class) @@ -734,10 +734,10 @@ namespace CppSharp.Generators.CSharp typePrinter.PushContext(CSharpTypePrinterContextKind.Native); var location = string.Format("CppSharp.SymbolResolver.ResolveSymbol(\"{0}\", \"{1}\")", - Path.GetFileNameWithoutExtension(libSymbol.Item1), libSymbol.Item2); + libSymbol.Item1, libSymbol.Item2); WriteLine("var {0} = ({1}*){2};", Helpers.GeneratedIdentifier("ptr"), - @var.Type, libSymbol); + @var.Type, location); typePrinter.PopContext(); @@ -1743,9 +1743,10 @@ namespace CppSharp.Generators.CSharp FindMangledDeclLibrary(function, out library); libName = (library != null) ? library.FileName : "SymbolNotFound"; + libName = Path.GetFileNameWithoutExtension(libName); } - Write("[DllImport(\"{0}\", ", Path.GetFileNameWithoutExtension(libName)); + Write("[DllImport(\"{0}\", ", libName); var callConv = Helpers.ToCSharpCallConv(function.CallingConvention); WriteLine("CallingConvention = CallingConvention.{0},", callConv);