Skip to content

Commit

Permalink
Change Trimming to TrimMode. Set PublishTrimmed to true when setting …
Browse files Browse the repository at this point in the history
…TrimMode to full.
  • Loading branch information
melytc committed Oct 24, 2023
1 parent f7ce50b commit fe143ab
Show file tree
Hide file tree
Showing 16 changed files with 97 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

namespace Microsoft.VisualStudio.ProjectSystem.VS.Properties;

[ExportDynamicEnumValuesProvider("TrimmingEnumProvider")]
[ExportDynamicEnumValuesProvider("TrimModeEnumProvider")]
[AppliesTo(ProjectCapability.DotNet)]
internal class TrimmingEnumProvider : IDynamicEnumValuesProvider
internal class TrimModeEnumProvider : IDynamicEnumValuesProvider
{
public Task<IDynamicEnumValuesGenerator> GetProviderAsync(IList<NameValuePair>? options)
{
return Task.FromResult<IDynamicEnumValuesGenerator>(new TrimmingEnumGenerator());
return Task.FromResult<IDynamicEnumValuesGenerator>(new TrimModeEnumGenerator());
}

private class TrimmingEnumGenerator : IDynamicEnumValuesGenerator
private class TrimModeEnumGenerator : IDynamicEnumValuesGenerator
{
private static readonly List<IEnumValue> s_enumValues = new()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE.md file in the project root for more information.

using Microsoft.VisualStudio.ProjectSystem.Properties;

namespace Microsoft.VisualStudio.ProjectSystem.VS.Properties;

[ExportInterceptingPropertyValueProvider("TrimMode", ExportInterceptingPropertyValueProviderFile.ProjectFile)]
internal class TrimModeValueProvider : InterceptingPropertyValueProviderBase
{
public override async Task<string?> OnSetPropertyValueAsync(string propertyName, string unevaluatedPropertyValue, IProjectProperties defaultProperties, IReadOnlyDictionary<string, string>? dimensionalConditions = null)
{
// When setting the TrimMode, we also need to set the PublishTrimmed property to true.
if (string.Equals(unevaluatedPropertyValue, "full", StringComparison.OrdinalIgnoreCase))
{
await defaultProperties.SetPropertyValueAsync("PublishTrimmed", "true");
}
else
{
// If the user sets the TrimMode to anything other than full, set the PublishTrimmed property to false.
await defaultProperties.SetPropertyValueAsync("PublishTrimmed", "false");
}

return await base.OnSetPropertyValueAsync(propertyName, unevaluatedPropertyValue, defaultProperties, dimensionalConditions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -431,12 +431,12 @@
</EnumProperty>

<!-- These Native AOT properties should not be visible for class library projects. -->
<DynamicEnumProperty Name="Trimming"
DisplayName="Trimming"
<DynamicEnumProperty Name="TrimMode"
DisplayName="Trim mode"
Description="Select the desired .NET trimming option for optimizing your application's deployment size and performance."
HelpUrl="https://go.microsoft.com/fwlink/?linkid=2240879"
Category="Publish"
EnumProvider="TrimmingEnumProvider"
EnumProvider="TrimModeEnumProvider"
MultipleValuesAllowed="False">
<DynamicEnumProperty.DataSource>
<DataSource HasConfigurationCondition="False"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fe143ab

Please sign in to comment.