Conflict with DotNet compatibility library and Unity editor mode

Hi guys,

Since my game use some classes which only existed in dotNet3.5 (or 4.0) but unity doest not support it, so I wrote some compatibility classes(using the same class name and namespace).

For instance:

Unity does not support ISet and HashSet (ISet is doNet4.0, HashSet doest not support mobile), so I write some code in unity like this:

//DotNetCompatibility.cs

namespace System.Collections.Generic

{

public interface ISet<T> : ICollection<T>
{
    new bool Add(T item);
    void ExceptWith(IEnumerable<T> other);
    //...
}

public class HashSet<T> : ISet<T>, ISerializable, IDeserializationCallback
{
    //...
}

}

Now I could use ISet and HashSet in Unity normally. (why no compile errors?)

If some times unity update dotNet library version, I will remove these class easily and dont modify other codes.

The Problem is:
When I use ISet and HashSet in edit mode (eg: use Unity Test Tools), a compile error occured: The imported type System.Collections.Generic.HashSet1’ is defined multiple times

What happened?

How unity interact with runtime mode and editor mode?

Using dotNet compatibility class is a bad idea? Or said: encapsulate the same name/namespace class (eg: Tuple) which pure only in dotNet4 is good idea because unity self never use them, but encapsulate the same name/namespace class in dotNet3.5 is bad idea, because unity editmode may use them?

How to resolve this problem?

Very thanks.

Unity3D has HashSet. I use it all the time. I use it in Asset Store products. I test on mobiles. For some reason ISet is not there, however, so you don’t have a thin interface for sets. Your refs will need to be HashSet, ICollection or IEnumerable or something.