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

Fix .NET Standard authoring support #1632

Merged
merged 2 commits into from
Jun 5, 2024
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
12 changes: 6 additions & 6 deletions src/cswinrt/code_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -3597,21 +3597,21 @@ private % AsInternal(InterfaceTag<%> _) => % ?? Make_%();
// generate the attribute on the Impl namespace metadata classes using the
// source generator rather than here as it allows us to better handle
// covariant interfaces. But for factory classes, we generate them here.
bool should_write_winrt_exposed_type_attribute(TypeDef const& type)
bool should_write_winrt_exposed_type_attribute(TypeDef const& type, bool isFactory)
{
if (settings.netstandard_compat)
{
return false;
}

// TODO: how to handle generic delegates
return get_category(type) == category::struct_type ||
return isFactory ||
get_category(type) == category::struct_type ||
(get_category(type) == category::delegate_type && distance(type.GenericParam()) == 0);
}

void write_winrt_exposed_type_attribute(writer& w, TypeDef const& type, bool isFactory)
{
if (should_write_winrt_exposed_type_attribute(type) || isFactory)
if (should_write_winrt_exposed_type_attribute(type, isFactory))
{
if (get_category(type) == category::struct_type)
{
Expand All @@ -3630,7 +3630,7 @@ private % AsInternal(InterfaceTag<%> _) => % ?? Make_%();

void write_winrt_exposed_type_class(writer& w, TypeDef const& type, bool isFactory)
{
if (should_write_winrt_exposed_type_attribute(type) || isFactory)
if (should_write_winrt_exposed_type_attribute(type, isFactory))
{
if (get_category(type) == category::class_type && isFactory)
{
Expand Down Expand Up @@ -10057,7 +10057,7 @@ bind_list<write_parameter_name_with_modifier>(", ", signature.params())

w.write(R"(
%
internal sealed class % : IActivationFactory%
internal sealed class % : global::WinRT.Interop.IActivationFactory%
{

static %()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,14 +300,10 @@ sealed class AsyncInfoToTaskBridge<TResult, TProgress> : TaskCompletionSource<TR

internal AsyncInfoToTaskBridge(IAsyncInfo asyncInfo, CancellationToken cancellationToken)
{
#if NET
ArgumentNullException.ThrowIfNull(asyncInfo);
#else
if (asyncInfo == null)
{
throw new ArgumentNullException(nameof(asyncInfo));
}
#endif

this._ct = cancellationToken;
if (this._ct.CanBeCanceled)
Expand Down
Loading