Browse Source

Put generated code into "Generated" folder of solution, add custom executable for running the editor from solution, note about pinvoke security suppression

Josh Engebretson 10 years ago
parent
commit
3f6150631e

+ 2 - 2
Script/AtomicNET/AtomicNET/AtomicNETBootstrap/Bootstrap.cs

@@ -19,7 +19,7 @@ public class AtomicLoadContext : LoadContext
     {
     {
       LoadContext.InitializeDefaultContext(new AtomicLoadContext());
       LoadContext.InitializeDefaultContext(new AtomicLoadContext());
       assemblyLoadPaths = _assemblyLoadPaths.Split(';').ToList();
       assemblyLoadPaths = _assemblyLoadPaths.Split(';').ToList();
-      Console.WriteLine("Bootstrap Startup paths: {0}", _assemblyLoadPaths);
+      //Console.WriteLine("Bootstrap Startup paths: {0}", _assemblyLoadPaths);
     }
     }
 
 
     public static void AddAssemblyLoadPath(string path)
     public static void AddAssemblyLoadPath(string path)
@@ -70,7 +70,7 @@ public class AtomicLoadContext : LoadContext
       {
       {
         try
         try
         {
         {
-            Console.WriteLine("Assembly Load Attempt: {0}", path + assemblyName.Name + ".dll");
+            //Console.WriteLine("Assembly Load Attempt: {0}", path + assemblyName.Name + ".dll");
             assembly = LoadFromAssemblyPath(path + assemblyName.Name + ".dll");
             assembly = LoadFromAssemblyPath(path + assemblyName.Name + ".dll");
             break;
             break;
         }
         }

+ 0 - 5
Source/AtomicNET/NETCore/NETCore.cpp

@@ -48,11 +48,6 @@ void NETCore::Shutdown()
 extern "C"
 extern "C"
 {
 {
 
 
-// http://ybeernet.blogspot.com/2011/03/techniques-of-calling-unmanaged-code.html
-// pinvoke is faster than [UnmanagedFunctionPointer] :/
-// [SuppressUnmanagedCodeSecurity] <--- add this attribute, in any event
-
-
 #ifdef ATOMIC_PLATFORM_WINDOWS
 #ifdef ATOMIC_PLATFORM_WINDOWS
 #pragma warning(disable: 4244) // possible loss of data
 #pragma warning(disable: 4244) // possible loss of data
 #define ATOMIC_EXPORT_API __declspec(dllexport)
 #define ATOMIC_EXPORT_API __declspec(dllexport)

+ 6 - 0
Source/ToolCore/JSBind/CSharp/CSClassWriter.cpp

@@ -175,6 +175,12 @@ void CSClassWriter::GenerateManagedSource(String& sourceOut)
 
 
     Indent();
     Indent();
     JSBPackage* package = klass_->GetPackage();
     JSBPackage* package = klass_->GetPackage();
+
+    // CoreCLR has pinvoke security demand code commented out, so we do not (currently) need this optimization:
+    // https://github.com/dotnet/coreclr/issues/1605
+    // line = "[SuppressUnmanagedCodeSecurity]\n";
+    // source += IndentLine(line);
+
     line = "[DllImport (Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]\n";
     line = "[DllImport (Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]\n";
     source += IndentLine(line);
     source += IndentLine(line);
     line = ToString("public static extern IntPtr csb_%s_%s_GetClassIDStatic();\n", package->GetName().CString(),klass_->GetName().CString());
     line = ToString("public static extern IntPtr csb_%s_%s_GetClassIDStatic();\n", package->GetName().CString(),klass_->GetName().CString());

+ 5 - 0
Source/ToolCore/JSBind/CSharp/CSFunctionWriter.cpp

@@ -281,6 +281,11 @@ void CSFunctionWriter::WriteManagedPInvokeFunctionSignature(String& source)
 {
 {
     source += "\n";
     source += "\n";
 
 
+    // CoreCLR has pinvoke security demand code commented out, so we do not (currently) need this optimization:
+    // https://github.com/dotnet/coreclr/issues/1605
+    // line = "[SuppressUnmanagedCodeSecurity]\n";
+    // source += IndentLine(line);
+
     String line = "[DllImport (Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]\n";
     String line = "[DllImport (Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]\n";
     source += IndentLine(line);
     source += IndentLine(line);
     JSBClass* klass = function_->GetClass();
     JSBClass* klass = function_->GetClass();

+ 29 - 1
Source/ToolCore/NETTools/NETProjectGen.cpp

@@ -72,7 +72,15 @@ void NETCSProject::CreateCompileItemGroup(XMLElement &projectRoot)
 
 
         for (unsigned j = 0; j < result.Size(); j++)
         for (unsigned j = 0; j < result.Size(); j++)
         {
         {
-            igroup.CreateChild("Compile").SetAttribute("Include", sourceFolder + result[j]);
+            XMLElement compile = igroup.CreateChild("Compile");
+
+            compile.SetAttribute("Include", sourceFolder + result[j]);
+
+            // put generated files into generated folder
+            if (sourceFolder.Contains("Generated") && sourceFolder.Contains("CSharp") && sourceFolder.Contains("Packages") )
+            {
+                compile.CreateChild("Link").SetValue("Generated\\" + result[j]);
+            }
 
 
         }
         }
 
 
@@ -154,6 +162,15 @@ void NETCSProject::CreateReleasePropertyGroup(XMLElement &projectRoot)
     GetAssemblySearchPaths(assemblySearchPaths);
     GetAssemblySearchPaths(assemblySearchPaths);
     pgroup.CreateChild("AssemblySearchPaths").SetValue(assemblySearchPaths);
     pgroup.CreateChild("AssemblySearchPaths").SetValue(assemblySearchPaths);
 
 
+    ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>();
+    const String& editorBinary = tenv->GetEditorBinary();
+
+    if (!projectGen_->GetGameBuild())
+    {
+        XMLElement command = pgroup.CreateChild("CustomCommands").CreateChild("CustomCommands").CreateChild("Command");
+        command.SetAttribute("type", "Execute");
+        command.SetAttribute("command", editorBinary.CString());
+    }
 }
 }
 
 
 void NETCSProject::CreateDebugPropertyGroup(XMLElement &projectRoot)
 void NETCSProject::CreateDebugPropertyGroup(XMLElement &projectRoot)
@@ -178,6 +195,16 @@ void NETCSProject::CreateDebugPropertyGroup(XMLElement &projectRoot)
     GetAssemblySearchPaths(assemblySearchPaths);
     GetAssemblySearchPaths(assemblySearchPaths);
     pgroup.CreateChild("AssemblySearchPaths").SetValue(assemblySearchPaths);
     pgroup.CreateChild("AssemblySearchPaths").SetValue(assemblySearchPaths);
 
 
+    ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>();
+    const String& editorBinary = tenv->GetEditorBinary();
+
+    if (!projectGen_->GetGameBuild())
+    {
+        XMLElement command = pgroup.CreateChild("CustomCommands").CreateChild("CustomCommands").CreateChild("Command");
+        command.SetAttribute("type", "Execute");
+        command.SetAttribute("command", editorBinary.CString());
+    }
+
 }
 }
 
 
 void NETCSProject::CreateMainPropertyGroup(XMLElement& projectRoot)
 void NETCSProject::CreateMainPropertyGroup(XMLElement& projectRoot)
@@ -195,6 +222,7 @@ void NETCSProject::CreateMainPropertyGroup(XMLElement& projectRoot)
     platform.SetValue("AnyCPU");
     platform.SetValue("AnyCPU");
 
 
     // ProjectGuid
     // ProjectGuid
+    // Look into Poco::UUIDGenerator
     XMLElement guid = pgroup.CreateChild("ProjectGuid");
     XMLElement guid = pgroup.CreateChild("ProjectGuid");
     guid.SetValue(projectGuid_);
     guid.SetValue(projectGuid_);
 
 

+ 1 - 1
Source/ToolCore/NETTools/NETProjectGen.h

@@ -125,7 +125,7 @@ public:
     bool LoadProject(const JSONValue& root, bool gameBuild = false);
     bool LoadProject(const JSONValue& root, bool gameBuild = false);
     bool LoadProject(const String& projectPath, bool gameBuild = false);
     bool LoadProject(const String& projectPath, bool gameBuild = false);
 
 
-private:
+private:    
 
 
     String scriptPlatform_;
     String scriptPlatform_;