You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README-GENERICS.md
+14-6Lines changed: 14 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,12 @@
1
-
# Public Preview for CLR with support for generics
1
+
# Generics Public Preview for .NET nanoFramework CLR
2
+
3
+
## Table of Contents
4
+
5
+
-[Generics in C# (Overview)](#generics-in-c-overview)
6
+
-[Using Preview Firmware with Generics Support](#using-preview-firmware-with-generics-support)
7
+
-[Installing the Preview Visual Studio Extension](#installing-the-preview-visual-studio-extension)
8
+
-[Updating Project NuGet Packages to 2.0+ Preview](#updating-project-nuget-packages-to-20-preview)
9
+
-[Feedback and Known Issues](#feedback-and-known-issues)
2
10
3
11
## Generics in C# (Overview)
4
12
@@ -24,7 +32,7 @@ int biggerInt = Max(10, 42); // works with int
24
32
stringlaterString=Max("apple", "zebra"); // works with string
25
33
```
26
34
27
-
**Example – Generic Class:** You can also define generic classes. For instance, a minimal generic stack class could be defined as:
35
+
**Example – Generic Class:** You can also define generic classes. For instance, a minimal generic stack class could be defined as:
28
36
29
37
```csharp
30
38
publicclassStack<T>
@@ -39,7 +47,7 @@ public class Stack<T>
39
47
40
48
This `Stack<T>` can be used as `Stack<int>` for an integer stack or `Stack<string>` for a string stack, etc., each providing compile-time type enforcement.
41
49
42
-
*Generics have been a fundamental feature in desktop .NET for years. However, due to the constraints of embedded devices, previous versions of **.NET nanoFramework** did **not support generics**. With this preview, nanoFramework is introducing support for generics, closing the gap with standard C# capabilities.* Developers can now write more flexible and reusable code on microcontrollers, similarly to how they would on the full .NET runtime. Keep in mind that this is an initial **preview** – while most generic scenarios are expected to work, there may be limitations or bugs as this feature is brand new to constrained devices.
50
+
*Generics have been a fundamental feature in desktop .NET for years. However, due to the constraints of embedded devices, previous versions of **.NET nanoFramework** did **not support generics**. With this preview, nanoFramework is introducing support for generics, closing the gap with standard C# capabilities.* Developers can now write more flexible and reusable code on microcontrollers, just as they would on the full .NET runtime. Keep in mind that this is an initial **preview** – while most generic scenarios are expected to work, there may be limitations or bugs as this feature is brand new to constrained devices.
43
51
44
52
## Using Preview Firmware with Generics Support
45
53
@@ -68,15 +76,15 @@ Developing with the generics preview requires a **preview version of the .NET na
68
76
69
77
These links provide the `.vsix` installer for the extension. (You can also set up the VSIX gallery feed in Visual Studio to get preview updates (instructions on [this](https://nanoframework.net/setup-visual-studio-to-access-preview-versions-feed/#:~:text=3,along%20with%20the%20following%20URL) blog post, but direct download is simplest.)
70
78
71
-
**2. Install the VSIX in Visual Studio:** After downloading the file, doubleclick on it and the extension installer will open. Just follow the workflow and confirm the options. Note that all Visual Studio instances have to be closed.
79
+
**2. Install the VSIX in Visual Studio:** After downloading the file, double-click on it and the extension installer will open. Just follow the workflow and confirm the options. Note that all Visual Studio instances have to be closed.
72
80
73
81
Once the preview extension is installed, Visual Studio will be aware of generics support for .NET nanoFramework projects. This extension update is necessary – older versions of the extension (from the official VS Marketplace) do not understand generics and would flag errors or fail to deploy projects using generics.
74
82
75
-
> **Warning:** Despite we've tried to make that possible using preview features in VS extension, it's not possible to support pre and postgenerics projects with the same extension. Therefore, you have to install the preview version for generics support or a stable one to work with the current stable versions. It is not an option to install pre and postgenerics extensions in VS2019 and VS2022, for example as both use the same msbuild components for the project system and builds.
83
+
> **Warning:** Despite our efforts to make this possible using the VS extension preview, it’s not possible to support pre- and post-generics projects with the same extension. Therefore, you have to install the preview version for generics support or a stable one to work with the current stable versions. It is not an option to install pre- and post-generics extensions in VS2019 and VS2022, for example, as both use the same msbuild components for the project system and builds.
76
84
77
85
## Updating Project NuGet Packages to 2.0+ Preview
78
86
79
-
In addition to firmware and the VS extension, your project’s NuGet packages (nanoFramework class libraries) must be updated to **preview versions (2.0.x or higher)** that include generics support. Core libraries are being been revved to **2.0.0-preview** (or later) for this feature. These preview NuGets are distributed through the public NuGet.org feed.
87
+
In addition to firmware and the VS extension, your project’s NuGet packages (nanoFramework class libraries) must be updated to **preview versions (2.0.x or higher)** that include generics support. Core libraries have been revved to **2.0.0-preview** (or later) for this feature. These preview NuGets are distributed through the public NuGet.org feed.
80
88
81
89
**Update NuGet Packages:** In your nanoFramework project, open **Manage NuGet Packages** and enable "Include prerelease" (if applicable) to see the preview versions. Update all relevant **.NET nanoFramework** packages (such as **nanoFramework.CoreLibrary**, **System.*** assemblies, etc.) to the latest 2.x preview versions available from NuGet feed. The **CoreLibrary** (mscorlib) is especially important to update, as generics support starts there.
0 commit comments