Skip to content

Conversation

@eerhardt
Copy link
Member

GetTypeInfo() calls are no longer necessary just to use Reflection APIs. And typically they allocate a small TypeDelegator object when used, so they should be avoided when not necessary.

I removed the obvious cases from the product, and a few occurrences in test code. However, I didn't tackle every place test code was calling it as there is a diminishing return.

Similar work is done in dotnet/runtime:

foreach (var constructor in instanceType.GetConstructors())
{
if (!constructor.IsStatic && constructor.IsPublic)
if (!constructor.IsStatic)
Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Hmmmm when?

Copy link
Member

Choose a reason for hiding this comment

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

Is constructor.IsPublic implied? Or does this change ActivatorUtilities.CreateInstance to use non-public ctors? If it's the latter, this seems like a fairly major breaking change.

Copy link
Member

Choose a reason for hiding this comment

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

Previous conversation about this: https://github.com/dotnet/runtime/pull/40227/files#r463897549
TLDR: GetConstructors returns only public constructors

Copy link
Member Author

Choose a reason for hiding this comment

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

Just looked again, it also only returns Instance constructors, so we could remove the IsStatic check from both copies (runtime and aspnetcore) of this code.

https://github.com/dotnet/runtime/blob/1821d9c14b970d58e0768256de138b6c0287e07d/src/libraries/System.Private.CoreLib/src/System/Type.cs#L175-L178

@Pilchie Pilchie added area-blazor Includes: Blazor, Razor Components area-dataprotection Includes: DataProtection area-hosting area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels Nov 19, 2020
@Pilchie
Copy link
Member

Pilchie commented Nov 19, 2020

Throwing a bunch of areas on for people to take a look.

@Tratcher
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@halter73 halter73 merged commit d7187b0 into dotnet:master Nov 25, 2020
@eerhardt eerhardt deleted the RemoveGetTypeInfo branch November 30, 2020 16:29
@amcasey amcasey added area-hosting Includes Hosting area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-blazor Includes: Blazor, Razor Components area-dataprotection Includes: DataProtection area-hosting Includes Hosting area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants