BackEnd\Components\Logging\BuildErrorTelemetryTracker.cs (54)
42private readonly int[] _errorCounts = new int[Enum.GetValues(typeof(ErrorCategory)).Length];
47private ErrorCategory _primaryCategory;
62ErrorCategory category = CategorizeError(errorCode, subcategory);
88Compiler: GetCountOrNull(ErrorCategory.Compiler),
89MsBuildGeneral: GetCountOrNull(ErrorCategory.MSBuildGeneral),
90MsBuildEvaluation: GetCountOrNull(ErrorCategory.MSBuildEvaluation),
91MsBuildExecution: GetCountOrNull(ErrorCategory.MSBuildExecution),
92MsBuildGraph: GetCountOrNull(ErrorCategory.MSBuildGraph),
93Task: GetCountOrNull(ErrorCategory.Tasks),
94SdkResolvers: GetCountOrNull(ErrorCategory.SDKResolvers),
95NetSdk: GetCountOrNull(ErrorCategory.NETSDK),
96NuGet: GetCountOrNull(ErrorCategory.NuGet),
97BuildCheck: GetCountOrNull(ErrorCategory.BuildCheck),
98NativeToolchain: GetCountOrNull(ErrorCategory.NativeToolchain),
99CodeAnalysis: GetCountOrNull(ErrorCategory.CodeAnalysis),
100Razor: GetCountOrNull(ErrorCategory.Razor),
101Wpf: GetCountOrNull(ErrorCategory.WPF),
102AspNet: GetCountOrNull(ErrorCategory.AspNet),
103Other: GetCountOrNull(ErrorCategory.Other));
116private int? GetCountOrNull(ErrorCategory category)
127private static ErrorCategory CategorizeError(string? errorCode, string? subcategory)
131return ErrorCategory.Other;
137return ErrorCategory.Compiler;
143return ErrorCategory.Compiler;
148return ErrorCategory.Other;
158('A', 'S') when StartsWithASP(errorCode) => ErrorCategory.AspNet,
161('B', 'C') => ErrorCategory.BuildCheck,
162('B', 'L') => ErrorCategory.AspNet, // Blazor
165('C', 'A') => ErrorCategory.CodeAnalysis,
166('C', 'L') => ErrorCategory.NativeToolchain,
167('C', 'V') when errorCode.Length >= 3 && char.ToUpperInvariant(errorCode[2]) == 'T' => ErrorCategory.NativeToolchain, // CVT*
168('C', >= '0' and <= '9') => ErrorCategory.NativeToolchain, // C1*, C2*, C4* (C/C++ compiler)
171('I', 'D') when errorCode.Length >= 3 && char.ToUpperInvariant(errorCode[2]) == 'E' => ErrorCategory.CodeAnalysis, // IDE*
174('L', 'N') when errorCode.Length >= 3 && char.ToUpperInvariant(errorCode[2]) == 'K' => ErrorCategory.NativeToolchain, // LNK*
177('M', 'C') => ErrorCategory.WPF, // MC* (Markup Compiler)
179('M', 'T') => ErrorCategory.NativeToolchain, // MT* (Manifest Tool)
182('N', 'E') when StartsWithNETSDK(errorCode) => ErrorCategory.NETSDK,
183('N', 'U') => ErrorCategory.NuGet,
186('R', 'C') => ErrorCategory.NativeToolchain, // RC* (Resource Compiler)
187('R', 'Z') => ErrorCategory.Razor,
190('X', 'C') => ErrorCategory.WPF, // XC* (XAML Compiler)
192_ => ErrorCategory.Other
241private static ErrorCategory CategorizeMSBError(ReadOnlySpan<char> codeSpan)
246return ErrorCategory.Other;
251>= 3001 and <= 3999 => ErrorCategory.Tasks,
252>= 4001 and <= 4099 => ErrorCategory.MSBuildGeneral,
253>= 4100 and <= 4199 => ErrorCategory.MSBuildEvaluation,
254>= 4200 and <= 4299 => ErrorCategory.SDKResolvers,
255>= 4300 and <= 4399 => ErrorCategory.MSBuildExecution,
256>= 4400 and <= 4499 => ErrorCategory.MSBuildGraph,
257>= 4500 and <= 4999 => ErrorCategory.MSBuildGeneral,
258>= 5001 and <= 5999 => ErrorCategory.MSBuildExecution,
259>= 6001 and <= 6999 => ErrorCategory.MSBuildExecution,
260_ => ErrorCategory.Other