Skip to content

Add Context checks to factory caching and simplify factory caching between factories and statics.#1367

Closed
jlaanstra wants to merge 38 commits into
microsoft:masterfrom
jlaanstra:user/jlaans/1112-4
Closed

Add Context checks to factory caching and simplify factory caching between factories and statics.#1367
jlaanstra wants to merge 38 commits into
microsoft:masterfrom
jlaanstra:user/jlaans/1112-4

Conversation

@jlaanstra
Copy link
Copy Markdown
Collaborator

Alternative implementation that maintains static classes compared to #1359

@jlaanstra jlaanstra marked this pull request as ready for review October 21, 2023 05:54
Copy link
Copy Markdown
Member

@Sergio0694 Sergio0694 left a comment

Choose a reason for hiding this comment

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

Just leaving a couple more comments 😄

private static extern unsafe int CoGetContextToken(IntPtr* contextToken);

[DllImport("api-ms-win-core-com-l1-1-0.dll")]
private static extern int CoGetObjectContext(ref Guid riid, out IntPtr ppv);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same note as in the other PR, could you make this use a blittable signature while at it?

Comment thread src/cswinrt/strings/WinRT.cs Outdated
Copy link
Copy Markdown
Member

@Sergio0694 Sergio0694 left a comment

Choose a reason for hiding this comment

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

Left a few comments 🙂
Also, Q: I see you removed INativeGuid, is that just because it'll all be done in another PR?

Comment thread src/cswinrt/strings/WinRT.cs Outdated
Comment thread src/cswinrt/strings/WinRT.cs Outdated
#endif
public static ObjectReference<I> ActivateInstance<
#if NET
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.None)]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this actually needed? Isn't I already not annotated for any dynamic access in this context? 🤔

@@ -491,7 +568,8 @@ public BaseActivationFactory(string typeNamespace, string typeFullName)
public unsafe ObjectReference<I> _ActivateInstance<I>()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also double checking: I see you removed the [UnconditionalSuppressMessage] below. Is this one still needed or can it also be removed after the other changes you did?

Comment thread src/cswinrt/strings/WinRT.cs Outdated
%
internal static % Instance => _instance;
}
private static % _% = new %("%.%", %.IID);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this ever reassigned at runtime? If not, shouldn't this be readonly to improve codegen?

{
auto class_type_name = classType.TypeName();
w.write(R"(
private static BaseActivationFactory _%Factory = new BaseActivationFactory("%.%");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same for this one, shouldn't it be readonly, or could this ever be reassigned?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants