/// <summary> /// This is the status page. /// </summary> /// <param name="category">The category that is filtered by.</param> /// <param name="hasImplementation">Has implementation filter.</param> /// <param name="status">Status filter.</param> /// <param name="codeFixStatus">Code fix status filter.</param> /// <returns>An <see cref="ActionResult"/> decribing the resulting page.</returns> public ActionResult Index( string category = null, bool? hasImplementation = null, string status = null, CodeFixStatus? codeFixStatus = null) { MainViewModel viewModel = JsonConvert.DeserializeObject<MainViewModel>(System.IO.File.ReadAllText(this.Server.MapPath("~/foo.json"))); var diagnostics = (from x in viewModel.Diagnostics where category == null || x.Category == category where hasImplementation == null || x.HasImplementation == hasImplementation where status == null || x.Status == status where codeFixStatus == null || x.CodeFixStatus == codeFixStatus select x).ToArray(); if (diagnostics.Length == 0) { // No entries found return this.HttpNotFound(); } viewModel.Diagnostics = diagnostics; return this.View(viewModel); }
private (CodeFixStatus codeFixStatus, FixAllStatus fixAllStatus) GetCodeFixAndFixAllStatus(string diagnosticId, INamedTypeSymbol classSymbol, out string noCodeFixReason) { CodeFixStatus codeFixStatus; FixAllStatus fixAllStatus; noCodeFixReason = null; var noCodeFixAttribute = classSymbol .GetAttributes() .SingleOrDefault(x => SymbolEqualityComparer.Default.Equals(x.AttributeClass, this.noCodeFixAttributeTypeSymbol)); bool hasCodeFix = noCodeFixAttribute == null; if (!hasCodeFix) { codeFixStatus = CodeFixStatus.NotImplemented; fixAllStatus = FixAllStatus.None; if (noCodeFixAttribute.ConstructorArguments.Length > 0) { noCodeFixReason = noCodeFixAttribute.ConstructorArguments[0].Value as string; } } else { // Check if the code fix actually exists var codeFixes = this.CodeFixProviders .Where(x => x.FixableDiagnosticIds.Contains(diagnosticId)) .Select(x => this.IsBatchFixer(x)) .ToArray(); hasCodeFix = codeFixes.Length > 0; codeFixStatus = hasCodeFix ? CodeFixStatus.Implemented : CodeFixStatus.NotYetImplemented; if (codeFixes.Any(x => x ?? false)) { fixAllStatus = FixAllStatus.BatchFixer; } else if (codeFixes.Any(x => x != null)) { fixAllStatus = FixAllStatus.CustomImplementation; } else { fixAllStatus = FixAllStatus.None; } } return(codeFixStatus, fixAllStatus); }
public async Task<IActionResult> Index( string category = null, bool? hasImplementation = null, string status = null, CodeFixStatus? codeFixStatus = null, FixAllStatus? fixAllStatus = null, string sha1 = null) { if (sha1 != null && sha1.Contains('.')) { return this.HttpBadRequest(); } try { MainViewModel viewModel = await this.dataResolver.ResolveAsync(sha1); var diagnostics = (from x in viewModel.Diagnostics where category == null || x.Category == category where hasImplementation == null || x.HasImplementation == hasImplementation where status == null || x.Status == status where codeFixStatus == null || x.CodeFixStatus == codeFixStatus where fixAllStatus == null || x.FixAllStatus == fixAllStatus select x).ToArray(); if (diagnostics.Length == 0) { // No entries found return this.HttpNotFound(); } ViewBag.Diagnostics = diagnostics; return this.View(viewModel); } catch (IOException) { return HttpNotFound(); } }