106
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.

wrote Mar 31, 2011 at 5:00 PM

wrote Apr 11, 2011 at 1:41 PM

wrote Apr 14, 2011 at 6:27 PM

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.

wrote Apr 16, 2011 at 10:37 PM

wrote Apr 25, 2011 at 4:33 PM

wrote Apr 25, 2011 at 8:27 PM

wrote May 2, 2011 at 6:53 PM

wrote May 14, 2011 at 2:34 PM

wrote Jun 28, 2011 at 12:57 AM

wrote Jul 13, 2011 at 11:36 AM

wrote Jul 21, 2011 at 12:33 PM

wrote Aug 1, 2011 at 8:55 PM

wrote Aug 7, 2011 at 1:55 AM

wrote Aug 13, 2011 at 9:46 AM

wrote Sep 2, 2011 at 11:14 PM

wrote Sep 5, 2011 at 6:43 AM

wrote Sep 5, 2011 at 11:00 AM

wrote Sep 7, 2011 at 6:02 AM

wrote Sep 8, 2011 at 7:14 AM

wrote Oct 20, 2011 at 8:36 PM

wrote Nov 7, 2011 at 8:39 PM

wrote Nov 19, 2011 at 8:11 PM

wrote Dec 2, 2011 at 3:36 AM

wrote Dec 8, 2011 at 1:40 AM

wrote Jan 7, 2012 at 9:58 AM

wrote Jan 13, 2012 at 11:39 AM

wrote Jan 15, 2012 at 8:19 AM

wrote Jan 18, 2012 at 11:06 AM

wrote Jan 24, 2012 at 8:19 PM

wrote Feb 3, 2012 at 8:58 PM

wrote Feb 5, 2012 at 5:48 AM

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.

wrote May 28, 2012 at 8:52 PM

wrote Jun 14, 2012 at 12:56 AM

wrote Jun 25, 2012 at 9:23 PM

wrote Jul 2, 2012 at 3:01 PM

wrote Jul 10, 2012 at 11:04 PM

wrote Jul 21, 2012 at 3:05 AM

wrote Aug 5, 2012 at 2:19 AM

wrote Aug 22, 2012 at 10:37 AM

wrote Aug 28, 2012 at 1:06 PM

wrote Sep 2, 2012 at 2:37 PM

wrote Sep 30, 2012 at 11:07 AM

wrote Oct 11, 2012 at 8:43 PM

wrote Nov 5, 2012 at 4:58 AM

wrote Nov 29, 2012 at 10:51 PM

wrote Dec 23, 2012 at 9:08 PM

wrote Dec 27, 2012 at 10:07 PM

wrote Jan 5, 2013 at 6:48 AM

wrote Jan 19, 2013 at 8:40 PM

wrote Feb 6, 2013 at 3:58 PM

wrote Feb 12, 2013 at 3:16 PM

wrote Feb 19, 2013 at 6:23 PM

wrote Feb 22, 2013 at 12:46 AM

wrote Mar 3, 2013 at 9:28 AM

wrote Mar 7, 2013 at 1:34 PM

wrote Mar 8, 2013 at 5:42 AM

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?

wrote May 26, 2013 at 8:55 PM

wrote Jul 5, 2013 at 8:23 PM

wrote Jul 26, 2013 at 4:02 AM

wrote Aug 1, 2013 at 6:27 PM

wrote Aug 3, 2013 at 12:46 PM

wrote Sep 27, 2013 at 4:58 AM

wrote Oct 13, 2013 at 9:22 AM

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.

wrote Oct 13, 2013 at 2:18 PM

wrote Oct 16, 2013 at 4:27 PM

wrote Nov 3, 2013 at 12:51 PM

wrote Nov 7, 2013 at 9:33 PM

wrote Nov 12, 2013 at 4:36 PM

wrote Nov 16, 2013 at 1:11 PM

wrote Dec 16, 2013 at 6:33 AM

wrote Jan 8, 2014 at 7:27 PM

wrote Jan 22, 2014 at 9:57 PM

wrote Feb 8, 2014 at 12:20 PM

wrote Feb 13, 2014 at 6:28 AM

wrote Feb 26, 2014 at 5:03 AM

wrote Mar 6, 2014 at 5:53 PM

wrote Mar 10, 2014 at 7:59 AM

wrote Jun 17, 2014 at 1:57 PM

wrote Jul 7, 2014 at 5:19 AM

wrote Sep 27, 2014 at 9:00 PM

mikeorb wrote Oct 2, 2014 at 11:01 PM

Generics please! I have very large API with generics throughout, beyond collections. Using generics in base classes, for example. I cannot use NETMF because of this limitation.

raffaeler wrote Oct 3, 2014 at 7:28 AM

mikeorb, I suggest you to use Mono on Raspberry Pi.
It's a very cheap hardware where mono give you full support of the .NET Framework 4.5 ... even the asynchronous task management and the full asp.net/owin stack where you can host a full-featured self-hosted WebApi service.

juliusfriedman wrote Oct 4, 2014 at 1:44 PM

Its not that difficult to add generics, or something like emit.

I would volunteer to add it but im working on a media library full time, after that I would be happy to improve regex and implement generics and possibly something like emit.

raffaeler wrote Oct 4, 2014 at 2:22 PM

Let's face to reality and compare the hw price and power, then .net language and library completeness, ... there is no competition.
Nowdays the gap is huge.

juliusfriedman wrote Oct 4, 2014 at 2:39 PM

Depends on where your coming from or going to, there is always competition especially when you consider the form factor and requirements for the platform.

More power isn't always the solution especially when it has to fit in something like a watch.

raffaeler wrote Oct 4, 2014 at 3:14 PM

I don't get your point.
Smartwatches already run super-powered CPUs with full featured operating systems.
For example Moto360 use ARM A8 (TI based chipset > 600MHz) with Linux/Android.

I loved Microframework. I wrote the first article on the microframework blog and opened this thread.
But let's face to reality, that time has gone. Hardware is better in price and power.
Small microcontrollers (like PIC, Atmel and Arduino) still make sense because you have the power of real-time processing over the microsecond but higher abstractions can use exactly the same resources of a PC with the big advantage of portability, testing and faster prototyping.

JanKucera wrote Oct 4, 2014 at 6:47 PM

Is anybody after the generics benefits actually? Because everybody so far seems to be concerned about code compatibility/reusability, in which case generics by syntactic sugar would do.

wrote Nov 10, 2014 at 1:11 PM

wrote Nov 26, 2014 at 8:32 AM

wrote Dec 4, 2014 at 2:14 PM

wrote Jan 18 at 5:50 PM

wrote Feb 20 at 7:45 AM