diff --git a/Jint/Collections/DictionarySlim.cs b/Jint/Collections/DictionarySlim.cs
index b25f062ee9..35ec3812f0 100644
--- a/Jint/Collections/DictionarySlim.cs
+++ b/Jint/Collections/DictionarySlim.cs
@@ -75,8 +75,8 @@ public void Clear()
public bool ContainsKey(TKey key)
{
Entry[] entries = _entries;
- for (int i = _buckets[key.GetHashCode() & (_buckets.Length-1)] - 1;
- (uint)i < (uint)entries.Length; i = entries[i].next)
+ for (int i = _buckets[key.GetHashCode() & (_buckets.Length - 1)] - 1;
+ (uint) i < (uint) entries.Length; i = entries[i].next)
{
if (key.Equals(entries[i].key))
return true;
@@ -89,7 +89,7 @@ public bool TryGetValue(TKey key, out TValue value)
{
Entry[] entries = _entries;
for (int i = _buckets[key.GetHashCode() & (_buckets.Length - 1)] - 1;
- (uint)i < (uint)entries.Length; i = entries[i].next)
+ (uint) i < (uint) entries.Length; i = entries[i].next)
{
if (key.Equals(entries[i].key))
{
@@ -152,7 +152,7 @@ public ref TValue GetOrAddValueRef(TKey key)
Entry[] entries = _entries;
int bucketIndex = key.GetHashCode() & (_buckets.Length - 1);
for (int i = _buckets[bucketIndex] - 1;
- (uint)i < (uint)entries.Length; i = entries[i].next)
+ (uint) i < (uint) entries.Length; i = entries[i].next)
{
if (key.Equals(entries[i].key))
return ref entries[i].value;
@@ -200,7 +200,7 @@ private Entry[] Resize()
Debug.Assert(_entries.Length == _count || _entries.Length == 1); // We only copy _count, so if it's longer we will miss some
int count = _count;
int newSize = _entries.Length * 2;
- if ((uint)newSize > (uint)int.MaxValue) // uint cast handles overflow
+ if ((uint) newSize > int.MaxValue) // uint cast handles overflow
throw new InvalidOperationException("Capacity Overflow");
var entries = new Entry[newSize];
diff --git a/Jint/Collections/StringDictionarySlim.cs b/Jint/Collections/StringDictionarySlim.cs
index c922f04bea..6a43054a28 100644
--- a/Jint/Collections/StringDictionarySlim.cs
+++ b/Jint/Collections/StringDictionarySlim.cs
@@ -127,7 +127,7 @@ public override ref TValue GetValueRefOrNullRef(Key key)
Entry[] entries = _entries;
int bucketIndex = key.HashCode & (_buckets.Length - 1);
for (int i = _buckets[bucketIndex] - 1;
- (uint)i < (uint)entries.Length; i = entries[i].next)
+ (uint) i < (uint) entries.Length; i = entries[i].next)
{
if (key.Name == entries[i].key.Name)
{
@@ -154,7 +154,7 @@ public override ref TValue GetValueRefOrAddDefault(Key key, out bool exists)
Entry[] entries = _entries;
int bucketIndex = key.HashCode & (_buckets.Length - 1);
for (int i = _buckets[bucketIndex] - 1;
- (uint)i < (uint)entries.Length; i = entries[i].next)
+ (uint) i < (uint) entries.Length; i = entries[i].next)
{
if (key.Name == entries[i].key.Name)
{
@@ -172,7 +172,7 @@ public bool TryAdd(Key key, TValue value)
Entry[] entries = _entries;
int bucketIndex = key.HashCode & (_buckets.Length - 1);
for (int i = _buckets[bucketIndex] - 1;
- (uint)i < (uint)entries.Length; i = entries[i].next)
+ (uint) i < (uint) entries.Length; i = entries[i].next)
{
if (key.Name == entries[i].key.Name)
{
@@ -226,7 +226,7 @@ private Entry[] Resize()
Debug.Assert(_entries.Length == _count || _entries.Length == 1); // We only copy _count, so if it's longer we will miss some
int count = _count;
int newSize = _entries.Length * 2;
- if ((uint)newSize > (uint)int.MaxValue) // uint cast handles overflow
+ if ((uint) newSize > int.MaxValue) // uint cast handles overflow
throw new InvalidOperationException("Capacity Overflow");
var entries = new Entry[newSize];
diff --git a/Jint/Engine.Modules.cs b/Jint/Engine.Modules.cs
index c1a7b313d4..d2aaf34f19 100644
--- a/Jint/Engine.Modules.cs
+++ b/Jint/Engine.Modules.cs
@@ -148,7 +148,7 @@ private static void LinkModule(string specifier, Module module)
private JsValue EvaluateModule(string specifier, Module module)
{
var ownsContext = _engine._activeEvaluationContext is null;
- _engine. _activeEvaluationContext ??= new EvaluationContext(_engine);
+ _engine._activeEvaluationContext ??= new EvaluationContext(_engine);
JsValue evaluationResult;
try
{
diff --git a/Jint/Engine.cs b/Jint/Engine.cs
index d4839854b0..cd33faa97a 100644
--- a/Jint/Engine.cs
+++ b/Jint/Engine.cs
@@ -52,7 +52,7 @@ public sealed partial class Engine : IDisposable
internal readonly bool _isDebugMode;
internal readonly bool _isStrict;
- private bool _customResolver;
+ private readonly bool _customResolver;
internal readonly IReferenceResolver _referenceResolver;
internal readonly ReferencePool _referencePool;
@@ -1608,7 +1608,7 @@ public void Dispose()
}
#if SUPPORTS_WEAK_TABLE_CLEAR
- _objectWrapperCache.Clear();
+ _objectWrapperCache.Clear();
#else
// we can expect that reflection is OK as we've been generating object wrappers already
var clearMethod = _objectWrapperCache.GetType().GetMethod("Clear", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
diff --git a/Jint/Extensions/Character.cs b/Jint/Extensions/Character.cs
index 924b34ba6b..64a8192983 100644
--- a/Jint/Extensions/Character.cs
+++ b/Jint/Extensions/Character.cs
@@ -10,7 +10,7 @@ internal static class Character
public const string AsciiWordCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static bool IsInRange(this char c, ushort min, ushort max) => (uint)(c - min) <= (uint)(max - min);
+ public static bool IsInRange(this char c, ushort min, ushort max) => (uint) (c - min) <= (uint) (max - min);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsOctalDigit(this char c) => c.IsInRange('0', '7');
diff --git a/Jint/Extensions/Hash.cs b/Jint/Extensions/Hash.cs
index dace6edf27..066d51823f 100644
--- a/Jint/Extensions/Hash.cs
+++ b/Jint/Extensions/Hash.cs
@@ -15,7 +15,7 @@ internal static class Hash
/// The offset bias value used in the FNV-1a algorithm
/// See http://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
///
- private const int FnvOffsetBias = unchecked((int)2166136261);
+ private const int FnvOffsetBias = unchecked((int) 2166136261);
///
/// The generative factor used in the FNV-1a algorithm
@@ -53,10 +53,10 @@ internal static int GetFNVHashCode(System.Text.StringBuilder text)
int hashCode = FnvOffsetBias;
#if NETCOREAPP3_1_OR_GREATER
- foreach (var chunk in text.GetChunks())
- {
- hashCode = CombineFNVHash(hashCode, chunk.Span);
- }
+ foreach (var chunk in text.GetChunks())
+ {
+ hashCode = CombineFNVHash(hashCode, chunk.Span);
+ }
#else
// StringBuilder.GetChunks is not available in this target framework. Since there is no other direct access
// to the underlying storage spans of StringBuilder, we fall back to using slower per-character operations.
diff --git a/Jint/Extensions/WebEncoders.cs b/Jint/Extensions/WebEncoders.cs
index 45d0b2188f..522099f248 100644
--- a/Jint/Extensions/WebEncoders.cs
+++ b/Jint/Extensions/WebEncoders.cs
@@ -136,16 +136,16 @@ public static string Base64UrlEncode(byte[] input, int offset, int count, bool o
#if NETCOREAPP
return Base64UrlEncode(input.AsSpan(offset, count), omitPadding);
#else
- // Special-case empty input
- if (count == 0)
- {
- return string.Empty;
- }
+ // Special-case empty input
+ if (count == 0)
+ {
+ return string.Empty;
+ }
- var buffer = new char[GetArraySizeRequiredToEncode(count)];
- var numBase64Chars = Base64UrlEncode(input, offset, buffer, outputOffset: 0, count: count, omitPadding);
+ var buffer = new char[GetArraySizeRequiredToEncode(count)];
+ var numBase64Chars = Base64UrlEncode(input, offset, buffer, outputOffset: 0, count: count, omitPadding);
- return new string(buffer, startIndex: 0, length: numBase64Chars);
+ return new string(buffer, startIndex: 0, length: numBase64Chars);
#endif
}
@@ -193,37 +193,37 @@ public static int Base64UrlEncode(byte[] input, int offset, char[] output, int o
#if NETCOREAPP
return Base64UrlEncode(input.AsSpan(offset, count), output.AsSpan(outputOffset), omitPadding);
#else
- // Special-case empty input.
- if (count == 0)
- {
- return 0;
- }
+ // Special-case empty input.
+ if (count == 0)
+ {
+ return 0;
+ }
- // Use base64url encoding with no padding characters. See RFC 4648, Sec. 5.
+ // Use base64url encoding with no padding characters. See RFC 4648, Sec. 5.
- // Start with default Base64 encoding.
- var numBase64Chars = Convert.ToBase64CharArray(input, offset, count, output, outputOffset);
+ // Start with default Base64 encoding.
+ var numBase64Chars = Convert.ToBase64CharArray(input, offset, count, output, outputOffset);
- // Fix up '+' -> '-' and '/' -> '_'. Drop padding characters.
- for (var i = outputOffset; i - outputOffset < numBase64Chars; i++)
+ // Fix up '+' -> '-' and '/' -> '_'. Drop padding characters.
+ for (var i = outputOffset; i - outputOffset < numBase64Chars; i++)
+ {
+ var ch = output[i];
+ if (ch == '+')
+ {
+ output[i] = '-';
+ }
+ else if (ch == '/')
{
- var ch = output[i];
- if (ch == '+')
- {
- output[i] = '-';
- }
- else if (ch == '/')
- {
- output[i] = '_';
- }
- else if (omitPadding && ch == '=')
- {
- // We've reached a padding character; truncate the remainder.
- return i - outputOffset;
- }
+ output[i] = '_';
}
+ else if (omitPadding && ch == '=')
+ {
+ // We've reached a padding character; truncate the remainder.
+ return i - outputOffset;
+ }
+ }
- return numBase64Chars;
+ return numBase64Chars;
#endif
}
diff --git a/Jint/HoistingScope.cs b/Jint/HoistingScope.cs
index 5334c83804..15a10ccdf0 100644
--- a/Jint/HoistingScope.cs
+++ b/Jint/HoistingScope.cs
@@ -174,7 +174,7 @@ public void Visit(Node node, Node? parent)
var childType = childNode.Type;
if (childType == NodeType.VariableDeclaration)
{
- var variableDeclaration = (VariableDeclaration)childNode;
+ var variableDeclaration = (VariableDeclaration) childNode;
if (variableDeclaration.Kind == VariableDeclarationKind.Var)
{
_variableDeclarations ??= [];
@@ -217,7 +217,7 @@ public void Visit(Node node, Node? parent)
if (parent is null || (node.Type != NodeType.BlockStatement && node.Type != NodeType.SwitchCase))
{
_functions ??= [];
- _functions.Add((FunctionDeclaration)childNode);
+ _functions.Add((FunctionDeclaration) childNode);
}
}
else if (childType == NodeType.ClassDeclaration && parent is null or AstModule)
diff --git a/Jint/Jint.csproj b/Jint/Jint.csproj
index dc9c3242b0..3e62322506 100644
--- a/Jint/Jint.csproj
+++ b/Jint/Jint.csproj
@@ -12,7 +12,7 @@
true
latest-Recommended
- false
+ true
true
README.md
diff --git a/Jint/Native/Array/ArrayConstructor.cs b/Jint/Native/Array/ArrayConstructor.cs
index c281e0478f..49b0612e24 100644
--- a/Jint/Native/Array/ArrayConstructor.cs
+++ b/Jint/Native/Array/ArrayConstructor.cs
@@ -42,7 +42,7 @@ protected override void Initialize()
var symbols = new SymbolDictionary(1)
{
- [GlobalSymbolRegistry.Species] = new GetSetPropertyDescriptor(get: new ClrFunction(Engine, "get [Symbol.species]", Species, 0, PropertyFlag.Configurable), set: Undefined,PropertyFlag.Configurable),
+ [GlobalSymbolRegistry.Species] = new GetSetPropertyDescriptor(get: new ClrFunction(Engine, "get [Symbol.species]", Species, 0, PropertyFlag.Configurable), set: Undefined, PropertyFlag.Configurable),
};
SetSymbols(symbols);
}
@@ -202,7 +202,7 @@ private JsValue Of(JsValue thisObject, JsCallArguments arguments)
// faster for real arrays
for (uint k = 0; k < arguments.Length; k++)
{
- var kValue = arguments[(int)k];
+ var kValue = arguments[(int) k];
ai.SetIndexValue(k, kValue, updateLength: k == arguments.Length - 1);
}
}
@@ -211,7 +211,7 @@ private JsValue Of(JsValue thisObject, JsCallArguments arguments)
// slower version
for (uint k = 0; k < arguments.Length; k++)
{
- var kValue = arguments[(int)k];
+ var kValue = arguments[(int) k];
var key = JsString.Create(k);
a.CreateDataPropertyOrThrow(key, kValue);
}
diff --git a/Jint/Native/Array/ArrayIteratorPrototype.cs b/Jint/Native/Array/ArrayIteratorPrototype.cs
index 696b212a84..543fcd607f 100644
--- a/Jint/Native/Array/ArrayIteratorPrototype.cs
+++ b/Jint/Native/Array/ArrayIteratorPrototype.cs
@@ -47,7 +47,7 @@ internal IteratorInstance Construct(ObjectInstance array, ArrayIteratorType kind
}
IteratorInstance instance = array is JsArray jsArray
- ? new ArrayIterator(Engine, jsArray, kind) { _prototype = this }
+ ? new ArrayIterator(Engine, jsArray, kind) { _prototype = this }
: new ArrayLikeIterator(Engine, array, kind) { _prototype = this };
return instance;
diff --git a/Jint/Native/Array/ArrayOperations.cs b/Jint/Native/Array/ArrayOperations.cs
index e9131b3850..e7a1f51017 100644
--- a/Jint/Native/Array/ArrayOperations.cs
+++ b/Jint/Native/Array/ArrayOperations.cs
@@ -602,7 +602,7 @@ public override void SetLength(ulong length)
public override void EnsureCapacity(ulong capacity)
{
- _target.EnsureCapacity((int)capacity);
+ _target.EnsureCapacity((int) capacity);
}
public override JsValue Get(ulong index) => index < (ulong) _target.Length ? ReadValue((int) index) : JsValue.Undefined;
@@ -631,7 +631,7 @@ public override void CreateDataPropertyOrThrow(ulong index, JsValue value)
public override void Set(ulong index, JsValue value, bool updateLength = false, bool throwOnError = true)
{
- _target.SetAt((int)index, value);
+ _target.SetAt((int) index, value);
}
public override void DeletePropertyOrThrow(ulong index)
diff --git a/Jint/Native/Array/ArrayPrototype.cs b/Jint/Native/Array/ArrayPrototype.cs
index 34fe0a0686..838ef0796f 100644
--- a/Jint/Native/Array/ArrayPrototype.cs
+++ b/Jint/Native/Array/ArrayPrototype.cs
@@ -69,7 +69,7 @@ protected override void Initialize()
["reduce"] = new LazyPropertyDescriptor(this, static prototype => new ClrFunction(prototype._engine, "reduce", prototype.Reduce, 1, PropertyFlag.Configurable), PropertyFlags),
["reduceRight"] = new LazyPropertyDescriptor(this, static prototype => new ClrFunction(prototype._engine, "reduceRight", prototype.ReduceRight, 1, PropertyFlag.Configurable), PropertyFlags),
["reverse"] = new LazyPropertyDescriptor(this, static prototype => new ClrFunction(prototype._engine, "reverse", prototype.Reverse, 0, PropertyFlag.Configurable), PropertyFlags),
- ["shift"] = new LazyPropertyDescriptor(this, static prototype => new ClrFunction(prototype._engine, "shift",prototype. Shift, 0, PropertyFlag.Configurable), PropertyFlags),
+ ["shift"] = new LazyPropertyDescriptor(this, static prototype => new ClrFunction(prototype._engine, "shift", prototype.Shift, 0, PropertyFlag.Configurable), PropertyFlags),
["slice"] = new LazyPropertyDescriptor(this, static prototype => new ClrFunction(prototype._engine, "slice", prototype.Slice, 2, PropertyFlag.Configurable), PropertyFlags),
["some"] = new LazyPropertyDescriptor(this, static prototype => new ClrFunction(prototype._engine, "some", prototype.Some, 1, PropertyFlag.Configurable), PropertyFlags),
["sort"] = new LazyPropertyDescriptor(this, static prototype => new ClrFunction(prototype._engine, "sort", prototype.Sort, 1, PropertyFlag.Configurable), PropertyFlags),
@@ -1093,11 +1093,13 @@ private JsValue Sort(JsValue thisObject, JsCallArguments arguments)
ordered = items.OrderBy(x => x, comparer);
}
#else
- #if NET8_0_OR_GREATER
- ordered = items.Order(comparer);
- #else
- ordered = items.OrderBy(x => x, comparer);
- #endif
+
+#if NET8_0_OR_GREATER
+ ordered = items.Order(comparer);
+#else
+ ordered = items.OrderBy(x => x, comparer);
+#endif
+
#endif
uint j = 0;
foreach (var item in ordered)
diff --git a/Jint/Native/ArrayBuffer/ArrayBufferConstructor.cs b/Jint/Native/ArrayBuffer/ArrayBufferConstructor.cs
index f279214b1e..9666b8249a 100644
--- a/Jint/Native/ArrayBuffer/ArrayBufferConstructor.cs
+++ b/Jint/Native/ArrayBuffer/ArrayBufferConstructor.cs
@@ -40,7 +40,7 @@ protected override void Initialize()
var symbols = new SymbolDictionary(1)
{
- [GlobalSymbolRegistry.Species] = new GetSetPropertyDescriptor(get: new ClrFunction(Engine, "get [Symbol.species]", Species, 0, lengthFlags), set: Undefined,PropertyFlag.Configurable),
+ [GlobalSymbolRegistry.Species] = new GetSetPropertyDescriptor(get: new ClrFunction(Engine, "get [Symbol.species]", Species, 0, lengthFlags), set: Undefined, PropertyFlag.Configurable),
};
SetSymbols(symbols);
}
diff --git a/Jint/Native/Date/DateConstructor.cs b/Jint/Native/Date/DateConstructor.cs
index 5d6c5cdb2d..d73039994d 100644
--- a/Jint/Native/Date/DateConstructor.cs
+++ b/Jint/Native/Date/DateConstructor.cs
@@ -87,7 +87,7 @@ private static JsValue Utc(JsValue thisObject, JsCallArguments arguments)
var yInteger = TypeConverter.ToInteger(y);
if (!double.IsNaN(y) && 0 <= yInteger && yInteger <= 99)
{
- y = yInteger + 1900;
+ y = yInteger + 1900;
}
var finalDate = DatePrototype.MakeDate(
diff --git a/Jint/Native/Date/DatePrototype.cs b/Jint/Native/Date/DatePrototype.cs
index 5c3e98b4bf..6a97971234 100644
--- a/Jint/Native/Date/DatePrototype.cs
+++ b/Jint/Native/Date/DatePrototype.cs
@@ -36,7 +36,7 @@ internal DatePrototype(
_timeSystem = engine.Options.TimeSystem;
}
- protected override void Initialize()
+ protected override void Initialize()
{
const PropertyFlag lengthFlags = PropertyFlag.Configurable;
const PropertyFlag propertyFlags = PropertyFlag.Configurable | PropertyFlag.Writable;
@@ -122,7 +122,7 @@ private JsValue ToPrimitive(JsValue thisObject, JsCallArguments arguments)
{
tryFirst = Types.String;
}
- else if (string.Equals(hintString, "number", StringComparison.Ordinal))
+ else if (string.Equals(hintString, "number", StringComparison.Ordinal))
{
tryFirst = Types.Number;
}
@@ -447,7 +447,7 @@ private JsValue GetTimezoneOffset(JsValue thisObject, JsCallArguments arguments)
{
return JsNumber.DoubleNaN;
}
- return (int) ((double) t.Value - LocalTime(t).Value)/MsPerMinute;
+ return (int) ((double) t.Value - LocalTime(t).Value) / MsPerMinute;
}
///
@@ -873,22 +873,22 @@ private static long TimeWithinDay(DatePresentation t)
///
private static int DaysInYear(double y)
{
- if (y%4 != 0)
+ if (y % 4 != 0)
{
return 365;
}
- if (y%4 == 0 && y%100 != 0)
+ if (y % 4 == 0 && y % 100 != 0)
{
return 366;
}
- if (y%100 == 0 && y%400 != 0)
+ if (y % 100 == 0 && y % 400 != 0)
{
return 365;
}
- if (y%400 == 0)
+ if (y % 400 == 0)
{
return 366;
}
@@ -901,10 +901,10 @@ private static int DaysInYear(double y)
///
private static int DayFromYear(DatePresentation y)
{
- return (int) (365*(y.Value - 1970)
- + System.Math.Floor((y.Value - 1969)/4d)
- - System.Math.Floor((y.Value - 1901)/100d)
- + System.Math.Floor((y.Value - 1601)/400d));
+ return (int) (365 * (y.Value - 1970)
+ + System.Math.Floor((y.Value - 1969) / 4d)
+ - System.Math.Floor((y.Value - 1901) / 100d)
+ + System.Math.Floor((y.Value - 1601) / 400d));
}
///
@@ -912,7 +912,7 @@ private static int DayFromYear(DatePresentation y)
///
private static long TimeFromYear(DatePresentation y)
{
- return MsPerDay*DayFromYear(y);
+ return MsPerDay * DayFromYear(y);
}
///
@@ -1032,7 +1032,7 @@ private static int DateFromTime(DatePresentation t)
return dayWithinYear + 1;
}
- if (monthFromTime== 1)
+ if (monthFromTime == 1)
{
return dayWithinYear - 30;
}
@@ -1185,7 +1185,7 @@ internal static double MakeTime(double hour, double min, double sec, double ms)
var m = TypeConverter.ToInteger(min);
var s = TypeConverter.ToInteger(sec);
var milli = TypeConverter.ToInteger(ms);
- var t = h*MsPerHour + m*MsPerMinute + s*MsPerSecond + milli;
+ var t = h * MsPerHour + m * MsPerMinute + s * MsPerSecond + milli;
return t;
}
@@ -1262,7 +1262,7 @@ private static bool AreFinite(double value1, double value2, double value3)
=> IsFinite(value1) && IsFinite(value2) && IsFinite(value3);
private static bool AreFinite(double value1, double value2, double value3, double value4)
- => IsFinite(value1) && IsFinite(value2) && IsFinite(value3) && IsFinite(value4);
+ => IsFinite(value1) && IsFinite(value2) && IsFinite(value3) && IsFinite(value4);
[StructLayout(LayoutKind.Auto)]
private readonly record struct Date(int Year, int Month, int Day);
diff --git a/Jint/Native/Function/FunctionInstance.Dynamic.cs b/Jint/Native/Function/FunctionInstance.Dynamic.cs
index d5a55f3082..882f99ff6e 100644
--- a/Jint/Native/Function/FunctionInstance.Dynamic.cs
+++ b/Jint/Native/Function/FunctionInstance.Dynamic.cs
@@ -199,6 +199,10 @@ internal ScriptFunction OrdinaryFunctionCreate(
function,
scope,
thisMode,
- functionPrototype) { _privateEnvironment = privateScope, _realm = _realm };
+ functionPrototype)
+ {
+ _privateEnvironment = privateScope,
+ _realm = _realm,
+ };
}
}
diff --git a/Jint/Native/Global/GlobalObject.cs b/Jint/Native/Global/GlobalObject.cs
index 304638f6b2..2e832be327 100644
--- a/Jint/Native/Global/GlobalObject.cs
+++ b/Jint/Native/Global/GlobalObject.cs
@@ -113,7 +113,7 @@ internal static JsValue ParseInt(JsValue thisObject, JsCallArguments arguments)
pow *= radix;
}
- return hasResult ? JsNumber.Create(sign * result) : JsNumber.DoubleNaN;
+ return hasResult ? JsNumber.Create(sign * result) : JsNumber.DoubleNaN;
}
///
@@ -223,7 +223,7 @@ internal static JsValue ParseFloat(JsValue thisObject, JsCallArguments arguments
// we should now have proper input part
#if SUPPORTS_SPAN_PARSE
- var substring = trimmedString.AsSpan(0, i);
+ var substring = trimmedString.AsSpan(0, i);
#else
var substring = trimmedString.Substring(0, i);
#endif
@@ -389,7 +389,7 @@ private JsValue Encode(string uriString, SearchValues allowedCharacters)
return builder.ToString();
- uriError:
+uriError:
_engine.SignalError(ExceptionHelper.CreateUriError(_realm, "URI malformed"));
return JsEmpty.Instance;
}
@@ -448,7 +448,7 @@ private JsValue Decode(string uriString, SearchValues? reservedSet)
k += 2;
if ((B & 0x80) == 0)
{
- C = (char)B;
+ C = (char) B;
#pragma warning disable CA2249
if (reservedSet == null || !reservedSet.Contains(C))
#pragma warning restore CA2249
@@ -508,7 +508,7 @@ private JsValue Decode(string uriString, SearchValues? reservedSet)
}
#if SUPPORTS_SPAN_PARSE
- _stringBuilder.Append(Encoding.UTF8.GetString(octets.Slice(0, n)));
+ _stringBuilder.Append(Encoding.UTF8.GetString(octets.Slice(0, n)));
#else
_stringBuilder.Append(Encoding.UTF8.GetString(octets, 0, n));
#endif
@@ -518,7 +518,7 @@ private JsValue Decode(string uriString, SearchValues? reservedSet)
return _stringBuilder.ToString();
- uriError:
+uriError:
_engine.SignalError(ExceptionHelper.CreateUriError(_realm, "URI malformed"));
return JsEmpty.Instance;
}
@@ -555,15 +555,15 @@ private static byte StringToIntBase16(ReadOnlySpan s)
private static bool IsDigit(char c, int radix, out int result)
{
int tmp;
- if ((uint)(c - '0') <= 9)
+ if ((uint) (c - '0') <= 9)
{
result = tmp = c - '0';
}
- else if ((uint)(c - 'A') <= 'Z' - 'A')
+ else if ((uint) (c - 'A') <= 'Z' - 'A')
{
result = tmp = c - 'A' + 10;
}
- else if ((uint)(c - 'a') <= 'z' - 'a')
+ else if ((uint) (c - 'a') <= 'z' - 'a')
{
result = tmp = c - 'a' + 10;
}
diff --git a/Jint/Native/Intl/IntlInstance.cs b/Jint/Native/Intl/IntlInstance.cs
index 5a6b3cbcb9..d8f60823a5 100644
--- a/Jint/Native/Intl/IntlInstance.cs
+++ b/Jint/Native/Intl/IntlInstance.cs
@@ -38,7 +38,7 @@ protected override void Initialize()
["PluralRules"] = new(_realm.Intrinsics.PluralRules, false, false, true),
["RelativeTimeFormat"] = new(_realm.Intrinsics.RelativeTimeFormat, false, false, true),
["Segmenter"] = new(_realm.Intrinsics.Segmenter, false, false, true),
- ["getCanonicalLocales "] = new(new ClrFunction(Engine, "getCanonicalLocales ", GetCanonicalLocales , 1, PropertyFlag.Configurable), true, false, true),
+ ["getCanonicalLocales "] = new(new ClrFunction(Engine, "getCanonicalLocales ", GetCanonicalLocales, 1, PropertyFlag.Configurable), true, false, true),
};
SetProperties(properties);
diff --git a/Jint/Native/JsArrayBuffer.cs b/Jint/Native/JsArrayBuffer.cs
index 5c19cf3222..d93f04a08f 100644
--- a/Jint/Native/JsArrayBuffer.cs
+++ b/Jint/Native/JsArrayBuffer.cs
@@ -268,7 +268,7 @@ private byte[] NumericToRawBytes(TypedArrayElementType type, TypedArrayValue val
else
{
// inlined conversion for faster speed instead of getting the method in spec
- var doubleValue = value.DoubleValue;
+ var doubleValue = value.DoubleValue;
var intValue = double.IsNaN(doubleValue) || doubleValue == 0 || double.IsInfinity(doubleValue)
? 0
: (long) doubleValue;
@@ -289,28 +289,28 @@ private byte[] NumericToRawBytes(TypedArrayElementType type, TypedArrayValue val
#if !NETSTANDARD2_1
rawBytes = BitConverter.GetBytes((short) intValue);
#else
- BitConverter.TryWriteBytes(rawBytes, (short) intValue);
+ BitConverter.TryWriteBytes(rawBytes, (short) intValue);
#endif
break;
case TypedArrayElementType.Uint16:
#if !NETSTANDARD2_1
rawBytes = BitConverter.GetBytes((ushort) intValue);
#else
- BitConverter.TryWriteBytes(rawBytes, (ushort) intValue);
+ BitConverter.TryWriteBytes(rawBytes, (ushort) intValue);
#endif
break;
case TypedArrayElementType.Int32:
#if !NETSTANDARD2_1
rawBytes = BitConverter.GetBytes((uint) intValue);
#else
- BitConverter.TryWriteBytes(rawBytes, (uint) intValue);
+ BitConverter.TryWriteBytes(rawBytes, (uint) intValue);
#endif
break;
case TypedArrayElementType.Uint32:
#if !NETSTANDARD2_1
rawBytes = BitConverter.GetBytes((uint) intValue);
#else
- BitConverter.TryWriteBytes(rawBytes, (uint) intValue);
+ BitConverter.TryWriteBytes(rawBytes, (uint) intValue);
#endif
break;
default:
diff --git a/Jint/Native/JsNumber.cs b/Jint/Native/JsNumber.cs
index bc4af32b2d..b075dbb512 100644
--- a/Jint/Native/JsNumber.cs
+++ b/Jint/Native/JsNumber.cs
@@ -128,7 +128,7 @@ private static JsNumber CreateNumberUnlikely(double value)
return DoubleNegativeInfinity;
}
- if (double.IsPositiveInfinity(value ))
+ if (double.IsPositiveInfinity(value))
{
return DoublePositiveInfinity;
}
diff --git a/Jint/Native/JsString.cs b/Jint/Native/JsString.cs
index 326efb99d3..b636f796f9 100644
--- a/Jint/Native/JsString.cs
+++ b/Jint/Native/JsString.cs
@@ -37,7 +37,7 @@ public class JsString : JsValue, IEquatable, IEquatable
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
internal string _value;
- private static ConcurrentDictionary _stringCache;
+ private static readonly ConcurrentDictionary _stringCache;
static JsString()
{
diff --git a/Jint/Native/JsValue.cs b/Jint/Native/JsValue.cs
index 0fd1581967..5ec5a43230 100644
--- a/Jint/Native/JsValue.cs
+++ b/Jint/Native/JsValue.cs
@@ -127,17 +127,17 @@ internal static JsValue ConvertAwaitableToPromise(Engine engine, object obj)
}
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP
- if (obj is ValueTask valueTask)
- {
- return ConvertTaskToPromise(engine, valueTask.AsTask());
- }
+ if (obj is ValueTask valueTask)
+ {
+ return ConvertTaskToPromise(engine, valueTask.AsTask());
+ }
- // ValueTask
- var asTask = obj.GetType().GetMethod(nameof(ValueTask
/// Current UTC time.
DateTimeOffset GetUtcNow();
-
+
///
/// Return the default time zone system is using. Usually , but can be altered via
/// engine configuration, see .
diff --git a/Jint/Runtime/Interop/DefaultObjectConverter.cs b/Jint/Runtime/Interop/DefaultObjectConverter.cs
index ec6478f01e..e11f8c0144 100644
--- a/Jint/Runtime/Interop/DefaultObjectConverter.cs
+++ b/Jint/Runtime/Interop/DefaultObjectConverter.cs
@@ -81,20 +81,20 @@ public static bool TryConvert(Engine engine, object value, Type? type, [NotNullW
}
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP
- if (value is ValueTask valueTask)
- {
- result = JsValue.ConvertAwaitableToPromise(engine, valueTask);
- return result is not null;
- }
+ if (value is ValueTask valueTask)
+ {
+ result = JsValue.ConvertAwaitableToPromise(engine, valueTask);
+ return result is not null;
+ }
#endif
}
#if NET8_0_OR_GREATER
- if (value is System.Text.Json.Nodes.JsonValue jsonValue)
- {
- result = ConvertSystemTextJsonValue(engine, jsonValue);
- return result is not null;
- }
+ if (value is System.Text.Json.Nodes.JsonValue jsonValue)
+ {
+ result = ConvertSystemTextJsonValue(engine, jsonValue);
+ return result is not null;
+ }
#endif
var t = value.GetType();
@@ -160,23 +160,23 @@ public static bool TryConvert(Engine engine, object value, Type? type, [NotNullW
}
#if NET8_0_OR_GREATER
- private static JsValue? ConvertSystemTextJsonValue(Engine engine, System.Text.Json.Nodes.JsonValue value)
+ private static JsValue? ConvertSystemTextJsonValue(Engine engine, System.Text.Json.Nodes.JsonValue value)
+ {
+ return value.GetValueKind() switch
{
- return value.GetValueKind() switch
- {
- System.Text.Json.JsonValueKind.Object => JsValue.FromObject(engine, value),
- System.Text.Json.JsonValueKind.Array => JsValue.FromObject(engine, value),
- System.Text.Json.JsonValueKind.String => JsString.Create(value.ToString()),
+ System.Text.Json.JsonValueKind.Object => JsValue.FromObject(engine, value),
+ System.Text.Json.JsonValueKind.Array => JsValue.FromObject(engine, value),
+ System.Text.Json.JsonValueKind.String => JsString.Create(value.ToString()),
#pragma warning disable IL2026, IL3050
- System.Text.Json.JsonValueKind.Number => value.TryGetValue(out var intValue) ? JsNumber.Create(intValue) : System.Text.Json.JsonSerializer.Deserialize(value),
+ System.Text.Json.JsonValueKind.Number => value.TryGetValue(out var intValue) ? JsNumber.Create(intValue) : System.Text.Json.JsonSerializer.Deserialize(value),
#pragma warning restore IL2026, IL3050
- System.Text.Json.JsonValueKind.True => JsBoolean.True,
- System.Text.Json.JsonValueKind.False => JsBoolean.False,
- System.Text.Json.JsonValueKind.Undefined => JsValue.Undefined,
- System.Text.Json.JsonValueKind.Null => JsValue.Null,
- _ => null
- };
- }
+ System.Text.Json.JsonValueKind.True => JsBoolean.True,
+ System.Text.Json.JsonValueKind.False => JsBoolean.False,
+ System.Text.Json.JsonValueKind.Undefined => JsValue.Undefined,
+ System.Text.Json.JsonValueKind.Null => JsValue.Null,
+ _ => null
+ };
+ }
#endif
private static bool TryConvertConvertible(Engine engine, IConvertible convertible, [NotNullWhen(true)] out JsValue? result)
diff --git a/Jint/Runtime/Interop/DelegateWrapper.cs b/Jint/Runtime/Interop/DelegateWrapper.cs
index c79dc2fe30..ab1969d807 100644
--- a/Jint/Runtime/Interop/DelegateWrapper.cs
+++ b/Jint/Runtime/Interop/DelegateWrapper.cs
@@ -158,19 +158,19 @@ private static bool IsAwaitable(object? obj)
return true;
}
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP
- if (obj is ValueTask)
- {
- return true;
- }
+ if (obj is ValueTask)
+ {
+ return true;
+ }
- // ValueTask is not derived from ValueTask, so we need to check for it explicitly
- var type = obj.GetType();
- if (!type.IsGenericType)
- {
- return false;
- }
+ // ValueTask is not derived from ValueTask, so we need to check for it explicitly
+ var type = obj.GetType();
+ if (!type.IsGenericType)
+ {
+ return false;
+ }
- return type.GetGenericTypeDefinition() == typeof(ValueTask<>);
+ return type.GetGenericTypeDefinition() == typeof(ValueTask<>);
#else
return false;
#endif
diff --git a/Jint/Runtime/Interop/GetterFunction.cs b/Jint/Runtime/Interop/GetterFunction.cs
index 5332ebcbb3..37923aa81e 100644
--- a/Jint/Runtime/Interop/GetterFunction.cs
+++ b/Jint/Runtime/Interop/GetterFunction.cs
@@ -6,7 +6,7 @@ namespace Jint.Runtime.Interop;
///
/// Represents a FunctionInstance wrapping a CLR getter.
///
-internal sealed class GetterFunction: Function
+internal sealed class GetterFunction : Function
{
private static readonly JsString _name = new JsString("get");
private readonly Func _getter;
diff --git a/Jint/Runtime/Interop/ObjectWrapper.cs b/Jint/Runtime/Interop/ObjectWrapper.cs
index f45f56e938..65c39cdc29 100644
--- a/Jint/Runtime/Interop/ObjectWrapper.cs
+++ b/Jint/Runtime/Interop/ObjectWrapper.cs
@@ -215,7 +215,7 @@ public override JsValue Get(JsValue property, JsValue receiver)
public override List GetOwnPropertyKeys(Types types = Types.Empty | Types.String | Types.Symbol)
{
- return [..EnumerateOwnPropertyKeys(types)];
+ return [.. EnumerateOwnPropertyKeys(types)];
}
public override IEnumerable> GetOwnProperties()
@@ -225,7 +225,7 @@ public override IEnumerable> GetOwnPro
yield return new KeyValuePair(key, GetOwnProperty(key));
}
}
-
+
private IEnumerable EnumerateOwnPropertyKeys(Types types)
{
// prefer object order, add possible other properties after
diff --git a/Jint/Runtime/Interop/Reflection/IndexerAccessor.cs b/Jint/Runtime/Interop/Reflection/IndexerAccessor.cs
index c05b409598..291e028f5c 100644
--- a/Jint/Runtime/Interop/Reflection/IndexerAccessor.cs
+++ b/Jint/Runtime/Interop/Reflection/IndexerAccessor.cs
@@ -88,7 +88,7 @@ internal static bool TryFindIndexer(
indexerAccessor = ComposeIndexerFactory(engine, targetType, candidate, paramType, propertyName, integerKey, paramTypeArray);
if (indexerAccessor != null)
{
- if (paramType != typeof(string) || integerKey is null)
+ if (paramType != typeof(string) || integerKey is null)
{
// exact match, we don't need to check for integer key
indexer = candidate;
diff --git a/Jint/Runtime/Interop/TypeReference.cs b/Jint/Runtime/Interop/TypeReference.cs
index c5ca07f3be..e665b4b944 100644
--- a/Jint/Runtime/Interop/TypeReference.cs
+++ b/Jint/Runtime/Interop/TypeReference.cs
@@ -308,7 +308,7 @@ private static ReflectionAccessor ResolveMemberAccessor(
var memberNameComparer = typeResolver.MemberNameComparer;
var typeResolverMemberNameCreator = typeResolver.MemberNameCreator;
#if NET7_0_OR_GREATER
- var enumValues = type.GetEnumValuesAsUnderlyingType();
+ var enumValues = type.GetEnumValuesAsUnderlyingType();
#else
var enumValues = Enum.GetValues(type);
#endif
diff --git a/Jint/Runtime/Interop/TypeResolver.cs b/Jint/Runtime/Interop/TypeResolver.cs
index eb863735a3..5dddd223f0 100644
--- a/Jint/Runtime/Interop/TypeResolver.cs
+++ b/Jint/Runtime/Interop/TypeResolver.cs
@@ -274,7 +274,7 @@ private static int CalculateIndexerScore(ParameterInfo parameter, bool isInteger
if (paramType == typeof(int))
{
- return isInteger ? 0 : 10;
+ return isInteger ? 0 : 10;
}
if (paramType == typeof(string))
@@ -483,7 +483,7 @@ public override bool Equals(string? x, string? y)
if (equals && x.Length > 1)
{
#if SUPPORTS_SPAN_PARSE
- equals = x.AsSpan(1).SequenceEqual(y.AsSpan(1));
+ equals = x.AsSpan(1).SequenceEqual(y.AsSpan(1));
#else
equals = string.Equals(x.Substring(1), y.Substring(1), StringComparison.Ordinal);
#endif
diff --git a/Jint/Runtime/Interpreter/DeclarationCache.cs b/Jint/Runtime/Interpreter/DeclarationCache.cs
index 5958619b98..81006cae2f 100644
--- a/Jint/Runtime/Interpreter/DeclarationCache.cs
+++ b/Jint/Runtime/Interpreter/DeclarationCache.cs
@@ -67,7 +67,7 @@ public static DeclarationCache Build(SwitchCase statement)
continue;
}
- var rootVariable = (VariableDeclaration)node;
+ var rootVariable = (VariableDeclaration) node;
if (rootVariable.Kind == VariableDeclarationKind.Var)
{
continue;
diff --git a/Jint/Runtime/Interpreter/Expressions/DestructuringPatternAssignmentExpression.cs b/Jint/Runtime/Interpreter/Expressions/DestructuringPatternAssignmentExpression.cs
index c149aa7957..2102ac44d4 100644
--- a/Jint/Runtime/Interpreter/Expressions/DestructuringPatternAssignmentExpression.cs
+++ b/Jint/Runtime/Interpreter/Expressions/DestructuringPatternAssignmentExpression.cs
@@ -222,7 +222,7 @@ private static JsValue HandleArrayPattern(
}
else
{
- AssignToReference(engine, reference!, array, environment);
+ AssignToReference(engine, reference!, array, environment);
}
}
else if (left is AssignmentPattern assignmentPattern)
diff --git a/Jint/Runtime/Interpreter/Expressions/JintBinaryExpression.cs b/Jint/Runtime/Interpreter/Expressions/JintBinaryExpression.cs
index ea8a50bf1f..11b04c1b9b 100644
--- a/Jint/Runtime/Interpreter/Expressions/JintBinaryExpression.cs
+++ b/Jint/Runtime/Interpreter/Expressions/JintBinaryExpression.cs
@@ -298,7 +298,7 @@ protected override object EvaluateInternal(EvaluationContext context)
if (AreIntegerOperands(left, right))
{
- return JsNumber.Create((long)left.AsInteger() + right.AsInteger());
+ return JsNumber.Create((long) left.AsInteger() + right.AsInteger());
}
var lprim = TypeConverter.ToPrimitive(left);
@@ -308,7 +308,7 @@ protected override object EvaluateInternal(EvaluationContext context)
{
result = JsString.Create(TypeConverter.ToString(lprim) + TypeConverter.ToString(rprim));
}
- else if (AreNonBigIntOperands(left,right))
+ else if (AreNonBigIntOperands(left, right))
{
result = JsNumber.Create(TypeConverter.ToNumber(lprim) + TypeConverter.ToNumber(rprim));
}
@@ -347,7 +347,7 @@ protected override object EvaluateInternal(EvaluationContext context)
if (AreIntegerOperands(left, right))
{
- number = JsNumber.Create((long)left.AsInteger() - right.AsInteger());
+ number = JsNumber.Create((long) left.AsInteger() - right.AsInteger());
}
else if (AreNonBigIntOperands(left, right))
{
@@ -525,7 +525,7 @@ protected override object EvaluateInternal(EvaluationContext context)
var right = TypeConverter.ToNumeric(rightReference);
JsValue result;
- if (AreNonBigIntOperands(left,right))
+ if (AreNonBigIntOperands(left, right))
{
// validation
var baseNumber = (JsNumber) left;
diff --git a/Jint/Runtime/Interpreter/Expressions/JintSequenceExpression.cs b/Jint/Runtime/Interpreter/Expressions/JintSequenceExpression.cs
index efb4f1132d..15078e1b6a 100644
--- a/Jint/Runtime/Interpreter/Expressions/JintSequenceExpression.cs
+++ b/Jint/Runtime/Interpreter/Expressions/JintSequenceExpression.cs
@@ -31,7 +31,7 @@ protected override object EvaluateInternal(EvaluationContext context)
Initialize();
_initialized = true;
}
-
+
var result = JsValue.Undefined;
foreach (var expression in _expressions)
{
diff --git a/Jint/Runtime/Interpreter/JintFunctionDefinition.cs b/Jint/Runtime/Interpreter/JintFunctionDefinition.cs
index 9394f5615f..f4adcea9b1 100644
--- a/Jint/Runtime/Interpreter/JintFunctionDefinition.cs
+++ b/Jint/Runtime/Interpreter/JintFunctionDefinition.cs
@@ -330,7 +330,7 @@ private static void GetBoundNames(
ref bool hasDuplicates,
ref bool hasArguments)
{
- Start:
+Start:
if (parameter.Type == NodeType.Identifier)
{
var key = (Key) ((Identifier) parameter).Name;
diff --git a/Jint/Runtime/Interpreter/Statements/ConstantReturnStatement.cs b/Jint/Runtime/Interpreter/Statements/ConstantReturnStatement.cs
index e441324194..b1de86555b 100644
--- a/Jint/Runtime/Interpreter/Statements/ConstantReturnStatement.cs
+++ b/Jint/Runtime/Interpreter/Statements/ConstantReturnStatement.cs
@@ -5,7 +5,7 @@ namespace Jint.Runtime.Interpreter.Statements;
internal sealed class ConstantStatement : JintStatement
{
private readonly JsValue _value;
- private CompletionType _completionType;
+ private readonly CompletionType _completionType;
public ConstantStatement(Statement statement, CompletionType completionType, JsValue value) : base(statement)
{
diff --git a/Jint/Runtime/Interpreter/Statements/JintSwitchBlock.cs b/Jint/Runtime/Interpreter/Statements/JintSwitchBlock.cs
index 78233ad789..28df41c9d5 100644
--- a/Jint/Runtime/Interpreter/Statements/JintSwitchBlock.cs
+++ b/Jint/Runtime/Interpreter/Statements/JintSwitchBlock.cs
@@ -44,7 +44,7 @@ public Completion Execute(EvaluationContext context, JsValue input)
DeclarativeEnvironment? blockEnv = null;
- start:
+start:
for (; i < temp.Length; i++)
{
var clause = temp[i];
diff --git a/Jint/Runtime/OrderedSet.cs b/Jint/Runtime/OrderedSet.cs
index 753cbcd0e6..4bc8d5962c 100644
--- a/Jint/Runtime/OrderedSet.cs
+++ b/Jint/Runtime/OrderedSet.cs
@@ -36,7 +36,7 @@ public OrderedSet Clone()
return new OrderedSet(EqualityComparer.Default)
{
_set = new HashSet(this._set, this._set.Comparer),
- _list = [..this._list]
+ _list = [.. this._list]
};
}
diff --git a/Jint/Runtime/TypeConverter.cs b/Jint/Runtime/TypeConverter.cs
index 49e4eaca31..856a9abc89 100644
--- a/Jint/Runtime/TypeConverter.cs
+++ b/Jint/Runtime/TypeConverter.cs
@@ -287,7 +287,7 @@ private static double ToNumber(string input)
return -0.0;
}
- return firstChar == '-' ? - 1 * n : n;
+ return firstChar == '-' ? -1 * n : n;
}
catch (Exception e) when (e is OverflowException)
{
@@ -670,7 +670,7 @@ internal static bool TryStringToBigInt(string str, out BigInteger result)
{
// we get better precision if we don't hit floating point parsing that is performed by Esprima
#if SUPPORTS_SPAN_PARSE
- var source = str.AsSpan(2);
+ var source = str.AsSpan(2);
#else
var source = str.Substring(2);
#endif