public static string GetCodeBehindClassName (ProjectFile file) { AspNetAppProject proj = file.Project as AspNetAppProject; if (proj == null) return null; return proj.GetCodebehindTypeName (file.Name); }
public string GetDefaultCustomToolForFileName (ProjectFile projectItem) { if (defaultCustomTools.ContainsKey (projectItem.FilePath.ToString ())) { return defaultCustomTools [projectItem.FilePath.ToString ()]; } return String.Empty; }
public static IssueSummary FromCodeIssue(ProjectFile file, BaseCodeIssueProvider provider, CodeIssue codeIssue) { var topLevelProvider = (provider as CodeIssueProvider) ?? provider.Parent; if (topLevelProvider == null) throw new ArgumentException ("must be a CodeIssueProvider or a BaseCodeIssueProvider with Parent != null", "provider"); var issueSummary = new IssueSummary { IssueDescription = codeIssue.Description, Region = codeIssue.Region, ProviderTitle = topLevelProvider.Title, ProviderDescription = topLevelProvider.Description, ProviderCategory = topLevelProvider.Category, Severity = topLevelProvider.GetSeverity (), IssueMarker = codeIssue.IssueMarker, File = file, Project = file.Project, InspectorIdString = codeIssue.InspectorIdString }; issueSummary.Actions = codeIssue.Actions.Select (a => new ActionSummary { Batchable = a.SupportsBatchRunning, SiblingKey = a.SiblingKey, Title = a.Title, Region = a.DocumentRegion, IssueSummary = issueSummary }).ToList (); return issueSummary; }
internal ProjectItem AddFileProjectItemWithDependentUsingFullPath(string path, string dependentUpon) { MD.ProjectFile fileProjectItem = CreateFileProjectItemUsingFullPath(path); fileProjectItem.DependsOn = dependentUpon; AddProjectItemToMSBuildProject(fileProjectItem); return(new ProjectItem(this, fileProjectItem)); }
private void HandleException(Exception ex, ProjectFile file, SingleFileCustomToolResult result) { if (ex is SpecFlowParserException) { SpecFlowParserException sfpex = (SpecFlowParserException) ex; if (sfpex.ErrorDetails == null || sfpex.ErrorDetails.Count == 0) { result.UnhandledException = ex; } else { var compilerErrors = new CompilerErrorCollection(); foreach (var errorDetail in sfpex.ErrorDetails) { var compilerError = new CompilerError(file.Name, errorDetail.ForcedLine, errorDetail.ForcedColumn, "0", errorDetail.Message); compilerErrors.Add(compilerError); } result.Errors.AddRange(compilerErrors); } } else { result.UnhandledException = ex; } }
public IAsyncOperation Generate (IProgressMonitor monitor, ProjectFile file, SingleFileCustomToolResult result) { return new ThreadAsyncOperation (delegate { var dnp = file.Project as DotNetProject; if (dnp == null) { var err = "ResXFileCodeGenerator can only be used with .NET projects"; result.Errors.Add (new CompilerError (null, 0, 0, null, err)); return; } var provider = dnp.LanguageBinding.GetCodeDomProvider (); if (provider == null) { var err = "ResXFileCodeGenerator can only be used with languages that support CodeDOM"; result.Errors.Add (new CompilerError (null, 0, 0, null, err)); return; } var outputfile = file.FilePath.ChangeExtension (".Designer." + provider.FileExtension); var ns = CustomToolService.GetFileNamespace (file, outputfile); var cn = provider.CreateValidIdentifier (file.FilePath.FileNameWithoutExtension); string[] unmatchable; var ccu = StronglyTypedResourceBuilder.Create (file.FilePath, cn, ns, provider, true, out unmatchable); foreach (var p in unmatchable) { var msg = string.Format ("Could not generate property for resource ID '{0}'", p); result.Errors.Add (new CompilerError (file.FilePath, 0, 0, null, msg)); } using (var w = new StreamWriter (outputfile, false, Encoding.UTF8)) provider.GenerateCodeFromCompileUnit (ccu, w, new CodeGeneratorOptions ()); result.GeneratedFilePath = outputfile; }, result); }
global::EnvDTE.ProjectItems CreateProjectItems (MD.ProjectFile projectItem) { if (projectItem.FilePath.IsDirectory) { return new DirectoryProjectItems (this); } return new FileProjectItems (this); }
void GenerateInternal (IProgressMonitor monitor, ProjectFile file, SingleFileCustomToolResult result) { var dnp = file.Project as DotNetProject; if (dnp == null || dnp.LanguageName != "C#") { var msg = "Razor templates are only supported in C# projects"; result.Errors.Add (new CompilerError (file.Name, -1, -1, null, msg)); monitor.Log.WriteLine (msg); return; } var host = PreprocessedRazorHost.Create (file.FilePath); var defaultOutputName = file.FilePath.ChangeExtension (".cs"); var ns = GetNamespaceHint (file, defaultOutputName); host.DefaultNamespace = ns; CompilerErrorCollection errors; var code = host.GenerateCode (out errors); result.Errors.AddRange (errors); var writer = new MonoDevelop.DesignerSupport.CodeBehindWriter (); writer.WriteFile (defaultOutputName, code); writer.WriteOpenFiles (); result.GeneratedFilePath = defaultOutputName; foreach (var err in result.Errors) { monitor.Log.WriteLine (err.ToString ()); } }
static ISingleFileCustomTool GetGenerator (ProjectFile file) { CustomToolExtensionNode node; if (!string.IsNullOrEmpty (file.Generator) && nodes.TryGetValue (file.Generator, out node)) return node.Tool; return null; }
static void GenerateInternal (IProgressMonitor monitor, ProjectFile file, SingleFileCustomToolResult result) { if (file.Project.SupportedLanguages.All (l => l != "C#")) { const string msg = "Razor templates are only supported in C# projects"; result.Errors.Add (new CompilerError (file.Name, -1, -1, null, msg)); monitor.Log.WriteLine (msg); return; } var host = new PreprocessedRazorHost (file.FilePath); var defaultOutputName = file.FilePath.ChangeExtension (".cs"); var ns = CustomToolService.GetFileNamespace (file, defaultOutputName); host.DefaultNamespace = ns; CompilerErrorCollection errors; var code = host.GenerateCode (out errors); result.Errors.AddRange (errors); var writer = new MonoDevelop.DesignerSupport.CodeBehindWriter (); writer.WriteFile (defaultOutputName, code); writer.WriteOpenFiles (); result.GeneratedFilePath = defaultOutputName; foreach (var err in result.Errors) { monitor.Log.WriteLine (err); } }
private static string GetDesignerFileName (ProjectFile file) { string directory = Path.GetDirectoryName (file.FilePath); string extension = Path.GetExtension (file.Name); string designerFile = Path.GetFileNameWithoutExtension (file.Name) + ".Designer" + extension; return Path.Combine (directory, designerFile); }
public static string GetCodeBehindClassName (ProjectFile file) { var proj = file.Project.GetService<AspNetAppProjectFlavor> (); if (proj == null) return null; return proj.GetCodebehindTypeName (file.Name); }
public static BuildResult UpdateDesignerFile ( CodeBehindWriter writer, DotNetProject project, ProjectFile file, ProjectFile designerFile ) { var result = new BuildResult (); //parse the ASP.NET file var parsedDocument = TypeSystemService.ParseFile (project, file.FilePath).Result as WebFormsParsedDocument; if (parsedDocument == null) { result.AddError (string.Format ("Failed to parse file '{0}'", file.Name)); return result; } //TODO: ensure type system is up to date CodeCompileUnit ccu; result.Append (GenerateCodeBehind (project, designerFile.FilePath, parsedDocument, out ccu)); if (ccu != null) { writer.WriteFile (designerFile.FilePath, ccu); } return result; }
List<Tuple<string, string, ProjectFile>> GenerateAllFiles () { //Slowest thing here is GetRelProjectPath, hence Tuple<,,> needs to be cached var list = new List<Tuple<string, string, ProjectFile>> (); foreach (var doc in IdeApp.Workbench.Documents) { // We only want to check it here if it's not part // of the open combine. Otherwise, it will get // checked down below. if (doc.Project == null && doc.IsFile) { var pf = new ProjectFile (doc.Name); list.Add (new Tuple<string, string, ProjectFile> (System.IO.Path.GetFileName (pf.FilePath), FileSearchResult.GetRelProjectPath (pf), pf)); } } var projects = IdeApp.Workspace.GetAllProjects (); foreach (var p in projects) { foreach (ProjectFile pf in p.Files) { if (pf.Subtype != Subtype.Directory && (pf.Flags & ProjectItemFlags.Hidden) != ProjectItemFlags.Hidden) { list.Add (new Tuple<string, string, ProjectFile> (System.IO.Path.GetFileName (pf.FilePath), FileSearchResult.GetRelProjectPath (pf), pf)); } } } return list; }
public void SetUp () { queue = new AnalysisJobQueue (); file1 = new ProjectFile ("file1.cs"); file2 = new ProjectFile ("file2.cs"); file3 = new ProjectFile ("file3.cs"); job = new SimpleAnalysisJob (new [] { file1, file2 }); }
public ProjectFileDescriptor (ProjectFile file) { this.file = file; project = file.Project; if (project != null) { project.FilePropertyChangedInProject += OnFilePropertyChangedInProject; } }
public static string BuildModuleName(ProjectFile pf) { // When handling an external link, keep it rooted though it might occur in a project's subfolder if (pf.IsLink || pf.IsExternalToProject) return pf.FilePath.FileNameWithoutExtension; return pf.ProjectVirtualPath.ChangeExtension(null).ToString().Replace(Path.DirectorySeparatorChar, '.'); }
public ProjectItem (Project project, MD.ProjectFile projectItem) { this.projectItem = projectItem; this.containingProject = project; this.ProjectItems = CreateProjectItems (projectItem); CreateProperties (); Kind = GetKindFromFileProjectItemType (); }
/// <summary>Initializes a new instance of the WebReferenceItem class.</summary> /// <param name="name">A string containing the name for the web reference.</param> public WebReferenceItem (WebServiceEngine engine, DotNetProject project, string name, FilePath basePath, ProjectFile mapFile) { this.engine = engine; this.name = name; this.project = project; this.mapFile = mapFile; BasePath = basePath.CanonicalPath; }
bool IsInProjectRootFolder(MD.ProjectFile item) { if (item.IsLink) { return(!HasDirectoryInPath(item.Link)); } return(!HasDirectoryInPath(item.FilePath)); }
public ProjectItem(Project project, MD.ProjectFile projectItem) { this.projectItem = projectItem; this.containingProject = project; this.ProjectItems = CreateProjectItems(projectItem); CreateProperties(); Kind = GetKindFromFileProjectItemType(); }
public string GetDefaultResourceId(ProjectFile pf) { if (String.IsNullOrEmpty (pf.DependsOn) || !File.Exists (pf.DependsOn)) // FIXME: Always returning null here //return MSBuildProjectService.GetDefaultResourceId (pf); return null; string ns = null; string classname = null; using (StreamReader rdr = new StreamReader (pf.DependsOn)) { int numopen = 0; while (true) { string tok = GetNextToken (rdr); if (tok == null) break; if (tok == "@") { //Handle @namespace, @class GetNextToken (rdr); continue; } if (String.Compare (tok, "namespace", false) == 0) ns = GetNextToken (rdr); if (tok == "{") numopen ++; if (tok == "}") { numopen --; if (numopen == 0) ns = String.Empty; } if (tok == "class") { classname = GetNextToken (rdr); break; } } if (classname == null) // FIXME: Always returning null here //return MSBuildProjectService.GetDefaultResourceId (pf); return null; string culture, extn, only_filename; if (MSBuildProjectService.TrySplitResourceName (pf.RelativePath, out only_filename, out culture, out extn)) extn = "." + culture + ".resources"; else extn = ".resources"; if (ns == null) return classname + extn; else return ns + '.' + classname + extn; } }
public static DeployProperties GetDeployProperties (ProjectFile file) { DeployProperties props = (DeployProperties) file.ExtendedProperties [typeof(DeployProperties)]; if (props != null) return props; props = new DeployProperties (file); file.ExtendedProperties [typeof(DeployProperties)] = props; return props; }
public async Task String () { ProjectItem item = new ProjectFile ("t1"); item.Metadata.SetValue ("a1", "v1"); var e = await Save (item); Assert.NotNull (e); Assert.AreEqual (1, e.ChildNodes.Count); AssertHasMetadata (e, "a1", "v1"); }
static void GenerateDesignerCode (CodeBehindWriter writer, ProjectFile xibFile, ProjectFile designerFile) { var ns = new CodeNamespace (((DotNetProject)designerFile.Project).GetDefaultNamespace (designerFile.FilePath)); var ccu = new CodeCompileUnit (); ccu.Namespaces.Add (ns); foreach (var ctd in CodeBehindGenerator.GetTypes (XDocument.Load (xibFile.FilePath), writer.Provider, writer.GeneratorOptions)) ns.Types.Add (ctd); writer.Write (ccu, designerFile.FilePath); }
public override bool AddToProject (SolutionItem policyParent, Project project, string language, string directory, string name) { var path = FilePath.Build (directory, project.Name + "-res.zip"); var file = new ProjectFile (path, "EmbeddedResource"); file.ResourceId = "XobotOS.Resources"; file.Visible = false; project.AddFile (file); return true; }
//from TextTemplatingFilePreprocessor static string GetNamespaceHint (ProjectFile file, string outputFile) { string ns = file.CustomToolNamespace; if (string.IsNullOrEmpty (ns) && !string.IsNullOrEmpty (outputFile)) { var dnp = ((DotNetProject) file.Project); ns = dnp.GetDefaultNamespace (outputFile); } return ns; }
ProjectItem CreateDirectoryProjectItem(string directoryName, string fullPath) { var directoryItem = new MD.ProjectFile(fullPath); return(new ProjectItem(project, directoryItem) { Kind = global::EnvDTE.Constants.vsProjectItemKindPhysicalFolder }); }
public IAsyncOperation Generate (IProgressMonitor monitor, ProjectFile file, SingleFileCustomToolResult result) { return new ThreadAsyncOperation (delegate { try { GenerateInternal (monitor, file, result); } catch (Exception ex) { result.UnhandledException = ex; } }, result); }
public Task Generate (ProgressMonitor monitor, ProjectFile file, SingleFileCustomToolResult result) { return Task.Run (delegate { try { GenerateInternal (monitor, file, result); } catch (Exception ex) { result.UnhandledException = ex; } }); }
MD.ProjectFile CreateFileProjectItemUsingPathRelativeToProject(string include, string fullPath) { var fileItem = new MD.ProjectFile(fullPath); if (IsLink(include)) { fileItem.Link = fullPath; } return(fileItem); }
public static bool IsCompileableFile(ProjectFile file) { if (!FilePath.PathComparer.Equals (file.FilePath.Extension, ".cs")) return false; return file.BuildAction == MonoDevelop.Projects.BuildAction.Compile || file.BuildAction == ApiDefinitionBuildAction || file.BuildAction == "BundleResource" || file.BuildAction == "BMacInputs"; }
public async Task Generate (ProgressMonitor monitor, ProjectFile file, SingleFileCustomToolResult result) { var buildResult = await file.Project.PerformGeneratorAsync (monitor, IdeApp.Workspace.ActiveConfiguration, this.targetName); foreach (var err in buildResult.BuildResult.Errors) { result.Errors.Add (new CompilerError (err.FileName, err.Line, err.Column, err.ErrorNumber, err.ErrorText) { IsWarning = err.IsWarning }); } }
public IEnumerable<BaseCodeIssueProvider> GetIssueProviders (ProjectFile file) { return RefactoringService.GetInspectors (DesktopService.GetMimeTypeForUri (file.Name)) .Where (provider => { var severity = provider.GetSeverity (); if (severity == Severity.None || !provider.GetIsEnabled ()) return false; return true; }); }
internal async Task UpdateAsync (Project project, ProjectFile[] files, CancellationToken token = default (CancellationToken)) { foreach (var file in files) { if (file.BuildAction == BuildAction.None) continue; var pd = await TypeSystemService.ParseFile (project, file.FilePath, token).ConfigureAwait (false); if (pd != null) UpdateTags (project, file.FilePath, await pd.GetTagCommentsAsync (token)); } }
public static void Update (ProjectFile file, bool force) { var tool = GetGenerator (file); if (tool == null) return; ProjectFile genFile = null; if (!string.IsNullOrEmpty (file.LastGenOutput)) genFile = file.Project.Files.GetFile (file.FilePath.ParentDirectory.Combine (file.LastGenOutput)); if (!force && genFile != null && File.Exists (genFile.FilePath) && File.GetLastWriteTime (file.FilePath) < File.GetLastWriteTime (genFile.FilePath)) { return; } TaskService.Errors.ClearByOwner (file); //if this file is already being run, cancel it lock (runningTasks) { IAsyncOperation runningTask; if (runningTasks.TryGetValue (file.FilePath, out runningTask)) { runningTask.Cancel (); runningTasks.Remove (file.FilePath); } } string title = GettextCatalog.GetString ("Custom Tool"); var monitor = IdeApp.Workbench.ProgressMonitors.GetOutputProgressMonitor (title, null, false, true); var result = new SingleFileCustomToolResult (); var aggOp = new AggregatedOperationMonitor (monitor); try { monitor.BeginTask (GettextCatalog.GetString ("Running generator '{0}' on file '{1}'...", file.Generator, file.Name), 1); var op = tool.Generate (monitor, file, result); runningTasks.Add (file.FilePath, op); aggOp.AddOperation (op); op.Completed += delegate { lock (runningTasks) { IAsyncOperation runningTask; if (runningTasks.TryGetValue (file.FilePath, out runningTask) && runningTask == op) { runningTasks.Remove (file.FilePath); UpdateCompleted (monitor, aggOp, file, genFile, result); } else { //it was cancelled because another was run for the same file, so just clean up aggOp.Dispose (); monitor.EndTask (); monitor.ReportWarning (GettextCatalog.GetString ("Cancelled because generator ran again for the same file")); monitor.Dispose (); } } }; } catch (Exception ex) { result.UnhandledException = ex; UpdateCompleted (monitor, aggOp, file, genFile, result); } }
async Task <List <DocumentInfo> > GenerateProjections(MonoDevelop.Projects.ProjectFile f, DocumentMap documentMap, MonoDevelop.Projects.Project p, CancellationToken token, ProjectData oldProjectData, HashSet <DocumentId> duplicates) { var mimeType = IdeServices.DesktopService.GetMimeTypeForUri(f.FilePath); var node = IdeApp.TypeSystemService.GetTypeSystemParserNode(mimeType, f.BuildAction); if (node == null || !node.Parser.CanGenerateProjection(mimeType, f.BuildAction, p.SupportedLanguages)) { return(new List <DocumentInfo> ()); } var content = TextFileProvider.Instance.GetReadOnlyTextEditorData(f.FilePath, throwOnFileNotFound: false); if (content == null) { return(new List <DocumentInfo> ()); } var options = new ParseOptions { FileName = f.FilePath, Project = p, Content = content, }; var generatedProjections = await node.Parser.GenerateProjections(options, token); var list = new List <Projection> (); var entry = new ProjectionEntry { File = f, Projections = list, }; var result = new List <DocumentInfo> (generatedProjections.Count); foreach (var projection in generatedProjections) { list.Add(projection); if (duplicates != null && !duplicates.Add(documentMap.GetOrCreate(projection.Document.FileName, oldProjectData?.DocumentData))) { continue; } var plainName = projection.Document.FileName.FileName; var folders = GetFolders(p.Name, f.ProjectVirtualPath); result.Add(DocumentInfo.Create( documentMap.GetOrCreate(projection.Document.FileName, oldProjectData?.DocumentData), plainName, folders, SourceCodeKind.Regular, TextLoader.From(TextAndVersion.Create(new MonoDevelopSourceText(projection.Document), VersionStamp.Create(), projection.Document.FileName)), projection.Document.FileName, false) ); } projections.AddProjectionEntry(entry); return(result); }
ProjectItem CreateDirectoryProjectItemIfDirectoryNotAlreadyIncluded(MD.ProjectFile fileItem) { string directory = fileItem.FilePath; if (!IsDirectoryIncludedAlready(directory)) { AddIncludedDirectory(directory); return(new ProjectItem(project, fileItem)); } return(null); }
ProjectItem ConvertFileToProjectItem(MD.ProjectFile fileItem) { if (IsInProjectRootFolder(fileItem)) { if (IsDirectory(fileItem)) { return(CreateDirectoryProjectItemIfDirectoryNotAlreadyIncluded(fileItem)); } return(new ProjectItem(project, fileItem)); } return(ConvertDirectoryToProjectItem(fileItem)); }
string GetDependentUpon(string path) { var dependentFile = new DependentFile(DotNetProject); MD.ProjectFile projectItem = dependentFile.GetParentFileProjectItem(path); if (projectItem != null) { string relativePath = GetRelativePath(projectItem.FilePath); return(Path.GetFileName(relativePath)); } return(null); }
ProjectItem ConvertDirectoryToProjectItem(MD.ProjectFile fileItem) { string relativePath = project.GetRelativePath(fileItem.FilePath); string subDirectoryName = GetFirstSubDirectoryName(relativePath); if (IsDirectoryInsideProject(subDirectoryName)) { string fullPath = project.DotNetProject.BaseDirectory.Combine(subDirectoryName); return(CreateDirectoryProjectItemIfDirectoryNotAlreadyIncluded(subDirectoryName, fullPath)); } return(null); }
internal void NotifyFilePropertyChangedInProject(ProjectFile file) { NotifyModified("Files"); OnFilePropertyChangedInProject(new ProjectFileEventArgs(this, file)); }
/// <summary> /// Adds a file to the project /// </summary> /// <param name='projectFile'> /// The file. /// </param> public void AddFile(ProjectFile projectFile) { Files.Add(projectFile); }
public void Remove(ProjectFile file) { Remove(file, null); }
bool IsDirectory(MD.ProjectFile fileItem) { return(fileItem.FilePath.IsDirectory); }
public void SolutionItemsEvents() { int countFileAddedToProject = 0; int countFileRemovedFromProject = 0; int countFileRenamedInProject = 0; int countReferenceAddedToProject = 0; int countReferenceRemovedFromProject = 0; int countSolutionItemAdded = 0; int countSolutionItemRemoved = 0; Solution sol = new Solution(); sol.FileAddedToProject += delegate { countFileAddedToProject++; }; sol.FileRemovedFromProject += delegate { countFileRemovedFromProject++; }; sol.FileRenamedInProject += delegate { countFileRenamedInProject++; }; sol.ReferenceAddedToProject += delegate { countReferenceAddedToProject++; }; sol.ReferenceRemovedFromProject += delegate { countReferenceRemovedFromProject++; }; sol.SolutionItemAdded += delegate { countSolutionItemAdded++; }; sol.SolutionItemRemoved += delegate { countSolutionItemRemoved++; }; Assert.AreEqual(0, countFileAddedToProject); Assert.AreEqual(0, countFileRemovedFromProject); Assert.AreEqual(0, countFileRenamedInProject); Assert.AreEqual(0, countReferenceAddedToProject); Assert.AreEqual(0, countReferenceRemovedFromProject); Assert.AreEqual(0, countSolutionItemAdded); Assert.AreEqual(0, countSolutionItemRemoved); SolutionFolder folder = new SolutionFolder(); folder.Name = "Folder1"; sol.RootFolder.Items.Add(folder); Assert.AreEqual(1, countSolutionItemAdded); Assert.AreEqual(0, sol.Items.Count); var project = Services.ProjectService.CreateDotNetProject("C#"); project.Name = "project1"; sol.RootFolder.Items.Add(project); Assert.AreEqual(2, countSolutionItemAdded); Assert.AreEqual(1, sol.Items.Count); var project2 = Services.ProjectService.CreateDotNetProject("C#"); project2.Name = "project2"; folder.Items.Add(project2); Assert.AreEqual(3, countSolutionItemAdded); Assert.AreEqual(2, sol.Items.Count); ProjectFile p1 = new ProjectFile("test1.cs"); project2.Files.Add(p1); Assert.AreEqual(1, countFileAddedToProject); ProjectFile p2 = new ProjectFile("test1.cs"); project.Files.Add(p2); Assert.AreEqual(2, countFileAddedToProject); p1.Name = "test2.cs"; Assert.AreEqual(1, countFileRenamedInProject); p2.Name = "test2.cs"; Assert.AreEqual(2, countFileRenamedInProject); project2.Files.Remove(p1); Assert.AreEqual(1, countFileRemovedFromProject); project.Files.Remove("test2.cs"); Assert.AreEqual(2, countFileRemovedFromProject); ProjectReference pr1 = ProjectReference.CreateAssemblyReference("SomeTest"); project.References.Add(pr1); Assert.AreEqual(1, countReferenceAddedToProject); ProjectReference pr2 = ProjectReference.CreateProjectReference(project); project2.References.Add(pr2); Assert.AreEqual(2, countReferenceAddedToProject); project.References.Remove(pr1); Assert.AreEqual(1, countReferenceRemovedFromProject); sol.RootFolder.Items.Remove(project); Assert.AreEqual(2, countReferenceRemovedFromProject, "Removing a project must remove all references to it"); Assert.AreEqual(1, countSolutionItemRemoved); Assert.AreEqual(1, sol.Items.Count); folder.Items.Remove(project2); Assert.AreEqual(2, countSolutionItemRemoved); Assert.AreEqual(0, sol.Items.Count); sol.RootFolder.Items.Remove(folder); Assert.AreEqual(2, countFileAddedToProject); Assert.AreEqual(2, countFileRemovedFromProject); Assert.AreEqual(2, countFileRenamedInProject); Assert.AreEqual(2, countReferenceAddedToProject); Assert.AreEqual(2, countReferenceRemovedFromProject); Assert.AreEqual(3, countSolutionItemAdded); Assert.AreEqual(3, countSolutionItemRemoved); sol.Dispose(); }
public static void CheckResourcesSolution(Solution sol) { DotNetProject p = (DotNetProject)sol.Items [0]; Assert.AreEqual("ResourcesTesterNamespace", p.DefaultNamespace); string f = Path.Combine(p.BaseDirectory, "Bitmap1.bmp"); ProjectFile pf = p.Files.GetFile(f); Assert.IsNotNull(pf, "Bitmap1.bmp not found"); Assert.AreEqual(BuildAction.EmbeddedResource, pf.BuildAction); Assert.AreEqual("ResourcesTesterNamespace.Bitmap1.bmp", pf.ResourceId); f = Path.Combine(p.BaseDirectory, "BitmapCultured.ca.bmp"); pf = p.Files.GetFile(f); Assert.IsNotNull(pf, "BitmapCultured.ca.bmp not found"); Assert.AreEqual(BuildAction.EmbeddedResource, pf.BuildAction); Assert.AreEqual("ResourcesTesterNamespace.BitmapCultured.bmp", pf.ResourceId); f = Path.Combine(p.BaseDirectory, "Cultured.ca.resx"); pf = p.Files.GetFile(f); Assert.IsNotNull(pf, "Cultured.ca.resx not found"); Assert.AreEqual(BuildAction.EmbeddedResource, pf.BuildAction); Assert.AreEqual("ResourcesTesterNamespace.Cultured.ca.resources", pf.ResourceId); f = Path.Combine(p.BaseDirectory, "FormFile.ca.resx"); pf = p.Files.GetFile(f); Assert.IsNotNull(pf, "FormFile.ca.resx not found"); Assert.AreEqual(BuildAction.EmbeddedResource, pf.BuildAction); Assert.AreEqual("ResourcesTester.Form1.ca.resources", pf.ResourceId); f = Path.Combine(p.BaseDirectory, "FormFile.resx"); pf = p.Files.GetFile(f); Assert.IsNotNull(pf, "FormFile.resx not found"); Assert.AreEqual(BuildAction.EmbeddedResource, pf.BuildAction); Assert.AreEqual("ResourcesTester.Form1.resources", pf.ResourceId); f = Path.Combine(p.BaseDirectory, "Normal.resx"); pf = p.Files.GetFile(f); Assert.IsNotNull(pf, "Normal.resx not found"); Assert.AreEqual(BuildAction.EmbeddedResource, pf.BuildAction); Assert.AreEqual("ResourcesTesterNamespace.Normal.resources", pf.ResourceId); string subdir = Path.Combine(p.BaseDirectory, "Subfolder"); f = Path.Combine(subdir, "Bitmap2.bmp"); pf = p.Files.GetFile(f); Assert.IsNotNull(pf, "Subfolder/Bitmap2.bmp not found"); Assert.AreEqual(BuildAction.EmbeddedResource, pf.BuildAction); Assert.AreEqual("ResourcesTesterNamespace.Subfolder.Bitmap2.bmp", pf.ResourceId); f = Path.Combine(subdir, "BitmapCultured2.ca.bmp"); pf = p.Files.GetFile(f); Assert.IsNotNull(pf, "Subfolder/BitmapCultured2.ca.bmp not found"); Assert.AreEqual(BuildAction.EmbeddedResource, pf.BuildAction); Assert.AreEqual("ResourcesTesterNamespace.Subfolder.BitmapCultured2.bmp", pf.ResourceId); f = Path.Combine(subdir, "Cultured2.ca.resx"); pf = p.Files.GetFile(f); Assert.IsNotNull(pf, "Subfolder/Cultured2.ca.resx not found"); Assert.AreEqual(BuildAction.EmbeddedResource, pf.BuildAction); Assert.AreEqual("ResourcesTesterNamespace.Subfolder.Cultured2.ca.resources", pf.ResourceId); f = Path.Combine(subdir, "FormFile2.ca.resx"); pf = p.Files.GetFile(f); Assert.IsNotNull(pf, "Subfolder/FormFile2.ca.resx not found"); Assert.AreEqual(BuildAction.EmbeddedResource, pf.BuildAction); Assert.AreEqual("ResourcesTester.Form2.ca.resources", pf.ResourceId); f = Path.Combine(subdir, "FormFile2.resx"); pf = p.Files.GetFile(f); Assert.IsNotNull(pf, "Subfolder/FormFile2.resx not found"); Assert.AreEqual(BuildAction.EmbeddedResource, pf.BuildAction); Assert.AreEqual("ResourcesTester.Form2.resources", pf.ResourceId); f = Path.Combine(subdir, "Normal2.resx"); pf = p.Files.GetFile(f); Assert.IsNotNull(pf, "Subfolder/Normal2.resx not found"); Assert.AreEqual(BuildAction.EmbeddedResource, pf.BuildAction); Assert.AreEqual("ResourcesTesterNamespace.Subfolder.Normal2.resources", pf.ResourceId); }
public DirectoryProjectItem(Project project, MD.ProjectFile projectItem) : base(project, projectItem) { }
public ProjectFilePathChangedEventArgs(ProjectFile projectFile, FilePath oldPath, FilePath newPath, FilePath oldVirtualPath, FilePath newVirtualPath) : base(projectFile, oldVirtualPath, newVirtualPath) { OldPath = oldPath; NewPath = newPath; }
internal void NotifyFileChangedInProject(ProjectFile file) { OnFileChangedInProject(new ProjectFileEventArgs(this, file)); }
internal void UpdateDependency(ProjectFile file, FilePath oldPath) { unresolvedDeps.Remove(file, oldPath); ResolveDependencies(file); }
public static bool IsDependentUponAnotherFile(this MD.ProjectFile projectItem) { return(!String.IsNullOrEmpty(projectItem.DependsOn)); }
static IEnumerable <string> GetFolders(string projectName, MonoDevelop.Projects.ProjectFile f) { return(new [] { projectName }.Concat(f.ProjectVirtualPath.ParentDirectory.ToString().Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar))); }
static DocumentInfo CreateDocumentInfo(SolutionData data, string projectName, ProjectData id, MonoDevelop.Projects.ProjectFile f) { var filePath = f.FilePath.ResolveLinks(); var folders = GetFolders(projectName, f); return(DocumentInfo.Create( id.DocumentData.GetOrCreate(filePath), Path.GetFileName(filePath), folders, f.SourceCodeKind, CreateTextLoader(filePath), filePath, isGenerated: false )); TextLoader CreateTextLoader(string fileName) => data.Files.GetOrAdd(fileName, a => new MonoDevelopTextLoader(a)); }
public static bool IsDependentUponFileName(this MD.ProjectFile projectItem, string fileName) { return(FilePath.Equals(projectItem.GetDependentUponFileName(), fileName)); }
public static string GetDependentUponFileName(this MD.ProjectFile projectItem) { string directory = Path.GetDirectoryName(projectItem.FilePath); return(Path.Combine(directory, projectItem.DependsOn)); }
static bool CanGenerateAnalysisContextForNonCompileable(MonoDevelop.Projects.Project p, MonoDevelop.Projects.ProjectFile f) { var mimeType = IdeServices.DesktopService.GetMimeTypeForUri(f.FilePath); var node = IdeApp.TypeSystemService.GetTypeSystemParserNode(mimeType, f.BuildAction); if (node?.Parser == null) { return(false); } return(node.Parser.CanGenerateAnalysisDocument(mimeType, f.BuildAction, p.SupportedLanguages)); }
public ProjectFileVirtualPathChangedEventArgs(ProjectFile projectFile, FilePath oldPath, FilePath newPath) { ProjectFile = projectFile; OldVirtualPath = oldPath; NewVirtualPath = newPath; }
public static bool IsDependentUpon(this MD.ProjectFile projectItem, MD.ProjectFile otherProjectItem) { return(projectItem.DependsOnFile == otherProjectItem); }
void AddProjectItemToMSBuildProject(MD.ProjectFile projectItem) { DotNetProject.AddFile(projectItem); }