本文整理汇总了C#中MonoDevelop.Projects.ProjectFile类的典型用法代码示例。如果您正苦于以下问题:C# ProjectFile类的具体用法?C# ProjectFile怎么用?C# ProjectFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProjectFile类属于MonoDevelop.Projects命名空间,在下文中一共展示了ProjectFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCodeBehindClassName
public static string GetCodeBehindClassName (ProjectFile file)
{
AspNetAppProject proj = file.Project as AspNetAppProject;
if (proj == null)
return null;
return proj.GetCodebehindTypeName (file.Name);
}
示例2: GenerateAllFiles
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;
}
示例3: GetDefaultCustomToolForFileName
public string GetDefaultCustomToolForFileName (ProjectFile projectItem)
{
if (defaultCustomTools.ContainsKey (projectItem.FilePath.ToString ())) {
return defaultCustomTools [projectItem.FilePath.ToString ()];
}
return String.Empty;
}
示例4: FromCodeIssue
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;
}
示例5: UpdateDesignerFile
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;
}
示例6: GenerateInternal
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);
}
}
示例7: GetDesignerFileName
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);
}
示例8: GetCodeBehindClassName
public static string GetCodeBehindClassName (ProjectFile file)
{
var proj = file.Project.GetService<AspNetAppProjectFlavor> ();
if (proj == null)
return null;
return proj.GetCodebehindTypeName (file.Name);
}
示例9: HandleException
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;
}
}
示例10: GetGenerator
static ISingleFileCustomTool GetGenerator (ProjectFile file)
{
CustomToolExtensionNode node;
if (!string.IsNullOrEmpty (file.Generator) && nodes.TryGetValue (file.Generator, out node))
return node.Tool;
return null;
}
示例11: GenerateInternal
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 ());
}
}
示例12: Generate
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);
}
示例13: BuildModuleName
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, '.');
}
示例14: ProjectFileDescriptor
public ProjectFileDescriptor (ProjectFile file)
{
this.file = file;
project = file.Project;
if (project != null) {
project.FilePropertyChangedInProject += OnFilePropertyChangedInProject;
}
}
示例15: SetUp
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 });
}