Skip to content

Commit d30daa4

Browse files
committed
fix libs error by rune BridgeNet Test Case
1 parent d3c4da2 commit d30daa4

16 files changed

Lines changed: 228 additions & 208 deletions

File tree

‎CSharp.lua/CoreSystem.Lua/CoreSystem/Collections/Linq.lua‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ local function elementAt(source, index)
10131013
if isArrayLike(source) then
10141014
local count = #source
10151015
if index < count then
1016-
return unWrap(source[index + 1])
1016+
return true, unWrap(source[index + 1])
10171017
end
10181018
else
10191019
local en = source:GetEnumerator()

‎CSharp.lua/CoreSystem.Lua/CoreSystem/Convert.lua‎

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ end
125125

126126
local function parseNumberFromBase(value, fromBase, min, max)
127127
if fromBase == 2 then
128-
value = parseBits(value, "^%s*(1)", fromBase)
128+
value = parseBits(value, "^%s*([01])", fromBase)
129129
elseif fromBase == 8 then
130-
value = parseBits(value, "^%s*([1-7])", fromBase)
130+
value = parseBits(value, "^%s*([0-7])", fromBase)
131131
elseif fromBase == 16 then
132132
local _, _, v = value:find("^%s*(%w+)%s*$")
133133
if not v then
@@ -162,16 +162,23 @@ local function toNumber(value, min, max, parse, objectTo, sign)
162162
local typename = type(value)
163163
if typename == "number" then
164164
if sign == false then
165-
if value < min or value > max then
166-
throw(OverflowException())
167-
end
168-
value = value * 1.0
165+
value = System.ToSingle(value * 1.0)
169166
elseif sign == true then
170167
value = value * 1.0
171168
else
172-
if value ~= floor(value) then
173-
local i = value >= 0 and 0.5 or -0.5
174-
value = trunc(value + i)
169+
local i = value
170+
value = trunc(value)
171+
if value ~= i then
172+
local dif = i - value
173+
if value >= 0 then
174+
if dif > 0.5 or (dif == 0.5 and value % 2 ~= 0) then
175+
value = value + 1
176+
end
177+
else
178+
if dif < 0.5 or (dif == -0.5 and value % 2 ~= 0) then
179+
value = value - 1
180+
end
181+
end
175182
end
176183
if value < min or value > max then
177184
throw(OverflowException())
@@ -259,7 +266,7 @@ local function objectToSingle(value)
259266
end
260267

261268
local function toSingle(value)
262-
return toNumber(value, -3.40282347E+38, 3.40282347E+38, ParseSingle, objectToSingle, false)
269+
return toNumber(value, nil, nil, ParseSingle, objectToSingle, false)
263270
end
264271

265272
local function objectToDouble(value)

‎CSharp.lua/CoreSystem.Lua/CoreSystem/Core.lua‎

Lines changed: 2 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -511,42 +511,18 @@ if version < 5.3 then
511511
end
512512

513513
function System.div(x, y)
514-
if y == 0 then
515-
throw(System.DivideByZeroException(), 1)
516-
end
514+
if y == 0 then throw(System.DivideByZeroException(), 1) end
517515
return trunc(x / y)
518516
end
519517

520-
function System.divOfNull(x, y)
521-
if x == nil or y == nil then
522-
return nil
523-
end
524-
if y == 0 then
525-
throw(System.DivideByZeroException(), 1)
526-
end
527-
return trunc(x / y)
528-
end
529-
530518
function System.mod(x, y)
531-
if y == 0 then
532-
throw(System.DivideByZeroException(), 1)
533-
end
519+
if y == 0 then throw(System.DivideByZeroException(), 1) end
534520
if x * y < 0 then
535521
return x % y - y
536522
end
537523
return x % y
538524
end
539525

