/// <summary> /// Retruns configuration used for converting config file. /// </summary> public static AstConversionConfiguration ForConfiguration(IFrontEndConfiguration configuration) { return(new AstConversionConfiguration( policyRules: configuration.EnabledPolicyRules, degreeOfParallelism: configuration.MaxFrontEndConcurrency(), disableLanguagePolicies: configuration.DisableLanguagePolicyAnalysis(), useLegacyOfficeLogic: configuration.UseLegacyOfficeLogic()) { PreserveFullNameSymbols = configuration.PreserveFullNames(), }); }
/// <summary> /// Lints a given set of specs that belong to a workspace and include any potential linter failures in the resulting one. /// </summary> public static Workspace CreateLintedWorkspaceForChangedSpecs( Workspace workspace, IEnumerable <ISourceFile> changedSpecsToLint, LoggingContext loggingContext, IFrontEndConfiguration configuration, PathTable pathTable) { var logger = BuildXL.FrontEnd.Script.Tracing.Logger.CreateLogger(preserveLogEvents: true); var linter = DiagnosticAnalyzer.Create( logger, loggingContext, new HashSet <string>(configuration.EnabledPolicyRules), disableLanguagePolicies: false); // Lint all files in parallel and wait for queue completion var linterQueue = new ActionBlock <ISourceFile>( (Action <ISourceFile>)LintFile, new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = configuration.MaxFrontEndConcurrency() }); foreach (var sourceFile in changedSpecsToLint) { linterQueue.Post(sourceFile); } linterQueue.Complete(); linterQueue.Completion.GetAwaiter().GetResult(); // Create a workspace with the extra failures (if any) and return it var linterFailures = ComputeLinterFailures(workspace, logger, pathTable); return(linterFailures.Count > 0 ? workspace.WithExtraFailures(linterFailures) : workspace); // Local functions void LintFile(ISourceFile sourceFile) { if (!sourceFile.HasDiagnostics()) { linter.AnalyzeFile(sourceFile, logger, loggingContext, pathTable, workspace); } } }
/// <nodoc/> public static int MaxTypeCheckingConcurrency(this IFrontEndConfiguration configuration) => configuration.MaxTypeCheckingConcurrency ?? configuration.MaxFrontEndConcurrency();