Skip to content

Commit

Permalink
Trim Null
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Oct 7, 2023
1 parent 39eef57 commit 5069863
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 29 deletions.
4 changes: 2 additions & 2 deletions NewLife.Core/Configuration/ApolloConfigProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ public class ApolloConfigProvider : HttpConfigProvider

private class ApolloModel
{
public String? WMetaServer { get; set; }
public String WMetaServer { get; set; } = null!;

public String? AppId { get; set; }
public String AppId { get; set; } = null!;

public String? NameSpace { get; set; }

Expand Down
9 changes: 7 additions & 2 deletions NewLife.Core/Configuration/ConfigHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public static void MapTo(this IConfigSection section, Object model, IConfigProvi
{
foreach (var cfg in childs)
{
if (cfg.Key == null) continue;
if (cfg.Key.IsNullOrEmpty()) continue;

dic[cfg.Key] = cfg.Value;

Expand Down Expand Up @@ -339,7 +339,12 @@ private static void MapArray(IConfigSection section, IConfigSection cfg, IList l

// 为了避免数组元素叠加,干掉原来的
section.Childs.Remove(cfg);
cfg = new ConfigSection { Key = cfg.Key, Childs = new List<IConfigSection>(), Comment = cfg.Comment };
cfg = new ConfigSection
{
Key = cfg.Key,
Childs = new List<IConfigSection>(),
Comment = cfg.Comment
};
section.Childs.Add(cfg);

// 数组元素是没有key的集合
Expand Down
4 changes: 2 additions & 2 deletions NewLife.Core/Configuration/HttpConfigProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ public class HttpConfigProvider : ConfigProvider
{
#region 属性
/// <summary>服务器</summary>
public String? Server { get; set; }
public String Server { get; set; } = null!;

/// <summary>服务操作 默认:Config/GetAll</summary>
public String Action { get; set; } = "Config/GetAll";

/// <summary>应用标识</summary>
public String? AppId { get; set; }
public String AppId { get; set; } = null!;

/// <summary>应用密钥</summary>
public String? Secret { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions NewLife.Core/Configuration/IConfigSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
public interface IConfigSection
{
/// <summary>配置名</summary>
String? Key { get; set; }
String Key { get; set; }

/// <summary>配置值</summary>
String? Value { get; set; }
Expand All @@ -26,7 +26,7 @@ public class ConfigSection : IConfigSection
{
#region 属性
/// <summary>配置名</summary>
public String? Key { get; set; }
public String Key { get; set; } = null!;

/// <summary>配置值</summary>
public String? Value { get; set; }
Expand Down
14 changes: 9 additions & 5 deletions NewLife.Core/Configuration/JsonConfigProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,16 @@ protected virtual void Map(IDictionary<String, Object?> src, IConfigSection sect
// 简单基元类型
else
{
var cfg2 = new ConfigSection
var key = elm?.GetType()?.Name;
if (!key.IsNullOrEmpty())
{
Key = elm?.GetType()?.Name,
Value = elm + "",
};
cfg.Childs.Add(cfg2);
var cfg2 = new ConfigSection
{
Key = key,
Value = elm + "",
};
cfg.Childs.Add(cfg2);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion NewLife.Core/Http/FormFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class FormFile
{
#region 属性
/// <summary>名称</summary>
public String? Name { get; set; }
public String Name { get; set; } = null!;

/// <summary>内容部署</summary>
public String? ContentDisposition { get; set; }
Expand Down
1 change: 0 additions & 1 deletion NewLife.Core/Http/TokenHttpFilter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Diagnostics;
using System.Net.Http;
using System.Net.Http.Headers;
using NewLife.Log;
using NewLife.Remoting;
Expand Down
8 changes: 4 additions & 4 deletions NewLife.Core/Log/ISpan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ namespace NewLife.Log;
public interface ISpan : IDisposable
{
/// <summary>唯一标识。随线程上下文、Http、Rpc传递,作为内部片段的父级</summary>
String? Id { get; set; }
String Id { get; set; }

/// <summary>父级片段标识</summary>
String? ParentId { get; set; }

/// <summary>跟踪标识。可用于关联多个片段,建立依赖关系,随线程上下文、Http、Rpc传递</summary>
String? TraceId { get; set; }
String TraceId { get; set; }

/// <summary>开始时间。Unix毫秒</summary>
Int64 StartTime { get; set; }
Expand Down Expand Up @@ -59,13 +59,13 @@ public class DefaultSpan : ISpan
public ISpanBuilder? Builder { get; private set; }

/// <summary>唯一标识。随线程上下文、Http、Rpc传递,作为内部片段的父级</summary>
public String? Id { get; set; }
public String Id { get; set; } = null!;

/// <summary>父级片段标识</summary>
public String? ParentId { get; set; }

/// <summary>跟踪标识。可用于关联多个片段,建立依赖关系,随线程上下文、Http、Rpc传递</summary>
public String? TraceId { get; set; }
public String TraceId { get; set; } = null!;

/// <summary>开始时间。Unix毫秒</summary>
public Int64 StartTime { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions NewLife.Core/Log/ISpanBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public interface ISpanBuilder
ITracer? Tracer { get; }

/// <summary>操作名</summary>
String? Name { get; set; }
String Name { get; set; }

/// <summary>开始时间。Unix毫秒</summary>
Int64 StartTime { get; set; }
Expand Down Expand Up @@ -62,7 +62,7 @@ public class DefaultSpanBuilder : ISpanBuilder
public ITracer? Tracer { get; }

/// <summary>操作名</summary>
public String? Name { get; set; }
public String Name { get; set; } = null!;

/// <summary>开始时间。Unix毫秒</summary>
public Int64 StartTime { get; set; }
Expand Down
1 change: 0 additions & 1 deletion NewLife.Core/Log/NetworkLog.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Net;
using System.Net.Http;
using System.Text;
using NewLife.Http;
using NewLife.Net;
Expand Down
2 changes: 1 addition & 1 deletion NewLife.Core/Net/IDnsResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public class DnsResolver : IDnsResolver

class DnsItem
{
public String? Host { get; set; }
public String Host { get; set; } = null!;

public IPAddress[]? Addresses { get; set; }

Expand Down
9 changes: 4 additions & 5 deletions NewLife.Core/Remoting/ApiHttpClient.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Http.Headers;
using System.Runtime.Serialization;
using System.Xml.Serialization;
using NewLife.Configuration;
Expand Down Expand Up @@ -96,7 +95,7 @@ public ApiHttpClient(IServiceProvider provider, String name) : this()
/// <param name="address"></param>
public void Add(String name, Uri address) => Services.Add(new Service { Name = name, Address = address });

private void ParseAndAdd(IList<Service> services, String name, String address)
private static void ParseAndAdd(IList<Service> services, String name, String address)
{
var url = address;
var svc = new Service
Expand Down Expand Up @@ -502,10 +501,10 @@ protected virtual HttpClient CreateClient()
public class Service
{
/// <summary>名称</summary>
public String? Name { get; set; }
public String Name { get; set; } = null!;

/// <summary>名称</summary>
public Uri? Address { get; set; }
public Uri Address { get; set; } = null!;

/// <summary>权重。用于负载均衡,默认1</summary>
public Int32 Weight { get; set; } = 1;
Expand Down
2 changes: 1 addition & 1 deletion NewLife.Core/Web/Link.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class Link
{
#region 属性
/// <summary>名称</summary>
public String? Name { get; set; }
public String Name { get; set; } = null!;

/// <summary>全名</summary>
public String? FullName { get; set; }
Expand Down

0 comments on commit 5069863

Please sign in to comment.