Skip to content

Support for generics <T> #782

Open
nanoframework/nf-interpreter
#3137

Description

@josesimoes

nanoFramework area: (CLR)

Work was started to on adding support for generics.
Considering that this is a work intensive effort, we are currently seeking financial sponsors to resume the work on this.
If you're a commercial user in need for this feature please reach out to to the Core Team. Keep in mind that all this it's a combined and community effort. Several small contributions can add up and bring in a huge impact!

https://docs.nanoframework.net/content/contributing/index.html

Workload breakdown:

  • CLR
  • Type System
  • Interpreter
  • Debugger Library (partial work)
  • Metadata processor (partial work)
  • Support in Visual Studio debugger engine

Fw size comparison:
ST_STM32F769I_DISCOVERY: 602460 -> 619932 bytes (+4440 / ~3%)
ESP32_PSRAM_REV0: 1245456 -> 1271312 bytes (+25856 / ~2%)
ESP32_S3_ALL 1362416 -> 1388416 bytes (+2600 / ~2%)

Activity

  1. self-assigned this
    on Jun 23, 2021
  2. pinned this issue on Jun 23, 2021
  3. changed the title [-]Support for generics T<>[/-] [+]Support for generics `Generic<T>`[/+] on Jun 23, 2021
  4. changed the title [-]Support for generics `Generic<T>`[/-] [+]Support for generics <T>[/+] on Jun 23, 2021
  5. stale commented on Aug 22, 2021

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

  6. added
    stale
    on Aug 22, 2021
  7. added
    📌 pinned
    and removed
    stale
    on Sep 19, 2021
  8. 11 remaining items

  9. josesimoes commented on Feb 7, 2022

    @josesimoes
    MemberAuthor

    The same applies. .NET nanoFramework mscorlib (along with the other libs that "mirror" .NET) are aligned with the full framework as much as possible. The exceptions are, obviously, the lack of generics and all that goes in tow like async/await, etc.
    When generics become available the "alignment" will be worked on.

  10. t9mike commented on Feb 8, 2022

    @t9mike

    Any estimate on funding required? What about a Gofundme? Get some heavy hitters in the .NET world to help spread the word (I could hit up one). I think a lot of C# fans would throw in some $ as they like the idea of improvement in this area even if they are not embedded developers or hobbyists.

    @Ellerbach said "still a long road to go" but 5 of 6 tasks are complete. Is that final task super challenging?

  11. Ellerbach commented on Feb 9, 2022

    @Ellerbach
    Member

    Hi @t9mike,
    It’s hard to estimate how much funding is required but we are speaking in units of 10K€, most likely 40K€+. Even if you see checked boxes, there is still quite some things to do. A checkbox in this context means: the minimum to see if it’s working is done. It doesn’t mean, it’s production code quality ready with all the tests. As soon as you introduce something that is a large change like this one, there will be, some small issues which will have to be investigated, some may be edge cases because some elements may be missing in the platform and will have to be added. It took years to have something stable on generics on the .NET Framework! OK, the compiler is now perfect for that but it has to be fitting into the small device.
    The debugger part is extremely complex. It takes hours to setup (2 Visual Studio sessions plus 1 VS Code plus hardware debugging), you need then to understand step by step what’s happening, it’s a lot of work.
    I love the idea of having a fund raising, I would love as well to see professional users funding this seriously as well. I’m sure that all together, something can be achieved. And it has as well to be fair and enough to make the changes and support afterward properly. Up to the point it can become a community effort.

  12. lvzuoxin commented on Aug 10, 2022

    @lvzuoxin

    Support for generics now?
    I want use nanoCLR for game develop C# script

  13. alberk8 commented on Aug 10, 2022

    @alberk8

    Support for generics now? I want use nanoCLR for game develop C# script

    I would think it is easier and cheaper to develop your game in Raspberry Pi and full dotnet framework is available. Maybe look at Meadows where full framework C# is supported.

  14. josesimoes commented on Aug 10, 2022

    @josesimoes
    MemberAuthor

    Development of this it's on hold. Progress will be reported here. 🙂

  15. acrigney commented on Aug 10, 2022

    @acrigney
  16. DocBrown101 commented on Aug 10, 2022

    @DocBrown101

    @acrigney But Meadow only works with a single board, which isn't cheap either.

  17. unpinned this issue on Mar 8, 2023
  18. pinned this issue on Mar 9, 2023
  19. 28106830 commented on Jan 8, 2025

    @28106830

    I sincerely hope to support generics. Currently, many MCUs have a clock frequency greater than 200MHz and a storage capacity of 16MB, RAM8MB
    I hope to configure generics as optional, so that high-capacity microcontrollers can use this benefit

  20. josesimoes commented on Dec 15, 2025

    @josesimoes
    MemberAuthor

    After years of waiting, planning, and deep engine work — the moment is here: generics are officially supported in .NET nanoFramework, and the public preview is live! 🥳

    This is a huge milestone for the platform — one of the most requested features since the beginning — and it fundamentally expands the kind of C# code you can write and reuse on constrained devices. We’ve aligned with the CLI/ECMA spec, extended our metadata model, updated the type system, upgraded the toolchain, and reimagined parts of the runtime to make this real.

    Read the full blog post.
    Doc with instructions here.

  21. Sour-Codes commented on Dec 15, 2025

    @Sour-Codes
    Contributor

    I almost spun off on the highway seeing the email notification of this.

    I'm immediately checking this out when I get a moment to sit down.

    Seriously, the best Christmas gift having generic support. I can get rid of my

    GenericType
    
    #if GENERIC_SUPPORT
    
    <SomeConstraintType>
    
    #endif
    
    variableName = GetSomeValue();

    workaround from all of my libraries.

    Thanks for the support.

  22. mikeobrien commented on Dec 15, 2025

    @mikeobrien

    This is HUGE! Big thanks to everyone involved!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions