Exemple #1
0
        internal void GenerateAndWriteSolutionAndProjects(ScriptEditorUtility.ScriptEditor scriptEditor)
        {
            // Only synchronize islands that have associated source files and ones that we actually want in the project.
            // This also filters out DLLs coming from .asmdef files in packages.
            IEnumerable <MonoIsland> islands = EditorCompilationInterface.GetAllMonoIslands().
                                               Where(i => 0 < i._files.Length && i._files.Any(f => ShouldFileBePartOfSolution(f)));

            var allAssetProjectParts = GenerateAllAssetProjectParts();

            var responseFilePath = Path.Combine("Assets", MonoCSharpCompiler.ReponseFilename);

            var responseFileData = ScriptCompilerBase.ParseResponseFileFromFile(Path.Combine(_projectDirectory, responseFilePath));

            if (responseFileData.Errors.Length > 0)
            {
                foreach (var error in responseFileData.Errors)
                {
                    UnityEngine.Debug.LogErrorFormat("{0} Parse Error : {1}", responseFilePath, error);
                }
            }

            SyncSolution(islands);
            var allProjectIslands = RelevantIslandsForMode(islands, ModeForCurrentExternalEditor()).ToList();

            foreach (MonoIsland island in allProjectIslands)
            {
                SyncProject(island, allAssetProjectParts, responseFileData, allProjectIslands);
            }

            if (scriptEditor == ScriptEditorUtility.ScriptEditor.VisualStudioCode)
            {
                WriteVSCodeSettingsFiles();
            }
        }
        ScriptCompilerBase.ResponseFileData parseResponseFileData(MonoIsland island, string responseFilePath)
        {
            var systemReferenceDirectories = CSharpLanguage.GetCSharpCompiler(island._target, true, "Assembly-CSharp") == CSharpCompiler.Microsoft &&
                                             PlayerSettings.GetScriptingBackend(BuildPipeline.GetBuildTargetGroup(island._target)) == ScriptingImplementation.WinRTDotNET
                ? MicrosoftCSharpCompiler.GetClassLibraries(island._target)
                : MonoLibraryHelpers.GetSystemReferenceDirectories(island._api_compatibility_level);

            ScriptCompilerBase.ResponseFileData responseFileData = ScriptCompilerBase.ParseResponseFileFromFile(
                Path.Combine(_projectDirectory, responseFilePath),
                _projectDirectory,
                systemReferenceDirectories);

            if (responseFileData.Errors.Length > 0)
            {
                foreach (var error in responseFileData.Errors)
                {
                    UnityEngine.Debug.LogErrorFormat("{0} Parse Error : {1}", responseFilePath, error);
                }
            }

            return(responseFileData);
        }
Exemple #3
0
 public static ResponseFileData ParseResponseFile(string relativePath, string projectDirectory, string[] systemReferenceDirectories)
 {
     return(ScriptCompilerBase.ParseResponseFileFromFile(relativePath, projectDirectory, systemReferenceDirectories));
 }
Exemple #4
0
        IEnumerable <ResponseFileData> ParseResponseFileData(MonoIsland island)
        {
            var systemReferenceDirectories = MonoLibraryHelpers.GetSystemReferenceDirectories(island._api_compatibility_level);

            Dictionary <string, ResponseFileData> responseFilesData = island._responseFiles.ToDictionary(x => x, x => ScriptCompilerBase.ParseResponseFileFromFile(
                                                                                                             x,
                                                                                                             _projectDirectory,
                                                                                                             systemReferenceDirectories
                                                                                                             ));

            Dictionary <string, ResponseFileData> responseFilesWithErrors = responseFilesData.Where(x => x.Value.Errors.Any())
                                                                            .ToDictionary(x => x.Key, x => x.Value);

            if (responseFilesWithErrors.Any())
            {
                foreach (var error in responseFilesWithErrors)
                {
                    foreach (var valueError in error.Value.Errors)
                    {
                        UnityEngine.Debug.LogErrorFormat("{0} Parse Error : {1}", error.Key, valueError);
                    }
                }
            }

            return(responseFilesData.Select(x => x.Value));
        }
Exemple #5
0
        IEnumerable <ScriptCompilerBase.ResponseFileData> ParseResponseFileData(MonoIsland island)
        {
            var systemReferenceDirectories = CSharpLanguage.GetCSharpCompiler(island._target, true, "Assembly-CSharp") == CSharpCompiler.Microsoft &&
                                             PlayerSettings.GetScriptingBackend(BuildPipeline.GetBuildTargetGroup(island._target)) == ScriptingImplementation.WinRTDotNET && !island._editor
                ? MicrosoftCSharpCompiler.GetClassLibraries(island._target, island._editor)
                : MonoLibraryHelpers.GetSystemReferenceDirectories(island._api_compatibility_level);

            Dictionary <string, ScriptCompilerBase.ResponseFileData> responseFilesData = island._responseFiles.ToDictionary(x => x, x => ScriptCompilerBase.ParseResponseFileFromFile(
                                                                                                                                Path.Combine(_projectDirectory, x),
                                                                                                                                _projectDirectory,
                                                                                                                                systemReferenceDirectories
                                                                                                                                ));

            Dictionary <string, ScriptCompilerBase.ResponseFileData> responseFilesWithErrors = responseFilesData.Where(x => x.Value.Errors.Any())
                                                                                               .ToDictionary(x => x.Key, x => x.Value);

            if (responseFilesWithErrors.Any())
            {
                foreach (var error in responseFilesWithErrors)
                {
                    foreach (var valueError in error.Value.Errors)
                    {
                        UnityEngine.Debug.LogErrorFormat("{0} Parse Error : {1}", error.Key, valueError);
                    }
                }
            }

            return(responseFilesData.Select(x => x.Value));
        }