Skip to content

Commit

Permalink
Add WorkItemAttribute
Browse files Browse the repository at this point in the history
  • Loading branch information
sharwell committed Jun 17, 2017
1 parent a5ca880 commit 9166e4f
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
10 changes: 10 additions & 0 deletions StyleCop.Analyzers/StyleCop.Analyzers.Test/AttributeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,15 @@ public void TestNoDiagnosticAttributeReason()
var attribute = new NoDiagnosticAttribute(reason);
Assert.Same(reason, attribute.Reason);
}

[Fact]
public void TestWorkItemAttribute()
{
int id = 1234;
string issueUri = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2419";
var attribute = new WorkItemAttribute(id, issueUri);
Assert.Equal(id, attribute.Id);
Assert.Same(issueUri, attribute.Location);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@
<Compile Include="SpecialRules\SA0002UnitTests.cs" />
<Compile Include="Verifiers\CodeFixVerifier.cs" />
<Compile Include="Verifiers\DiagnosticVerifier.cs" />
<Compile Include="WorkItemAttribute.cs" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\build\keys\TestingKey.snk">
Expand Down
37 changes: 37 additions & 0 deletions StyleCop.Analyzers/StyleCop.Analyzers.Test/WorkItemAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.

namespace StyleCop.Analyzers.Test
{
using System;

/// <summary>
/// Used to tag test methods or types which are created for a given WorkItem
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
public sealed class WorkItemAttribute : Attribute
{
/// <summary>
/// Initializes a new instance of the <see cref="WorkItemAttribute"/> class.
/// </summary>
/// <param name="id">The ID of the issue in the original tracker where the work item was first reported. This
/// could be a GitHub issue or pull request number, or the number of a Microsoft-internal bug.</param>
/// <param name="issueUri">The URI where the work item can be viewed. This is a link to work item
/// <paramref name="id"/> in the original source.</param>
public WorkItemAttribute(int id, string issueUri)
{
this.Id = id;
this.Location = issueUri;
}

public int Id
{
get;
}

public string Location
{
get;
}
}
}

0 comments on commit 9166e4f

Please sign in to comment.