Exemple #1
0
        public bool OpenProject(string path, int line, int column)
        {
            var fastOpenResult = EditorPluginInterop.OpenFileDllImplementation(path, line, column);

            if (fastOpenResult)
            {
                return(true);
            }

            if (IsOSX)
            {
                return(OpenOSXApp(path, line, column));
            }

            var solution = GetSolutionFile(path); // TODO: If solution file doesn't exist resync.

            solution = solution == "" ? "" : $"\"{solution}\"";
            var process = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName        = CodeEditor.CurrentEditorInstallation,
                    Arguments       = $"{solution} -l {line} \"{path}\"",
                    UseShellExecute = true,
                }
            };

            process.Start();

            return(true);
        }
        public void Initialize(string editorPath)
        {
            var assembly = EditorPluginInterop.EditorPluginAssembly;

            if (EditorPluginInterop.EditorPluginIsLoadedFromAssets(assembly))
            {
                Debug.LogError($"Please delete {assembly.Location}. Unity 2019.2+ loads it directly from Rider installation. To disable this, open Rider's settings, search and uncheck 'Automatically install and update Rider's Unity editor plugin'.");
                return;
            }

            var dllName = "JetBrains.Rider.Unity.Editor.Plugin.Full.Repacked.dll";
            var relPath = "../../plugins/rider-unity/EditorPlugin";

            if (SystemInfo.operatingSystemFamily == OperatingSystemFamily.MacOSX)
            {
                relPath = "Contents/plugins/rider-unity/EditorPlugin";
            }
            var dllFile = new FileInfo(Path.Combine(Path.Combine(editorPath, relPath), dllName));

            if (dllFile.Exists)
            {
                var bytes = File.ReadAllBytes(dllFile.FullName);
                assembly = AppDomain.CurrentDomain.Load(bytes); // doesn't lock assembly on disk
                // assembly = AppDomain.CurrentDomain.Load(AssemblyName.GetAssemblyName(dllFile.FullName)); // use this for external source debug
                EditorPluginInterop.InitEntryPoint(assembly);
            }
            else
            {
                Debug.Log($"Unable to find Rider EditorPlugin {dllFile.FullName} for Unity ");
            }
        }
Exemple #3
0
        public void Initialize(string editorPath)
        {
            var assembly = EditorPluginInterop.EditorPluginAssembly;

            if (EditorPluginInterop.EditorPluginIsLoadedFromAssets(assembly))
            {
                Debug.LogError($"Please delete {assembly.Location}. Unity 2019.2+ loads it directly from Rider installation. To disable this, open Rider's settings, search and uncheck 'Automatically install and update Rider's Unity editor plugin'.");
                return;
            }

            // for debugging rider editor plugin
            if (RiderPathUtil.IsRiderDevEditor(editorPath))
            {
                LoadEditorPluginForDevEditor(editorPath);
            }
            else
            {
                var relPath = "../../plugins/rider-unity/EditorPlugin";
                if (SystemInfo.operatingSystemFamily == OperatingSystemFamily.MacOSX)
                {
                    relPath = "Contents/plugins/rider-unity/EditorPlugin";
                }
                var baseDir = Path.Combine(editorPath, relPath);
                var dllFile = new FileInfo(Path.Combine(baseDir, $"{EditorPluginInterop.EditorPluginAssemblyName}.dll"));

                if (!dllFile.Exists)
                {
                    dllFile = new FileInfo(Path.Combine(baseDir,
                                                        $"{EditorPluginInterop.EditorPluginAssemblyNameFallback}.dll"));
                }

                if (dllFile.Exists)
                {
                    var bytes = File.ReadAllBytes(dllFile.FullName);
                    assembly = AppDomain.CurrentDomain.Load(bytes); // doesn't lock assembly on disk
                    if (PluginSettings.SelectedLoggingLevel >= LoggingLevel.TRACE)
                    {
                        Debug.Log($"Rider EditorPlugin loaded from {dllFile.FullName}");
                    }

                    EditorPluginInterop.InitEntryPoint(assembly);
                }
                else
                {
                    Debug.Log($"Unable to find Rider EditorPlugin {dllFile.FullName} for Unity ");
                }
            }
        }
        public bool OpenProject(string path, int line, int column)
        {
            if (path != "" && !SupportsExtension(path)) // Assets - Open C# Project passes empty path here
            {
                return(false);
            }

            if (path == "" && SystemInfo.operatingSystemFamily == OperatingSystemFamily.MacOSX)
            {
                // there is a bug in DllImplementation - use package implementation here instead https://github.cds.internal.unity3d.com/unity/com.unity.ide.rider/issues/21
                return(OpenOSXApp(path, line, column));
            }

            if (!IsUnityScript(path))
            {
                m_ProjectGeneration.SyncIfNeeded(affectedFiles: new string[] { }, new string[] { });
                var fastOpenResult = EditorPluginInterop.OpenFileDllImplementation(path, line, column);
                if (fastOpenResult)
                {
                    return(true);
                }
            }

            if (SystemInfo.operatingSystemFamily == OperatingSystemFamily.MacOSX)
            {
                return(OpenOSXApp(path, line, column));
            }

            var solution = GetSolutionFile(path); // TODO: If solution file doesn't exist resync.

            solution = solution == "" ? "" : $"\"{solution}\"";
            var process = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName        = CodeEditor.CurrentEditorInstallation,
                    Arguments       = $"{solution} -l {line} \"{path}\"",
                    UseShellExecute = true,
                }
            };

            process.Start();

            return(true);
        }
