Skip to content

Commit d40bee5

Browse files
committed
Bug fixes to embedded mode
1 parent 4a42758 commit d40bee5

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

components/DependencyPropertyGenerator/CommunityToolkit.DependencyPropertyGenerator.SourceGenerators/EmbeddedResources/GeneratedDependencyProperty.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// The .NET Foundation licenses this file to you under the MIT license.
77
// See the LICENSE file in the project root for more information.
88

9-
#if GENERATED_DEPENDENCY_PROPERTY_PRIVATE_ASSETS_ALL_MODE
9+
#if GENERATED_DEPENDENCY_PROPERTY_EMBEDDED_MODE
1010

1111
namespace CommunityToolkit.WinUI
1212
{

components/DependencyPropertyGenerator/CommunityToolkit.DependencyPropertyGenerator.SourceGenerators/EmbeddedResources/GeneratedDependencyPropertyAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// The .NET Foundation licenses this file to you under the MIT license.
77
// See the LICENSE file in the project root for more information.
88

9-
#if GENERATED_DEPENDENCY_PROPERTY_PRIVATE_ASSETS_ALL_MODE
9+
#if GENERATED_DEPENDENCY_PROPERTY_ATTRIBUTE_EMBEDDED_MODE
1010

1111
namespace CommunityToolkit.WinUI
1212
{

components/DependencyPropertyGenerator/src/CommunityToolkit.WinUI.DependencyPropertyGenerator.targets

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,29 @@
77
<DependencyPropertyGeneratorUseWindowsUIXaml Condition="'$(DependencyPropertyGeneratorUseWindowsUIXaml)' == '' AND '$(UseUwp)' != 'true'">false<DependencyPropertyGeneratorUseWindowsUIXaml>
88
</PropertyGroup>
99

10+
<!-- Properties for the embedded mode, with defaults -->
11+
<PropertyGroup>
12+
<EnableGeneratedDependencyPropertyAttributeEmbeddedMode Condition="'$(EnableGeneratedDependencyPropertyAttributeEmbeddedMode)' == ''">false</EnableGeneratedDependencyPropertyAttributeEmbeddedMode>
13+
<EnableGeneratedDependencyPropertyEmbeddedMode Condition="'$(EnableGeneratedDependencyPropertyEmbeddedMode)' == ''">false</EnableGeneratedDependencyPropertyEmbeddedMode>
14+
</PropertyGroup>
15+
1016
<!-- Allow the source generators to detect the selected XAML mode -->
1117
<ItemGroup>
1218
<CompilerVisibleProperty Include="DependencyPropertyGeneratorUseWindowsUIXaml" />
1319
</ItemGroup>
1420

15-
<!-- Define the 'GENERATED_DEPENDENCY_PROPERTY_USE_WINDOWS_UI_XAML' name, if needed -->
16-
<PropertyGroup Condition="'$(EnableGeneratedDependencyPropertyEmbeddedMode)' == 'true' AND '$(DependencyPropertyGeneratorUseWindowsUIXaml)' == 'true'">
17-
<DefineConstants>$(DefineConstants);GENERATED_DEPENDENCY_PROPERTY_USE_WINDOWS_UI_XAML</DefineConstants>
21+
<!-- Define the build constants depending on the current configuration -->
22+
<PropertyGroup>
23+
<DefineConstants Condition="'$(DependencyPropertyGeneratorUseWindowsUIXaml)' == 'true'">$(DefineConstants);GENERATED_DEPENDENCY_PROPERTY_USE_WINDOWS_UI_XAML</DefineConstants>
24+
<DefineConstants Condition="'$(EnableGeneratedDependencyPropertyAttributeEmbeddedMode)' == 'true'">$(DefineConstants);GENERATED_DEPENDENCY_PROPERTY_ATTRIBUTE_EMBEDDED_MODE</DefineConstants>
25+
<DefineConstants Condition="'$(EnableGeneratedDependencyPropertyEmbeddedMode)' == 'true'">$(DefineConstants);GENERATED_DEPENDENCY_PROPERTY_EMBEDDED_MODE</DefineConstants>
1826
</PropertyGroup>
1927

2028
<!-- Emit additional messages for invalid configurations when referencing the runtime library -->
2129
<Target Name="CommunityToolkitGeneratedDependencyPropertyCheckForInvalidEmbeddedMode"
2230
DependsOnTargets="ResolveAssemblyReferences"
2331
BeforeTargets="CoreCompile"
24-
Condition="'$(EnableGeneratedDependencyPropertyEmbeddedMode)' == 'true'">
32+
Condition="'$(EnableGeneratedDependencyPropertyAttributeEmbeddedMode)' == 'true' OR '$(EnableGeneratedDependencyPropertyEmbeddedMode)' == 'true'">
2533
<ItemGroup>
2634
<CommunityToolkitGeneratedDependencyPropertyUwpDllReferencePath Include="@(ReferencePath)" Condition="'%(Filename)%(Extension)' == 'CommunityToolkit.Uwp.GeneratedDependencyProperty.dll'" />
2735
<CommunityToolkitGeneratedDependencyPropertyWinUIDllReferencePath Include="@(ReferencePath)" Condition="'%(Filename)%(Extension)' == 'CommunityToolkit.WinUI.GeneratedDependencyProperty.dll'" />
@@ -36,7 +44,7 @@
3644
<Error Condition="'$(CommunityToolkitGeneratedDependencyPropertyDllReferenced)' == 'true'"
3745
Code="WCTDPCFG0001"
3846
HelpLink="https://aka.ms/toolkit/labs/windows"
39-
Text="This project is referencing the '[GeneratedDependencyProperty]' .dll file, but it's also setting 'EnableGeneratedDependencyPropertyEmbeddedMode'. The embedded mode can only be used when the .dll file is not being referenced. Make sure to use 'PrivateAssets=&quot;all&quot;' and 'ExcludeAssets=&quot;lib&quot;' in the '&lt;PackageReference&gt;' element for the NuGet package." />
47+
Text="This project is referencing the '[GeneratedDependencyProperty]' .dll file, but it's also enabling the embedded mode for its public APIs. The embedded mode can only be used when the .dll file is not being referenced. Make sure to use 'PrivateAssets=&quot;all&quot;' and 'ExcludeAssets=&quot;lib&quot;' in the '&lt;PackageReference&gt;' element for the NuGet package." />
4048
</Target>
4149

4250
<!-- Check the Roslyn version and warn if it's not high enough (we don't need to remove the analyzers, as they're leveraging multi-targeting) -->

0 commit comments

Comments
 (0)