98
Vote

Generics support for MF

description

Provide support for generics types for .NET MF.
This support is particularly necessary when porting small projects or libraries from the desktop, where re-working the code is not prohibitive but re-testing is delicate.
Having generics would allow to skip most of the testing altogether thus allowing true interoperability.
Furthermore a source code could be shared by adding an existing desktop source using "add as a link" in Visual Studio. The directives #define/#if can adjust the differences between MicroFramework and desktop implementations.
 
Real use case example: exchanging data between a balance and the MF device
  • write the source code for the desktop using the serial port
  • the collected data from the balance will use for example List<T> to provide more robustness
  • test the protocol implementation on the desktop
  • create a new library MF project
  • "add as link" the desktop source code in the MF project
  • add required #define and #if/#endif as required (for example to fix "using" namespaces definitions)

comments

staceyw wrote Mar 30, 2011 at 2:06 PM

+1. Doing things like simple ports for things like Rx or Linq ports loose of a lot of luster when having to resort to Object.

rogihee wrote Apr 14, 2011 at 6:35 PM

+1. I recently ported a project from desktop USB automotive device to embedded FEZ Cobra where I created a new micro project with "add as link" for the core "model". Not having generics for simple things as list<type> was the biggest hurdle to overcome.

juliusfriedman wrote Apr 20, 2012 at 12:02 PM

Also I just realized that similar to how you can use IL to allow mathematica operations across double and integer types by modifying the DLL after compilation you can probably utilize reflection and or some type of indirection to perform the same operations in the MF.

http://www.codeproject.com/Articles/33617/Arithmetic-in-Generic-Classes-in-C

http://stackoverflow.com/questions/1251507/is-it-possible-to-call-value-type-operators-via-reflection

If we can't have generics then possibly also the addition of the Dynamic Type would be helpful for these types of scenarios inter alia.

juliusfriedman wrote Apr 15, 2013 at 11:25 PM

This might be applicable for a way of thinking about generics if you know what your doing.

If we had use of the Emit class this would be almost implementable here on the Micro Fx.

http://www.codeproject.com/Articles/578116/Complete-Managed-Media-Aggregation-Part-III-Quantu

raffaeler wrote Apr 16, 2013 at 11:14 AM

The main point for my request is to ease porting code.
I can also write a code generator on desktop which starts from generic classes and create all the possible variants of the untyped classes, but it's tedious and not easy to mantain.

We are now in 2013 and the market offers Raspberry PI for ridiculous prices with a full OS. Microframework can still make sense but the support should absolutely be first-class, otherwise there is no story.

TomSpilman wrote Apr 21, 2013 at 7:37 PM

What is the status of this? I know that some work has happened to support generics, what happened to that?

dthorpe wrote Oct 13, 2013 at 9:45 AM

Need generics.

The sub-300kb MF system memory budget was admirable 5 years ago, but with $80 mainboards now shipping with 16MB of RAM the memory budget argument against generics no longer holds water. It's time to move the platform forward.