Skip to content

Conversation

@jjonescz
Copy link
Member

@jjonescz jjonescz commented May 5, 2025

Allows searching for tests marked with WorkItemAttribute, e.g., in VS Test Explorer via Trait:"...issue url..." or Trait:IssueNumber:

image

@ghost ghost added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels May 5, 2025
@jjonescz jjonescz marked this pull request as ready for review May 5, 2025 13:17
@jjonescz jjonescz requested a review from a team as a code owner May 5, 2025 13:17
var arguments = traitAttribute.GetConstructorArguments().ToArray();
if (arguments is [int id, string url])
{
yield return new KeyValuePair<string, string>("WorkItemId", id.ToString());
Copy link
Member

@jcouv jcouv May 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do "WorkItemId" and "WorkItemUrl" show up? Do we have to type a query like Trait: "WorkItemId=12345" or would Trait: 12345 work? #Closed

Copy link
Member Author

@jjonescz jjonescz May 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latter works. I think you could write the former to be more specific though.

}
else if (arguments is [string onlyUrl])
{
yield return new KeyValuePair<string, string>("WorkItemUrl", onlyUrl);
Copy link
Member

@jcouv jcouv May 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the case where the WorkItem only contains a URL (which is what we now commonly do), maybe we should extract the ID and make it available to search on too? #Closed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if there is just WorkItem(url) attribute, searching for Trait:IssueId works as well (i.e., a substring match is enough)

{
public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute)
{
var arguments = traitAttribute.GetConstructorArguments().ToArray();
Copy link
Member

@jcouv jcouv May 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we check that we're dealing with the WorkItem attribute? #Closed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could but it's not necessary - the WorkItemTraitDiscoverer is only used for WorkItemAttribute thanks to the corresponding [TraitDiscoverer("Microsoft.CodeAnalysis.Test.Utilities.WorkItemTraitDiscoverer", assemblyName: "Microsoft.CodeAnalysis.Test.Utilities")]. This is modeled after https://github.com/dotnet/roslyn/blob/3f3096be868cee0fa3d99875da1739caeb742553/src/Compilers/Test/Core/Traits/CompilerTraitDiscoverer.cs which also doesn't check the attribute type


namespace Microsoft.CodeAnalysis.Test.Utilities;

public sealed class WorkItemTraitDiscoverer : ITraitDiscoverer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allows searching for tests marked with WorkItemAttribute, e.g., in VS Test Explorer via Trait:"...issue url..."

Could you give an example/screenshot of what the experience looks like once the discoverer is in place?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added screenshot to PR description.

@jcouv jcouv self-assigned this May 5, 2025
Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Thanks (iteration 1)

@jjonescz jjonescz merged commit 1e14d8a into dotnet:main May 6, 2025
24 checks passed
@jjonescz jjonescz deleted the workitem branch May 6, 2025 10:24
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone May 6, 2025
@RikkiGibson RikkiGibson modified the milestones: Next, 18.0 P1 Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants