public IProjectContent UpdateProjectContent(IUnresolvedFile oldFile, IUnresolvedFile newFile)
        {
            if (oldFile == null && newFile == null)
            {
                return(this);
            }
            if (oldFile != null && newFile != null)
            {
                if (!Base.Platform.FileNameComparer.Equals(oldFile.FileName, newFile.FileName))
                {
                    throw new ArgumentException("When both oldFile and newFile are specified, they must use the same file name.");
                }
            }
            VSharpProjectContent pc = Clone();

            if (newFile == null)
            {
                pc.unresolvedFiles.Remove(oldFile.FileName);
            }
            else
            {
                pc.unresolvedFiles[newFile.FileName] = newFile;
            }
            return(pc);
        }
        public IProjectContent AddAssemblyReferences(params IAssemblyReference[] references)
        {
            VSharpProjectContent pc = Clone();

            pc.assemblyReferences.AddRange(references);
            return(pc);
        }
        public IProjectContent SetLocation(string newLocation)
        {
            VSharpProjectContent pc = Clone();

            pc.location = newLocation;
            return(pc);
        }
        public IProjectContent SetProjectFileName(string newProjectFileName)
        {
            VSharpProjectContent pc = Clone();

            pc.projectFileName = newProjectFileName;
            return(pc);
        }
 protected VSharpProjectContent(VSharpProjectContent pc)
 {
     this.assemblyName       = pc.assemblyName;
     this.fullAssemblyName   = pc.fullAssemblyName;
     this.projectFileName    = pc.projectFileName;
     this.location           = pc.location;
     this.unresolvedFiles    = new Dictionary <string, IUnresolvedFile>(pc.unresolvedFiles, Base.Platform.FileNameComparer);
     this.assemblyReferences = new List <IAssemblyReference>(pc.assemblyReferences);
     this.compilerSettings   = pc.compilerSettings;
 }
        /// <summary>
        /// Removes the files with the specified names.
        /// </summary>
        public IProjectContent RemoveFiles(IEnumerable <string> fileNames)
        {
            VSharpProjectContent pc = Clone();

            foreach (var fileName in fileNames)
            {
                pc.unresolvedFiles.Remove(fileName);
            }
            return(pc);
        }
        /// <summary>
        /// Adds the specified files to the project content.
        /// If a file with the same name already exists, updated the existing file.
        /// </summary>
        public IProjectContent AddOrUpdateFiles(IEnumerable <IUnresolvedFile> newFiles)
        {
            VSharpProjectContent pc = Clone();

            foreach (var file in newFiles)
            {
                pc.unresolvedFiles[file.FileName] = file;
            }
            return(pc);
        }
        public IProjectContent RemoveAssemblyReferences(params IAssemblyReference[] references)
        {
            VSharpProjectContent pc = Clone();

            foreach (var r in references)
            {
                pc.assemblyReferences.Remove(r);
            }
            return(pc);
        }
        /// <summary>
        /// Sets both the short and the full assembly names.
        /// </summary>
        /// <param name="newAssemblyName">New full assembly name.</param>
        public IProjectContent SetAssemblyName(string newAssemblyName)
        {
            VSharpProjectContent pc = Clone();

            pc.fullAssemblyName = newAssemblyName;
            int pos = newAssemblyName != null?newAssemblyName.IndexOf(',') : -1;

            pc.assemblyName = pos < 0 ? newAssemblyName : newAssemblyName.Substring(0, pos);
            return(pc);
        }
        public IProjectContent SetCompilerSettings(object compilerSettings)
        {
            if (!(compilerSettings is CompilerSettings))
            {
                throw new ArgumentException("Settings must be an instance of " + typeof(CompilerSettings).FullName, "compilerSettings");
            }
            VSharpProjectContent pc = Clone();

            pc.compilerSettings = (CompilerSettings)compilerSettings;
            return(pc);
        }
        public IProjectContent UpdateProjectContent(IEnumerable <IUnresolvedFile> oldFiles, IEnumerable <IUnresolvedFile> newFiles)
        {
            VSharpProjectContent pc = Clone();

            if (oldFiles != null)
            {
                foreach (var oldFile in oldFiles)
                {
                    pc.unresolvedFiles.Remove(oldFile.FileName);
                }
            }
            if (newFiles != null)
            {
                foreach (var newFile in newFiles)
                {
                    pc.unresolvedFiles.Add(newFile.FileName, newFile);
                }
            }
            return(pc);
        }
Exemple #12
0
 internal VSharpAssembly(ICompilation compilation, VSharpProjectContent projectContent)
 {
     this.compilation    = compilation;
     this.projectContent = projectContent;
     this.context        = new SimpleTypeResolveContext(this);
 }