本文整理汇总了C#中MonoDevelop.Projects.DotNetAssemblyProject类的典型用法代码示例。如果您正苦于以下问题:C# DotNetAssemblyProject类的具体用法?C# DotNetAssemblyProject怎么用?C# DotNetAssemblyProject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DotNetAssemblyProject类属于MonoDevelop.Projects命名空间,在下文中一共展示了DotNetAssemblyProject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:telebovich,项目名称:monodevelop,代码行数:35,代码来源:ResolveNamespaceTests.cs
示例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");
}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:8,代码来源:SolutionFolderTests.cs
示例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);
}
开发者ID:0xb1dd1e,项目名称:MonoDevelop.UnityMode,代码行数:9,代码来源:ProjectUpdater.cs
示例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";
}
开发者ID:0xb1dd1e,项目名称:MonoDevelop.UnityMode,代码行数:10,代码来源:ProjectUpdaterTests.cs
示例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);
}
开发者ID:0xb1dd1e,项目名称:MonoDevelop.UnityMode,代码行数:10,代码来源:ProjectUpdater.cs
示例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;
}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:52,代码来源:CodeCompletionBugTests.cs
示例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)));
}
开发者ID:0xb1dd1e,项目名称:MonoDevelop.UnityMode,代码行数:13,代码来源:ProjectUpdater.cs
示例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";
}
开发者ID:0xb1dd1e,项目名称:MonoDevelop.UnityMode,代码行数:13,代码来源:ProjectUpdater.cs
示例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"));
}
开发者ID:brantwedel,项目名称:monodevelop,代码行数:15,代码来源:SharedAssetsProjectTests.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;
}
开发者ID:Tak,项目名称:monodevelop-novell,代码行数:47,代码来源:ParameterCompletionTests.cs
示例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;
}
开发者ID:0xb1dd1e,项目名称:MonoDevelop.UnityMode,代码行数:19,代码来源:SolutionUpdater.cs
示例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));
}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:22,代码来源:MdsTests.cs
示例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);
}
开发者ID:newky2k,项目名称:monodevelop,代码行数:23,代码来源:ProjectTests.cs
示例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));
}
开发者ID:brantwedel,项目名称:monodevelop,代码行数:24,代码来源:SharedAssetsProjectTests.cs
示例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;
}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:79,代码来源:MonoMakefileFormat.cs
示例16: ModelQueries
public void ModelQueries()
{
DotNetProject it2, it3, it4;
DummySolutionItem it1;
string someFile, someId;
Workspace ws = new Workspace ();
Workspace cws = new Workspace ();
ws.Items.Add (cws);
Solution sol1 = new Solution ();
cws.Items.Add (sol1);
sol1.RootFolder.Items.Add (it1 = new DummySolutionItem ());
sol1.RootFolder.Items.Add (it2 = new DotNetAssemblyProject ("C#"));
Solution sol2 = new Solution ();
cws.Items.Add (sol2);
SolutionFolder f = new SolutionFolder ();
sol2.RootFolder.Items.Add (f);
f.Items.Add (it3 = new DotNetAssemblyProject ("C#"));
f.Items.Add (it4 = new DotNetAssemblyProject ("C#"));
it3.Name = "it3";
it4.FileName = "/test/it4";
someFile = it4.FileName;
someId = it3.ItemId;
Assert.IsFalse (string.IsNullOrEmpty (someId));
Assert.AreEqual (2, sol1.Items.Count);
Assert.IsTrue (sol1.Items.Contains (it1));
Assert.IsTrue (sol1.Items.Contains (it2));
Assert.AreEqual (2, sol2.Items.Count);
Assert.IsTrue (sol2.Items.Contains (it3));
Assert.IsTrue (sol2.Items.Contains (it4));
ReadOnlyCollection<SolutionItem> its = ws.GetAllSolutionItems ();
Assert.AreEqual (7, its.Count);
Assert.IsTrue (its.Contains (it1));
Assert.IsTrue (its.Contains (it2));
Assert.IsTrue (its.Contains (it3));
Assert.IsTrue (its.Contains (it4));
Assert.IsTrue (its.Contains (sol1.RootFolder));
Assert.IsTrue (its.Contains (sol2.RootFolder));
Assert.IsTrue (its.Contains (f));
ReadOnlyCollection<DotNetProject> its2 = ws.GetAllSolutionItems<DotNetProject> ();
Assert.AreEqual (3, its2.Count);
Assert.IsTrue (its2.Contains (it2));
Assert.IsTrue (its2.Contains (it3));
Assert.IsTrue (its2.Contains (it4));
ReadOnlyCollection<Project> its3 = ws.GetAllProjects ();
Assert.AreEqual (3, its3.Count);
Assert.IsTrue (its3.Contains (it2));
Assert.IsTrue (its3.Contains (it3));
Assert.IsTrue (its3.Contains (it4));
ReadOnlyCollection<Solution> its4 = ws.GetAllSolutions ();
Assert.AreEqual (2, its4.Count);
Assert.IsTrue (its4.Contains (sol1));
Assert.IsTrue (its4.Contains (sol2));
ReadOnlyCollection<WorkspaceItem> its5= ws.GetAllItems ();
Assert.AreEqual (4, its5.Count);
Assert.IsTrue (its5.Contains (ws));
Assert.IsTrue (its5.Contains (cws));
Assert.IsTrue (its5.Contains (sol2));
Assert.IsTrue (its5.Contains (sol2));
ReadOnlyCollection<Workspace> its6 = ws.GetAllItems<Workspace> ();
Assert.AreEqual (2, its6.Count);
Assert.IsTrue (its6.Contains (ws));
Assert.IsTrue (its6.Contains (cws));
SolutionEntityItem fi = ws.FindSolutionItem (someFile);
Assert.AreEqual (it4, fi);
fi = ws.FindSolutionItem (someFile + ".wrong");
Assert.IsNull (fi);
SolutionItem si = sol2.GetSolutionItem (someId);
Assert.AreEqual (it3, si);
fi = sol2.FindSolutionItem (someFile);
Assert.AreEqual (it4, fi);
fi = sol2.FindProjectByName ("it3");
Assert.AreEqual (it3, fi);
fi = sol2.FindProjectByName ("it4");
Assert.AreEqual (it4, fi);
fi = sol2.FindProjectByName ("it2");
Assert.IsNull (fi);
}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:96,代码来源:WorkspaceTests.cs
示例17: CreateProject
public static DotNetProject CreateProject (string dir, string lang, string name)
{
DotNetAssemblyProject project = new DotNetAssemblyProject (lang);
InitializeProject (dir, project, name);
return project;
}
开发者ID:segaman,项目名称:monodevelop,代码行数:6,代码来源:TestProjectsChecks.cs
示例18: CreatePrjxFromCsproj
public SolutionEntityItem CreatePrjxFromCsproj (string csprojFileName, IProgressMonitor monitor)
{
try {
FileFormat format = Services.ProjectService.FileFormats.GetFileFormatForFile (csprojFileName, typeof(SolutionEntityItem));
if (format != null && format.Id != "VS2003ProjectFileFormat")
return (SolutionEntityItem) Services.ProjectService.ReadSolutionItem (monitor, csprojFileName);
MonoDevelop.Prj2Make.Schema.Csproj.VisualStudioProject csprojObj = null;
monitor.BeginTask (GettextCatalog.GetString ("Importing project: ") + csprojFileName, 4);
DotNetAssemblyProject prjxObj = new DotNetAssemblyProject ("C#", null, null);
prjxFileName = String.Format ("{0}.mdp",
Path.Combine (Path.GetDirectoryName (csprojFileName),
Path.GetFileNameWithoutExtension (csprojFileName))
);
// Load the csproj
using (TextFileReader fsIn = new TextFileReader (csprojFileName)) {
XmlSerializer xmlDeSer = new XmlSerializer (typeof(VisualStudioProject));
csprojObj = (VisualStudioProject) xmlDeSer.Deserialize (fsIn);
}
monitor.Step (1);
// Begin prjxObj population
prjxObj.FileName = prjxFileName;
prjxObj.Name = Path.GetFileNameWithoutExtension(csprojFileName);
prjxObj.Description = "";
prjxObj.NewFileSearch = NewFileSearch.None;
prjxObj.DefaultNamespace = csprojObj.CSHARP.Build.Settings.RootNamespace;
GetContents (prjxObj, csprojObj.CSHARP.Files.Include, prjxObj.Files, monitor);
monitor.Step (1);
GetReferences (prjxObj, csprojObj.CSHARP.Build.References, prjxObj.References, monitor);
monitor.Step (1);
prjxObj.Configurations.Clear ();
foreach (Config cblock in csprojObj.CSHARP.Build.Settings.Config)
{
prjxObj.Configurations.Add (CreateConfigurationBlock (
prjxObj,
cblock,
csprojObj.CSHARP.Build.Settings.AssemblyName,
csprojObj.CSHARP.Build.Settings.OutputType,
monitor
));
}
monitor.Step (1);
return prjxObj;
} catch (Exception ex) {
monitor.ReportError (GettextCatalog.GetString ("Could not import project:") + csprojFileName, ex);
throw;
} finally {
monitor.EndTask ();
}
}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:60,代码来源:MsPrjHelper.cs
示例19: CreateRefactoringOptions
internal static RefactoringOptions CreateRefactoringOptions (string text)
{
int cursorPosition = -1;
int endPos = text.IndexOf ('$');
if (endPos >= 0) {
cursorPosition = endPos;
text = text.Substring (0, cursorPosition) + text.Substring (cursorPosition + 1);
}
int selectionStart = -1;
int selectionEnd = -1;
int idx = text.IndexOf ("<-");
if (idx >= 0) {
selectionStart = idx;
text = text.Substring (0, idx) + text.Substring (idx + 2);
selectionEnd = idx = text.IndexOf ("->");
text = text.Substring (0, idx) + text.Substring (idx + 2);
if (cursorPosition < 0)
cursorPosition = selectionEnd - 1;
}
TestWorkbenchWindow tww = new TestWorkbenchWindow ();
TestViewContent sev = new TestViewContent ();
// return new RefactoringOptions ();
DotNetProject project = new DotNetAssemblyProject ("C#");
Solution solution = new Solution ();
solution.RootFolder.Items.Add (project);
project.FileName = GetTempFile (".csproj");
string file = GetTempFile (".cs");
project.AddFile (file);
string parsedText = text;
string editorText = text;
ProjectDomService.Load (project);
ProjectDom dom = ProjectDomService.GetProjectDom (project);
dom.ForceUpdate (true);
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;
var doc = new MonoDevelop.Ide.Gui.Document (tww);
doc.Editor.Document.MimeType = "text/x-csharp";
doc.Editor.Document.FileName = file;
doc.ParsedDocument = new McsParser ().Parse (null, sev.ContentName, parsedText);
foreach (var e in doc.ParsedDocument.Errors)
Console.WriteLine (e);
if (cursorPosition >= 0)
doc.Editor.Caret.Offset = cursorPosition;
if (selectionStart >= 0)
doc.Editor.SetSelection (selectionStart, selectionEnd);
NRefactoryResolver resolver = new NRefactoryResolver (dom,
doc.ParsedDocument.CompilationUnit,
sev.Data,
file);
ExpressionResult expressionResult;
if (selectionStart >= 0) {
expressionResult = new ExpressionResult (editorText.Substring (selectionStart, selectionEnd - selectionStart).Trim ());
endPos = selectionEnd;
} else {
expressionResult = new NewCSharpExpressionFinder (dom).FindFullExpression (doc.Editor, cursorPosition + 1);
}
ResolveResult resolveResult = endPos >= 0 ? resolver.Resolve (expressionResult, new DomLocation (doc.Editor.Caret.Line, doc.Editor.Caret.Column)) : null;
RefactoringOptions result = new RefactoringOptions {
Document = doc,
Dom = dom,
ResolveResult = resolveResult,
SelectedItem = null
};
if (resolveResult is MemberResolveResult)
result.SelectedItem = ((MemberResolveResult)resolveResult).ResolvedMember;
if (resolveResult is LocalVariableResolveResult)
result.SelectedItem = ((LocalVariableResolveResult)resolveResult).LocalVariable;
if (resolveResult is ParameterResolveResult)
result.SelectedItem = ((ParameterResolveResult)resolveResult).Parameter;
result.TestFileProvider = new FileProvider (result);
return result;
}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:86,代码来源:ExtractMethodTests.cs
示例20: SanitizeProjectNamespace
public void SanitizeProjectNamespace ()
{
var info = new ProjectCreateInformation {
ProjectBasePath = "/tmp/test",
ProjectName = "abc.0"
};
var project = new DotNetAssemblyProject ("C#", info, null);
Assert.AreEqual ("abc", project.DefaultNamespace);
info.ProjectName = "a.";
project = new DotNetAssemblyProject ("C#", info, null);
Assert.AreEqual ("a", project.DefaultNamespace);
}
开发者ID:riverans,项目名称:monodevelop,代码行数:13,代码来源:ProjectTests.cs
注:本文中的MonoDevelop.Projects.DotNetAssemblyProject类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论