Skip to content

Commit 33139c8

Browse files
committed
fix Math.ctor
1 parent 90684b0 commit 33139c8

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

Src/MyHelper/MyType.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ public static void TestAllTypes()
115115
{
116116
var o = f.GetValue(null);
117117
if (o is Delegate d) continue;
118-
Console.WriteLine($"\t{f.Name} = {(o == null ? "...................." : o.ToString())}");
118+
Console.WriteLine($"\t{f.Name} = {(o == null ? "......" : o.ToString())}");
119119
}
120120
catch (Exception ex)
121121
{
122-
Console.WriteLine($"\t{f.Name} = !!!!!!!!!!!!!!!!!!{ex.Message}");
122+
Console.WriteLine($"\t{f.Name} = ******{ex.Message}");
123123
}
124124
}
125125
}

Src/Shone.Math.Net5.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@
2727
<OutputPath>C:\Hjx\Shone2020\Shone.Math\</OutputPath>
2828
</PropertyGroup>
2929

30+
<ItemGroup>
31+
<Compile Remove="Misc\**" />
32+
<EmbeddedResource Remove="Misc\**" />
33+
<None Remove="Misc\**" />
34+
</ItemGroup>
35+
3036
<ItemGroup>
3137
<Compile Include="AutoGenerated\Memory.cs" />
3238
<Compile Include="AutoGenerated\MyArray.cs" />

Src/Shone.Math.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,11 @@ static Math()
167167

168168
if (NumType == MyType.Real) return;
169169
if (NumType == MyType.Bool) MaxValue = FromInt(1);
170-
if (!MyType.HasOneSet.Contains(NumType)) One = FromInt(1);
171-
if (!MyType.UnsignedSet.Contains(NumType)) MinusOne = FromInt(-1);
170+
if (!MyType.HasOneSet.Contains(NumType))
171+
{
172+
One = FromInt(1);
173+
if (!MyType.UnsignedSet.Contains(NumType)) MinusOne = FromInt(-1);
174+
}
172175
if (!MyType.IEEESet.Contains(NumType))
173176
{
174177
NegativeInfinity = MinValue;
@@ -195,11 +198,16 @@ private static void AddConsts(Type extension, FieldInfo[] fields)
195198
if (f.FieldType != NumType) continue;
196199
foreach (var field in fields)
197200
{
198-
if (field.Name == name)
201+
if (field.FieldType != NumType || field.Name != name) continue;
202+
try
199203
{
200204
field.SetValue(null, (T)f.GetValue(null));
201-
break;
202205
}
206+
catch
207+
{
208+
throw new Exception($"Cannot init the field {NumType.Name}.{name} from: {f}");
209+
}
210+
break;
203211
}
204212
}
205213
}
@@ -215,7 +223,7 @@ private static void setDelegate(FieldInfo[] fields, string name, MethodInfo m)
215223
}
216224
catch
217225
{
218-
throw new Exception($"Cannot init the method {name}");
226+
throw new Exception($"Cannot init the method {NumType.Name}.{name} from {m}");
219227
}
220228
break;
221229
}

netcoreapp5.0/Shone.Math.dll

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)