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

feat: Add support for solution filter files (.slnf) and fix version detection in launcher #2676

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

laske185
Copy link
Contributor

PR Details

Add support for solution filter files (*.slnf) to open a subset of projects of a solution.
Fixed the version detection in the launcher for last opened sdpkg files.

Related Issue

Solves #2675

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My change requires a change to the documentation.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have built and run the editor to try this change out.

return packageVersion;
}
}
else if (Regex.IsMatch(Path.GetExtension(fullPath), @"\.slnf?$", RegexOptions.IgnoreCase))
Copy link
Member

Choose a reason for hiding this comment

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

Consider using a compile-time regex.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved the regex to a static readonly field.

    public static readonly Regex SolutionFileRegex = new(@"\.slnf?$", RegexOptions.IgnoreCase | RegexOptions.Compiled);

Copy link
Member

Choose a reason for hiding this comment

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

I was more thinking of using the new GeneratedRegex attribute that triggers a source generator.

See

#if NET7_0_OR_GREATER
private static readonly Regex SemanticVersionRegex = GetSemanticVersionRegex();
private static readonly Regex StrictSemanticVersionRegex = GetStrictSemanticVersionRegex();
#else
private static readonly Regex SemanticVersionRegex = new Regex(@"^(?<Version>\d+(\s*\.\s*\d+){0,3})(?<Release>-[0-9a-z]*[\.0-9a-z-]*)?(?<BuildMetadata>\+[0-9a-z]*[\.0-9a-z-]*)?$", Flags);
private static readonly Regex StrictSemanticVersionRegex = new Regex(@"^(?<Version>\d+(\.\d+){2})(?<Release>-[0-9a-z]*[\.0-9a-z-]*)?(?<BuildMetadata>\+[0-9a-z]*[\.0-9a-z-]*)?$", Flags);
#endif
and
#if NET7_0_OR_GREATER
[GeneratedRegex(@"^(?<Version>\d+(\s*\.\s*\d+){0,3})(?<Release>-[0-9a-z]*[\.0-9a-z-]*)?(?<BuildMetadata>\+[0-9a-z]*[\.0-9a-z-]*)?$", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture)]
private static partial Regex GetSemanticVersionRegex();
[GeneratedRegex(@"^(?<Version>\d+(\.\d+){2})(?<Release>-[0-9a-z]*[\.0-9a-z-]*)?(?<BuildMetadata>\+[0-9a-z]*[\.0-9a-z-]*)?$", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture)]
private static partial Regex GetStrictSemanticVersionRegex();
#endif

…ction, use naming policy for JSON deserialization and improve null checks
@IXLLEGACYIXL
Copy link
Collaborator

so changing an excluded project still triggers reload?

@laske185
Copy link
Contributor Author

Good point. I extended the FromSolutionFilterStream-function to include all parent solution folders. With that, the existing logic also adds all dependencies to the solution, as when opening a sdpkg-file.

This following slnf-file example would also load all needed projects like MyGame.csproj. All excluded projects do not have to trigger the reload because they are not needed by the Stride relevant projects.

{
  "solution": {
    "path": "MyGame.sln",
    "projects": [
      "MyGame.Android\\MyGame.Andriod.csproj",
      "MyGame.Windows\\MyGame.Windows.csproj"      
    ]
  }
}

@IXLLEGACYIXL
Copy link
Collaborator

changing something in an exlcuded project will still trigger reload as the projectwachre has is own roslyn workspace

@laske185
Copy link
Contributor Author

Yes, the reload work as before in all loaded projects. This means all project from the solution filter file and their dependencies.

@laske185
Copy link
Contributor Author

I fixed the path set to the solution object to the filter file instead of the referenced solution. Restarting the editor then opens the filtered solution instead of the complete solution.

@IXLLEGACYIXL
Copy link
Collaborator

the projectwatcher watches the files and reacts on typing,, and has his own msbuild workspace so, if i change an excluded project it will still cause a reload

also check if with your changes reloading works, also reloading chained projects like sub projects in your solution should trigger a reload chain

@laske185
Copy link
Contributor Author

The reload works with solution files same as with solution filter files because there is no difference after determining the projects to load.

I tested the reload and it is working in simple projects, same as when opening sln-files. In larger projects, the project watcher is extreme buggy and not working - it doesn't matter whether I open a sln or slnf file. The projectwatcher deletes complete projects and causes crashes of the game studio. So I have no idea why you are asking so insistently about the projectwatcher. Fixing it is not part of this PR.

@IXLLEGACYIXL
Copy link
Collaborator

IXLLEGACYIXL commented Mar 12, 2025

the projectwatcher wasnt buggy before thats why

or atleast not in way that i know of

@laske185 laske185 marked this pull request as draft March 13, 2025 18:39
@IXLLEGACYIXL
Copy link
Collaborator

https://github.com/stride3d/stride/blob/master/sources/editor/Stride.Assets.Presentation/AssetEditors/ProjectWatcher.cs#L385
here the solution gets opened, you will have to fix that as well to consider the solution file you want, and confirm that the reloading still works

@laske185
Copy link
Contributor Author

laske185 commented Mar 14, 2025

Thanks for the hint. I will take a look at it. Additionally, I would like to check why it is so slow in my project that it seems that the projectwatcher is not working.

I found the reason the projectwatcher or the save algorithm deletes my files in some projects. I have multiple projects with an equal name in different folders in my solution. Changes in one of these projects forces the problem. I get this dialog. When clicking OK and Saving the projects, all files of one of the two projects is deleted.
image
But I think this will be a new issue I have to create.

Currently, I have these To-dos:

  • Fixing the projectwatcher watching the loaded projects.
  • Saving overwrites the slnf-file with the content of a normal solution.

@IXLLEGACYIXL
Copy link
Collaborator

Thanks for the hint. I will take a look at it. Additionally, I would like to check why it is so slow in my project that it seems that the projectwatcher is not working.

I found the reason the projectwatcher or the save algorithm deletes my files in some projects. I have multiple projects with an equal name in different folders in my solution. Changes in one of these projects forces the problem. I get this dialog. When clicking OK and Saving the projects, all files of one of the two projects is deleted. image But I think this will be a new issue I have to create.

Currently, I have these To-dos:

* Fixing the projectwatcher watching the loaded projects.

* Saving overwrites the `slnf`-file with the content of a normal solution.

the projectwatcher doesnt run that dialog, the project watcher collects a string list of project names and sends them to the listeners to update and there is only 2 upddatable things, the code editor and the reload mechanism , i think in the codeviewmodel but idk , you gotta look there OR check the list that gets sent to them

to be a list is important for dependency updates to allow multiple projeects being changed and the studio will reload all dependencies in a chain, this way mutli project solutions became possible, ik now there is a bug that it just deletes unsaved files but your problem doesnt sound like that at all, so i dont know

@IXLLEGACYIXL
Copy link
Collaborator

additionally you have in the projectwatcher https://github.com/stride3d/stride/blob/master/sources/editor/Stride.Assets.Presentation/AssetEditors/ProjectWatcher.cs#L63
mybe this gets set wwrong when you launch studio so the start project is picked wrongly?

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

Successfully merging this pull request may close these issues.

3 participants