Skip to content

Commit

Permalink
fix: error in C#
Browse files Browse the repository at this point in the history
  • Loading branch information
h-hg authored and JacksonTian committed Oct 13, 2023
1 parent 9b45fcd commit 76ec737
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions csharp/core/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ namespace AlibabaCloud.TeaUtil
public static class Common
{
private static readonly string _defaultUserAgent;
private static readonly _processStartTime;
private static readonly long _processStartTime;
private static long _seqId = 0;

Check warning on line 28 in csharp/core/Common.cs

View workflow job for this annotation

GitHub Actions / build

The field 'Common._seqId' is assigned but its value is never used

Check warning on line 28 in csharp/core/Common.cs

View workflow job for this annotation

GitHub Actions / build

The field 'Common._seqId' is assigned but its value is never used

Check warning on line 28 in csharp/core/Common.cs

View workflow job for this annotation

GitHub Actions / build

The field 'Common._seqId' is assigned but its value is never used

Check warning on line 28 in csharp/core/Common.cs

View workflow job for this annotation

GitHub Actions / build

The field 'Common._seqId' is assigned but its value is never used

static Common()
{
_defaultUserAgent = GetDefaultUserAgent();
_processStartTime = Process.GetCurrentProcess().StartTime;
double ticks = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds;
_processStartTime = (long)(ticks * 1000);
}

public static byte[] ToBytes(string val)
Expand Down Expand Up @@ -136,7 +137,7 @@ public static string GetNonce()
long currentTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();

Check failure on line 137 in csharp/core/Common.cs

View workflow job for this annotation

GitHub Actions / build

'DateTimeOffset' does not contain a definition for 'ToUnixTimeMilliseconds' and no accessible extension method 'ToUnixTimeMilliseconds' accepting a first argument of type 'DateTimeOffset' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 137 in csharp/core/Common.cs

View workflow job for this annotation

GitHub Actions / build

'DateTimeOffset' does not contain a definition for 'ToUnixTimeMilliseconds' and no accessible extension method 'ToUnixTimeMilliseconds' accepting a first argument of type 'DateTimeOffset' could be found (are you missing a using directive or an assembly reference?)
long seq = Interlocked.Increment(ref seqId);

Check failure on line 138 in csharp/core/Common.cs

View workflow job for this annotation

GitHub Actions / build

The name 'seqId' does not exist in the current context

Check failure on line 138 in csharp/core/Common.cs

View workflow job for this annotation

GitHub Actions / build

The name 'seqId' does not exist in the current context

Check failure on line 138 in csharp/core/Common.cs

View workflow job for this annotation

GitHub Actions / build

The name 'seqId' does not exist in the current context

Check failure on line 138 in csharp/core/Common.cs

View workflow job for this annotation

GitHub Actions / build

The name 'seqId' does not exist in the current context
long randNum = new Random().NextInt64();

Check failure on line 139 in csharp/core/Common.cs

View workflow job for this annotation

GitHub Actions / build

'Random' does not contain a definition for 'NextInt64' and no accessible extension method 'NextInt64' accepting a first argument of type 'Random' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 139 in csharp/core/Common.cs

View workflow job for this annotation

GitHub Actions / build

'Random' does not contain a definition for 'NextInt64' and no accessible extension method 'NextInt64' accepting a first argument of type 'Random' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 139 in csharp/core/Common.cs

View workflow job for this annotation

GitHub Actions / build

'Random' does not contain a definition for 'NextInt64' and no accessible extension method 'NextInt64' accepting a first argument of type 'Random' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 139 in csharp/core/Common.cs

View workflow job for this annotation

GitHub Actions / build

'Random' does not contain a definition for 'NextInt64' and no accessible extension method 'NextInt64' accepting a first argument of type 'Random' could be found (are you missing a using directive or an assembly reference?)
string msg = $"{process_start_time}-{thread_id}-{current_time}-{seq}-{randNum}";
string msg = string.Format("{0}-{1}-{2}-{3}", _processStartTime, threadId, currentTime, seq, randNum);
using (MD5 md5 = MD5.Create())
{
byte[] hash = md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(msg));
Expand Down

0 comments on commit 76ec737

Please sign in to comment.