540-
function System.modOfNull(x, y)
541-
if x == nil or y == nil then
542-
return nil
543-
end
544-
if y == 0 then
545-
throw(System.DivideByZeroException(), 1)
546-
end
547-
return x % y
548-
end
549-
550526
function System.toUInt(v, max, mask, checked)
551527
if v >= 0 and v <= max then
552528
return v
@@ -731,62 +707,6 @@ else
731707
function System.div(x, y) if x * y < 0 then return -(-x // y) end return x // y end
732708
function System.mod(x, y) if x * y < 0 then return x % y - y end return x % y end
733709
734-
function System.bnotOfNull(x)
735-
if x == nil
736-
then return nil
737-
end
738-
return ~v
739-
end
740-
741-
function System.bandOfNull(x, y)
742-
if x == nil or y == nil then
743-
return nil
744-
end
745-
return x & y
746-
end
747-
748-
function System.borOfNull(x, y)
749-
if x == nil or y == nil then
750-
return nil
751-
end
752-
return x | y
753-
end
754-
755-
function System.xorOfNull(x, y)
756-
if x == nil or y == nil then
757-
return nil
758-
end
759-
return x ~ y
760-
end
761-
762-
function System.slOfNull(x, y)
763-
if x == nil or y == nil then
764-
return nil
765-
end
766-
return x << y
767-
end
768-
769-
function System.srOfNull(x, y)
770-
if x == nil or y == nil then
771-
return nil
772-
end
773-
return x >> y
774-
end
775-
776-
function System.divOfNull(x, y)
777-
if x == nil or y == nil then
778-
return nil
779-
end
780-
return x // y
781-
end
782-
783-
function System.modOfNull(x, y)
784-
if x == nil or y == nil then
785-
return nil
786-
end
787-
return x % y
788-
end
789-
790710
local function toUInt (v, max, mask, checked)
791711
if v >= 0 and v <= max then
792712
return v

‎CSharp.lua/CoreSystem.Lua/CoreSystem/Exception.lua‎

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,15 @@ local SystemException = define("System.SystemException", {
8484
local ArgumentException = define("System.ArgumentException", {
8585
__tostring = toString,
8686
__inherits__ = { SystemException },
87-
__ctor__ = function(this, message, paramName, innerException)
87+
__ctor__ = function(this, message, paramName, innerException)
88+
if type(paramName) == "table" then
89+
paramName, innerException = nil, paramName
90+
end
8891
ctorOfException(this, message or "Value does not fall within the expected range.", innerException)
8992
this.paramName = paramName
93+
if paramName and #paramName > 0 then
94+
this.message = this.message .. "\nParameter name: " .. paramName
95+
end
9096
end,
9197
getParamName = function(this)
9298
return this.paramName
@@ -97,27 +103,15 @@ define("System.ArgumentNullException", {
97103
__tostring = toString,
98104
__inherits__ = { ArgumentException },
99105
__ctor__ = function(this, paramName, message, innerException)
100-
if not message then
101-
message = "Value cannot be null."
102-
if paramName then
103-
message = message .. "\nParameter name: " .. paramName
104-
end
105-
end
106-
ArgumentException.__ctor__(this, message, paramName, innerException)
106+
ArgumentException.__ctor__(this, message or "Value cannot be null.", paramName, innerException)
107107
end
108108
})
109109

110110
define("System.ArgumentOutOfRangeException", {
111111
__tostring = toString,
112112
__inherits__ = { ArgumentException },
113113
__ctor__ = function(this, paramName, message, innerException, actualValue)
114-
if not message then
115-
message = "Value is out of range."
116-
if paramName then
117-
message = message .. "\nParameter name = " .. paramName
118-
end
119-
end
120-
ArgumentException.__ctor__(this, message, paramName, innerException)
114+
ArgumentException.__ctor__(this, message or "Specified argument was out of the range of valid values.", paramName, innerException)
121115
this.actualValue = actualValue
122116
end,
123117
getActualValue = function(this)
@@ -127,7 +121,7 @@ define("System.ArgumentOutOfRangeException", {
127121

128122
define("System.IndexOutOfRangeException", {
129123
__tostring = toString,
130-
__inherits__ = { Exception },
124+
__inherits__ = { SystemException },
131125
__ctor__ = function (this, message, innerException)
132126
ctorOfException(this, message or "Index was outside the bounds of the array.", innerException)
133127
end
@@ -158,17 +152,18 @@ define("System.CultureNotFoundException", {
158152
end
159153
})
160154

161-
define("System.KeyNotFoundException", {
155+
local KeyNotFoundException = define("System.Collections.Generic.KeyNotFoundException", {
162156
__tostring = toString,
163-
__inherits__ = { Exception },
157+
__inherits__ = { SystemException },
164158
__ctor__ = function(this, message, innerException)
165-
ctorOfException(this, message or "Key not found.", innerException)
159+
ctorOfException(this, message or "The given key was not present in the dictionary.", innerException)
166160
end
167161
})
162+
System.KeyNotFoundException = KeyNotFoundException
168163

169164
local ArithmeticException = define("System.ArithmeticException", {
170165
__tostring = toString,
171-
__inherits__ = { Exception },
166+
__inherits__ = { SystemException },
172167
__ctor__ = function(this, message, innerException)
173168
ctorOfException(this, message or "Overflow or underflow in the arithmetic operation.", innerException)
174169
end
@@ -178,7 +173,7 @@ define("System.DivideByZeroException", {
178173
__tostring = toString,
179174
__inherits__ = { ArithmeticException },
180175
__ctor__ = function(this, message, innerException)
181-
ArithmeticException.__ctor__(this, message or "Division by 0.", innerException)
176+
ArithmeticException.__ctor__(this, message or "Attempted to divide by zero.", innerException)
182177
end
183178
})
184179

@@ -192,47 +187,47 @@ define("System.OverflowException", {
192187

193188
define("System.FormatException", {
194189
__tostring = toString,
195-
__inherits__ = { Exception },
190+
__inherits__ = { SystemException },
196191
__ctor__ = function(this, message, innerException)
197192
ctorOfException(this, message or "Invalid format.", innerException)
198193
end
199194
})
200195

201196
define("System.InvalidCastException", {
202197
__tostring = toString,
203-
__inherits__ = { Exception },
198+
__inherits__ = { SystemException },
204199
__ctor__ = function(this, message, innerException)
205200
ctorOfException(this, message or "Specified cast is not valid.", innerException)
206201
end
207202
})
208203

209204
define("System.InvalidOperationException", {
210205
__tostring = toString,
211-
__inherits__ = { Exception },
206+
__inherits__ = { SystemException },
212207
__ctor__ = function(this, message, innerException)
213208
ctorOfException(this, message or "Operation is not valid due to the current state of the object.", innerException)
214209
end
215210
})
216211

217212
define("System.NotImplementedException", {
218213
__tostring = toString,
219-
__inherits__ = { Exception },
214+
__inherits__ = { SystemException },
220215
__ctor__ = function(this, message, innerException)
221216
ctorOfException(this, message or "The method or operation is not implemented.", innerException)
222217
end
223218
})
224219

225220
define("System.NotSupportedException", {
226221
__tostring = toString,
227-
__inherits__ = { Exception },
222+
__inherits__ = { SystemException },
228223
__ctor__ = function(this, message, innerException)
229224
ctorOfException(this, message or "Specified method is not supported.", innerException)
230225
end
231226
})
232227

233228
define("System.NullReferenceException", {
234229
__tostring = toString,
235-
__inherits__ = { Exception },
230+
__inherits__ = { SystemException },
236231
__ctor__ = function(this, message, innerException)
237232
ctorOfException(this, message or "Object reference not set to an instance of an object.", innerException)
238233
end

0 commit comments

Comments
 (0)