/// <summary> /// Extracts meta comments from all C# files of this compilation, including project files and files added through meta option 'c'. /// Returns false if there are errors, except with flag ForCodeInfo. Then use <see cref="Errors"/>. /// </summary> /// <param name="f">Main C# file. If projFolder not null, must be the main file of the project.</param> /// <param name="projFolder">Project folder of the main file, or null if it is not in a project.</param> /// <param name="flags"></param> public bool Parse(FileNode f, FileNode projFolder, EMPFlags flags) { Debug.Assert(Errors == null); //cannot be called multiple times Errors = new ErrBuilder(); _flags = flags; _ParseFile(f, true); if (projFolder != null) { foreach (var ff in projFolder.EnumProjectClassFiles(f)) { _ParseFile(ff, false); } } if (_filesC != null) { foreach (var ff in _filesC) { if (CodeFiles.Exists(o => o.f == ff)) { continue; } _ParseFile(ff, false); } } if (!Optimize) { if (!Defines.Contains("DEBUG")) { Defines.Add("DEBUG"); } if (!Defines.Contains("TRACE")) { Defines.Add("TRACE"); } } //if(Role == ERole.exeProgram && !Defines.Contains("EXE")) Defines.Add("EXE"); //rejected _FinalCheckOptions(); if (Errors.ErrorCount > 0) { if (flags.Has(EMPFlags.PrintErrors)) { Errors.PrintAll(); } return(false); } return(true); }
/// <summary> /// Extracts meta comments from a single C# file. /// </summary> /// <param name="f"></param> /// <param name="isMain">If false, it is a file added through meta option 'c'.</param> void _ParseFile(FileNode f, bool isMain) { //var p1 = APerf.Create(); string code = f.GetText(cache: true); //p1.Next(); bool isScript = f.IsScript; if (_isMain = isMain) { Name = APath.GetFileName(f.Name, true); IsScript = isScript; Optimize = DefaultOptimize; WarningLevel = DefaultWarningLevel; NoWarnings = DefaultNoWarnings != null ? new List <string>(DefaultNoWarnings) : new List <string>(); Defines = new List <string>(); Role = DefaultRole(isScript); CodeFiles = new List <MetaCodeFile>(); References = new MetaReferences(); } CodeFiles.Add(new MetaCodeFile(f, code)); _fn = f; _code = code; int endOf = FindMetaComments(code); if (endOf > 0) { if (isMain) { EndOfMeta = endOf; } foreach (var t in EnumOptions(code, endOf)) { //var p1 = APerf.Create(); _ParseOption(t.Name(), t.Value(), t.nameStart, t.valueStart); //p1.Next(); var t1 = p1.TimeTotal; if(t1 > 5) AOutput.Write(t1, t.Name(), t.Value()); } } //p1.NW(); }
protected void AppendCode(string className, StringBuilder code) { Code.Append(code); CodeFiles.Add(className, code); }
public void AddCodeFile(CodeFile codeFile) { CurrentCodeFile = codeFile; lock (CodeFiles) CodeFiles.Add(codeFile); }
public void ShouldReturnAllFiles() { var files = new CodeFiles(TestDirectory); files.Count().Should().Equal(2); }
void ReleaseDesignerOutlets() { if (iOSPlotView != null) { iOSPlotView.Dispose(); iOSPlotView = null; } if (AndroidPlotView != null) { AndroidPlotView.Dispose(); AndroidPlotView = null; } if (UWPPlotView != null) { UWPPlotView.Dispose(); UWPPlotView = null; } if (AmountOfFiles != null) { AmountOfFiles.Dispose(); AmountOfFiles = null; } if (AndroidFiles != null) { AndroidFiles.Dispose(); AndroidFiles = null; } if (AndroidLOC != null) { AndroidLOC.Dispose(); AndroidLOC = null; } if (AndroidSpecificCode != null) { AndroidSpecificCode.Dispose(); AndroidSpecificCode = null; } if (ButtonOpenFile != null) { ButtonOpenFile.Dispose(); ButtonOpenFile = null; } if (ButtonShareLink != null) { ButtonShareLink.Dispose(); ButtonShareLink = null; } if (CodeFiles != null) { CodeFiles.Dispose(); CodeFiles = null; } if (CoreLOC != null) { CoreLOC.Dispose(); CoreLOC = null; } if (iOSFiles != null) { iOSFiles.Dispose(); iOSFiles = null; } if (iOSLOC != null) { iOSLOC.Dispose(); iOSLOC = null; } if (iOSSpecificCode != null) { iOSSpecificCode.Dispose(); iOSSpecificCode = null; } if (ProgressBar != null) { ProgressBar.Dispose(); ProgressBar = null; } if (ShareCodeInAndroid != null) { ShareCodeInAndroid.Dispose(); ShareCodeInAndroid = null; } if (ShareCodeIniOS != null) { ShareCodeIniOS.Dispose(); ShareCodeIniOS = null; } if (ShareCodeInUWP != null) { ShareCodeInUWP.Dispose(); ShareCodeInUWP = null; } if (ShareLink != null) { ShareLink.Dispose(); ShareLink = null; } if (TotalLOC != null) { TotalLOC.Dispose(); TotalLOC = null; } if (TotalUILines != null) { TotalUILines.Dispose(); TotalUILines = null; } if (UIFiles != null) { UIFiles.Dispose(); UIFiles = null; } if (UWPFiles != null) { UWPFiles.Dispose(); UWPFiles = null; } if (UWPLOC != null) { UWPLOC.Dispose(); UWPLOC = null; } if (UWPSpecificCode != null) { UWPSpecificCode.Dispose(); UWPSpecificCode = null; } }