Skip to content

Commit

Permalink
Create SuppressMessage attribute params properly
Browse files Browse the repository at this point in the history
  • Loading branch information
citizenmatt committed Aug 30, 2016
1 parent dbb14a1 commit 2729559
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions install/StyleCop.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<summary>StyleCop analyzes C# source code to enforce a set of style and consistency rules. Maintained by JetBrains</summary>
<description>StyleCop analyzes C# source code to enforce a set of style and consistency rules. This plugin is compatible with StyleCop 4.7.54, and maintained by JetBrains.</description>
<releaseNotes>
&#8226; Create SuppressMessage attribute parameters more reliably
&#8226; Works properly if StyleCop 4.7.49 is already loaded in Visual Studio

From 2016.1.3:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ namespace StyleCop.ReSharper.BulbItems.Framework
using JetBrains.Application.Settings;
using JetBrains.ProjectModel;
using JetBrains.ReSharper.Psi;
using JetBrains.ReSharper.Psi.CodeStyle;
using JetBrains.ReSharper.Psi.CSharp;
using JetBrains.ReSharper.Psi.CSharp.CodeStyle;
using JetBrains.ReSharper.Psi.CSharp.Tree;
using JetBrains.TextControl;

Expand Down Expand Up @@ -61,8 +63,6 @@ public override void ExecuteTransactionInner(ISolution solution, ITextControl te

string justificationText = settingsStore.GetValue((StyleCopOptionsSettingsKey key) => key.SuppressStyleCopAttributeJustificationText);

IAttributesOwnerDeclaration attributesOwnerDeclaration = declaration as IAttributesOwnerDeclaration;

CSharpElementFactory factory = CSharpElementFactory.GetInstance(declaration.GetPsiModule());

ITypeElement typeElement = Utils.GetTypeElement(declaration, "System.Diagnostics.CodeAnalysis.SuppressMessageAttribute");
Expand All @@ -73,9 +73,12 @@ public override void ExecuteTransactionInner(ISolution solution, ITextControl te

ICSharpArgument newArg2 = attribute.AddArgumentAfter(Utils.CreateConstructorArgumentValueExpression(declaration.GetPsiModule(), ruleText), newArg1);

attribute.AddArgumentAfter(Utils.CreateArgumentValueExpression(declaration.GetPsiModule(), "Justification = \"" + justificationText + "\""), newArg2);
IPropertyAssignment propertyAssignment = factory.CreatePropertyAssignment(
"Justification",
factory.CreateExpression("\"$0\"", justificationText));
attribute.AddPropertyAssignmentAfter(propertyAssignment, null);

attributesOwnerDeclaration.AddAttributeAfter(attribute, null);
declaration.AddAttributeAfter(attribute, null);
}
}
}
Expand Down

0 comments on commit 2729559

Please sign in to comment.