Skip to content

Clean up Pubternal Types in SignalR #11162

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

Merged
merged 15 commits into from
Jun 18, 2019
Merged

Conversation

mikaelm12
Copy link
Contributor

@mikaelm12 mikaelm12 commented Jun 12, 2019

Issue: #10169

Some things to note

  • ServerSentEventsMessageFormatter used in the Microbenchmark project but that causes a bunch of issues
  • HubOptionsSetup and HubOptionsSetup<T> is used in SignalRDependencyInjectionExtensions so Ieft those as pubternal. Didn't want to use internals visible to in this case. Should this just be public?

@mikaelm12 mikaelm12 added the area-signalr Includes: SignalR clients and servers label Jun 12, 2019
@halter73
Copy link
Member

I think HubOptionsSetup and HubOptionsSetup<T> should be public if they're referenced across shipped assemblies.

@halter73
Copy link
Member

The approval assumes HubOptionsSetup and HubOptionsSetup<T> are the last pubternal types and will be made public.

@mikaelm12
Copy link
Contributor Author

I agree about the HubOptions. The ServerSentEventsMessageFormatter is currently still pubternal because of the Microbenchmarking project. I still need to resolve that

@analogrelay
Copy link
Contributor

The ServerSentEventsMessageFormatter is currently still pubternal because of the Microbenchmarking project. I still need to resolve that

It seems OK to use InternalsVisibleTo there, does it not work? It turns out Arcade is the one that provides the InternalsVisibleTo MSBuild item and we do support it in AspNetCore. See https://github.com/aspnet/AspNetCore/blob/f28cf2bbc8e97a05be575a61af08f01edf0ac9c9/src/Middleware/HeaderPropagation/src/Microsoft.AspNetCore.HeaderPropagation.csproj#L12-L14

@analogrelay
Copy link
Contributor

  • HubOptionsSetup and HubOptionsSetup<T> is used in SignalRDependencyInjectionExtensions so Ieft those as pubternal.

Seems unfortunate but it would be pretty funky to refactor. We could put a method in ...SignalR.Core somewhere that takes an IServiceProvider and registers HubOptionsSetup in it, but that gets a bit messy. Make sure only the constructor (because DI requires public constructors) and interface implementations are public

@davidfowl
Copy link
Member

The ref assembly is the only way to review this change.

@mikaelm12
Copy link
Contributor Author

It seems OK to use InternalsVisibleTo there, does it not work?

I should have elaborated in the description. Just adding internals visible to doesn't doesn't quite solve the issue. It causes some ambiguous references to types like MemoryBufferWriter. That's the last thing I need to work through.

Copy link
Member

@BrennanConroy BrennanConroy left a comment

Choose a reason for hiding this comment

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

We should also try to switch to the new <InternalsVisibleTo> tag in .csproj's!

@mikaelm12 mikaelm12 force-pushed the mikaelm12/CleanPubternalTypes branch from 669e6a4 to 6ebe8c9 Compare June 13, 2019 21:55
@mikaelm12
Copy link
Contributor Author

Had to revert the change to use the InternalsVisibleTo msbuild tag because it doesn't work with Moq
Filed an issue with arcade: dotnet/arcade#3068

@mikaelm12
Copy link
Contributor Author

@aspnet-hello
Copy link

This comment was made automatically. If there is a problem contact [email protected].

I've triaged the above build. I've created/commented on the following issue(s)
https://github.com/aspnet/AspNetCore-Internal/issues/2303

@Pilchie
Copy link
Member

Pilchie commented Jun 18, 2019

Roslyn is able to use InternalsVisibleTo in MSBuild with Moq (see here)

@BrennanConroy
Copy link
Member

@mikaelm12
Copy link
Contributor Author

Ah okay, I'll try that out. Thanks!

@mikaelm12 mikaelm12 requested a review from halter73 June 18, 2019 16:43
new HubContext<THub>(lifetimeManager),
hubOptions,
globalHubOptions,
new Logger<DefaultHubDispatcher<THub>>(loggerFactory));
Copy link
Member

Choose a reason for hiding this comment

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

Wow this is kinda gross 😄

Copy link
Member

Choose a reason for hiding this comment

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

Should we also remove HubDispatcher from DI now that it's no longer used in DI?

Copy link
Member

@davidfowl davidfowl left a comment

Choose a reason for hiding this comment

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

I'll follow up with why ServerSentEventsMessageFormatter is public.

@mikaelm12 mikaelm12 merged commit 04c3192 into master Jun 18, 2019
@ghost ghost deleted the mikaelm12/CleanPubternalTypes branch June 18, 2019 17:32
@mikaelm12
Copy link
Contributor Author

Going to follow this up with another clean up pr for InternalsVisibleTo and SSEMessageFormatter

@parkycai
Copy link

parkycai commented Aug 2, 2019

Is there a new way to implement custom HubDispatcher and inject it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-signalr Includes: SignalR clients and servers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants