Skip to content
New issue

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

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

Already on GitHub? # to your account

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

Closed

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
@KevinRansom KevinRansom force-pushed the ImproveDirectoryAttribute branch 3 times, most recently from 1e413e8 to 5d7fe2b Compare January 2, 2025 02:57
@KevinRansom KevinRansom marked this pull request as ready for review January 2, 2025 08:31
@KevinRansom KevinRansom changed the title WIP: Adding a new DataAttribute to improve specifying realsig, optimize and baselines. Adding a new DataAttribute to improve specifying realsig, optimize and baselines. Jan 2, 2025
@@ -242,7 +242,7 @@ type CompilationUtil private () =
with
| _ -> (errors, [||])
finally
try Directory.Delete(Path.GetDirectoryName ilFilePath, true) with _ -> ()
() //try Directory.Delete(Path.GetDirectoryName ilFilePath, true) with _ -> ()
Copy link
Member

Choose a reason for hiding this comment

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

Ping.

try
Directory.Delete(initialProject.ProjectDir, true)
with _ -> ()
() //try Directory.Delete(initialProject.ProjectDir, true) with _ -> ()
Copy link
Member

Choose a reason for hiding this comment

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

?

Copy link
Member Author

Choose a reason for hiding this comment

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

That is temporary, although I think I will add an an environment variable to turn off deletes.

@@ -1,202 +0,0 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

namespace Conformance.Conformance.DeclarationElements.CustomAttributes.AttributeUsage
Copy link
Member

Choose a reason for hiding this comment

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

Where did those go?

@T-Gro
Copy link
Member

T-Gro commented Jan 2, 2025

Can you please help with making the review surface more manageable?

I see some file re-orgs, file renames as well as bulk (regex?) changes of attribute usage.
If you could comment on the bulk changes done, we could isolate the bigger changes and focus on those (and trust that a regex bulk change works as it should)

@KevinRansom
Copy link
Member Author

Can you please help with making the review surface more manageable?

I see some file re-orgs, file renames as well as bulk (regex?) changes of attribute usage. If you could comment on the bulk changes done, we could isolate the bigger changes and focus on those (and trust that a regex bulk change works as it should)

What I can do is split it into a few PR's.

  1. The new dataattribute + refactor + a couple of test cases
  2. A couple of PR's with a subset of each test case.

The only change I really care about is the new attribute and the refactor.

How does that sound?

@KevinRansom KevinRansom force-pushed the ImproveDirectoryAttribute branch from b370561 to 403c43c Compare January 2, 2025 20:45
@KevinRansom KevinRansom marked this pull request as draft January 2, 2025 20:48
@KevinRansom KevinRansom force-pushed the ImproveDirectoryAttribute branch from 403c43c to 7a713b3 Compare January 3, 2025 00:54
psfinaki pushed a commit that referenced this pull request Jan 7, 2025
…18195)

* refactor

* tests/FSharp.Compiler.ComponentTests/EmittedIL/ForLoop
psfinaki pushed a commit that referenced this pull request Jan 8, 2025
…18196)

* More tests - directory attribute improvements

* methordresolution
@KevinRansom KevinRansom closed this Jan 8, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants