From 9b8764ec32ebbee4aed5246e3dfc15b280007ad7 Mon Sep 17 00:00:00 2001 From: Joshua Larkin <70237359+j0shuams@users.noreply.github.com> Date: Tue, 10 May 2022 19:01:21 -0700 Subject: [PATCH] Add public option to embedded support for enums (#1187) * Add option to generate enums as public with embedded option --- nuget/Microsoft.Windows.CsWinRT.targets | 2 ++ .../TestEmbedded/TestEmbeddedLibrary/TestEmbeddedLibrary.csproj | 2 ++ src/cswinrt/code_writers.h | 2 +- src/cswinrt/main.cpp | 2 ++ src/cswinrt/settings.h | 1 + 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/nuget/Microsoft.Windows.CsWinRT.targets b/nuget/Microsoft.Windows.CsWinRT.targets index 2de8d08cf..654b87753 100644 --- a/nuget/Microsoft.Windows.CsWinRT.targets +++ b/nuget/Microsoft.Windows.CsWinRT.targets @@ -140,6 +140,7 @@ Copyright (C) Microsoft Corporation. All rights reserved. -internal -embedded + -public_enums net5.0 net6.0 netstandard2.0 @@ -153,6 +154,7 @@ $(CsWinRTWindowsMetadataInput) $(CsWinRTFilters) $(CsWinRTIncludeWinRTInterop) $(CsWinRTEmbeddedProjection) +$(CsWinRTEmbeddedEnums) diff --git a/src/Samples/TestEmbedded/TestEmbeddedLibrary/TestEmbeddedLibrary.csproj b/src/Samples/TestEmbedded/TestEmbeddedLibrary/TestEmbeddedLibrary.csproj index ea19698c8..864ae677b 100644 --- a/src/Samples/TestEmbedded/TestEmbeddedLibrary/TestEmbeddedLibrary.csproj +++ b/src/Samples/TestEmbedded/TestEmbeddedLibrary/TestEmbeddedLibrary.csproj @@ -11,6 +11,8 @@ 10.0.19041.0 true true + diff --git a/src/cswinrt/code_writers.h b/src/cswinrt/code_writers.h index 06d225a10..ce770fadb 100644 --- a/src/cswinrt/code_writers.h +++ b/src/cswinrt/code_writers.h @@ -7024,7 +7024,7 @@ global::WinRT.ComWrappersSupport.FindObject<%>(%).Invoke(%) )", bind(type), bind(type, true), - internal_accessibility(), + (settings.internal || settings.embedded) ? (settings.public_enums ? "public" : "internal") : "public", bind(type, typedef_name_type::Projected, false), enum_underlying_type); { for (auto&& field : type.FieldList()) diff --git a/src/cswinrt/main.cpp b/src/cswinrt/main.cpp index 109ca6add..345663a12 100644 --- a/src/cswinrt/main.cpp +++ b/src/cswinrt/main.cpp @@ -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, {}, {} }, }; @@ -97,6 +98,7 @@ Where 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")) diff --git a/src/cswinrt/settings.h b/src/cswinrt/settings.h index 44783a145..978bfacd8 100644 --- a/src/cswinrt/settings.h +++ b/src/cswinrt/settings.h @@ -14,6 +14,7 @@ namespace cswinrt bool component{}; bool internal{}; bool embedded{}; + bool public_enums{}; }; extern settings_type settings;