ESP32 上的 .NET nanoFramework 是否支持泛型
Does .NET nanoFramework on ESP32 support generics
我正在尝试使用通用 class 编写一个针对 ESP32 的 C# 应用程序。启动调试器时,Visual Studio nanoFramework 扩展的调试过程似乎在“加载部署程序集”步骤陷入无限循环。
这是我在 VS2019 调试中看到的输出 window:
Waiting for nanoDevice to initialize...
Debugger found. Resuming boot sequence.
Create Type System.
Loading Deployment Assemblies.
Assembly: Esp32NanoframeworkScratch (1.0.0.0) (212 RAM - 488 ROM - 226 METADATA)
AssemblyRef = 4 bytes ( 1 elements)
TypeRef = 8 bytes ( 2 elements)
FieldRef = 4 bytes ( 1 elements)
MethodRef = 16 bytes ( 4 elements)
TypeDef = 16 bytes ( 2 elements)
FieldDef = 4 bytes ( 1 elements)
MethodDef = 12 bytes ( 5 elements)
StaticFields = 0 bytes ( 0 elements)
Attributes = 0 bytes ( 0 elements)
TypeSpec = 0 bytes ( 0 elements)
Resources = 0 bytes ( 0 elements)
Resources Files = 0 bytes ( 0 elements)
Resources Data = 0 bytes
Strings = 96 bytes
Signatures = 22 bytes
ByteCode = 40 bytes
Assembly: mscorlib (1.10.3.0) (3948 RAM - 31220 ROM - 18795 METADATA)
AssemblyRef = 0 bytes ( 0 elements)
TypeRef = 0 bytes ( 0 elements)
FieldRef = 0 bytes ( 0 elements)
MethodRef = 0 bytes ( 0 elements)
TypeDef = 1112 bytes ( 139 elements)
FieldDef = 200 bytes ( 99 elements)
MethodDef = 1568 bytes ( 783 elements)
StaticFields = 144 bytes ( 12 elements)
Attributes = 40 bytes ( 5 elements)
TypeSpec = 4 bytes ( 1 elements)
Resources = 0 bytes ( 0 elements)
Resources Files = 0 bytes ( 0 elements)
Resources Data = 0 bytes
Strings = 2609 bytes
Signatures = 2095 bytes
ByteCode = 9686 bytes
Resolving.
Assembly: mscorlib (1.10.3.0) (3948 RAM - 31220 ROM - 18795 METADATA)
…(repeats the mscorlib assembly table forever)
默认的 NFProject 模板在我的硬件上构建、启动和调试都没有问题。但是,添加泛型 class 会导致如上所示的无限循环:
using System.Threading;
namespace Esp32NanoframeworkScratch
{
public class Program
{
public static void Main()
{
_ = new GenericBox<object> { Value = new object() };
Thread.Sleep(Timeout.Infinite);
}
class GenericBox<T>
{
public T Value { get; set; }
}
}
}
此重现不受泛型 class 是否为内部的影响,也不受使用的特定类型参数的影响。如果我实例化并调用 Func<T>
.
,问题也会重现
我注意到 in 2018 (see the final comment below the article) a member of the nanoFramework project reported that generics were not supported. However, I'm not able to find any documentation regarding generics support / non-support. Searching around I've found this merged pull request that appears to add support for generics, and this blog post 将对 System.Collections.Generic
和 Linq 的支持描述为“不一致”。
nanoframework 目前是否支持泛型?如果没有,该项目是否打算在未来支持泛型?
泛型支持正在开发中。目前唯一缺少的部分是在 VS 调试器库中添加对它的支持。我们计划尽快解决这个问题。
我正在尝试使用通用 class 编写一个针对 ESP32 的 C# 应用程序。启动调试器时,Visual Studio nanoFramework 扩展的调试过程似乎在“加载部署程序集”步骤陷入无限循环。
这是我在 VS2019 调试中看到的输出 window:
Waiting for nanoDevice to initialize...
Debugger found. Resuming boot sequence.
Create Type System.
Loading Deployment Assemblies.
Assembly: Esp32NanoframeworkScratch (1.0.0.0) (212 RAM - 488 ROM - 226 METADATA)
AssemblyRef = 4 bytes ( 1 elements)
TypeRef = 8 bytes ( 2 elements)
FieldRef = 4 bytes ( 1 elements)
MethodRef = 16 bytes ( 4 elements)
TypeDef = 16 bytes ( 2 elements)
FieldDef = 4 bytes ( 1 elements)
MethodDef = 12 bytes ( 5 elements)
StaticFields = 0 bytes ( 0 elements)
Attributes = 0 bytes ( 0 elements)
TypeSpec = 0 bytes ( 0 elements)
Resources = 0 bytes ( 0 elements)
Resources Files = 0 bytes ( 0 elements)
Resources Data = 0 bytes
Strings = 96 bytes
Signatures = 22 bytes
ByteCode = 40 bytes
Assembly: mscorlib (1.10.3.0) (3948 RAM - 31220 ROM - 18795 METADATA)
AssemblyRef = 0 bytes ( 0 elements)
TypeRef = 0 bytes ( 0 elements)
FieldRef = 0 bytes ( 0 elements)
MethodRef = 0 bytes ( 0 elements)
TypeDef = 1112 bytes ( 139 elements)
FieldDef = 200 bytes ( 99 elements)
MethodDef = 1568 bytes ( 783 elements)
StaticFields = 144 bytes ( 12 elements)
Attributes = 40 bytes ( 5 elements)
TypeSpec = 4 bytes ( 1 elements)
Resources = 0 bytes ( 0 elements)
Resources Files = 0 bytes ( 0 elements)
Resources Data = 0 bytes
Strings = 2609 bytes
Signatures = 2095 bytes
ByteCode = 9686 bytes
Resolving.
Assembly: mscorlib (1.10.3.0) (3948 RAM - 31220 ROM - 18795 METADATA)
…(repeats the mscorlib assembly table forever)
默认的 NFProject 模板在我的硬件上构建、启动和调试都没有问题。但是,添加泛型 class 会导致如上所示的无限循环:
using System.Threading;
namespace Esp32NanoframeworkScratch
{
public class Program
{
public static void Main()
{
_ = new GenericBox<object> { Value = new object() };
Thread.Sleep(Timeout.Infinite);
}
class GenericBox<T>
{
public T Value { get; set; }
}
}
}
此重现不受泛型 class 是否为内部的影响,也不受使用的特定类型参数的影响。如果我实例化并调用 Func<T>
.
我注意到 in 2018 (see the final comment below the article) a member of the nanoFramework project reported that generics were not supported. However, I'm not able to find any documentation regarding generics support / non-support. Searching around I've found this merged pull request that appears to add support for generics, and this blog post 将对 System.Collections.Generic
和 Linq 的支持描述为“不一致”。
nanoframework 目前是否支持泛型?如果没有,该项目是否打算在未来支持泛型?
泛型支持正在开发中。目前唯一缺少的部分是在 VS 调试器库中添加对它的支持。我们计划尽快解决这个问题。