AdaGide Logo

A# support for .NET 2.0 generics


 

 

The 2.0 release of .NET includes generic classes and methods.  A sample generic class looks like the following in C#:

public class Dictionary<TKey,TValue> {

   public void Add(TKey key, TValue value);

}

 

In A#, msil2ada generates the following:

 

generic

   type TKey is private;

   type TValue is private;

package Dictionary is

   type Typ is tagged...

   procedure Add(This : in access Typ; key : TKey; value : TValue);

end Dictionary;

 

To instantiate it, you need to do a normal instantiation of the generic, but also specify an import:

 

package MyDictionary is new Dictionary(MSSyst.String.Ref, Integer);

pragma Import(MSIL, MyDictionary);

 

Generic methods are currently not supported.  MSIL2Ada does not automatically generate specifications for generic child classes with generic parents.