Skip to content

Commit

Permalink
新增net6/net7/net8输出,支持JsonPropertyName指定Json属性名,解决序列化问题
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Nov 6, 2024
1 parent 24da5d1 commit c7fbcae
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion NewLife.IoT/NewLife.IoT.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.1;netstandard2.0;net40;net45;net461</TargetFrameworks>
<TargetFrameworks>netstandard2.1;netstandard2.0;net40;net45;net461;net6.0;net7.0;net8.0</TargetFrameworks>
<AssemblyTitle>IoT Standard</AssemblyTitle>
<Description>IoT standard library, which defines various communication protocol standards and specifications in the Internet of Things field, without specific implementation. Used for IoT platform construction and unifying various hardware driver protocols. IoT标准库,定义物联网领域的各种通信协议标准规范,不含具体实现。用于IoT平台建设,以及统一各种硬件驱动协议</Description>
<Company>新生命开发团队</Company>
Expand Down
8 changes: 7 additions & 1 deletion NewLife.IoT/ThingSpecification/EventSpec.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Runtime.Serialization;
#if NETCOREAPP
using System.Text.Json.Serialization;
#endif

namespace NewLife.IoT.ThingSpecification;

Expand All @@ -19,7 +22,10 @@ public class EventSpec : SpecBase
/// <summary>
/// 描述
/// </summary>
[DataMember(Name="desc")]
#if NETCOREAPP
[JsonPropertyName("desc")]
#endif
[DataMember(Name = "desc")]
public String? Description { get; set; }

/// <summary>
Expand Down
6 changes: 6 additions & 0 deletions NewLife.IoT/ThingSpecification/PropertyExtend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
using System.Xml.Serialization;
using NewLife.Collections;
using NewLife.IoT.ThingModels;
#if NETCOREAPP
using System.Text.Json.Serialization;
#endif

namespace NewLife.IoT.ThingSpecification;

Expand All @@ -13,6 +16,9 @@ public class PropertyExtend : IDictionarySource
{
#region 属性
/// <summary>唯一标识</summary>
#if NETCOREAPP
[JsonPropertyName("identifier")]
#endif
[DataMember(Name = "identifier")]
public String Id { get; set; } = null!;

Expand Down
9 changes: 9 additions & 0 deletions NewLife.IoT/ThingSpecification/ServiceSpec.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System.Reflection;
using System.Runtime.Serialization;
#if NETCOREAPP
using System.Text.Json.Serialization;
#endif

namespace NewLife.IoT.ThingSpecification;

Expand All @@ -15,12 +18,18 @@ public class ServiceSpec : SpecBase
/// <summary>
/// 调用类型。sync/async
/// </summary>
#if NETCOREAPP
[JsonPropertyName("callType")]
#endif
[DataMember(Name = "callType")]
public String? Type { get; set; }

/// <summary>
/// 描述
/// </summary>
#if NETCOREAPP
[JsonPropertyName("desc")]
#endif
[DataMember(Name = "desc")]
public String? Description { get; set; }

Expand Down
6 changes: 6 additions & 0 deletions NewLife.IoT/ThingSpecification/SpecBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Runtime.Serialization;
#if NETCOREAPP
using System.Text.Json.Serialization;
#endif

namespace NewLife.IoT.ThingSpecification;

Expand All @@ -11,6 +14,9 @@ public abstract class SpecBase
/// <summary>
/// 唯一标识
/// </summary>
#if NETCOREAPP
[JsonPropertyName("identifier")]
#endif
[DataMember(Name = "identifier")]
public String Id { get; set; } = null!;

Expand Down

0 comments on commit c7fbcae

Please sign in to comment.