internal virtual void EnsureProjectProperties()
        {
            Logger.ZLogTrace("EnsureProjectProperties at " + (Location ?? "") + " ...");

            UpdateSdkTargetIfNeeded(Location);

            var project = OpenProject(Location, GetEvaluationConditions());

            ValidateProject(project);

            EnsureOverflowMode(project);

            EnsureDefaultNamespace(project);

            EnsureAssemblyName(project);

            EnsureAssemblyLocation(project);

            SourceFiles       = GetSourceFiles(project);
            ParsedSourceFiles = new ParsedSourceFile[SourceFiles.Count];

            EnsureDefineConstants(project);

            ReadH5Specific(project);

            CloseProject(project);

            Logger.ZLogTrace("EnsureProjectProperties done");
        }
Exemple #2
0
        public string GenerateSourceMap(string fileName, string content, Action<SourceMapBuilder> before = null)
        {
            if (AssemblyInfo.SourceMap.Enabled)
            {
                var projectPath = Path.GetDirectoryName(Location);

                SourceMapGenerator.Generate(fileName, projectPath, ref content,
                    before,
                    (sourceRelativePath) =>
                    {
                        string path = null;
                        ParsedSourceFile sourceFile = null;

                        try
                        {
                            path = Path.Combine(projectPath, sourceRelativePath);
                            sourceFile = ParsedSourceFiles.First(pf => pf.ParsedFile.FileName == path);

                            return sourceFile.SyntaxTree.TextSource ?? sourceFile.SyntaxTree.ToString(GetFormatter());
                        }
                        catch (Exception ex)
                        {
                            throw (TranslatorException)TranslatorException.Create(
                                "Could not get ParsedSourceFile for SourceMap. Exception: {0}; projectPath: {1}; sourceRelativePath: {2}; path: {3}.",
                                ex.ToString(), projectPath, sourceRelativePath, path);
                        }

                    },
                    new string[0], SourceFiles, AssemblyInfo.SourceMap.Eol
                );
            }

            return content;
        }