Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Adding a new DataAttribute to improve specifying realsig, optimize and baselines. #18161

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

KevinRansom
Copy link
Member

image

Todo:
-[] Convert more tests to use the new attribute.

@KevinRansom KevinRansom requested a review from a team as a code owner December 18, 2024 11:04
Copy link
Contributor

✅ No release notes required

@KevinRansom KevinRansom marked this pull request as draft December 18, 2024 11:06
helper.Value ()

member _.Value(): CompilationUnit =
let frame = StackTrace().GetFrame(1) // Get the calling method's frame
Copy link
Member

Choose a reason for hiding this comment

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

Would it be possible to use https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/caller-information instead?
Why exactly do we need it?

Copy link
Member Author

Choose a reason for hiding this comment

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

@T-Gro , no. The Xunit.Sdk.DataAttribute.GetData override requires a MethodInfo instance. The caller-information attributes return the names of the member, the source file and line numbers.

Here is the Xunit description:
https://csharp-tokyo.github.io/xUnit-Hands-on/class_xunit_1_1_sdk_1_1_data_attribute.html#ab74ea9efe0a313e19ac0e8d8136a9071

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 need it, because GetData _ = is how XUnit retrieves the test data instance, and in this case we are using the DirectoryAttribute to create a compiler instance, and so we need to 'pretend' we are being xunit. It is true that our DirectoryAttribute doesn't actually use it, but we do need an instance to even invoke the method. And there is a decent probablility that at some point in the future DirectoryAttribute.GetData() will use it, so I didn't want to pass Unchecked.DefaultOf.

Copy link
Contributor

Choose a reason for hiding this comment

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

If we reuse the functionality of DirectoryAttribute possibly we could extract createCompilationUnit from it into a module or maybe inherit?

Copy link
Member Author

Choose a reason for hiding this comment

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

@majocha --- I'm still trying to figure out what we need. But we can certainly refactor, if necessary once we understand the necessities.

@KevinRansom KevinRansom force-pushed the ImproveDirectoryAttribute branch from 9111444 to ee66618 Compare December 21, 2024 05:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: New
Development

Successfully merging this pull request may close these issues.

3 participants