Skip to content

Commit 83aa426

Browse files
committed
优化编译警告
1 parent af16539 commit 83aa426

16 files changed

+50
-59
lines changed

.github/workflows/dotnet-publish-prerelease.yml

+9-28
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@ jobs:
2020
dotnet-version: 8.0.x
2121
- name: Publish
2222
run: |
23-
dotnet publish -c Release -r linux-x64 --self-contained -p:PublishTrimmed=true -p:PublishSingleFile=true -o app/linux-x64
24-
dotnet publish -c Release -r win-x64 --self-contained -p:PublishTrimmed=true -p:PublishSingleFile=true -o app/win-x64
23+
dotnet publish -c Release -r linux-x64 --self-contained -p:PublishTrimmed=true -p:PublishSingleFile=true -o app/linux-x64-with-runtime
24+
dotnet publish -c Release -r win-x64 --self-contained -p:PublishTrimmed=true -p:PublishSingleFile=true -o app/win-x64-with-runtime
25+
dotnet publish -c Release -r linux-x64 --no-self-contained -p:PublishReadyToRun=true -p:PublishSingleFile=true -o app/linux-x64-without-runtime
26+
dotnet publish -c Release -r win-x64 --no-self-contained -p:PublishReadyToRun=true -p:PublishSingleFile=true -o app/win-x64-without-runtime
2527
cd app
26-
mv linux-x64/appsettings.Example.json linux-x64/appsettings.json
27-
zip -r ${{ github.ref_name }}-linux-x64.zip linux-x64/*
28-
mv win-x64/appsettings.Example.json win-x64/appsettings.json
29-
zip -r ${{ github.ref_name }}-win-x64.zip win-x64/*
28+
find . -type f -name 'appsettings.Example.json' -execdir mv {} appsettings.json \;
29+
find . -maxdepth 1 -type d ! -name '.' | xargs -I {} sh -c 'cd "{}" && zip -r "../${{ github.ref_name }}-$(basename {}).zip" *'
30+
find . -maxdepth 1 -type d ! -name '.' -exec rm -rf {} +
3031
- name: Upload artifacts
3132
uses: actions/upload-artifact@v3
3233
with:
@@ -55,28 +56,8 @@ jobs:
5556
release_name: Release ${{ github.ref }}
5657
draft: false
5758
prerelease: true
58-
59-
- name: Upload Release Asset for Linux-x64
60-
id: upload_linux
61-
uses: actions/upload-release-asset@v1
62-
env:
63-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64-
with:
65-
upload_url: ${{ steps.create_release.outputs.upload_url }}
66-
asset_path: app/${{ github.ref_name }}-linux-x64.zip
67-
asset_name: ${{ github.ref_name }}-linux-x64.zip
68-
asset_content_type: application/zip
69-
70-
- name: Upload Release Asset for Windows-x64
71-
id: upload_win
72-
uses: actions/upload-release-asset@v1
73-
env:
74-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75-
with:
76-
upload_url: ${{ steps.create_release.outputs.upload_url }}
77-
asset_path: app/${{ github.ref_name }}-win-x64.zip
78-
asset_name: ${{ github.ref_name }}-win-x64.zip
79-
asset_content_type: application/zip
59+
files: |
60+
app/*
8061
8162
cleanup:
8263
name: Cleanup

.github/workflows/dotnet-publish-release.yml

+7-6
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@ jobs:
2020
dotnet-version: 8.0.x
2121
- name: Publish
2222
run: |
23-
dotnet publish -c Release -r linux-x64 --self-contained -p:PublishTrimmed=true -p:PublishSingleFile=true -o app/linux-x64
24-
dotnet publish -c Release -r win-x64 --self-contained -p:PublishTrimmed=true -p:PublishSingleFile=true -o app/win-x64
23+
dotnet publish -c Release -r linux-x64 --self-contained -p:PublishTrimmed=true -p:PublishSingleFile=true -o app/linux-x64-with-runtime
24+
dotnet publish -c Release -r win-x64 --self-contained -p:PublishTrimmed=true -p:PublishSingleFile=true -o app/win-x64-with-runtime
25+
dotnet publish -c Release -r linux-x64 --no-self-contained -p:PublishReadyToRun=true -p:PublishSingleFile=true -o app/linux-x64-without-runtime
26+
dotnet publish -c Release -r win-x64 --no-self-contained -p:PublishReadyToRun=true -p:PublishSingleFile=true -o app/win-x64-without-runtime
2527
cd app
26-
mv linux-x64/appsettings.Example.json linux-x64/appsettings.json
27-
zip -r ${{ github.ref_name }}-linux-x64.zip linux-x64/*
28-
mv win-x64/appsettings.Example.json win-x64/appsettings.json
29-
zip -r ${{ github.ref_name }}-win-x64.zip win-x64/*
28+
find . -type f -name 'appsettings.Example.json' -execdir mv {} appsettings.json \;
29+
find . -maxdepth 1 -type d ! -name '.' | xargs -I {} sh -c 'cd "{}" && zip -r "../${{ github.ref_name }}-$(basename {}).zip" *'
30+
find . -maxdepth 1 -type d ! -name '.' -exec rm -rf {} +
3031
- name: Upload artifacts
3132
uses: actions/upload-artifact@v3
3233
with:

src/TokenPay.sln

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D54245C4-8D70-442B-91C0-0053856152B0}"
99
ProjectSection(SolutionItems) = preProject
1010
.dockerignore = .dockerignore
11-
.editorconfig = .editorconfig
1211
.gitattributes = .gitattributes
1312
.gitignore = .gitignore
1413
docker-compose.yml = docker-compose.yml

src/TokenPay/BgServices/UpdateRateService.cs

+2
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ protected override async Task ExecuteAsync()
127127
}
128128
}
129129

130+
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
130131
class Datum
131132
{
132133
public bool bestOption { get; set; }
@@ -150,4 +151,5 @@ enum OkxSide
150151
Sell
151152
}
152153

154+
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
153155
}

src/TokenPay/Domains/TokenOrders.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class TokenOrders
4949
/// <summary>
5050
/// 区块链币种
5151
/// </summary>
52-
public string Currency { get; set; }
52+
public required string Currency { get; set; }
5353
/// <summary>
5454
/// 订单金额,保留4位小数
5555
/// </summary>

src/TokenPay/Domains/TokenRate.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class TokenRate
1010
/// 币种
1111
/// </summary>
1212
[Column(MapType = typeof(string))]
13-
public string Currency { get; set; }
13+
public required string Currency { get; set; }
1414
/// <summary>
1515
/// 法币
1616
/// </summary>

src/TokenPay/Domains/Tokens.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ namespace TokenPay.Domains
55
public class Tokens
66
{
77
[Key]
8-
public string Id { get; set; }
8+
public required string Id { get; set; }
99
/// <summary>
1010
/// 地址
1111
/// </summary>
12-
public string Address { get; set; }
12+
public required string Address { get; set; }
1313
/// <summary>
1414
/// 密钥
1515
/// </summary>
16-
public string Key { get; set; }
16+
public required string Key { get; set; }
1717
/// <summary>
1818
/// 币种
1919
/// </summary>

src/TokenPay/Helper/EnergyApi.cs

+2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public async Task<EnergyResponse<OrderData>> CreateOrder(CreateOrderModel model)
7878
}
7979

8080
}
81+
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
8182
public class CreateOrderModel
8283
{
8384
/// <summary>
@@ -307,4 +308,5 @@ public class OrderPriceData
307308
[JsonProperty("pay_amount")]
308309
public decimal Price { get; set; }
309310
}
311+
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
310312
}

src/TokenPay/Helper/QueryTronAction.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace TokenPay.Helper
2828

2929
public static partial class QueryTronAction
3030
{
31-
public static IConfiguration configuration { get; set; }
31+
public static IConfiguration configuration { get; set; } = null!;
3232
/// <summary>
3333
/// 获取USDT余额
3434
/// </summary>
@@ -370,11 +370,11 @@ public static async Task<decimal> GetTRXAsync(string address)
370370
var result = await resultData.ReceiveJson<JObject>();
371371
if (result.ContainsKey("Error") && result["Error"] != null)
372372
{
373-
return (false, result["Error"].ToString(), null);
373+
return (false, result["Error"]?.ToString(), null);
374374
}
375375
var transaction = result;
376376
// Sign
377-
var txId = transaction["txID"].ToString().FromHexToByteArray();
377+
var txId = transaction["txID"]?.ToString().FromHexToByteArray();
378378
var wallet0 = new TronWallet(privateKey);
379379
Signature signature = wallet0.Sign(txId);
380380
TronSignature tronSignature = new TronSignature(signature);

src/TokenPay/Helper/TelegramBot.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public TelegramBot(IConfiguration configuration)
1717
_userId = configuration.GetValue<long>("Telegram:AdminUserId");
1818
this._configuration = configuration;
1919
}
20-
public static TelegramBotInfo BotInfo;
20+
public static TelegramBotInfo BotInfo = null!;
2121
public async Task<TelegramResult<TelegramBotInfo>?> GetMeAsync(string? TelegramApiHost = null)
2222
{
2323
if (string.IsNullOrEmpty(_botToken) || _userId == 0)
@@ -71,6 +71,7 @@ public TelegramBot(IConfiguration configuration)
7171
}
7272
}
7373

74+
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
7475
public class TelegramBotInfo
7576
{
7677
[JsonProperty("id")]
@@ -149,4 +150,5 @@ public class TelegramResult<T>
149150
[JsonProperty("result")]
150151
public T Result { get; set; }
151152
}
153+
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
152154
}

src/TokenPay/Models/CreateOrderViewModel.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class CreateOrderViewModel
2929
[Display(Name = "币种")]
3030
[Required(ErrorMessage = "{0}为必传参数")]
3131
//[(ErrorMessage = "{1}不是有效的{0}")]
32-
public string Currency { get; set; }
32+
public required string Currency { get; set; }
3333
/// <summary>
3434
/// 在回调通知或订单信息中原样返回
3535
/// </summary>

src/TokenPay/Models/EthModel/BaseResponse.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ namespace TokenPay.Models.EthModel
55
public class BaseResponse<T>
66
{
77
[JsonProperty("status")]
8-
public string Status { get; set; }
8+
public string? Status { get; set; }
99

1010
[JsonProperty("message")]
11-
public string Message { get; set; }
11+
public string? Message { get; set; }
1212

1313
[JsonProperty("result")]
14-
public List<T> Result { get; set; }
14+
public List<T> Result { get; set; } = [];
1515
}
1616
}

src/TokenPay/Models/EthModel/ERC20Transaction.cs

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace TokenPay.Models.EthModel
55
{
6+
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
67
public class ERC20Transaction
78
{
89
[JsonProperty("blockNumber")]
@@ -64,4 +65,5 @@ public class ERC20Transaction
6465
[JsonProperty("confirmations")]
6566
public decimal Confirmations { get; set; }
6667
}
68+
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
6769
}

src/TokenPay/Models/EthModel/EVMChain.cs

+10-10
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ public class EVMChain
99
/// <summary>
1010
/// 链名
1111
/// </summary>
12-
public string ChainName { get; set; }
12+
public required string ChainName { get; set; }
1313
/// <summary>
1414
/// 链名-英文
1515
/// </summary>
16-
public string ChainNameEN { get; set; }
16+
public required string ChainNameEN { get; set; }
1717
/// <summary>
1818
/// 基本币名称
1919
/// </summary>
20-
public string BaseCoin { get; set; }
20+
public required string BaseCoin { get; set; }
2121
/// <summary>
2222
/// 最少确认数
2323
/// </summary>
@@ -29,33 +29,33 @@ public class EVMChain
2929
/// <summary>
3030
/// 区块浏览器Host
3131
/// </summary>
32-
public string ScanHost { get; set; }
32+
public string? ScanHost { get; set; }
3333
/// <summary>
3434
/// Api Host
3535
/// </summary>
36-
public string ApiHost { get; set; }
36+
public required string ApiHost { get; set; }
3737
/// <summary>
3838
/// Api Key
3939
/// </summary>
40-
public string ApiKey { get; set; }
40+
public required string ApiKey { get; set; }
4141
/// <summary>
4242
/// ERC20Name
4343
/// </summary>
44-
public string ERC20Name { get; set; }
44+
public required string ERC20Name { get; set; }
4545
/// <summary>
4646
/// 代币
4747
/// </summary>
48-
public List<EVMErc20> ERC20 { get; set; }
48+
public List<EVMErc20> ERC20 { get; set; } = new();
4949
}
5050
public class EVMErc20
5151
{
5252
/// <summary>
5353
/// 币种名称
5454
/// </summary>
55-
public string Name { get; set; }
55+
public required string Name { get; set; }
5656
/// <summary>
5757
/// 合约地址
5858
/// </summary>
59-
public string ContractAddress { get; set; }
59+
public required string ContractAddress { get; set; }
6060
}
6161
}

src/TokenPay/Models/EthModel/EthTransaction.cs

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace TokenPay.Models.EthModel
55
{
6+
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
67
public class EthTransaction
78
{
89
[JsonProperty("blockNumber")]
@@ -70,4 +71,5 @@ public decimal RealAmount(int decimals)
7071
[JsonProperty("functionName")]
7172
public string FunctionName { get; set; }
7273
}
74+
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
7375
}

src/TokenPay/Models/ReturnData.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class ReturnData<T>
77
public bool Success { get; set; }
88
public string? Message { get; set; }
99
public T? Data { get; set; }
10-
public SortedDictionary<string, object?> Info { get; set; }
10+
public SortedDictionary<string, object?>? Info { get; set; }
1111
}
1212
public class ReturnData
1313
{

0 commit comments

Comments
 (0)