Skip to content

Commit 9166e4f

Browse files
committed
Add WorkItemAttribute
1 parent a5ca880 commit 9166e4f

3 files changed

Lines changed: 48 additions & 0 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/AttributeTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,15 @@ public void TestNoDiagnosticAttributeReason()
2222
var attribute = new NoDiagnosticAttribute(reason);
2323
Assert.Same(reason, attribute.Reason);
2424
}
25+
26+
[Fact]
27+
public void TestWorkItemAttribute()
28+
{
29+
int id = 1234;
30+
string issueUri = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2419";
31+
var attribute = new WorkItemAttribute(id, issueUri);
32+
Assert.Equal(id, attribute.Id);
33+
Assert.Same(issueUri, attribute.Location);
34+
}
2535
}
2636
}

StyleCop.Analyzers/StyleCop.Analyzers.Test/StyleCop.Analyzers.Test.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@
410410
<Compile Include="SpecialRules\SA0002UnitTests.cs" />
411411
<Compile Include="Verifiers\CodeFixVerifier.cs" />
412412
<Compile Include="Verifiers\DiagnosticVerifier.cs" />
413+
<Compile Include="WorkItemAttribute.cs" />
413414
</ItemGroup>
414415
<ItemGroup>
415416
<None Include="..\..\build\keys\TestingKey.snk">
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2+
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
3+
4+
namespace StyleCop.Analyzers.Test
5+
{
6+
using System;
7+
8+
/// <summary>
9+
/// Used to tag test methods or types which are created for a given WorkItem
10+
/// </summary>
11+
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
12+
public sealed class WorkItemAttribute : Attribute
13+
{
14+
/// <summary>
15+
/// Initializes a new instance of the <see cref="WorkItemAttribute"/> class.
16+
/// </summary>
17+
/// <param name="id">The ID of the issue in the original tracker where the work item was first reported. This
18+
/// could be a GitHub issue or pull request number, or the number of a Microsoft-internal bug.</param>
19+
/// <param name="issueUri">The URI where the work item can be viewed. This is a link to work item
20+
/// <paramref name="id"/> in the original source.</param>
21+
public WorkItemAttribute(int id, string issueUri)
22+
{
23+
this.Id = id;
24+
this.Location = issueUri;
25+
}
26+
27+
public int Id
28+
{
29+
get;
30+
}
31+
32+
public string Location
33+
{
34+
get;
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)