Skip to content
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 public option to embedded support for enums #1187

Merged
merged 6 commits into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions nuget/Microsoft.Windows.CsWinRT.targets
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ Copyright (C) Microsoft Corporation. All rights reserved.

<CsWinRTInternalProjection Condition="'$(CsWinRTPrivateProjection)' == 'true'">-internal</CsWinRTInternalProjection>
<CsWinRTEmbeddedProjection Condition="'$(CsWinRTEmbedded)' == 'true'">-embedded</CsWinRTEmbeddedProjection>
<CsWinRTEmbeddedEnums Condition="'$(CsWinRTEmbeddedPublicEnums)' == 'true'">-public_enums</CsWinRTEmbeddedEnums>
<CsWinRTExeTFM Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) == 5">net5.0</CsWinRTExeTFM>
<CsWinRTExeTFM Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) > 5">net6.0</CsWinRTExeTFM>
<CsWinRTExeTFM Condition="'$(CsWinRTExeTFM)' == ''">netstandard2.0</CsWinRTExeTFM>
Expand All @@ -153,6 +154,7 @@ $(CsWinRTWindowsMetadataInput)
$(CsWinRTFilters)
$(CsWinRTIncludeWinRTInterop)
$(CsWinRTEmbeddedProjection)
$(CsWinRTEmbeddedEnums)
</CsWinRTParams>

<CsWinRTPrivateParams Condition="'$(CsWinRTPrivateParams)' == ''">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<CsWinRTWindowsMetadata>10.0.19041.0</CsWinRTWindowsMetadata>
<SimulateCsWinRTNugetReference>true</SimulateCsWinRTNugetReference>
<CsWinRTGenerateProjection>true</CsWinRTGenerateProjection>
<!-- Will expose enums as public in the projection
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want a test or something for this option?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to leave testing this particular case to manual testing. We'd need another library for the different projection, plus the bells and whistles. I think the impact of these changes is low enough to not warrant such additional testing infrastructure.

<CsWinRTEmbeddedPublicEnums>true</CsWinRTEmbeddedPublicEnums> -->
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/cswinrt/code_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -7024,7 +7024,7 @@ global::WinRT.ComWrappersSupport.FindObject<%>(%).Invoke(%)
)",
bind<write_winrt_attribute>(type),
bind<write_type_custom_attributes>(type, true),
internal_accessibility(),
(settings.internal || settings.embedded) ? (settings.public_enums ? "public" : "internal") : "public",
bind<write_type_name>(type, typedef_name_type::Projected, false), enum_underlying_type);
{
for (auto&& field : type.FieldList())
Expand Down
2 changes: 2 additions & 0 deletions src/cswinrt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace cswinrt
{ "verbose", 0, 0, {}, "Show detailed progress information" },
{ "internal", 0, 0, {}, "Generates a private projection."},
{ "embedded", 0, 0, {}, "Generates an embedded projection."},
{ "public_enums", 0, 0, {}, "Used with embedded option to generate enums as public"},
{ "help", 0, option::no_max, {}, "Show detailed help" },
{ "?", 0, option::no_max, {}, {} },
};
Expand Down Expand Up @@ -97,6 +98,7 @@ Where <spec> is one or more of:
settings.component = args.exists("component");
settings.internal = args.exists("internal");
settings.embedded = args.exists("embedded");
settings.public_enums = args.exists("public_enums");
settings.input = args.files("input", database::is_database);

for (auto && include : args.values("include"))
Expand Down
1 change: 1 addition & 0 deletions src/cswinrt/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace cswinrt
bool component{};
bool internal{};
bool embedded{};
bool public_enums{};
};

extern settings_type settings;
Expand Down