本文整理汇总了C#中MonoDevelop.Projects.DotNetAssemblyProject类的典型用法代码示例。如果您正苦于以下问题:C# DotNetAssemblyProject类的具体用法?C# DotNetAssemblyProject怎么用?C# DotNetAssemblyProject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DotNetAssemblyProject类属于MonoDevelop.Projects命名空间,在下文中一共展示了DotNetAssemblyProject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Setup
static Document Setup (string input)
{
var tww = new TestWorkbenchWindow ();
var content = new TestViewContent ();
var project = new DotNetAssemblyProject ("C#");
project.Name = "test";
project.References.Add (new ProjectReference (ReferenceType.Package, "System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"));
project.References.Add (new ProjectReference (ReferenceType.Package, "System.Core"));
project.FileName = "test.csproj";
TypeSystemService.LoadProject (project);
TypeSystemService.GetProjectContentWrapper (project).ReconnectAssemblyReferences ();
content.Project = project;
tww.ViewContent = content;
content.ContentName = "a.cs";
content.GetTextEditorData ().Document.MimeType = "text/x-csharp";
var doc = new Document (tww);
var text = input;
int endPos = text.IndexOf ('$');
if (endPos >= 0)
text = text.Substring (0, endPos) + text.Substring (endPos + 1);
content.Text = text;
content.CursorPosition = Math.Max (0, endPos);
var compExt = new CSharpCompletionTextEditorExtension ();
compExt.Initialize (doc);
content.Contents.Add (compExt);
doc.UpdateParseDocument ();
return doc;
}
示例2: CheckProjectContainsItself
public void CheckProjectContainsItself()
{
var folder = new SolutionFolder ();
var project = new DotNetAssemblyProject { Name = "foo" };
folder.AddItem (project);
Assert.IsNotNull (folder.GetProjectContainingFile (project.FileName), "#1");
}
示例3: ProcessReferences
static void ProcessReferences (DotNetAssemblyProject project, MonoIsland update)
{
var referencesToAdd = update.References.Where (r => project.References.All(r2 => r2.Reference != r)).ToArray ();
foreach (var reference in referencesToAdd)
project.References.Add (ProjectReferenceFor (reference));
var referencesToRemove = project.References.Where (r => update.References.All(r2 => r.Reference != r2)).ToArray ();
project.References.RemoveRange (referencesToRemove);
}
示例4: TestSetup
public void TestSetup()
{
_project = new DotNetAssemblyProject ("C#");
var p = new CSharpCompilerParameters ();
var config = new DotNetProjectConfiguration () { CompilationParameters = p };
_project.DefaultConfiguration = config;
_update = new MonoIsland ();
_update.BaseDirectory = "/mybase";
}
示例5: ProcessDefines
static void ProcessDefines (DotNetAssemblyProject project, MonoIsland update)
{
var compilationParameters = (CSharpCompilerParameters)((DotNetProjectConfiguration)project.DefaultConfiguration).CompilationParameters;
var toAdd = update.Defines.Where (d => !compilationParameters.HasDefineSymbol (d)).ToArray ();
var toRemove = compilationParameters.GetDefineSymbols().Where (d => !update.Defines.Contains (d)).ToArray ();
foreach (var define in toAdd)
compilationParameters.AddDefineSymbol (define);
foreach (var define in toRemove)
compilationParameters.RemoveDefineSymbol (define);
}
示例6: CreateProvider
static CompletionDataList CreateProvider (string text, bool isCtrlSpace)
{
string parsedText;
string editorText;
int cursorPosition = text.IndexOf ('$');
int endPos = text.IndexOf ('$', cursorPosition + 1);
if (endPos == -1)
parsedText = editorText = text.Substring (0, cursorPosition) + text.Substring (cursorPosition + 1);
else {
parsedText = text.Substring (0, cursorPosition) + new string (' ', endPos - cursorPosition) + text.Substring (endPos + 1);
editorText = text.Substring (0, cursorPosition) + text.Substring (cursorPosition + 1, endPos - cursorPosition - 1) + text.Substring (endPos + 1);
cursorPosition = endPos - 1;
}
TestWorkbenchWindow tww = new TestWorkbenchWindow ();
TestViewContent sev = new TestViewContent ();
DotNetProject project = new DotNetAssemblyProject ("C#");
project.FileName = GetTempFile (".csproj");
string file = GetTempFile (".cs");
project.AddFile (file);
ProjectDomService.Load (project);
ProjectDom dom = ProjectDomService.GetProjectDom (project);
dom.ForceUpdate (true);
ProjectDomService.Parse (project, file, null, delegate { return parsedText; });
ProjectDomService.Parse (project, file, null, delegate { return parsedText; });
sev.Project = project;
sev.ContentName = file;
sev.Text = editorText;
sev.CursorPosition = cursorPosition;
tww.ViewContent = sev;
Document doc = new Document (tww);
doc.ParsedDocument = new NRefactoryParser ().Parse (null, sev.ContentName, parsedText);
foreach (var e in doc.ParsedDocument.Errors)
Console.WriteLine (e);
CSharpTextEditorCompletion textEditorCompletion = new CSharpTextEditorCompletion (doc);
int triggerWordLength = 1;
CodeCompletionContext ctx = new CodeCompletionContext ();
ctx.TriggerOffset = sev.CursorPosition;
int line, column;
sev.GetLineColumnFromPosition (sev.CursorPosition, out line, out column);
ctx.TriggerLine = line;
ctx.TriggerLineOffset = column;
if (isCtrlSpace)
return textEditorCompletion.CodeCompletionCommand (ctx) as CompletionDataList;
else
return textEditorCompletion.HandleCodeCompletion (ctx, editorText[cursorPosition - 1] , ref triggerWordLength) as CompletionDataList;
}
示例7: ProcessFiles
static void ProcessFiles (DotNetAssemblyProject project, MonoIsland update)
{
var updateFiles = update.Files.Select (f => Path.GetFullPath(project.BaseDirectory + "/" + f)).ToArray();
var toRemove = project.Files.Where (f => updateFiles.All(f2 => f.FilePath.FullPath != f2)).ToArray ();
var toAdd = updateFiles.Where(f => project.Files.All(f2 => f2.FilePath.FullPath != f)).ToArray();
if(toRemove.Length > 0)
project.Files.RemoveRange (toRemove);
if(toAdd.Length > 0)
project.AddFiles (toAdd.Select (f => new FilePath (f)));
}
示例8: Update
public static void Update (DotNetAssemblyProject project, MonoIsland update)
{
if (update.BaseDirectory != project.BaseDirectory)
project.BaseDirectory = update.BaseDirectory;
ProcessFiles (project, update);
ProcessDefines (project, update);
ProcessReferences (project, update);
project.Name = update.Name;
var dotNetProjectConfiguration = ((DotNetProjectConfiguration)project.DefaultConfiguration);
dotNetProjectConfiguration.OutputAssembly = project.Name + ".dll";
}
示例9: IncludingProjectAddedAfterShared
public void IncludingProjectAddedAfterShared()
{
var sol = new Solution ();
var shared = new SharedAssetsProject ("C#");
shared.AddFile ("Foo.cs");
sol.RootFolder.AddItem (shared);
// Reference to shared is added before adding project to solution
var main = new DotNetAssemblyProject ("C#");
main.References.Add (new ProjectReference (shared));
sol.RootFolder.AddItem (main);
Assert.IsNotNull (main.Files.GetFile ("Foo.cs"));
}
示例10: CreateProvider
internal static IParameterDataProvider CreateProvider (string text)
{
string parsedText;
string editorText;
int cursorPosition = text.IndexOf ('$');
int endPos = text.IndexOf ('$', cursorPosition + 1);
if (endPos == -1)
parsedText = editorText = text.Substring (0, cursorPosition) + text.Substring (cursorPosition + 1);
else {
parsedText = text.Substring (0, cursorPosition) + new string (' ', endPos - cursorPosition) + text.Substring (endPos + 1);
editorText = text.Substring (0, cursorPosition) + text.Substring (cursorPosition + 1, endPos - cursorPosition - 1) + text.Substring (endPos + 1);
cursorPosition = endPos - 1;
}
TestWorkbenchWindow tww = new TestWorkbenchWindow ();
TestViewContent sev = new TestViewContent ();
DotNetProject project = new DotNetAssemblyProject ("C#");
project.FileName = GetTempFile (".csproj");
string file = GetTempFile (".cs");
project.AddFile (file);
ProjectDomService.Load (project);
// ProjectDom dom = ProjectDomService.GetProjectDom (project);
ProjectDomService.Parse (project, file, delegate { return parsedText; });
ProjectDomService.Parse (project, file, delegate { return parsedText; });
sev.Project = project;
sev.ContentName = file;
sev.Text = editorText;
sev.CursorPosition = cursorPosition;
tww.ViewContent = sev;
Document doc = new Document (tww);
doc.ParsedDocument = new NRefactoryParser ().Parse (null, sev.ContentName, parsedText);
CSharpTextEditorCompletion textEditorCompletion = new CSharpTextEditorCompletion (doc);
CodeCompletionContext ctx = new CodeCompletionContext ();
ctx.TriggerOffset = sev.CursorPosition;
int line, column;
sev.GetLineColumnFromPosition (sev.CursorPosition, out line, out column);
ctx.TriggerLine = line;
ctx.TriggerLineOffset = column - 1;
IParameterDataProvider result = textEditorCompletion.HandleParameterCompletion (ctx, editorText[cursorPosition - 1]);
ProjectDomService.Unload (project);
return result;
}
示例11: CreateMonoDevelopProjectFromProjectUpdate
static DotNetAssemblyProject CreateMonoDevelopProjectFromProjectUpdate (UnitySolution solution, MonoIsland projectUpdate)
{
var p = new DotNetAssemblyProject (projectUpdate.Language);
// FIXME
switch (projectUpdate.Language)
{
default:
var dotNetProjectConfig = (DotNetProjectConfiguration)p.AddNewConfiguration ("Debug");
dotNetProjectConfig.CompilationParameters = new CSharpCompilerParameters();
p.DefaultConfiguration = dotNetProjectConfig;
break;
}
var rootFolder = solution.RootFolder;
rootFolder.AddItem (p);
solution.DefaultConfiguration.AddItem (p).Build = true;
return p;
}
示例12: TestSaveWorkspace
public void TestSaveWorkspace()
{
// Saving a workspace must save all solutions and projects it contains
string dir = Util.CreateTmpDir ("TestSaveWorkspace");
Workspace ws = new Workspace ();
ws.FileName = Path.Combine (dir, "workspace");
Solution sol = new Solution ();
sol.FileName = Path.Combine (dir, "thesolution");
ws.Items.Add (sol);
DotNetAssemblyProject p = new DotNetAssemblyProject ("C#");
p.FileName = Path.Combine (dir, "theproject");
sol.RootFolder.Items.Add (p);
ws.Save (Util.GetMonitor ());
Assert.IsTrue (File.Exists (ws.FileName));
Assert.IsTrue (File.Exists (sol.FileName));
Assert.IsTrue (File.Exists (p.FileName));
}
示例13: ProjectFilePaths
public void ProjectFilePaths ()
{
DotNetProject project = new DotNetAssemblyProject ("C#");
string dir = Environment.CurrentDirectory;
ProjectFile file1 = project.AddFile (Util.Combine (dir, "test1.cs"), BuildAction.Compile);
Assert.AreEqual (Util.Combine (dir, "test1.cs"), file1.Name);
ProjectFile file2 = project.AddFile (Util.Combine (dir, "aaa", "..", "bbb", "test2.cs"), BuildAction.Compile);
Assert.AreEqual (Util.Combine (dir, "bbb", "test2.cs"), file2.Name);
ProjectFile file = project.Files.GetFile (Util.Combine (dir, "test1.cs"));
Assert.AreEqual (file1, file);
file = project.Files.GetFile (Util.Combine (dir, "aaa", "..", "test1.cs"));
Assert.AreEqual (file1, file);
file = project.Files.GetFile (Util.Combine (dir, "bbb", "test2.cs"));
Assert.AreEqual (file2, file);
file = project.Files.GetFile (Util.Combine (dir, "aaa", "..", "bbb", "test2.cs"));
Assert.AreEqual (file2, file);
}
示例14: RemoveSharedProjectFromSolution
public void RemoveSharedProjectFromSolution()
{
var sol = new Solution ();
var shared = new SharedAssetsProject ("C#");
shared.AddFile ("Foo.cs");
var main = new DotNetAssemblyProject ("C#");
var pref = new ProjectReference (shared);
main.References.Add (pref);
sol.RootFolder.AddItem (main);
sol.RootFolder.AddItem (shared);
Assert.IsNotNull (main.Files.GetFile ("Foo.cs"));
Assert.IsTrue (main.References.Contains (pref));
sol.RootFolder.Items.Remove (shared);
// The shared file and the reference must be gone.
Assert.IsNull (main.Files.GetFile ("Foo.cs"));
Assert.IsFalse (main.References.Contains (pref));
}
示例15: ReadFile
public object ReadFile (FilePath fileName, bool hasParentSolution, IProgressMonitor monitor)
{
FilePath basePath = fileName.ParentDirectory;
MonoMakefile mkfile = new MonoMakefile (fileName);
string aname = mkfile.GetVariable ("LIBRARY");
if (aname == null) aname = mkfile.GetVariable ("PROGRAM");
try {
ProjectExtensionUtil.BeginLoadOperation ();
if (aname != null) {
// It is a project
monitor.BeginTask ("Loading '" + fileName + "'", 0);
DotNetAssemblyProject project = new DotNetAssemblyProject ("C#");
MonoSolutionItemHandler handler = new MonoSolutionItemHandler (project);
ProjectExtensionUtil.InstallHandler (handler, project);
project.Name = Path.GetFileName (basePath);
handler.Read (mkfile);
monitor.EndTask ();
return project;
} else {
string subdirs;
StringBuilder subdirsBuilder = new StringBuilder ();
subdirsBuilder.Append (mkfile.GetVariable ("common_dirs"));
if (subdirsBuilder.Length != 0) {
subdirsBuilder.Append ("\t");
subdirsBuilder.Append (mkfile.GetVariable ("net_2_0_dirs"));
}
if (subdirsBuilder.Length == 0)
subdirsBuilder.Append (mkfile.GetVariable ("SUBDIRS"));
subdirs = subdirsBuilder.ToString ();
if (subdirs != null && (subdirs = subdirs.Trim (' ','\t')) != "")
{
object retObject;
SolutionFolder folder;
if (!hasParentSolution) {
Solution sol = new Solution ();
sol.ConvertToFormat (Services.ProjectService.FileFormats.GetFileFormat ("MonoMakefile"), false);
sol.FileName = fileName;
folder = sol.RootFolder;
retObject = sol;
foreach (string conf in MonoMakefileFormat.Configurations) {
SolutionConfiguration sc = new SolutionConfiguration (conf);
sol.Configurations.Add (sc);
}
} else {
folder = new SolutionFolder ();
folder.Name = Path.GetFileName (Path.GetDirectoryName (fileName));
retObject = folder;
}
subdirs = subdirs.Replace ('\t',' ');
string[] dirs = subdirs.Split (' ');
monitor.BeginTask ("Loading '" + fileName + "'", dirs.Length);
Hashtable added = new Hashtable ();
foreach (string dir in dirs) {
if (added.Contains (dir)) continue;
added.Add (dir, dir);
monitor.Step (1);
if (dir == null) continue;
string tdir = dir.Trim ();
if (tdir == "") continue;
string mfile = Path.Combine (Path.Combine (basePath, tdir), "Makefile");
if (File.Exists (mfile) && CanReadFile (mfile, typeof(SolutionItem))) {
SolutionItem it = (SolutionItem) ReadFile (mfile, true, monitor);
folder.Items.Add (it);
}
}
monitor.EndTask ();
return retObject;
}
}
} finally {
ProjectExtensionUtil.EndLoadOperation ();
}
return null;
}