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

Change from "sln" to "solution" as primary, and add "sln" as alias #43607

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

SourceCodeWhen
Copy link

This is in respect to issue #40817

Changes have been made to tests that relied on certain outputs using "sln" and hard-baked calls to "sln" from internal code/inlined test params.

I also pulled out the command name to a const string and the aliases to a readonly array to make it more in-line with other command implementations.

There's a surprising amount of things that relied somewhat on the "sln" keyword being returned for parts of testing, etc. So if preferred I can strip back the PR to leave "sln" as the primary and add "solution" as an alias, reverting the changes to the tests that needed changing.

Cheers!

…" to a shorthand alias.

Additional changes have been made to tests that relied on certain outputs using "sln" and hard-baked calls to "sln" from internal code.
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Infrastructure untriaged Request triage from a team member labels Sep 20, 2024
@SourceCodeWhen
Copy link
Author

@dotnet-policy-service agree

@SourceCodeWhen SourceCodeWhen marked this pull request as draft September 20, 2024 23:33
…ngs downstream expecting SLN such as aspire, etc? Will need someone with more knowledge to check if this could affect things downstream.
@kasperk81
Copy link
Contributor

is it compatible with .sln vs. .slnx future plan #18739?

@SourceCodeWhen
Copy link
Author

There's no changes in it to parsing of .sln/.slnx files, only for "dotnet sln {args}" to also allow "dotnet solution {args}".

Specifically, "dotnet solution {args}" being the default, and "dotnet sln {args}" now being an alias. So this shouldn't conflict with #18739 from what I understand. 😊

@kasperk81
Copy link
Contributor

i can't wait to switch to slnx. keeping a close eye on #40817 progress 🔭


for (int i = 0; i < CommandAliases.Length; i++)
{
command.Aliases.Add(CommandAliases[i]);
Copy link
Member

Choose a reason for hiding this comment

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

since there's only one alias, probably could just make the Alias a string and call add to clean this up

@marcpopMSFT
Copy link
Member

Triage: This change is actually a prereq we had in mind for doing the new slnx support. Were you going to publish this PR and add tests as well? We'll want to add a doc bug once this merges and we'll probably want this to target 9.0.2xx (not sure when slnx is coming but hopefully before 10).

@SourceCodeWhen
Copy link
Author

Triage: This change is actually a prereq we had in mind for doing the new slnx support. Were you going to publish this PR and add tests as well? We'll want to add a doc bug once this merges and we'll probably want this to target 9.0.2xx (not sure when slnx is coming but hopefully before 10).

Hi there!

Yep! I plan on incorporating that change you mentioned and writing up some new tests this weekend so I can swap to Ready for Review. :)

Cheers!

@baronfel
Copy link
Member

Wonderful news @SourceCodeWhen - let us know if you need any help/guidance getting this ready.

@@ -205,7 +205,7 @@ public IEnumerable<string> GetCustomDefaultConfigurationValueIfSpecified()
/// <summary>
/// Returns an arbitrary project for the solution. Relies on the .NET SDK PrepareForPublish or _VerifyPackReleaseConfigurations MSBuild targets to catch conflicting values of a given property, like PublishRelease or PackRelease.
/// </summary>
/// <param name="sln">The solution to get an arbitrary project from.</param>
/// <param name="solution">The solution to get an arbitrary project from.</param>
Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't change if the sln parameter on this function is not changing.

Copy link
Member

@nagilson nagilson left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution to .NET 😊 Your changes look great to me. I do have one nit pick comment. The tests are failing but it looks like only due to an issue on the repo and not your fault. Hopefully that issue will get cleaned up soon and we can merge!

@SourceCodeWhen
Copy link
Author

Thank you for your contribution to .NET 😊 Your changes look great to me. I do have one nit pick comment. The tests are failing but it looks like only due to an issue on the repo and not your fault. Hopefully that issue will get cleaned up soon and we can merge!

Thanks!

I develop on Linux so ive been trying to work out what was happening for a while now, haha.

I thought it could have potentially been due to the test run effectively going twice for the same folder destination, one with "sln" and one with "solution", and the call on windows throwing an error compared to other platforms.

If it's a bug on the repo however then that makes life easier, haha.

Cheers!

@SourceCodeWhen SourceCodeWhen marked this pull request as ready for review October 2, 2024 14:32
@nagilson
Copy link
Member

nagilson commented Oct 9, 2024

@SourceCodeWhen This PR is almost there now! :)

There are 3 remaining test failures mostly related to dotnet solution add.
The failure is due to a missing argument. When you call CopyTestAsset, you should provide a 2nd parameter when migrating from a fact to a theory. That parameter should be the parameter to the test.

Example

        [Theory]
        [InlineData(true)]
        [InlineData(false)]
        public void It_publishes_on_release_if_PublishRelease_property_set(bool optedOut)
        {
            var helloWorldAsset = _testAssetsManager
               .CopyTestAsset("HelloWorld", $"{optedOut}")
               .WithSource();

optedOut is passed as a 2nd parameter to copy test asset to prevent test folders from having a clobbering race condition

@SourceCodeWhen
Copy link
Author

@SourceCodeWhen This PR is almost there now! :)

There are 3 remaining test failures mostly related to dotnet solution add. The failure is due to a missing argument. When you call CopyTestAsset, you should provide a 2nd parameter when migrating from a fact to a theory. That parameter should be the parameter to the test.

Example

        [Theory]
        [InlineData(true)]
        [InlineData(false)]
        public void It_publishes_on_release_if_PublishRelease_property_set(bool optedOut)
        {
            var helloWorldAsset = _testAssetsManager
               .CopyTestAsset("HelloWorld", $"{optedOut}")
               .WithSource();

optedOut is passed as a 2nd parameter to copy test asset to prevent test folders from having a clobbering race condition

Aha! That makes a ton of sense! :)

I've gone ahead and added the solution command to the identifier parameter of CopyTestAsset method wherever I've seen it crop up. In the case that something was already there before, I've concatenated the command on so as to be unique. Will see how the tests go on the pipeline now!

Thanks a lot for the point in the right direction. :)

@nagilson
Copy link
Member

nagilson commented Oct 9, 2024

Thanks, it looks good now but there's a new repo issue 😅 Waiting for it to be fixed.
I really appreciate your fast upkeep on this and great work on the fix! 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants