public static string GetTemplate(this StyleErrorType type) { var attribute = type.GetAttribute <MessageTemplateAttribute>(); if (attribute == null) { throw new ArgumentNullException($"Bad StyleErrorType {type}, it has no MessageTemplate attribute"); } return(attribute.Template); }
public async Task <bool> IsStyleErrorEnabled(StyleErrorType errorType) { await CacheSettings(); if (settingsCache.ContainsKey(errorType)) { return(settingsCache[errorType]); } /* By default all style validation errors are enabled */ return(true); }
public async Task EnableStyleError(StyleErrorType errorType, bool isEnabled) { var oldSettings = await db.StyleErrorSettings.FirstOrDefaultAsync(s => s.ErrorType == errorType); if (oldSettings == null) { db.StyleErrorSettings.Add(new StyleErrorSettings { ErrorType = errorType, IsEnabled = isEnabled, }); } else { oldSettings.IsEnabled = isEnabled; } await db.SaveChangesAsync(); }
public SolutionStyleError(StyleErrorType errorType, SyntaxNodeOrToken nodeOrToken, params object[] arguments) : this(errorType, nodeOrToken.GetFileLinePositionSpan(), arguments) { }
public SolutionStyleError(StyleErrorType errorType, SyntaxToken token, params object[] arguments) : this(errorType, GetFileLinePositionSpan(token), arguments) { }
public SolutionStyleError(StyleErrorType errorType, SyntaxNode node, params object[] arguments) : this(errorType, GetFileLinePositionSpan(node), arguments) { }
public SolutionStyleError(StyleErrorType errorType, FileLinePositionSpan span, params object[] arguments) { ErrorType = errorType; Span = span; Message = string.Format(errorType.GetTemplate(), arguments); }