Skip to content

Commit 83aa426

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

16 files changed

Lines changed: 50 additions & 59 deletions

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

Lines changed: 9 additions & 28 deletions
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

Lines changed: 7 additions & 6 deletions
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 3 additions & 1 deletion
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
}

0 commit comments

Comments
 (0)