-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
JsonPropertyPostAction: allow to create file and path #41959
Conversation
private const string AllowFileCreationArgument = "allowFileCreation"; | ||
private const string AllowPathCreationArgument = "allowPathCreation"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Split into 2 properties to allow users to be able to add the missing property path without forcing requirement to allow file creation.
There is some potential discussion here because it's not really making sense to allow file creation and not allow path creation so we could maybe have some kind of enum instead (e.g. CreationMode
with None
being the default, Path
and File
or FileAndPath
). We could also keep the boolean and say the allowPathCreation
is assumed to be true
when allowFileCreation
is set to true
.
} | ||
|
||
return node; | ||
} | ||
|
||
private static IReadOnlyList<string> FindFilesInCurrentProjectOrSolutionFolder( | ||
private static string[] FindFilesInCurrentFolderOrParentFolder( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to better match actual logic in place.
IPhysicalFileSystem fileSystem, | ||
string startPath, | ||
string matchPattern, | ||
Func<string, bool>? secondaryFilter = null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused.
IPhysicalFileSystem fileSystem, | ||
string startPath, | ||
string matchPattern, | ||
Func<string, bool>? secondaryFilter = null, | ||
int maxAllowedAboveDirectories = 250) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was forced to 1 on the only calling place.
} | ||
|
||
directory = Path.GetPathRoot(directory) != directory ? Directory.GetParent(directory)?.FullName : null; | ||
numberOfUpLevels++; | ||
} | ||
while (directory != null && numberOfUpLevels <= maxAllowedAboveDirectories); | ||
while (directory != null && numberOfUpLevels <= 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be good to have a better walk-up logic but I couldn't think of anything that would work for all/most cases.
- Walking up to first project found is problematic for templates adding project as we would never walk-up.
- Walking up to first sln found can lead to walking up to root if no sln exists
- Walking up to repo root is hard because we have nothing to understand where to stop (is it git folder? is it something else?).
Error seems unrelated to this PR: |
Ping @dotnet/templating-engine-maintainers |
Looks good to me! |
@MiYanni Could you please have a look at this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the 2 properties is fine for the time being. It gets the functionality across without additional work in the code. Everything else looks good.
I keep getting different issues with the VMR leg (at every update) but they are all unlinked from my change. Is there a way to force merge? |
We would like to promote
MSTest.Sdk
as the default recommendation for MSTest test templates as part of .NET 9 and it seems a lot more convenient to handle the version through theglobal.json
file rather than a local version.To do so, we need to be able to either add or edit a
global.json
file but there is no easy way to do so. The best match would be to use the Add property to an existing json file post-action but it doesn't allow file creation nor even path creation.I had a chat with @YuliiaKovalova and @baronfel who suggested that I work on a PR improving the post-action.