Exemple #5
0
        public bool OpenProject(string path, int line, int column)
        {
            var projectGeneration = (ProjectGeneration.ProjectGeneration)m_ProjectGeneration;

            // Assets - Open C# Project passes empty path here
            if (path != "" && !projectGeneration.HasValidExtension(path))
            {
                return(false);
            }

            if (!IsUnityScript(path))
            {
                m_ProjectGeneration.SyncIfNeeded(affectedFiles: new string[] { }, new string[] { });
                var fastOpenResult = EditorPluginInterop.OpenFileDllImplementation(path, line, column);
                if (fastOpenResult)
                {
                    return(true);
                }
            }

            if (SystemInfo.operatingSystemFamily == OperatingSystemFamily.MacOSX)
            {
                return(OpenOSXApp(path, line, column));
            }

            var solution = GetSolutionFile(path); // TODO: If solution file doesn't exist resync.

            solution = solution == "" ? "" : $"\"{solution}\"";
            var process = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName        = CodeEditor.CurrentEditorInstallation,
                    Arguments       = $"{solution} -l {line} \"{path}\"",
                    UseShellExecute = true,
                }
            };

            process.Start();

            return(true);
        }
Exemple #6
0
        private static void LoadEditorPluginForDevEditor(string editorPath)
        {
            var file = new FileInfo(editorPath);

            if (SystemInfo.operatingSystemFamily == OperatingSystemFamily.MacOSX)
            {
                file = new FileInfo(Path.Combine(editorPath, "rider-dev.bat"));
            }

            if (!file.Exists)
            {
                Debug.Log($"Unable to determine path to EditorPlugin from {file}");
                return;
            }

            var dllPath = File.ReadLines(file.FullName).FirstOrDefault();

            if (dllPath == null)
            {
                Debug.Log($"Unable to determine path to EditorPlugin from {file}");
                return;
            }

            var dllFile = new FileInfo(dllPath);

            if (!dllFile.Exists)
            {
                Debug.Log($"Unable to find Rider EditorPlugin {dllPath} for Unity ");
                return;
            }

            var assembly = AppDomain.CurrentDomain.Load(AssemblyName.GetAssemblyName(dllFile.FullName));

            if (PluginSettings.SelectedLoggingLevel >= LoggingLevel.TRACE)
            {
                Debug.Log($"Rider EditorPlugin loaded from {dllFile.FullName}");
            }

            EditorPluginInterop.InitEntryPoint(assembly);
        }
        public void Initialize(string editorPath)
        {
            if (EditorPluginInterop.EditorPluginIsLoadedFromAssets())
            {
                Debug.LogError($"Please delete {EditorPluginInterop.GetEditorPluginAssembly().Location}. Unity 2019.2+ loads it directly from Rider installation.");
                return;
            }

            var dllName = "JetBrains.Rider.Unity.Editor.Plugin.Full.Repacked.dll";
            var relPath = "../../plugins/rider-unity/EditorPlugin";

            if (SystemInfo.operatingSystemFamily == OperatingSystemFamily.MacOSX)
            {
                relPath = "Contents/plugins/rider-unity/EditorPlugin";
            }
            var dllFile = new FileInfo(Path.Combine(Path.Combine(editorPath, relPath), dllName));

            if (dllFile.Exists)
            {
                // doesn't lock assembly on disk
                var bytes   = File.ReadAllBytes(dllFile.FullName);
                var pdbFile = new FileInfo(Path.ChangeExtension(dllFile.FullName, ".pdb"));
                if (pdbFile.Exists)
                {
                    AppDomain.CurrentDomain.Load(bytes, File.ReadAllBytes(pdbFile.FullName));
                }
                else
                {
                    AppDomain.CurrentDomain.Load(bytes);
                    // AppDomain.CurrentDomain.Load(AssemblyName.GetAssemblyName(dllFile.FullName)); // use this for external source debug
                }
                EditorPluginInterop.InitEntryPoint();
            }
            else
            {
                Debug.Log((object)($"Unable to find Rider EditorPlugin {dllFile.FullName} for Unity "));
            }
        }