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

Update staging with latest #1374

Merged
merged 9 commits into from
Nov 4, 2023
7 changes: 3 additions & 4 deletions build/AzurePipelineTemplates/CsWinRT-Variables.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
variables:
MajorVersion: 2
MinorVersion: 0
PatchVersion: 4
PatchVersion: 5
WinRT.Runtime.AssemblyVersion: '2.0.0.0'
Net5.SDK.Feed: 'https://dotnetcli.blob.core.windows.net/dotnet'
Net5.SDK.Version: '5.0.408'
Net6.SDK.Version: '6.0.413'
Net6.SDK.Version: '6.0.415'
NoSamples: 'false'

# This 'coalesce' pattern allows the yml to define a default value for a variable but allows the value to be overridden at queue time.
# E.g. '_IsRelease' defaults to empty string, but if 'IsRelease' is set at queue time that value will be used.

_IsRelease: $[coalesce(variables.IsRelease, '')]
_RunBenchmarks: $[coalesce(variables.RunBenchmarks, 'false')]
_DotNetRuntimeVersion: $[coalesce(variables.DotNetRuntimeVersion, '5.0.17')]
_DotNetRuntimeVersion: $[coalesce(variables.DotNetRuntimeVersion, '6.0.23')]
_WindowsSdkVersionSuffix: $[coalesce(variables.WindowsSdkPackageVersionSuffix, '25')]
_PublishCsWinMD: $[coalesce(variables.PublishCsWinMD, 'false')]
4 changes: 2 additions & 2 deletions src/build.cmd
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@echo off
if /i "%cswinrt_echo%" == "on" @echo on

set CsWinRTBuildNetSDKVersion=6.0.413
set CsWinRTBuildNet7SDKVersion=7.0.400
set CsWinRTBuildNetSDKVersion=6.0.415
set CsWinRTBuildNet7SDKVersion=7.0.402
set this_dir=%~dp0

:dotnet
Expand Down
82 changes: 58 additions & 24 deletions src/cswinrt/code_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -1867,7 +1867,7 @@ internal sealed class _%
private IObjectReference _obj;
public _%()
{
_obj = %(GuidGenerator.GetIID(typeof(%.%).GetHelperType()));
_obj = %(%.IID);
}

%
Expand All @@ -1877,8 +1877,7 @@ internal static % Instance => (%)_instance;
cache_type_name,
cache_type_name,
factoryAs,
class_type.TypeNamespace(),
cache_type_name,
bind<write_type_name>(class_type, typedef_name_type::StaticAbiClass, true),
instance,
cache_type_name,
cache_type_name);
Expand Down Expand Up @@ -2092,7 +2091,7 @@ private IObjectReference % => __% ?? Make__%();
private static volatile IObjectReference __%;
private static IObjectReference Make__%()
{
global::System.Threading.Interlocked.CompareExchange(ref __%, %As(GuidGenerator.GetIID(typeof(%).GetHelperType())), null);
global::System.Threading.Interlocked.CompareExchange(ref __%, %As(%.IID), null);
return __%;
}
private static IObjectReference % => __% ?? Make__%();
Expand All @@ -2102,7 +2101,7 @@ private static IObjectReference % => __% ?? Make__%();
objrefname,
objrefname,
target,
bind<write_type_name>(factory.type, typedef_name_type::Projected, false),
bind<write_type_name>(factory.type, typedef_name_type::StaticAbiClass, true),
objrefname,
objrefname,
objrefname,
Expand Down Expand Up @@ -4081,7 +4080,7 @@ private IObjectReference _obj;
private IntPtr ThisPtr => _obj.ThisPtr;
public _%()
{
_obj = ActivationFactory<%>.As(GuidGenerator.GetIID(typeof(%.%).GetHelperType()));
_obj = ActivationFactory<%>.As(%.IID);
}

private static _% _instance = new _%();
Expand All @@ -4092,8 +4091,7 @@ internal static _% Instance => _instance;
cache_type_name,
cache_type_name,
class_type.TypeName(),
class_type.TypeNamespace(),
cache_type_name,
bind<write_type_name>(factory_type, typedef_name_type::StaticAbiClass, true),
cache_type_name,
cache_type_name,
cache_type_name,
Expand Down Expand Up @@ -4675,6 +4673,39 @@ return eventSource.EventActions;
get<uint8_t>(get_arg(10)));
}

