예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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();
        }
예제 #4
0
 public SolutionStyleError(StyleErrorType errorType, SyntaxNodeOrToken nodeOrToken, params object[] arguments)
     : this(errorType, nodeOrToken.GetFileLinePositionSpan(), arguments)
 {
 }
예제 #5
0
 public SolutionStyleError(StyleErrorType errorType, SyntaxToken token, params object[] arguments)
     : this(errorType, GetFileLinePositionSpan(token), arguments)
 {
 }
예제 #6
0
 public SolutionStyleError(StyleErrorType errorType, SyntaxNode node, params object[] arguments)
     : this(errorType, GetFileLinePositionSpan(node), arguments)
 {
 }
예제 #7
0
 public SolutionStyleError(StyleErrorType errorType, FileLinePositionSpan span, params object[] arguments)
 {
     ErrorType = errorType;
     Span      = span;
     Message   = string.Format(errorType.GetTemplate(), arguments);
 }