-
Notifications
You must be signed in to change notification settings - Fork 386
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
Add property to view .user file command line arguments #8494
Conversation
c7f5b91
to
d16a4f6
Compare
6c85bb7
to
83c06c9
Compare
|
||
XmlDocument doc = new XmlDocument(); | ||
|
||
#pragma warning disable CA3075 // Insecure DTD processing in XML |
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.
Please verify this is safe to suppress. This may be a security concern.
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.
Fixed. Setting XmlResolver
to null as suggested in https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca3075#solution-6
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.
Why is this #pragma
still in the code? If you've fixed the issue, can you remove it?
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.
For some reason the static analysis still believes this is unsafe.
...operties/InterceptedProjectProperties/DebugPropertyPage/RemoveStartArgumentsActionHandler.cs
Outdated
Show resolved
Hide resolved
...operties/InterceptedProjectProperties/DebugPropertyPage/RemoveStartArgumentsActionHandler.cs
Outdated
Show resolved
Hide resolved
...operties/InterceptedProjectProperties/DebugPropertyPage/RemoveStartArgumentsActionHandler.cs
Outdated
Show resolved
Hide resolved
...operties/InterceptedProjectProperties/DebugPropertyPage/RemoveStartArgumentsActionHandler.cs
Outdated
Show resolved
Hide resolved
<StringProperty Name="StartArguments" | ||
DisplayName="ReadOnly .user file command line arguments" | ||
Description="Deprecated. This is only visible if there are command line arguments in the .user file to pass to the executable." | ||
ReadOnly="False"> |
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.
Why not ReadOnly="True"
here?
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.
removed in last commit
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 don't think this should be removed. I think it should be added.
Currently, this property will be editable. Yet I don't think that's what we want, is it? We want to display the value here, and allow the user to migrate the value from .user to .json.
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.
Even if we set this ReadOnly="True", cps will mark it as read only because it thinks this is a common property.
...Studio.ProjectSystem.Managed/ProjectSystem/Rules/PropertyPages/ProjectDebugPropertyPage.xaml
Outdated
Show resolved
Hide resolved
...operties/InterceptedProjectProperties/DebugPropertyPage/RemoveStartArgumentsActionHandler.cs
Show resolved
Hide resolved
9d43d61
to
03f5dad
Compare
...operties/InterceptedProjectProperties/DebugPropertyPage/RemoveStartArgumentsActionHandler.cs
Outdated
Show resolved
Hide resolved
...operties/InterceptedProjectProperties/DebugPropertyPage/RemoveStartArgumentsActionHandler.cs
Outdated
Show resolved
Hide resolved
...operties/InterceptedProjectProperties/DebugPropertyPage/RemoveStartArgumentsActionHandler.cs
Outdated
Show resolved
Hide resolved
|
||
public Task HandleAsync(UnconfiguredProject project, IReadOnlyDictionary<string, string> editorMetadata) | ||
{ | ||
_xmlFile = project.FullPath + UserSuffix; |
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.
Please check with the CPS team about whether it would be better to use CPS APIs to modify the .user file, rather than doing direct XML-to-disk changes here.
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.
The cps apis marked this property as read only and doesn't allow to make changes to it.
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.
The .user file is part of the loaded project; in general we shouldn't modify directly.
Do we understand why "StartArguments" is being treated as read-only?
ece2787
to
9c68547
Compare
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.
- We need to understand why the property is being treated as read-only.
- Don't modify the .user file directly.
- Please add unit tests.
|
||
public Task HandleAsync(UnconfiguredProject project, IReadOnlyDictionary<string, string> editorMetadata) | ||
{ | ||
_xmlFile = project.FullPath + UserSuffix; |
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.
The .user file is part of the loaded project; in general we shouldn't modify directly.
Do we understand why "StartArguments" is being treated as read-only?
|
||
private async Task CopyUserArgsToLaunchProfileAsync(UnconfiguredProject project) | ||
{ | ||
ILaunchSettingsProvider? launchSettingsProvider = project.Services.ExportProvider.GetExportedValue<ILaunchSettingsProvider>(); |
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.
Any reason to do this rather than import the ILaunchSettingsProvider
in a constructor?
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.
Among other things it would make it easier to write unit tests for this.
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 already tried importing ILaunchSettingsProvider
in the constructor, but I got a lot of composition errors.
private const string UserSuffix = ".user"; | ||
|
||
private string? _xmlFile; | ||
private List<string>? userFileCommandArgs; |
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.
_userFileCommandArgs
|
||
foreach (string? commandArg in userFileCommandArgs) | ||
{ | ||
writableLaunchSettings.ActiveProfile.CommandLineArgs += " " + commandArg; |
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.
You need to account for:
CommandLineArgs
may benull
.CommandLineArgs
may be the empty string.
|
||
foreach (string? commandArg in userFileCommandArgs) | ||
{ | ||
writableLaunchSettings.ActiveProfile.CommandLineArgs += " " + commandArg; |
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.
Also, this is going to move the StartArguments
to the command line arguments of the active profile. I see two potential problems:
- The user may not be editing the active profile. In that case the arguments will just seem to disappear when they click the link.
StartArguments
potentially affect launch/debug regardless of the launch profile, but this will move them to one specific launch profile.
I'm not sure either of those is really a problem, but we should think about those scenarios.
Converting this pr to draft since there is still unclear why |
9c68547
to
37acd35
Compare
Fixes AB#1274456
Microsoft Reviewers: Open in CodeFlow