void write_guid_bytes(writer& w, TypeDef const& type)
{
auto attribute = get_attribute(type, "Windows.Foundation.Metadata", "GuidAttribute");
if (!attribute)
{
throw_invalid("'Windows.Foundation.Metadata.GuidAttribute' attribute for type '", type.TypeNamespace(), ".", type.TypeName(), "' not found");
}

auto args = attribute.Value().FixedArgs();

using std::get;

auto get_arg = [&](decltype(args)::size_type index) { return get<ElemSig>(args[index].value).value; };

w.write_printf(R"(0x%X, 0x%X, 0x%X, 0x%X, 0x%X, 0x%X, 0x%X, 0x%X, 0x%X, 0x%X, 0x%X, 0x%X, 0x%X, 0x%X, 0x%X, 0x%X)",
(get<uint32_t>(get_arg(0)) >> 0) & 0xFF,
(get<uint32_t>(get_arg(0)) >> 8) & 0xFF,
(get<uint32_t>(get_arg(0)) >> 16) & 0xFF,
(get<uint32_t>(get_arg(0)) >> 24) & 0xFF,
(get<uint16_t>(get_arg(1)) >> 0) & 0xFF,
(get<uint16_t>(get_arg(1)) >> 8) & 0xFF,
(get<uint16_t>(get_arg(2)) >> 0) & 0xFF,
(get<uint16_t>(get_arg(2)) >> 8) & 0xFF,
get<uint8_t>(get_arg(3)),
get<uint8_t>(get_arg(4)),
get<uint8_t>(get_arg(5)),
get<uint8_t>(get_arg(6)),
get<uint8_t>(get_arg(7)),
get<uint8_t>(get_arg(8)),
get<uint8_t>(get_arg(9)),
get<uint8_t>(get_arg(10)));
}

void write_type_inheritance(writer& w, TypeDef const& type, type_semantics base_semantics, bool add_custom_qi, bool include_exclusive_interface)
{
auto delimiter{ " : " };
Expand Down Expand Up @@ -6006,25 +6037,28 @@ public static Guid PIID = Vftbl.PIID;

w.write(R"(% static class %
{
internal static global::System.Guid IID { get; } = new Guid(new global::System.ReadOnlySpan<byte>(new byte[] { % }));

%
}
)",
(is_exclusive_to(iface) || is_projection_internal(iface)) ? "internal" : internal_accessibility(),
bind<write_type_name>(iface, typedef_name_type::StaticAbiClass, false),
[&](writer& w) {
if (!fast_abi_class_val.has_value() || (!fast_abi_class_val.value().contains_other_interface(iface) && !interfaces_equal(fast_abi_class_val.value().default_interface, iface))) {
write_static_abi_class_members(w, iface, INSPECTABLE_METHOD_COUNT);
return;
}
auto abi_methods_start_index = INSPECTABLE_METHOD_COUNT;
write_static_abi_class_members(w, fast_abi_class_val.value().default_interface, abi_methods_start_index);
abi_methods_start_index += distance(fast_abi_class_val.value().default_interface.MethodList()) + get_class_hierarchy_index(fast_abi_class_val.value().class_type);
for (auto&& other_iface : fast_abi_class_val.value().other_interfaces)
{
write_static_abi_class_members(w, other_iface, abi_methods_start_index);
abi_methods_start_index += distance(other_iface.MethodList());
}
});
(is_exclusive_to(iface) || is_projection_internal(iface)) ? "internal" : internal_accessibility(),
bind<write_type_name>(iface, typedef_name_type::StaticAbiClass, false),
bind<write_guid_bytes>(iface),
[&](writer& w) {
if (!fast_abi_class_val.has_value() || (!fast_abi_class_val.value().contains_other_interface(iface) && !interfaces_equal(fast_abi_class_val.value().default_interface, iface))) {
write_static_abi_class_members(w, iface, INSPECTABLE_METHOD_COUNT);
return;
}
auto abi_methods_start_index = INSPECTABLE_METHOD_COUNT;
write_static_abi_class_members(w, fast_abi_class_val.value().default_interface, abi_methods_start_index);
abi_methods_start_index += distance(fast_abi_class_val.value().default_interface.MethodList()) + get_class_hierarchy_index(fast_abi_class_val.value().class_type);
for (auto&& other_iface : fast_abi_class_val.value().other_interfaces)
{
write_static_abi_class_members(w, other_iface, abi_methods_start_index);
abi_methods_start_index += distance(other_iface.MethodList());
}
});
}

bool write_abi_interface(writer& w, TypeDef const& type)
Expand Down