Skip to content

Commit

Permalink
Address PR feedback.
Browse files Browse the repository at this point in the history
Avoid allocating a new list by using List.RemoveAll.
There's no need to have different properties: the VB-specific file replaces the base one and it is only included for VB projects, so we can also remove the visibility condition.
Unfortunately, this reverts the changes that caused the localization files to change but doesn't reset their status to translated.
  • Loading branch information
melytc committed Oct 26, 2023
1 parent bbf773c commit 01b9b81
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace Microsoft.VisualStudio.ProjectSystem.VS.Properties;

// The AppliesTo metadata has no effect given the limitations described in https://github.com/dotnet/project-system/issues/8170.
[ExportInterceptingPropertyValueProvider(InterceptedStartupObjectProperty, ExportInterceptingPropertyValueProviderFile.ProjectFile)]
[ExportInterceptingPropertyValueProvider(StartupObjectProperty, ExportInterceptingPropertyValueProviderFile.ProjectFile)]
[AppliesTo(ProjectCapability.WPF + "|" + ProjectCapability.WindowsForms)]
internal class StartupObjectValueProvider : InterceptingPropertyValueProviderBase
{
Expand All @@ -17,7 +17,6 @@ internal class StartupObjectValueProvider : InterceptingPropertyValueProviderBas
private const string DisabledValue = "WindowsFormsWithCustomSubMain";

internal const string UseWinFormsProperty = "UseWindowsForms";
internal const string InterceptedStartupObjectProperty = "StartupObjectVB";
internal const string StartupObjectProperty = "StartupObject";
internal const string RootNamespaceProperty = "RootNamespace";

Expand Down Expand Up @@ -62,13 +61,11 @@ public StartupObjectValueProvider(IMyAppFileAccessor myAppXmlFileAccessor, Uncon
{
// Else, if it's other than a Windows Forms project, save the StartupObject property in the project file as usual.
// Or if the ApplicationFramework property is disabled, save the StartupObject property in the project file as usual.
await defaultProperties.SetPropertyValueAsync(StartupObjectProperty, rootNameSpace + "." + unevaluatedPropertyValue);
return null;
return rootNameSpace + "." + unevaluatedPropertyValue;
}
}
// This check can be removed when https://github.com/dotnet/project-system/issues/8170 is addressed.
await defaultProperties.SetPropertyValueAsync(StartupObjectProperty, unevaluatedPropertyValue);
return null;
return rootNameSpace + "." + unevaluatedPropertyValue;
}

public override async Task<string> OnGetEvaluatedPropertyValueAsync(string propertyName, string evaluatedPropertyValue, IProjectProperties defaultProperties)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public async Task<ICollection<IEnumValue>> GetListedValuesAsync()
}

// Remove My.MyApplication entry if any.
enumValues = enumValues.Where(ep => !ep.Name.Contains("My.MyApplication")).ToList();
enumValues.RemoveAll(ep => ep.Name.Contains("My.MyApplication"));

return enumValues;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
For VB projects, we expect to see every Form in the assembly directly or indirectly inherited from Form.
We specify this by setting the SearchForEntryPointsInFormsOnly to true.
We also want to ensure that the property always has a value. -->
<DynamicEnumProperty Name="StartupObjectVB"
<DynamicEnumProperty Name="StartupObject"
DisplayName="Startup object"
Description="Defines the entry point to be called when the application loads. Generally this is set either to the main form in your application or to the 'Main' procedure that should run when the application starts. Class libraries do not define an entry point."
Category="General"
Expand All @@ -48,9 +48,7 @@
<DynamicEnumProperty.Metadata>
<NameValuePair Name="VisibilityCondition">
<NameValuePair.Value>
(and
(is-vb)
(not (has-evaluated-value "Application" "OutputType" "Library")))
(not (has-evaluated-value "Application" "OutputType" "Library"))
</NameValuePair.Value>
</NameValuePair>
</DynamicEnumProperty.Metadata>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,7 @@
<DynamicEnumProperty.Metadata>
<NameValuePair Name="VisibilityCondition">
<NameValuePair.Value>
(and
(not (is-vb))
(not (has-evaluated-value "Application" "OutputType" "Library")))
(not (has-evaluated-value "Application" "OutputType" "Library"))
</NameValuePair.Value>
</NameValuePair>
</DynamicEnumProperty.Metadata>
Expand Down

0 comments on commit 01b9b81

Please sign in to comment.