Skip to content

Uno.Extensions.Navigation.UI semantics around thread safety, loaded assemblies #2943

Description

@jonpryor

While working on #2899 -- and trying to address the trimmer errors (^H "warnings"), I encountered RouteResolverDefault.cs and had concerns.

Firstly, thread safety:

public static IList<string> Excludes { get; } = new List<string>();

Generally, static members should be thread safe. AssemblyExtensions.Excludes is not: it's a List<string>, modifiable from AssemblyExtensions.SafeGetTypes(). If multiple threads try to use .SafeGetTypes() concurrently, .Excludes may be corrupted or the code may throw unexpectedly. Or RouteResolverDefault.LoadedTypes may throw if another thread modifies AssemblyExtensions.Excludes while it's executing.

Secondly, assembly loading semantics: RouteResolverDefault.LoadedTypes calls AppDomain.CurrentDomain.GetAssemblies() the first time it's invoked, saving the results. This seems somewhat "odd", in that nothing prevents assemblies from being loaded after the initial .LoadedTypes call, a'la:

  1. App launches
  2. App uses RouteResolverDefault.LoadedTypes, set of types is cached.
  3. App uses Assembly.Load*() to load a new assembly.
  4. Subsequent use of RouteResolverDefault.LoadedTypes doesn't see types from (3).

Is this a problem?

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions