Skip to content

Commit 450e6cf

Browse files
committed
[1.9.2] HashCode取消储存顺序判断
1 parent 695bbcd commit 450e6cf

7 files changed

Lines changed: 18 additions & 14 deletions

File tree

LinePutScript.sln

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1414
.editorconfig = .editorconfig
1515
EndProjectSection
1616
EndProject
17+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Release", "Release", "{DCF4908D-2FC7-4C9B-A90C-FB65BAD88E0F}"
18+
EndProject
1719
Global
1820
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1921
Debug|Any CPU = Debug|Any CPU

LinePutScript/Converter/LPSConvert.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,7 @@ public static string GetObjectString(object? value, ConvertType type = ConvertTy
376376
MethodInfo miConstructed = mi.MakeGenericMethod(att.ILineType);
377377
object[] args = { value, att?.Name ?? "deflinename" };
378378
return Sub.TextReplace(((ILine)miConstructed.Invoke(null, args)).ToString());
379-
#pragma warning restore CS8600
380-
#pragma warning restore CS8602
379+
381380
}
382381
switch (Type)
383382
{
@@ -406,15 +405,19 @@ public static string GetObjectString(object? value, ConvertType type = ConvertTy
406405
sb.Append(',');
407406
}
408407
return sb.ToString().TrimEnd(',');
408+
#pragma warning restore CS8600
409+
#pragma warning restore CS8602
409410
case ConvertType.ToDictionary:
410411
sb = new StringBuilder();
412+
#pragma warning disable CS8605 // 取消装箱可能为 null 的值。
411413
foreach (DictionaryEntry obj in (IDictionary)value)
412414
{
413415
sb.Append(Sub.TextReplace(GetObjectString(obj.Key)));
414416
sb.Append('=');
415417
sb.Append(obj.Value == null ? "" : Sub.TextReplace(GetObjectString(obj.Value)));
416418
sb.Append("/n");
417419
}
420+
#pragma warning restore CS8605 // 取消装箱可能为 null 的值。
418421
return sb.ToString().TrimEnd('/', 'n');
419422

420423
default:
@@ -452,9 +455,7 @@ public static string GetObjectString(object? value, ConvertType type = ConvertTy
452455
object[] args = { value, linename };
453456
#pragma warning disable CS8603 // 可能返回 null 引用。
454457
return (TLine)miConstructed.Invoke(null, args);
455-
#pragma warning restore CS8603 // 可能返回 null 引用。
456-
#pragma warning restore CS8600
457-
#pragma warning restore CS8602
458+
458459
case ConvertType.Converter:
459460
if (att?.Converter != null)
460461
t.Info = ConvertFunction.Convert(att.Converter, value);
@@ -485,14 +486,19 @@ public static string GetObjectString(object? value, ConvertType type = ConvertTy
485486
}
486487
t.info = sb.ToString().TrimEnd(',');
487488
break;
489+
#pragma warning restore CS8603 // 可能返回 null 引用。
490+
#pragma warning restore CS8600
491+
#pragma warning restore CS8602
488492
case ConvertType.ToDictionary:
493+
#pragma warning disable CS8605 // 取消装箱可能为 null 的值。
489494
foreach (DictionaryEntry obj in (IDictionary)value)
490495
{
491496
TLine newt = new TLine();
492497
newt.Name = GetObjectString(obj.Key);
493498
newt.info = obj.Value == null ? "" : Sub.TextReplace(GetObjectString(obj.Value));
494499
t.Add(newt);
495500
}
501+
#pragma warning restore CS8605 // 取消装箱可能为 null 的值。
496502
break;
497503
default:
498504
t.Info = value.ToString() ?? "";

LinePutScript/Core/LinePutScript.Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<ImplicitUsings>disable</ImplicitUsings>
5-
<TargetFramework>net6.0</TargetFramework>
5+
<TargetFramework>netcoreapp3.1</TargetFramework>
66
<LangVersion>9.0</LangVersion>
77
<Nullable>enable</Nullable>
88
<GenerateDocumentationFile>True</GenerateDocumentationFile>

LinePutScript/Dictionary/LPS_D.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,10 +548,9 @@ public override string ToString()
548548
/// <returns>64位哈希代码</returns>
549549
public long GetLongHashCode()
550550
{
551-
int id = 2;
552551
long hash = 0;
553552
foreach (ILine li in Assemblage.Values)
554-
hash += li.GetLongHashCode() * id++;
553+
hash += li.GetLongHashCode();
555554
return hash;
556555
}
557556
/// <summary>

LinePutScript/Dictionary/Line_D.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,11 +748,10 @@ public override void Load(string lps)
748748
/// <returns>64位哈希代码</returns>
749749
public override long GetLongHashCode()
750750
{
751-
int id = 5;
752751
long hash = GetHashCode(Name) * 2 + GetHashCode(info) * 3 + GetHashCode(text) * 4;
753752
foreach (ISub su in Subs.Values)
754753
{
755-
hash += su.GetLongHashCode() * id++;
754+
hash += su.GetLongHashCode();
756755
}
757756
return hash;
758757
}

LinePutScript/Line.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,11 +559,10 @@ public void ToString(StringBuilder str)
559559
/// <returns>64位哈希代码</returns>
560560
public override long GetLongHashCode()
561561
{
562-
int id = 5;
563562
long hash = GetHashCode(Name) * 2 + GetHashCode(info) * 3 + GetHashCode(text) * 4;
564563
foreach (ISub su in Subs)
565564
{
566-
hash += su.GetLongHashCode() * id++;
565+
hash += su.GetLongHashCode();
567566
}
568567
return hash;
569568
}

LinePutScript/LpsDocument.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,10 +580,9 @@ public override string ToString()
580580
/// <returns>64位哈希代码</returns>
581581
public long GetLongHashCode()
582582
{
583-
int id = 2;
584583
long hash = 0;
585584
foreach (ILine li in Assemblage)
586-
hash += li.GetLongHashCode() * id++;
585+
hash += li.GetLongHashCode();
587586
return hash;
588587
}
589588
/// <summary>

0 commit comments

Comments
 (0)