Example #1
0
        public NRefactory.CSharpFile AddOrUpdateProjectItemFile(string projectFilePath, string codeRelativeFilePath, string sourceCode)
        {
            var projectAbsoluteFilePath = PathExt.MakePathAbsolute(Solution.FullName, projectFilePath);
            var codeAbsoluteFilePath    = PathExt.MakePathAbsolute(projectAbsoluteFilePath, codeRelativeFilePath);

            try
            {
                //Add Or Get CSharpProject in Solution by Project Name
                var project = AddOrUpdateProject(projectAbsoluteFilePath);

                //If CSharpFile exists (by fileName) in CSharpProject remove it
                RemoveCSharpFileFromProject(project, codeAbsoluteFilePath);

                //Create a new CSharpFile
                var newFile = new NRefactory.CSharpFile(project, codeAbsoluteFilePath, sourceCode);

                //Add the file to the Project
                project.AddCSharpFile(newFile);

                //Recreate the compilation so the Type system is up to date.
                Solution.RecreateCompilations();

                return(newFile);
            }
            catch (Exception e)
            {
                _log.Error("Excpetion in AddOrUpdateCodeGeneratorFileSource: " + e.Message, e);
                throw;
            }
        }
Example #2
0
        public CSharpFile AddCSharpFile(CSharpFile file)
        {
            Files.Add(file);

            // Add parsed files to the type system
            ProjectContent = ProjectContent.AddOrUpdateFiles(Files.Select(f => f.UnresolvedTypeSystemForFile));

            return(file);
        }
Example #3
0
        public NRefactory.CSharpFile AddOrUpdateProjectItemFile(string projectFilePath, string codeRelativeFilePath, string sourceCode)
        {
            var projectAbsoluteFilePath = PathExt.MakePathAbsolute(Solution.FullName, projectFilePath);
            var codeAbsoluteFilePath = PathExt.MakePathAbsolute(projectAbsoluteFilePath, codeRelativeFilePath);

            try
            {
                //Add Or Get CSharpProject in Solution by Project Name
                var project = AddOrUpdateProject(projectAbsoluteFilePath);

                //If CSharpFile exists (by fileName) in CSharpProject remove it
                RemoveCSharpFileFromProject(project, codeAbsoluteFilePath);

                //Create a new CSharpFile
                var newFile = new NRefactory.CSharpFile(project, codeAbsoluteFilePath, sourceCode);

                //Add the file to the Project
                project.AddCSharpFile(newFile);

                //Recreate the compilation so the Type system is up to date.
                Solution.RecreateCompilations();

                return newFile;

            }
            catch (Exception e)
            {
                _log.Error("Excpetion in AddOrUpdateCodeGeneratorFileSource: " + e.Message, e);
                throw;
            }
        }
Example #4
0
        public CSharpFile AddCSharpFile(CSharpFile file)
        {
            Files.Add(file);

            // Add parsed files to the type system
            ProjectContent = ProjectContent.AddOrUpdateFiles(Files.Select(f => f.UnresolvedTypeSystemForFile));

            return file;
        }