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 Context checks to factory caching and simplify factory caching between factories and statics. #1367

Closed
wants to merge 38 commits into from

Conversation

jlaanstra
Copy link
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
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 😄

{
[DllImport("api-ms-win-core-com-l1-1-0.dll")]
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
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?

src/cswinrt/strings/WinRT.cs Outdated Show resolved Hide resolved
Copy link
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?

src/cswinrt/strings/WinRT.cs Outdated Show resolved Hide resolved
src/cswinrt/strings/WinRT.cs Outdated Show resolved Hide resolved
#if NET
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2091:RequiresUnreferencedCode",
Justification = "No members of the generic type are dynamically accessed in this code path.")]
#endif
public static ObjectReference<I> ActivateInstance<
#if NET
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.None)]
Copy link
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
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?

%
internal static % Instance => _instance;
}
private static % _% = new %("%.%", %.IID);
Copy link
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
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