Ambiguous method: ToHashSet (Linq vs Sirenix.Utilities)

Issue #794 resolved
Gustave Leibbrandt created an issue
  1. What happened?

    1. Get an error message: CS0121: The call is ambiguous between the following methods or properties: 'Sirenix.Utilities.LinqExtensions.ToHashSet<T>(System.Collections.Generic.IEnumerable<T>)' and 'System.Linq.Enumerable.ToHashSet<TSource>(System.Collections.Generic.IEnumerable<TSource>)'
  2. How can we reproduce it?

    1. ```csharp using System; using System.Collections.Generic; using System.Linq; using Sirenix.Utilities;

      static HashSet<Type> scriptableObjectTypes = AssemblyUtilities.GetTypes(AssemblyTypeFlags.CustomTypes) .Where(t => t.IsClass && typeof(ScriptableObject).IsAssignableFrom(t) && !typeof(EditorWindow).IsAssignableFrom(t) && !typeof(Editor).IsAssignableFrom(t)) .ToHashSet(); ```

  3. What version of Unity are you using?

    1. 2021.2.0b6
  4. What version of Odin are you using? (See "Tools > Odin Inspector > About")

    1. 3.0.7
  5. Do you have Editor Only mode enabled?

    1. No
  6. What operating system are you on?

    1. macOs 10.15.7

Comments (2)

  1. Antonio Rafael Antunes Miranda

    You can use aliases for the Sirenix.Utilities types:

    using AssemblyUtilities = Sirenix.Utilities.AssemblyUtilities;
    using AssemblyTypeFlags = Sirenix.Utilities.AssemblyTypeFlags;
    

    And then remove the Sirenix.Utilities using directive

  2. Log in to comment