string GetReferenceLibraryPath(MonoDevelop.Projects.ProjectReference pref) { string path = null; if (pref.ReferenceType == ReferenceType.Project) { DotNetProject p = pref.ResolveProject(project.ParentSolution) as DotNetProject; if (p != null) { path = p.GetOutputFileName(IdeApp.Workspace.ActiveConfiguration); } } else if (pref.ReferenceType == ReferenceType.Assembly) { path = pref.Reference; } else if (pref.ReferenceType == ReferenceType.Package) { path = pref.Reference; } if (path != null && GuiBuilderService.SteticApp.IsWidgetLibrary(path)) { return(path); } else { return(null); } }
public static NUnitVersion?GetNUnitVersion(ProjectReference p) { if (p.Reference.IndexOf("GuiUnit", StringComparison.OrdinalIgnoreCase) != -1 || p.Reference.StartsWith("nunitlite", StringComparison.OrdinalIgnoreCase)) { return(NUnitVersion.NUnit2); } if (p.Reference.IndexOf("nunit.framework", StringComparison.OrdinalIgnoreCase) != -1) { var selector = p.Project?.DefaultConfiguration.Selector; if (selector == null) { return(NUnitVersion.Unknown); } var f = p.GetReferencedFileNames(selector).FirstOrDefault(); if (f != null && File.Exists(f)) { try { var aname = new AssemblyName(SystemAssemblyService.GetAssemblyName(f)); if (aname.Version.Major == 2) { return(NUnitVersion.NUnit2); } else { return(NUnitVersion.NUnit3); } } catch (Exception ex) { LoggingService.LogError("Could not get assembly version", ex); } } } return(null); }
public static string GetReferenceName(ProjectReference pref) { string stored = pref.StoredReference; int idx =stored.IndexOf (","); if (idx == -1) return stored.Trim (); return stored.Substring (0, idx).Trim (); }
public AddImport(Document doc, ResolveResult resolveResult, string ns, MonoDevelop.Projects.ProjectReference reference, bool addUsing, AstNode node) { this.doc = doc; this.resolveResult = resolveResult; this.ns = ns; this.reference = reference; this.addUsing = addUsing; this.node = node; }
public static bool IsQyotoReference(ProjectReference pref) { if (pref.ReferenceType != ReferenceType.Gac) return false; int idx = pref.StoredReference.IndexOf(","); if (idx == -1) return false; string name = pref.StoredReference.Substring(0, idx).Trim(); return name == "qt-dotnet"; }
/// <summary> /// Gets the xunit.net version from the reference. /// </summary> /// <returns>The xunit.net version.</returns> /// <param name="p">Project reference.</param> public static XUnitVersion?GetXUnitVersion(ProjectReference p) { if (p.Reference == "xunit") // xUnit.Net 1.x { return(XUnitVersion.XUnit); } if (p.Reference.IndexOf("xunit.core", StringComparison.OrdinalIgnoreCase) != -1) // xUnit.Net 2.x { return(XUnitVersion.XUnit2); } return(null); }
internal virtual void AddReference(string path) { DispatchService.GuiSyncDispatch(() => { if (!HasReference(path)) { if (Path.IsPathRooted(path)) { DotNetProject.AddReference(path); } else { var reference = new MD.ProjectReference(MD.ReferenceType.Package, path); DotNetProject.References.Add(reference); } } }); }
static bool CanReference(Document doc, MonoDevelop.Projects.ProjectReference projectReference) { var project = doc.Project as DotNetProject; if (project == null || projectReference == null || project.ParentSolution == null) { return(true); } switch (projectReference.ReferenceType) { case ReferenceType.Project: var referenceProject = projectReference.ResolveProject(project.ParentSolution) as DotNetProject; if (referenceProject == null) { return(true); } string reason; return(project.CanReferenceProject(referenceProject, out reason)); } return(true); }
public static ProjectDescriptor CreateProjectDescriptor (XmlElement xmlElement, FilePath baseDirectory) { ProjectDescriptor projectDescriptor = new ProjectDescriptor (); projectDescriptor.name = xmlElement.GetAttribute ("name"); projectDescriptor.type = xmlElement.GetAttribute ("type"); if (String.IsNullOrEmpty (projectDescriptor.type)) projectDescriptor.type = "DotNet"; if (xmlElement["Files"] != null) { foreach (XmlNode xmlNode in xmlElement["Files"].ChildNodes) if (xmlNode is XmlElement) projectDescriptor.files.Add ( FileDescriptionTemplate.CreateTemplate ((XmlElement)xmlNode, baseDirectory)); } if (xmlElement["Resources"] != null) { foreach (XmlNode xmlNode in xmlElement["Resources"].ChildNodes) { if (xmlNode is XmlElement) { var fileTemplate = FileDescriptionTemplate.CreateTemplate ((XmlElement)xmlNode, baseDirectory); if (fileTemplate is SingleFileDescriptionTemplate) projectDescriptor.resources.Add ((SingleFileDescriptionTemplate)fileTemplate); else MessageService.ShowError (GettextCatalog.GetString ("Only single-file templates allowed to generate resource files")); } } } if (xmlElement["References"] != null) { foreach (XmlNode xmlNode in xmlElement["References"].ChildNodes) { XmlElement elem = (XmlElement)xmlNode; var refType = elem.GetAttribute ("type"); ProjectReference projectReference = new ProjectReference ((ReferenceType)Enum.Parse (typeof(ReferenceType), refType), elem.GetAttribute ("refto")); string specificVersion = elem.GetAttribute ("SpecificVersion"); if (!string.IsNullOrEmpty (specificVersion)) projectReference.SpecificVersion = bool.Parse (specificVersion); projectDescriptor.references.Add (projectReference); } } projectDescriptor.projectOptions = xmlElement["Options"]; if (projectDescriptor.projectOptions == null) projectDescriptor.projectOptions = xmlElement.OwnerDocument.CreateElement ("Options"); return projectDescriptor; }
public PossibleNamespace (string @namespace, bool isAccessibleWithGlobalUsing, MonoDevelop.Projects.ProjectReference reference = null) { this.Namespace = @namespace; this.IsAccessibleWithGlobalUsing = isAccessibleWithGlobalUsing; this.Reference = reference; }
internal virtual void OnProjectReferenceAdded (ProjectReference pref) { ProjectDom dom = ProjectDomService.GetDom (pref.Reference, true); if (dom != null && references != null) this.references.Add (dom); }
public void Execute_ReferenceHasLocalCopyFalseWhenUninstalled_ReferenceHasLocalCopyFalseAfterBeingReinstalled () { CreateAction ("MyPackage", "1.2.3.4"); FakePackage package = AddPackageToSourceRepository ("MyPackage", "1.2.3.4"); var firstReferenceBeingAdded = new ProjectReference (ReferenceType.Assembly, "NewAssembly"); var secondReferenceBeingAdded = new ProjectReference (ReferenceType.Assembly, "NUnit.Framework"); project.FakeUninstallPackageAction.ExecuteAction = () => { var referenceBeingRemoved = new ProjectReference (ReferenceType.Assembly, "NUnit.Framework") { LocalCopy = false }; packageManagementEvents.OnReferenceRemoving (referenceBeingRemoved); }; bool installActionMaintainsLocalCopyReferences = false; project.InstallPackageExecuteAction = () => { installActionMaintainsLocalCopyReferences = project.LastInstallPackageCreated.PreserveLocalCopyReferences; packageManagementEvents.OnReferenceAdding (firstReferenceBeingAdded); packageManagementEvents.OnReferenceAdding (secondReferenceBeingAdded); }; action.Execute (); Assert.IsTrue (firstReferenceBeingAdded.LocalCopy); Assert.IsFalse (secondReferenceBeingAdded.LocalCopy); Assert.IsFalse (installActionMaintainsLocalCopyReferences, "Should be false since the reinstall action will maintain the local copies"); }
public Reference (Project project, MD.ProjectReference referenceProjectItem) { this.project = project; this.referenceProjectItem = referenceProjectItem; }
public void SignalRefChange(ProjectReference refInfo, bool newState) { }
public async Task MakefileSynchronization() { if (Platform.IsWindows) { Assert.Ignore(); } string solFile = Util.GetSampleProject("console-project-with-makefile", "ConsoleProject.sln"); Solution sol = (Solution)await Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), solFile); DotNetProject p = (DotNetProject)sol.Items [0]; Assert.AreEqual(2, p.Files.Count); string f = Path.Combine(p.BaseDirectory, "Program.cs"); Assert.IsTrue(p.Files.GetFile(f) != null, "Contains Program.cs"); f = Path.Combine(p.BaseDirectory, "Properties"); f = Path.Combine(f, "AssemblyInfo.cs"); Assert.IsTrue(p.Files.GetFile(f) != null, "Contains Properties/AssemblyInfo.cs"); List <string> refs = new List <string> (); refs.Add("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); refs.Add("System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); refs.Add("System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); Assert.AreEqual(3, p.References.Count); ProjectReference xmlRef = null; foreach (ProjectReference pref in p.References) { Assert.IsTrue(refs.Contains(pref.Reference), "Contains reference " + pref.Reference); refs.Remove(pref.Reference); if (pref.Reference.StartsWith("System.Xml")) { xmlRef = pref; } } // Test saving p.References.Remove(xmlRef); p.References.Add(ProjectReference.CreateAssemblyReference("System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")); p.Files.Remove(f); p.Files.Add(new ProjectFile(Path.Combine(p.BaseDirectory, "Class1.cs"), BuildAction.Compile)); await sol.SaveAsync(Util.GetMonitor()); string makefile = File.ReadAllText(Path.Combine(p.BaseDirectory, "Makefile")); string[] values = GetVariable(makefile, "FILES").Split(' '); Assert.AreEqual(2, values.Length); Assert.AreEqual("Class1.cs", values [0]); Assert.AreEqual("Program.cs", values [1]); values = GetVariable(makefile, "REFERENCES").Split(' '); Assert.AreEqual(3, values.Length); Assert.AreEqual("System", values [0]); Assert.AreEqual("System.Data", values [1]); Assert.AreEqual("System.Web", values [2]); sol.Dispose(); }
internal void NotifyReferenceAddedToProject(ProjectReference reference) { SetNeedsBuilding(true); NotifyModified("References"); OnReferenceAddedToProject(new ProjectReferenceEventArgs(this, reference)); }
string GacRefToString (ProjectReference pr, Dictionary<string, bool> hasAcSubstPackages, MakefileVar refVar) { //Gac ref can be a full name OR a path! //FIXME: Use GetReferencedFileName and GetPackageFromPath ? string fullname = pr.Reference; SystemPackage pkg = pr.Package; if (pkg == null) { //reference could be a path pkg = assemblyContext.GetPackageFromPath (Path.GetFullPath (pr.Reference)); if (pkg != null) { //Path try { fullname = AssemblyName.GetAssemblyName (pr.Reference).FullName; //If this throws : Invalid assembly! //let it fall through and be emitted as a asm ref } catch (FileNotFoundException) { pkg = null; } catch (BadImageFormatException) { pkg = null; } } } if (pkg == null) return AsmRefToString (pr.GetReferencedFileNames (ConfigurationSelector.Default) [0], refVar, false); // Reference is from a package if (pkg.IsCorePackage) //pkg:mono, Eg. System, System.Data etc return fullname.Split (new char [] {','}, 2) [0]; //Ref is from a non-core package string varname = null; if (UseAutotools) //Check whether ref'ed in configure.in varname = ConfiguredPackages.GetVarNameFromName (pkg.Name); if (varname == null) { //Package not referenced in configure.in //Or not a autotools based project, //so emit -pkg: if (!hasAcSubstPackages.ContainsKey (pkg.Name)) { if (UseAutotools) { //Warn only if UseAutotools string msg = GettextCatalog.GetString ( "A reference to the pkg-config package '{0}' is being emitted to the Makefile, " + "because at least one assembly from the package is used in the project '{1}'. However, " + "this dependency is not specified in the configure.in file, so you might need to " + "add it to ensure that the project builds successfully on other systems.", pkg.Name, pr.OwnerProject.Name); LoggingService.LogWarning (msg); monitor.ReportWarning (msg); } hasAcSubstPackages [pkg.Name] = false; } } else { // If the package as AC_SUBST(FOO_LIBS) defined, then // emit FOO_LIBS, else emit -pkg:foo if (ConfiguredPackages.HasAcSubst (varname + "_LIBS")) { hasAcSubstPackages [varname] = true; } else { hasAcSubstPackages [pkg.Name] = false; } } return null; }
public async Task AddRemoveReferenceEvents() { string solFile = Util.GetSampleProject("console-project", "ConsoleProject.sln"); Solution sol = (Solution)await Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), solFile); var p = (DotNetProject)sol.Items [0]; int added = 0, removed = 0, modifiedRefs = 0, modifiedItems = 0, refsChanged = 0; // We should get two ReferenceAdded events (one for each reference), but only one global modified and assemblies changed event. var refs = new [] { ProjectReference.CreateAssemblyReference("Foo"), ProjectReference.CreateAssemblyReference("Bar") }; p.ReferenceAddedToProject += delegate { added++; Assert.IsTrue(refs.All(r => r.OwnerProject != null)); }; p.ReferenceRemovedFromProject += delegate { removed++; Assert.IsTrue(refs.All(r => r.OwnerProject == null)); }; EventHandler refsChangedHandler = delegate { refsChanged++; Assert.IsTrue(refs.All(r => r.OwnerProject != null)); }; p.ReferencedAssembliesChanged += refsChangedHandler; SolutionItemModifiedEventHandler modifiedHandler = delegate(object sender, SolutionItemModifiedEventArgs e) { foreach (var ev in e) { if (ev.Hint == "References") { modifiedRefs++; } if (ev.Hint == "Items") { modifiedItems++; } } Assert.IsTrue(refs.All(r => r.OwnerProject != null)); }; p.Modified += modifiedHandler; p.References.AddRange(refs); Assert.AreEqual(2, added); Assert.AreEqual(1, modifiedRefs); Assert.AreEqual(1, modifiedItems); Assert.AreEqual(1, refsChanged); modifiedRefs = modifiedItems = refsChanged = 0; p.ReferencedAssembliesChanged -= refsChangedHandler; p.Modified -= modifiedHandler; refsChangedHandler = delegate { refsChanged++; Assert.IsTrue(refs.All(r => r.OwnerProject == null)); }; p.ReferencedAssembliesChanged += refsChangedHandler; modifiedHandler = delegate(object sender, SolutionItemModifiedEventArgs e) { foreach (var ev in e) { if (ev.Hint == "References") { modifiedRefs++; } if (ev.Hint == "Items") { modifiedItems++; } } Assert.IsTrue(refs.All(r => r.OwnerProject == null)); }; p.Modified += modifiedHandler; p.References.RemoveRange(refs); Assert.AreEqual(2, removed); Assert.AreEqual(1, modifiedRefs); Assert.AreEqual(1, modifiedItems); Assert.AreEqual(1, refsChanged); sol.Dispose(); }
public Reference(Project project, MD.ProjectReference referenceProjectItem) { this.project = project; this.referenceProjectItem = referenceProjectItem; }
public Reference3(Project project, MD.ProjectReference referenceProjectItem) : base(project, referenceProjectItem) { }
internal void RemoveReference(MD.ProjectReference referenceItem) { DotNetProject.References.Remove(referenceItem); }
bool IsReferenceMatch(MD.ProjectReference reference, string include) { return(String.Equals(reference.Reference, include, StringComparison.InvariantCultureIgnoreCase)); }
public ProjectReference AddReference (string filename) { foreach (ProjectReference rInfo in References) { if (rInfo.Reference == filename) { return rInfo; } } ProjectReference newReferenceInformation = new ProjectReference (ReferenceType.Assembly, filename); References.Add (newReferenceInformation); return newReferenceInformation; }
public PossibleNamespace(string @namespace, bool isAccessibleWithGlobalUsing, MonoDevelop.Projects.ProjectReference reference = null) { this.Namespace = @namespace; this.IsAccessibleWithGlobalUsing = isAccessibleWithGlobalUsing; this.Reference = reference; }
ProjectReference AddNewGacReference (DotNetProject project, SystemAssembly sa) { ProjectReference pref = new ProjectReference (sa); project.References.Add (pref); newGacRefs [sa.Location] = pref; return pref; }
public void SaveSharedProject () { Solution sol = TestProjectsChecks.CreateConsoleSolution ("shared-project"); sol.ConvertToFormat (Util.FileFormatMSBuild12, true); sol.Save (Util.GetMonitor ()); var pc = (DotNetProject) sol.Items [0]; // Add shared project var sp = new SharedAssetsProject () { LanguageName = "C#", DefaultNamespace = "TestNamespace" }; sp.AddFile (sol.ItemDirectory.Combine ("Test.cs")); sp.Save (sol.ItemDirectory.Combine ("Shared"), Util.GetMonitor ()); sol.RootFolder.AddItem (sp); sol.Save (Util.GetMonitor ()); // Make sure we compare using the same guid string solXml = File.ReadAllText (sol.FileName).Replace (pc.ItemId, "{7DE4B613-BAB6-49DE-83FA-707D4E120306}").Replace (sp.ItemId, "{8DD793BE-42C3-4D66-8359-460CEE75980D}"); string projectXml = Util.GetXmlFileInfoset (pc.FileName).Replace (pc.ItemId, "{7DE4B613-BAB6-49DE-83FA-707D4E120306}"); string sharedProjectXml = Util.GetXmlFileInfoset (sp.FileName).Replace (sp.ItemId, "{8DD793BE-42C3-4D66-8359-460CEE75980D}"); string sharedProjectItemsXml = Util.GetXmlFileInfoset (sp.FileName.ChangeExtension (".projitems")).Replace (sp.ItemId, "{8DD793BE-42C3-4D66-8359-460CEE75980D}"); string refSolXml = Util.ToWindowsEndings (File.ReadAllText (Util.GetSampleProjectPath ("generated-shared-project", "TestSolution.sln"))); string refProjectXml = Util.ToWindowsEndings (Util.GetXmlFileInfoset (Util.GetSampleProjectPath ("generated-shared-project", "TestProject.csproj"))); string refSharedProjectXml = Util.ToWindowsEndings (Util.GetXmlFileInfoset (Util.GetSampleProjectPath ("generated-shared-project", "Shared.shproj"))); string refSharedProjectItemsXml = Util.ToWindowsEndings (Util.GetXmlFileInfoset (Util.GetSampleProjectPath ("generated-shared-project", "Shared.projitems"))); Assert.AreEqual (refSolXml, solXml); Assert.AreEqual (refProjectXml, projectXml); Assert.AreEqual (refSharedProjectXml, sharedProjectXml); Assert.AreEqual (refSharedProjectItemsXml, sharedProjectItemsXml); // Add a reference var r = new ProjectReference (sp); pc.References.Add (r); sol.Save (Util.GetMonitor ()); solXml = File.ReadAllText (sol.FileName).Replace (pc.ItemId, "{7DE4B613-BAB6-49DE-83FA-707D4E120306}").Replace (sp.ItemId, "{8DD793BE-42C3-4D66-8359-460CEE75980D}"); projectXml = Util.GetXmlFileInfoset (pc.FileName).Replace (pc.ItemId, "{7DE4B613-BAB6-49DE-83FA-707D4E120306}"); sharedProjectXml = Util.GetXmlFileInfoset (sp.FileName).Replace (sp.ItemId, "{8DD793BE-42C3-4D66-8359-460CEE75980D}"); sharedProjectItemsXml = Util.GetXmlFileInfoset (sp.FileName.ChangeExtension (".projitems")).Replace (sp.ItemId, "{8DD793BE-42C3-4D66-8359-460CEE75980D}"); refProjectXml = Util.ToWindowsEndings (Util.GetXmlFileInfoset (Util.GetSampleProjectPath ("generated-shared-project", "TestProject.csproj.saved1"))); Assert.AreEqual (refSolXml, solXml); Assert.AreEqual (refProjectXml, projectXml); Assert.AreEqual (refSharedProjectXml, sharedProjectXml); Assert.AreEqual (refSharedProjectItemsXml, sharedProjectItemsXml); // Add a file and change the default namespace sp.DefaultNamespace = "TestNamespace2"; var file = sp.AddFile (sol.ItemDirectory.Combine ("Test2.cs")); sol.Save (Util.GetMonitor ()); solXml = File.ReadAllText (sol.FileName).Replace (pc.ItemId, "{7DE4B613-BAB6-49DE-83FA-707D4E120306}").Replace (sp.ItemId, "{8DD793BE-42C3-4D66-8359-460CEE75980D}"); projectXml = Util.GetXmlFileInfoset (pc.FileName).Replace (pc.ItemId, "{7DE4B613-BAB6-49DE-83FA-707D4E120306}"); sharedProjectXml = Util.GetXmlFileInfoset (sp.FileName).Replace (sp.ItemId, "{8DD793BE-42C3-4D66-8359-460CEE75980D}"); sharedProjectItemsXml = Util.GetXmlFileInfoset (sp.FileName.ChangeExtension (".projitems")).Replace (sp.ItemId, "{8DD793BE-42C3-4D66-8359-460CEE75980D}"); refSharedProjectItemsXml = Util.ToWindowsEndings (Util.GetXmlFileInfoset (Util.GetSampleProjectPath ("generated-shared-project", "Shared.projitems.saved1"))); Assert.AreEqual (refSolXml, solXml); Assert.AreEqual (refProjectXml, projectXml); Assert.AreEqual (refSharedProjectXml, sharedProjectXml); Assert.AreEqual (refSharedProjectItemsXml, sharedProjectItemsXml); // Remove a file and restore the namespace sp.DefaultNamespace = "TestNamespace"; sp.Files.Remove (file); sol.Save (Util.GetMonitor ()); solXml = File.ReadAllText (sol.FileName).Replace (pc.ItemId, "{7DE4B613-BAB6-49DE-83FA-707D4E120306}").Replace (sp.ItemId, "{8DD793BE-42C3-4D66-8359-460CEE75980D}"); projectXml = Util.GetXmlFileInfoset (pc.FileName).Replace (pc.ItemId, "{7DE4B613-BAB6-49DE-83FA-707D4E120306}"); sharedProjectXml = Util.GetXmlFileInfoset (sp.FileName).Replace (sp.ItemId, "{8DD793BE-42C3-4D66-8359-460CEE75980D}"); sharedProjectItemsXml = Util.GetXmlFileInfoset (sp.FileName.ChangeExtension (".projitems")).Replace (sp.ItemId, "{8DD793BE-42C3-4D66-8359-460CEE75980D}"); refSharedProjectItemsXml = Util.ToWindowsEndings (Util.GetXmlFileInfoset (Util.GetSampleProjectPath ("generated-shared-project", "Shared.projitems"))); Assert.AreEqual (refSolXml, solXml); Assert.AreEqual (refProjectXml, projectXml); Assert.AreEqual (refSharedProjectXml, sharedProjectXml); Assert.AreEqual (refSharedProjectItemsXml, sharedProjectItemsXml); // Remove reference pc.References.Remove (r); sol.Save (Util.GetMonitor ()); solXml = File.ReadAllText (sol.FileName).Replace (pc.ItemId, "{7DE4B613-BAB6-49DE-83FA-707D4E120306}").Replace (sp.ItemId, "{8DD793BE-42C3-4D66-8359-460CEE75980D}"); projectXml = Util.GetXmlFileInfoset (pc.FileName).Replace (pc.ItemId, "{7DE4B613-BAB6-49DE-83FA-707D4E120306}"); sharedProjectXml = Util.GetXmlFileInfoset (sp.FileName).Replace (sp.ItemId, "{8DD793BE-42C3-4D66-8359-460CEE75980D}"); sharedProjectItemsXml = Util.GetXmlFileInfoset (sp.FileName.ChangeExtension (".projitems")).Replace (sp.ItemId, "{8DD793BE-42C3-4D66-8359-460CEE75980D}"); refProjectXml = Util.ToWindowsEndings (Util.GetXmlFileInfoset (Util.GetSampleProjectPath ("generated-shared-project", "TestProject.csproj"))); Assert.AreEqual (refSolXml, solXml); Assert.AreEqual (refProjectXml, projectXml); Assert.AreEqual (refSharedProjectXml, sharedProjectXml); Assert.AreEqual (refSharedProjectItemsXml, sharedProjectItemsXml); }
string ProjectRefToString (ProjectReference pr, MakefileVar refVar) { string [] tmp = pr.GetReferencedFileNames (ConfigurationSelector.Default); if (tmp == null || tmp.Length == 0) //Reference not found, ignoring return null; return AsmRefToString (tmp [0], refVar, true); }
internal void NotifyReferenceAddedToProject (ProjectReference reference) { NotifyModified ("References"); OnReferenceAddedToProject (new ProjectReferenceEventArgs (this, reference)); }
static bool IsGtkReference (ProjectReference pref) { if (pref.ReferenceType != ReferenceType.Gac) return false; int idx = pref.StoredReference.IndexOf (","); if (idx == -1) return false; string name = pref.StoredReference.Substring (0, idx).Trim (); return name == "gtk-sharp"; }
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); DotNetAssemblyProject project = new DotNetAssemblyProject("C#"); project.Name = "project1"; sol.RootFolder.Items.Add(project); Assert.AreEqual(2, countSolutionItemAdded); Assert.AreEqual(1, sol.Items.Count); DotNetAssemblyProject project2 = new DotNetAssemblyProject("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 = new ProjectReference(ReferenceType.Package, "SomeTest"); project.References.Add(pr1); Assert.AreEqual(1, countReferenceAddedToProject); ProjectReference pr2 = new ProjectReference(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); }
internal void NotifyReferenceRemovedFromProject (ProjectReference reference) { NotifyModified ("References"); OnReferenceRemovedFromProject (new ProjectReferenceEventArgs (this, reference)); }
TreeIter AppendReference (ProjectReference refInfo) { foreach (var p in panels) p.SignalRefChange (refInfo, true); switch (refInfo.ReferenceType) { case ReferenceType.Assembly: return AddAssemplyReference (refInfo); case ReferenceType.Project: return AddProjectReference (refInfo); case ReferenceType.Package: return AddPackageReference (refInfo); default: return TreeIter.Zero; } }
/// <summary> /// Determines whether the specified reference is a Monobjc one. /// </summary> /// <param name = "reference">The reference.</param> /// <returns> /// <c>true</c> if the specified reference is a Monobjc one; otherwise, <c>false</c>. /// </returns> public static bool IsMonobjcReference(ProjectReference reference) { return reference.Reference.StartsWith ("Monobjc"); }
TreeIter AddAssemplyReference (ProjectReference refInfo) { string txt = GLib.Markup.EscapeText (System.IO.Path.GetFileName (refInfo.Reference)) + "\n"; txt += "<span color='darkgrey'><small>" + GLib.Markup.EscapeText (System.IO.Path.GetFullPath (refInfo.Reference)) + "</small></span>"; return refTreeStore.AppendValues (txt, GetTypeText (refInfo), System.IO.Path.GetFullPath (refInfo.Reference), refInfo, ImageService.GetIcon ("md-empty-file-icon", IconSize.Dnd)); }
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); DotNetAssemblyProject project = new DotNetAssemblyProject ("C#"); project.Name = "project1"; sol.RootFolder.Items.Add (project); Assert.AreEqual (2, countSolutionItemAdded); Assert.AreEqual (1, sol.Items.Count); DotNetAssemblyProject project2 = new DotNetAssemblyProject ("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 = new ProjectReference (ReferenceType.Package, "SomeTest"); project.References.Add (pr1); Assert.AreEqual (1, countReferenceAddedToProject); ProjectReference pr2 = new ProjectReference (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); }
TreeIter AddProjectReference (ProjectReference refInfo) { Solution c = configureProject.ParentSolution; if (c == null) return TreeIter.Zero; Project p = c.FindProjectByName (refInfo.Reference); if (p == null) return TreeIter.Zero; string txt = GLib.Markup.EscapeText (System.IO.Path.GetFileName (refInfo.Reference)) + "\n"; txt += "<span color='darkgrey'><small>" + GLib.Markup.EscapeText (p.BaseDirectory.ToString ()) + "</small></span>"; return refTreeStore.AppendValues (txt, GetTypeText (refInfo), p.BaseDirectory.ToString (), refInfo, ImageService.GetIcon ("md-project", IconSize.Dnd)); }
public virtual void GenerateFiles (DotNetProject project, string namspace, string referenceName) { //make sure we have a valid value for the namespace if (string.IsNullOrEmpty (namspace)) { namspace = project.GetDefaultNamespace (null); } // Create the base directory if it does not exists FilePath basePath = GetReferencePath (project, referenceName).CanonicalPath; if (!Directory.Exists (basePath)) Directory.CreateDirectory (basePath); // Remove old files from the service directory List<ProjectFile> toRemove = new List<ProjectFile>(project.Files.GetFilesInPath (basePath)); foreach (ProjectFile f in toRemove) project.Files.Remove (f); // Generate the wsdl, disco and map files string mapSpec = GenerateDescriptionFiles (project, basePath); // Generate the proxy class string proxySpec = CreateProxyFile (project, basePath, namspace + "." + referenceName, "Reference"); ProjectFile mapFile = new ProjectFile (mapSpec); mapFile.BuildAction = BuildAction.None; mapFile.Subtype = Subtype.Code; mapFile.Generator = ProxyGenerator; project.Files.Add (mapFile); ProjectFile proxyFile = new ProjectFile (proxySpec); proxyFile.BuildAction = BuildAction.Compile; proxyFile.Subtype = Subtype.Code; proxyFile.DependsOn = mapFile.FilePath; project.Files.Add (proxyFile); mapFile.LastGenOutput = proxyFile.FilePath.FileName; item = new WebReferenceItem (engine, project, referenceName, basePath, mapFile); // Add references to the project if they do not exist ProjectReference packageRef; foreach (string refName in GetAssemblyReferences ()) { string targetName = project.TargetRuntime.AssemblyContext.GetAssemblyNameForVersion (refName, null, project.TargetFramework); //FIXME: warn when we could not find a matching target assembly if (targetName != null) { packageRef = new ProjectReference (ReferenceType.Package, targetName); if (!project.References.Contains (packageRef)) project.References.Add (packageRef); } } WebReferencesService.NotifyWebReferencesChanged (project); }
TreeIter AddPackageReference (ProjectReference refInfo) { string txt = GLib.Markup.EscapeText (System.IO.Path.GetFileNameWithoutExtension (refInfo.Reference)); int i = refInfo.Reference.IndexOf (','); if (i != -1) txt = GLib.Markup.EscapeText (txt.Substring (0, i)) + "\n<span color='darkgrey'><small>" + GLib.Markup.EscapeText (refInfo.Reference.Substring (i+1).Trim()) + "</small></span>"; return refTreeStore.AppendValues (txt, GetTypeText (refInfo), refInfo.Reference, refInfo, ImageService.GetIcon ("md-package", IconSize.Dnd)); }
public AddImport (Document doc, ResolveResult resolveResult, string ns, MonoDevelop.Projects.ProjectReference reference, bool addUsing, AstNode node) { this.doc = doc; this.resolveResult = resolveResult; this.ns = ns; this.reference = reference; this.addUsing = addUsing; this.node = node; }
string GetTypeText (ProjectReference pref) { switch (pref.ReferenceType) { case ReferenceType.Package: return GettextCatalog.GetString ("Package"); case ReferenceType.Assembly: return GettextCatalog.GetString ("Assembly"); case ReferenceType.Project: return GettextCatalog.GetString ("Project"); default: return ""; } }
internal virtual void OnProjectReferenceRemoved (ProjectReference pref) { ProjectDom dom = ProjectDomService.GetDom (pref.Reference); if (dom != null && references != null) { this.references.Remove (dom); ProjectDomService.UnrefDom (dom.Uri); } }
public void AddReference (ProjectReference pref) { TreeIter iter = FindReference (pref.ReferenceType, pref.Reference); if (!iter.Equals (TreeIter.Zero)) return; TreeIter ni = AppendReference (pref); if (!ni.Equals (TreeIter.Zero)) ReferencesTreeView.ScrollToCell (refTreeStore.GetPath (ni), null, false, 0, 0); }
/// <summary> /// Tests if a reference is from xunit.net. /// </summary> /// <returns><code>true</code> if the reference is from xunit.net. Otherwise, <code>false</code>.</returns> /// <param name="p">Project reference.</param> public static bool IsXUnitReference(ProjectReference p) { return(GetXUnitVersion(p).HasValue); }
public static bool IsNUnitReference(ProjectReference p) { return(p.Reference.IndexOf("GuiUnit", StringComparison.OrdinalIgnoreCase) != -1 || p.Reference.IndexOf("nunit.framework") != -1 || p.Reference.IndexOf("nunit.core") != -1 || p.Reference.IndexOf("nunitlite") != -1); }
internal void NotifyReferenceAddedToProject (ProjectReference reference) { SetNeedsBuilding (true); NotifyModified ("References"); OnReferenceAddedToProject (new ProjectReferenceEventArgs (this, reference)); }
public override void OnNodeDrop (object dataObject, DragOperation operation) { // It allows dropping either project references or projects. // Dropping a project creates a new project reference to that project DotNetProject project = dataObject as DotNetProject; if (project != null) { ProjectReference pr = new ProjectReference (project); DotNetProject p = CurrentNode.GetParentDataItem (typeof(DotNetProject), false) as DotNetProject; // Circular dependencies are not allowed. if (HasCircularReference (project, p.Name)) return; // If the reference already exists, bail out if (ProjectReferencesProject (p, project.Name)) return; p.References.Add (pr); IdeApp.ProjectOperations.Save (p); return; } // It's dropping a ProjectReference object. ProjectReference pref = dataObject as ProjectReference; ITreeNavigator nav = CurrentNode; if (operation == DragOperation.Move) { NodePosition pos = nav.CurrentPosition; nav.MoveToObject (dataObject); DotNetProject p = nav.GetParentDataItem (typeof(DotNetProject), true) as DotNetProject; nav.MoveToPosition (pos); DotNetProject p2 = nav.GetParentDataItem (typeof(DotNetProject), true) as DotNetProject; p.References.Remove (pref); // Check if there is a cyclic reference after removing from the source project if (pref.ReferenceType == ReferenceType.Project) { DotNetProject pdest = p.ParentSolution.FindProjectByName (pref.Reference) as DotNetProject; if (pdest == null || ProjectReferencesProject (pdest, p2.Name)) { // Restore the dep p.References.Add (pref); return; } } p2.References.Add (pref); IdeApp.ProjectOperations.Save (p); IdeApp.ProjectOperations.Save (p2); } else { nav.MoveToParent (typeof(DotNetProject)); DotNetProject p = nav.DataItem as DotNetProject; // Check for cyclic referencies if (pref.ReferenceType == ReferenceType.Project) { DotNetProject pdest = p.ParentSolution.FindProjectByName (pref.Reference) as DotNetProject; if (pdest == null) return; if (HasCircularReference (pdest, p.Name)) return; // The reference is already there if (ProjectReferencesProject (p, pdest.Name)) return; } p.References.Add ((ProjectReference) pref.Clone ()); IdeApp.ProjectOperations.Save (p); } }
public void SignalRefChange (ProjectReference refInfo, bool newState) { if (!showAll && refInfo.ReferenceType != ReferenceType.Package) return; TreeIter iter; bool found = false; if (store.GetIterFirst (out iter)) { do { if (refInfo.ReferenceType == (ReferenceType) store.GetValue(iter, ColType)) { switch (refInfo.ReferenceType) { case ReferenceType.Package: SystemAssembly systemAssembly = store.GetValue(iter, ColAssembly) as SystemAssembly; if ((refInfo.Reference == systemAssembly.FullName) && (refInfo.Package == systemAssembly.Package) ) found = true; break; case ReferenceType.Project: if ((string)store.GetValue (iter, ColFullName) == refInfo.Reference) found = true; break; case ReferenceType.Assembly: if ((string)store.GetValue (iter, ColFullName) == refInfo.Reference) found = true; break; } } } while (!found && store.IterNext (ref iter)); } if (found) store.SetValue(iter, ColSelected, newState); SetSelection (refInfo.ReferenceType, refInfo.Reference, refInfo.Package != null ? refInfo.Package.Name : "", newState); }
public ProjectReferenceEventArgs(Project project, ProjectReference reference) { this.project = project; this.reference = reference; }