Skip to content

Commit

Permalink
Remove Routing with a Fully Qualified Type name
Browse files Browse the repository at this point in the history
This behavior is not trim-compatible, since it just a random string "route name" and calls Type.GetType with it, and then Activator.CreateInstance. The trimmer might have removed the whole type, or even the constructor on the Type. This would cause a trimmed application to behave differently than an untrimmed application.

I do not know of anyone who relies on this behavior, and there are no tests for it. So removing it seems like the best path forward.

Contributes to dotnet#1962
  • Loading branch information
eerhardt committed Mar 3, 2022
1 parent a7b8329 commit 04e10fb
Showing 1 changed file with 0 additions and 17 deletions.
17 changes: 0 additions & 17 deletions src/Controls/src/Core/Routing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,23 +142,6 @@ public static Element GetOrCreateContent(string route, IServiceProvider services
if (s_routes.TryGetValue(route, out var content))
result = content.GetOrCreate(services);

if (result == null)
{
// okay maybe its a type, we'll try that just to be nice to the user
var type = Type.GetType(route);
if (type != null)
{
if (services != null)
{
result = (services.GetService(type) ?? Activator.CreateInstance(type)) as Element;
}
else
{
result = Activator.CreateInstance(type) as Element;
}
}
}

if (result != null)
SetRoute(result, route);

Expand Down

0 comments on commit 04e10fb

Please sign in to comment.