/// <summary>
 /// Adds the replacement value to a key.
 /// </summary>
 /// <param name="key">The  expected key.</param>
 /// <param name="value">The value.</param>
 /// <exception cref="KeyNotFoundException"></exception>
 public void AddReplacementValue(string key, string value)
 {
     if (!ReplacementTable.ContainsKey(key))
     {
         throw new KeyNotFoundException();
     }
     ReplacementTable[key] = value;
 }
Example #2
0
        protected override void Analyze(SyntaxNodeAnalysisContext context, AttributeSyntax attributeSyntax)
        {
            SyntaxHelper.ParseAttributeArguments(attributeSyntax, (argName, expression) =>
            {
                if (argName == null || !ReplacementTable.ContainsKey(argName))
                {
                    return;
                }

                var argLocation = expression.Parent.GetLocation();
                var argNameFix  = ReplacementTable[argName];

                context.ReportDiagnostic(Diagnostic.Create(
                                             Descriptors.DeprecatedReplaceableAttributeArgument, argLocation, argName, argNameFix));
            });
        }