Browse Source

Code changes to keep NET 8 analyzers happy (#1685)

Marko Lahma 1 year ago
parent
commit
6653ec842c
47 changed files with 102 additions and 37 deletions
  1. 2 2
      Jint/Engine.Modules.cs
  2. 12 0
      Jint/Extensions/Polyfills.cs
  3. 2 0
      Jint/Native/Array/ArrayConstructor.cs
  4. 2 0
      Jint/Native/Array/ArrayPrototype.cs
  5. 2 0
      Jint/Native/ArrayBuffer/ArrayBufferPrototype.cs
  6. 1 1
      Jint/Native/Boolean/BooleanPrototype.cs
  7. 2 0
      Jint/Native/DataView/DataViewPrototype.cs
  8. 2 0
      Jint/Native/Date/DateConstructor.cs
  9. 2 0
      Jint/Native/Date/DatePrototype.cs
  10. 1 0
      Jint/Native/Date/MimeKit.cs
  11. 3 3
      Jint/Native/Function/FunctionConstructor.cs
  12. 2 2
      Jint/Native/Function/FunctionInstance.Dynamic.cs
  13. 2 0
      Jint/Native/Function/FunctionPrototype.cs
  14. 3 3
      Jint/Native/Global/GlobalObject.cs
  15. 2 0
      Jint/Native/Intl/IntlInstance.cs
  16. 1 1
      Jint/Native/Iterator/IteratorInstance.cs
  17. 2 2
      Jint/Native/Json/JsonParser.cs
  18. 2 0
      Jint/Native/Map/MapConstructor.cs
  19. 2 0
      Jint/Native/Map/MapPrototype.cs
  20. 2 0
      Jint/Native/Object/ObjectConstructor.cs
  21. 2 0
      Jint/Native/Object/ObjectPrototype.cs
  22. 1 1
      Jint/Native/Promise/PromiseConstructor.cs
  23. 2 2
      Jint/Native/Promise/PromisePrototype.cs
  24. 2 0
      Jint/Native/Proxy/ProxyConstructor.cs
  25. 2 0
      Jint/Native/Reflect/ReflectInstance.cs
  26. 1 1
      Jint/Native/RegExp/RegExpConstructor.cs
  27. 9 7
      Jint/Native/RegExp/RegExpPrototype.cs
  28. 2 0
      Jint/Native/Set/SetPrototype.cs
  29. 1 1
      Jint/Native/ShadowRealm/ShadowRealm.cs
  30. 3 1
      Jint/Native/String/StringConstructor.cs
  31. 2 0
      Jint/Native/String/StringPrototype.cs
  32. 2 0
      Jint/Native/Symbol/SymbolConstructor.cs
  33. 2 0
      Jint/Native/Symbol/SymbolPrototype.cs
  34. 2 0
      Jint/Native/TypedArray/IntrinsicTypedArrayConstructor.cs
  35. 2 0
      Jint/Native/TypedArray/IntrinsicTypedArrayPrototype.cs
  36. 2 0
      Jint/Native/WeakMap/WeakMapPrototype.cs
  37. 2 0
      Jint/Native/WeakSet/WeakSetPrototype.cs
  38. 2 0
      Jint/Runtime/CallStack/JintCallStack.cs
  39. 1 1
      Jint/Runtime/Interop/DefaultObjectConverter.cs
  40. 1 1
      Jint/Runtime/Interop/NamespaceReference.cs
  41. 1 1
      Jint/Runtime/Interop/ObjectWrapper.cs
  42. 4 2
      Jint/Runtime/Interop/TypeReference.cs
  43. 1 1
      Jint/Runtime/Interpreter/Expressions/JintCallExpression.cs
  44. 1 1
      Jint/Runtime/Interpreter/Expressions/JintMemberExpression.cs
  45. 1 1
      Jint/Runtime/Interpreter/Expressions/JintObjectExpression.cs
  46. 1 1
      Jint/Runtime/Modules/DefaultModuleLoader.cs
  47. 1 1
      Jint/Runtime/Modules/ModuleRecord.cs

+ 2 - 2
Jint/Engine.Modules.cs

@@ -49,7 +49,7 @@ namespace Jint
             return module;
             return module;
         }
         }
 
 
-        private CyclicModuleRecord LoadFromBuilder(string specifier, ModuleBuilder moduleBuilder, ResolvedSpecifier moduleResolution)
+        private BuilderModuleRecord LoadFromBuilder(string specifier, ModuleBuilder moduleBuilder, ResolvedSpecifier moduleResolution)
         {
         {
             var parsedModule = moduleBuilder.Parse();
             var parsedModule = moduleBuilder.Parse();
             var module = new BuilderModuleRecord(this, Realm, parsedModule, null, false);
             var module = new BuilderModuleRecord(this, Realm, parsedModule, null, false);
@@ -59,7 +59,7 @@ namespace Jint
             return module;
             return module;
         }
         }
 
 
-        private CyclicModuleRecord LoaderFromModuleLoader(ResolvedSpecifier moduleResolution)
+        private SourceTextModuleRecord LoaderFromModuleLoader(ResolvedSpecifier moduleResolution)
         {
         {
             var parsedModule = ModuleLoader.LoadModule(this, moduleResolution);
             var parsedModule = ModuleLoader.LoadModule(this, moduleResolution);
             var module = new SourceTextModuleRecord(this, Realm, parsedModule, moduleResolution.Uri?.LocalPath, false);
             var module = new SourceTextModuleRecord(this, Realm, parsedModule, moduleResolution.Uri?.LocalPath, false);

+ 12 - 0
Jint/Extensions/Polyfills.cs

@@ -0,0 +1,12 @@
+namespace Jint;
+
+internal static class Polyfills
+{
+#if NETFRAMEWORK || NETSTANDARD2_0
+    internal static bool Contains(this string source, char c) => source.IndexOf(c) != -1;
+#endif
+
+#if NETFRAMEWORK || NETSTANDARD2_0
+    internal static bool StartsWith(this string source, char c) => source.Length > 0 && source[0] == c;
+#endif
+}

+ 2 - 0
Jint/Native/Array/ArrayConstructor.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CA1859 // Use concrete types when possible for improved performance -- most of constructor methods return JsValue
+
 using System.Collections;
 using System.Collections;
 using Jint.Collections;
 using Jint.Collections;
 using Jint.Native.Function;
 using Jint.Native.Function;

+ 2 - 0
Jint/Native/Array/ArrayPrototype.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CA1859 // Use concrete types when possible for improved performance -- most of prototype methods return JsValue
+
 using System.Linq;
 using System.Linq;
 using Jint.Collections;
 using Jint.Collections;
 using Jint.Native.Iterator;
 using Jint.Native.Iterator;

+ 2 - 0
Jint/Native/ArrayBuffer/ArrayBufferPrototype.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CA1859 // Use concrete types when possible for improved performance -- most of prototype methods return JsValue
+
 using Jint.Collections;
 using Jint.Collections;
 using Jint.Native.Object;
 using Jint.Native.Object;
 using Jint.Native.Symbol;
 using Jint.Native.Symbol;

+ 1 - 1
Jint/Native/Boolean/BooleanPrototype.cs

@@ -52,7 +52,7 @@ namespace Jint.Native.Boolean
             return Undefined;
             return Undefined;
         }
         }
 
 
-        private JsValue ToBooleanString(JsValue thisObject, JsValue[] arguments)
+        private JsString ToBooleanString(JsValue thisObject, JsValue[] arguments)
         {
         {
             var b = ValueOf(thisObject, Arguments.Empty);
             var b = ValueOf(thisObject, Arguments.Empty);
             return ((JsBoolean) b)._value ? JsString.TrueString : JsString.FalseString;
             return ((JsBoolean) b)._value ? JsString.TrueString : JsString.FalseString;

+ 2 - 0
Jint/Native/DataView/DataViewPrototype.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CA1859 // Use concrete types when possible for improved performance -- most of prototype methods return JsValue
+
 using Jint.Collections;
 using Jint.Collections;
 using Jint.Native.ArrayBuffer;
 using Jint.Native.ArrayBuffer;
 using Jint.Native.Object;
 using Jint.Native.Object;

+ 2 - 0
Jint/Native/Date/DateConstructor.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CA1859 // Use concrete types when possible for improved performance -- most of constructor methods return JsValue
+
 using Jint.Collections;
 using Jint.Collections;
 using Jint.Native.Function;
 using Jint.Native.Function;
 using Jint.Native.Object;
 using Jint.Native.Object;

+ 2 - 0
Jint/Native/Date/DatePrototype.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CA1859 // Use concrete types when possible for improved performance -- most of prototype methods return JsValue
+
 using System.Globalization;
 using System.Globalization;
 using System.Runtime.CompilerServices;
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 using System.Runtime.InteropServices;

+ 1 - 0
Jint/Native/Date/MimeKit.cs

@@ -1,4 +1,5 @@
 #nullable disable
 #nullable disable
+#pragma warning disable CA1510
 
 
 namespace Jint.Native.Date;
 namespace Jint.Native.Date;
 
 

+ 3 - 3
Jint/Native/Function/FunctionConstructor.cs

@@ -67,7 +67,7 @@ namespace Jint.Native.Function
         /// <summary>
         /// <summary>
         /// https://tc39.es/ecma262/#sec-runtime-semantics-instantiateasyncfunctionobject
         /// https://tc39.es/ecma262/#sec-runtime-semantics-instantiateasyncfunctionobject
         /// </summary>
         /// </summary>
-        private FunctionInstance InstantiateAsyncFunctionObject(
+        private ScriptFunctionInstance InstantiateAsyncFunctionObject(
             JintFunctionDefinition functionDeclaration,
             JintFunctionDefinition functionDeclaration,
             EnvironmentRecord env,
             EnvironmentRecord env,
             PrivateEnvironmentRecord? privateEnv)
             PrivateEnvironmentRecord? privateEnv)
@@ -87,7 +87,7 @@ namespace Jint.Native.Function
         /// <summary>
         /// <summary>
         /// https://tc39.es/ecma262/#sec-runtime-semantics-instantiateordinaryfunctionobject
         /// https://tc39.es/ecma262/#sec-runtime-semantics-instantiateordinaryfunctionobject
         /// </summary>
         /// </summary>
-        private FunctionInstance InstantiateOrdinaryFunctionObject(
+        private ScriptFunctionInstance InstantiateOrdinaryFunctionObject(
             JintFunctionDefinition functionDeclaration,
             JintFunctionDefinition functionDeclaration,
             EnvironmentRecord env,
             EnvironmentRecord env,
             PrivateEnvironmentRecord? privateEnv)
             PrivateEnvironmentRecord? privateEnv)
@@ -108,7 +108,7 @@ namespace Jint.Native.Function
         /// <summary>
         /// <summary>
         /// https://tc39.es/ecma262/#sec-runtime-semantics-instantiategeneratorfunctionobject
         /// https://tc39.es/ecma262/#sec-runtime-semantics-instantiategeneratorfunctionobject
         /// </summary>
         /// </summary>
-        private FunctionInstance InstantiateGeneratorFunctionObject(
+        private ScriptFunctionInstance InstantiateGeneratorFunctionObject(
             JintFunctionDefinition functionDeclaration,
             JintFunctionDefinition functionDeclaration,
             EnvironmentRecord scope,
             EnvironmentRecord scope,
             PrivateEnvironmentRecord? privateScope)
             PrivateEnvironmentRecord? privateScope)

+ 2 - 2
Jint/Native/Function/FunctionInstance.Dynamic.cs

@@ -115,7 +115,7 @@ public partial class FunctionInstance
                         break;
                         break;
                 }
                 }
 
 
-                if (p.IndexOf('/') != -1)
+                if (p.Contains('/'))
                 {
                 {
                     // ensure comments don't screw up things
                     // ensure comments don't screw up things
                     functionExpression += "\n" + p + "\n";
                     functionExpression += "\n" + p + "\n";
@@ -127,7 +127,7 @@ public partial class FunctionInstance
 
 
                 functionExpression += ")";
                 functionExpression += ")";
 
 
-                if (body.IndexOf('/') != -1)
+                if (body.Contains('/'))
                 {
                 {
                     // ensure comments don't screw up things
                     // ensure comments don't screw up things
                     functionExpression += "{\n" + body + "\n}";
                     functionExpression += "{\n" + body + "\n}";

+ 2 - 0
Jint/Native/Function/FunctionPrototype.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CA1859 // Use concrete types when possible for improved performance -- most of prototype methods return JsValue
+
 using Jint.Collections;
 using Jint.Collections;
 using Jint.Native.Array;
 using Jint.Native.Array;
 using Jint.Native.Object;
 using Jint.Native.Object;

+ 3 - 3
Jint/Native/Global/GlobalObject.cs

@@ -320,7 +320,7 @@ namespace Jint.Native.Global
             for (var k = 0; k < strLen; k++)
             for (var k = 0; k < strLen; k++)
             {
             {
                 var c = uriString[k];
                 var c = uriString[k];
-                if (c is >= 'a' and <= 'z' || c is >= 'A' and <= 'Z' || c is >= '0' and <= '9' || unescapedUriSet.IndexOf(c) != -1)
+                if (c is >= 'a' and <= 'z' || c is >= 'A' and <= 'Z' || c is >= '0' and <= '9' || unescapedUriSet.Contains(c))
                 {
                 {
                     _stringBuilder.Append(c);
                     _stringBuilder.Append(c);
                 }
                 }
@@ -594,7 +594,7 @@ uriError:
         /// </summary>
         /// </summary>
         public JsValue Escape(JsValue thisObject, JsValue[] arguments)
         public JsValue Escape(JsValue thisObject, JsValue[] arguments)
         {
         {
-            const string WhiteList = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@*_ + -./";
+            const string AllowList = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@*_ + -./";
             var uriString = TypeConverter.ToString(arguments.At(0));
             var uriString = TypeConverter.ToString(arguments.At(0));
 
 
             var strLen = uriString.Length;
             var strLen = uriString.Length;
@@ -605,7 +605,7 @@ uriError:
             for (var k = 0; k < strLen; k++)
             for (var k = 0; k < strLen; k++)
             {
             {
                 var c = uriString[k];
                 var c = uriString[k];
-                if (WhiteList.IndexOf(c) != -1)
+                if (AllowList.Contains(c))
                 {
                 {
                     _stringBuilder.Append(c);
                     _stringBuilder.Append(c);
                 }
                 }

+ 2 - 0
Jint/Native/Intl/IntlInstance.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CA1859 // Use concrete types when possible for improved performance -- most of prototype methods return JsValue
+
 using Jint.Collections;
 using Jint.Collections;
 using Jint.Native.Object;
 using Jint.Native.Object;
 using Jint.Native.Symbol;
 using Jint.Native.Symbol;

+ 1 - 1
Jint/Native/Iterator/IteratorInstance.cs

@@ -27,7 +27,7 @@ namespace Jint.Native.Iterator
         /// <summary>
         /// <summary>
         /// https://tc39.es/ecma262/#sec-createiterresultobject
         /// https://tc39.es/ecma262/#sec-createiterresultobject
         /// </summary>
         /// </summary>
-        private ObjectInstance CreateIterResultObject(JsValue value, bool done)
+        private IteratorResult CreateIterResultObject(JsValue value, bool done)
         {
         {
             return new IteratorResult(_engine, value, JsBoolean.Create(done));
             return new IteratorResult(_engine, value, JsBoolean.Create(done));
         }
         }

+ 2 - 2
Jint/Native/Json/JsonParser.cs

@@ -506,7 +506,7 @@ namespace Jint.Native.Json
             return _lookahead.Type == Tokens.Punctuator && value == _lookahead.FirstCharacter;
             return _lookahead.Type == Tokens.Punctuator && value == _lookahead.FirstCharacter;
         }
         }
 
 
-        private ObjectInstance ParseJsonArray(ref State state)
+        private JsArray ParseJsonArray(ref State state)
         {
         {
             if ((++state.CurrentDepth) > _maxDepth)
             if ((++state.CurrentDepth) > _maxDepth)
             {
             {
@@ -603,7 +603,7 @@ namespace Jint.Native.Json
             return result ?? new JsArray(_engine, elements!.ToArray());
             return result ?? new JsArray(_engine, elements!.ToArray());
         }
         }
 
 
-        private ObjectInstance ParseJsonObject(ref State state)
+        private JsObject ParseJsonObject(ref State state)
         {
         {
             if ((++state.CurrentDepth) > _maxDepth)
             if ((++state.CurrentDepth) > _maxDepth)
             {
             {

+ 2 - 0
Jint/Native/Map/MapConstructor.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CA1859 // Use concrete types when possible for improved performance -- most of constructor methods return JsValue
+
 using Jint.Collections;
 using Jint.Collections;
 using Jint.Native.Function;
 using Jint.Native.Function;
 using Jint.Native.Iterator;
 using Jint.Native.Iterator;

+ 2 - 0
Jint/Native/Map/MapPrototype.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CA1859 // Use concrete types when possible for improved performance -- most of prototype methods return JsValue
+
 using Jint.Collections;
 using Jint.Collections;
 using Jint.Native.Object;
 using Jint.Native.Object;
 using Jint.Native.Symbol;
 using Jint.Native.Symbol;

+ 2 - 0
Jint/Native/Object/ObjectConstructor.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CA1859 // Use concrete types when possible for improved performance -- most of constructor methods return JsValue
+
 using Jint.Collections;
 using Jint.Collections;
 using Jint.Native.Iterator;
 using Jint.Native.Iterator;
 using Jint.Runtime;
 using Jint.Runtime;

+ 2 - 0
Jint/Native/Object/ObjectPrototype.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CA1859 // Use concrete types when possible for improved performance -- most of prototype methods return JsValue
+
 using Jint.Collections;
 using Jint.Collections;
 using Jint.Native.Array;
 using Jint.Native.Array;
 using Jint.Native.Proxy;
 using Jint.Native.Proxy;

+ 1 - 1
Jint/Native/Promise/PromiseConstructor.cs

@@ -114,7 +114,7 @@ namespace Jint.Native.Promise
             return PromiseResolve(thisObject, x);
             return PromiseResolve(thisObject, x);
         }
         }
 
 
-        private JsValue WithResolvers(JsValue thisObject, JsValue[] arguments)
+        private JsObject WithResolvers(JsValue thisObject, JsValue[] arguments)
         {
         {
             var promiseCapability = NewPromiseCapability(_engine, thisObject);
             var promiseCapability = NewPromiseCapability(_engine, thisObject);
             var obj = OrdinaryObjectCreate(_engine, _engine.Realm.Intrinsics.Object.PrototypeObject);
             var obj = OrdinaryObjectCreate(_engine, _engine.Realm.Intrinsics.Object.PrototypeObject);

+ 2 - 2
Jint/Native/Promise/PromisePrototype.cs

@@ -118,7 +118,7 @@ namespace Jint.Native.Promise
         }
         }
 
 
         // https://tc39.es/ecma262/#sec-thenfinallyfunctions
         // https://tc39.es/ecma262/#sec-thenfinallyfunctions
-        private JsValue ThenFinallyFunctions(ICallable onFinally, IConstructor ctor) =>
+        private ClrFunctionInstance ThenFinallyFunctions(ICallable onFinally, IConstructor ctor) =>
             new ClrFunctionInstance(_engine, "", (_, args) =>
             new ClrFunctionInstance(_engine, "", (_, args) =>
             {
             {
                 var value = args.At(0);
                 var value = args.At(0);
@@ -137,7 +137,7 @@ namespace Jint.Native.Promise
             }, 1, PropertyFlag.Configurable);
             }, 1, PropertyFlag.Configurable);
 
 
         // https://tc39.es/ecma262/#sec-catchfinallyfunctions
         // https://tc39.es/ecma262/#sec-catchfinallyfunctions
-        private JsValue CatchFinallyFunctions(ICallable onFinally, IConstructor ctor) =>
+        private ClrFunctionInstance CatchFinallyFunctions(ICallable onFinally, IConstructor ctor) =>
             new ClrFunctionInstance(_engine, "", (_, args) =>
             new ClrFunctionInstance(_engine, "", (_, args) =>
             {
             {
                 var reason = args.At(0);
                 var reason = args.At(0);

+ 2 - 0
Jint/Native/Proxy/ProxyConstructor.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CA1859 // Use concrete types when possible for improved performance -- most of constructor methods return JsValue
+
 using Jint.Collections;
 using Jint.Collections;
 using Jint.Native.Object;
 using Jint.Native.Object;
 using Jint.Runtime;
 using Jint.Runtime;

+ 2 - 0
Jint/Native/Reflect/ReflectInstance.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CA1859 // Use concrete types when possible for improved performance -- most of prototype methods return JsValue
+
 using Jint.Collections;
 using Jint.Collections;
 using Jint.Native.Function;
 using Jint.Native.Function;
 using Jint.Native.Object;
 using Jint.Native.Object;

+ 1 - 1
Jint/Native/RegExp/RegExpConstructor.cs

@@ -92,7 +92,7 @@ namespace Jint.Native.RegExp
             return RegExpInitialize(r, p, f);
             return RegExpInitialize(r, p, f);
         }
         }
 
 
-        private ObjectInstance RegExpInitialize(JsRegExp r, JsValue pattern, JsValue flags)
+        private JsRegExp RegExpInitialize(JsRegExp r, JsValue pattern, JsValue flags)
         {
         {
             var p = pattern.IsUndefined() ? "" : TypeConverter.ToString(pattern);
             var p = pattern.IsUndefined() ? "" : TypeConverter.ToString(pattern);
             if (string.IsNullOrEmpty(p))
             if (string.IsNullOrEmpty(p))

+ 9 - 7
Jint/Native/RegExp/RegExpPrototype.cs

@@ -1,4 +1,6 @@
-using System.Text.RegularExpressions;
+#pragma warning disable CA1859 // Use concrete types when possible for improved performance -- most of prototype methods return JsValue
+
+using System.Text.RegularExpressions;
 using Jint.Collections;
 using Jint.Collections;
 using Jint.Native.Number;
 using Jint.Native.Number;
 using Jint.Native.Object;
 using Jint.Native.Object;
@@ -139,17 +141,17 @@ namespace Jint.Native.RegExp
             {
             {
                 var value = TypeConverter.ToString(replaceValue);
                 var value = TypeConverter.ToString(replaceValue);
                 replaceValue = value;
                 replaceValue = value;
-                mayHaveNamedCaptures = value.IndexOf('$') != -1;
+                mayHaveNamedCaptures = value.Contains('$');
             }
             }
 
 
             var flags = TypeConverter.ToString(rx.Get(PropertyFlags));
             var flags = TypeConverter.ToString(rx.Get(PropertyFlags));
-            var global = flags.IndexOf('g') != -1;
+            var global = flags.Contains('g');
 
 
             var fullUnicode = false;
             var fullUnicode = false;
 
 
             if (global)
             if (global)
             {
             {
-                fullUnicode = flags.IndexOf('u') != -1;
+                fullUnicode = flags.Contains('u');
                 rx.Set(JsRegExp.PropertyLastIndex, 0, true);
                 rx.Set(JsRegExp.PropertyLastIndex, 0, true);
             }
             }
 
 
@@ -527,7 +529,7 @@ namespace Jint.Native.RegExp
             return SplitSlow(s, splitter, unicodeMatching, lengthA, lim);
             return SplitSlow(s, splitter, unicodeMatching, lengthA, lim);
         }
         }
 
 
-        private JsValue SplitSlow(string s, ObjectInstance splitter, bool unicodeMatching, uint lengthA, long lim)
+        private JsArray SplitSlow(string s, ObjectInstance splitter, bool unicodeMatching, uint lengthA, long lim)
         {
         {
             var a = _realm.Intrinsics.Array.ArrayCreate(0);
             var a = _realm.Intrinsics.Array.ArrayCreate(0);
             ulong previousStringIndex = 0;
             ulong previousStringIndex = 0;
@@ -684,13 +686,13 @@ namespace Jint.Native.RegExp
 
 
             var s = TypeConverter.ToString(arguments.At(0));
             var s = TypeConverter.ToString(arguments.At(0));
             var flags = TypeConverter.ToString(rx.Get(PropertyFlags));
             var flags = TypeConverter.ToString(rx.Get(PropertyFlags));
-            var global = flags.IndexOf('g') != -1;
+            var global = flags.Contains('g');
             if (!global)
             if (!global)
             {
             {
                 return RegExpExec(rx, s);
                 return RegExpExec(rx, s);
             }
             }
 
 
-            var fullUnicode = flags.IndexOf('u') != -1;
+            var fullUnicode = flags.Contains('u');
             rx.Set(JsRegExp.PropertyLastIndex, JsNumber.PositiveZero, true);
             rx.Set(JsRegExp.PropertyLastIndex, JsNumber.PositiveZero, true);
 
 
             if (!fullUnicode
             if (!fullUnicode

+ 2 - 0
Jint/Native/Set/SetPrototype.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CA1859 // Use concrete types when possible for improved performance -- most of prototype methods return JsValue
+
 using Jint.Collections;
 using Jint.Collections;
 using Jint.Native.Object;
 using Jint.Native.Object;
 using Jint.Native.Symbol;
 using Jint.Native.Symbol;

+ 1 - 1
Jint/Native/ShadowRealm/ShadowRealm.cs

@@ -210,7 +210,7 @@ public sealed class ShadowRealm : ObjectInstance
     /// <summary>
     /// <summary>
     /// https://tc39.es/proposal-shadowrealm/#sec-wrappedfunctioncreate
     /// https://tc39.es/proposal-shadowrealm/#sec-wrappedfunctioncreate
     /// </summary>
     /// </summary>
-    private static JsValue WrappedFunctionCreate(Realm throwerRealm, Realm callerRealm, ObjectInstance target)
+    private static WrappedFunction WrappedFunctionCreate(Realm throwerRealm, Realm callerRealm, ObjectInstance target)
     {
     {
         var wrapped = new WrappedFunction(callerRealm.GlobalEnv._engine, callerRealm, target);
         var wrapped = new WrappedFunction(callerRealm.GlobalEnv._engine, callerRealm, target);
         try
         try

+ 3 - 1
Jint/Native/String/StringConstructor.cs

@@ -1,4 +1,6 @@
-using Jint.Collections;
+#pragma warning disable CA1859 // Use concrete types when possible for improved performance -- most of prototype methods return JsValue
+
+using Jint.Collections;
 using Jint.Native.Array;
 using Jint.Native.Array;
 using Jint.Native.Function;
 using Jint.Native.Function;
 using Jint.Native.Object;
 using Jint.Native.Object;

+ 2 - 0
Jint/Native/String/StringPrototype.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CA1859 // Use concrete types when possible for improved performance -- most of prototype methods return JsValue
+
 using System.Globalization;
 using System.Globalization;
 using System.Runtime.CompilerServices;
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 using System.Runtime.InteropServices;

+ 2 - 0
Jint/Native/Symbol/SymbolConstructor.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CA1859 // Use concrete types when possible for improved performance -- most of constructor methods return JsValue
+
 using Jint.Collections;
 using Jint.Collections;
 using Jint.Native.Function;
 using Jint.Native.Function;
 using Jint.Native.Object;
 using Jint.Native.Object;

+ 2 - 0
Jint/Native/Symbol/SymbolPrototype.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CA1859 // Use concrete types when possible for improved performance -- most of prototype methods return JsValue
+
 using Jint.Collections;
 using Jint.Collections;
 using Jint.Native.Object;
 using Jint.Native.Object;
 using Jint.Runtime;
 using Jint.Runtime;

+ 2 - 0
Jint/Native/TypedArray/IntrinsicTypedArrayConstructor.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CA1859 // Use concrete types when possible for improved performance -- most of constructor methods return JsValue
+
 using Jint.Collections;
 using Jint.Collections;
 using Jint.Native.Object;
 using Jint.Native.Object;
 using Jint.Native.Symbol;
 using Jint.Native.Symbol;

+ 2 - 0
Jint/Native/TypedArray/IntrinsicTypedArrayPrototype.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CA1859 // Use concrete types when possible for improved performance -- most of prototype methods return JsValue
+
 using System.Linq;
 using System.Linq;
 using Jint.Collections;
 using Jint.Collections;
 using Jint.Native.Array;
 using Jint.Native.Array;

+ 2 - 0
Jint/Native/WeakMap/WeakMapPrototype.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CA1859 // Use concrete types when possible for improved performance -- most of prototype methods return JsValue
+
 using Jint.Collections;
 using Jint.Collections;
 using Jint.Native.Object;
 using Jint.Native.Object;
 using Jint.Native.Symbol;
 using Jint.Native.Symbol;

+ 2 - 0
Jint/Native/WeakSet/WeakSetPrototype.cs

@@ -1,3 +1,5 @@
+#pragma warning disable CA1859 // Use concrete types when possible for improved performance -- most of prototype methods return JsValue
+
 using Jint.Collections;
 using Jint.Collections;
 using Jint.Native.Object;
 using Jint.Native.Object;
 using Jint.Native.Symbol;
 using Jint.Native.Symbol;

+ 2 - 0
Jint/Runtime/CallStack/JintCallStack.cs

@@ -63,8 +63,10 @@ namespace Jint.Runtime.CallStack
             if (_statistics is not null)
             if (_statistics is not null)
             {
             {
 #pragma warning disable CA1854
 #pragma warning disable CA1854
+#pragma warning disable CA1864
                 if (_statistics.ContainsKey(item))
                 if (_statistics.ContainsKey(item))
 #pragma warning restore CA1854
 #pragma warning restore CA1854
+#pragma warning restore CA1864
                 {
                 {
                     return ++_statistics[item];
                     return ++_statistics[item];
                 }
                 }

+ 1 - 1
Jint/Runtime/Interop/DefaultObjectConverter.cs

@@ -162,7 +162,7 @@ namespace Jint
             return result is not null;
             return result is not null;
         }
         }
 
 
-        private static JsValue ConvertArray(Engine e, object v)
+        private static JsArray ConvertArray(Engine e, object v)
         {
         {
             var array = (Array) v;
             var array = (Array) v;
             var arrayLength = (uint) array.Length;
             var arrayLength = (uint) array.Length;

+ 1 - 1
Jint/Runtime/Interop/NamespaceReference.cs

@@ -117,7 +117,7 @@ namespace Jint.Runtime.Interop
                     return TypeReference.CreateTypeReference(_engine, type);
                     return TypeReference.CreateTypeReference(_engine, type);
                 }
                 }
 
 
-                var lastPeriodPos = path.LastIndexOf(".", StringComparison.Ordinal);
+                var lastPeriodPos = path.LastIndexOf('.');
                 var trimPath = path.Substring(0, lastPeriodPos);
                 var trimPath = path.Substring(0, lastPeriodPos);
                 type = GetType(assembly, trimPath);
                 type = GetType(assembly, trimPath);
                 if (type != null)
                 if (type != null)

+ 1 - 1
Jint/Runtime/Interop/ObjectWrapper.cs

@@ -290,7 +290,7 @@ namespace Jint.Runtime.Interop
                 : new EnumerableIterator(wrapper._engine, (IEnumerable) wrapper.Target);
                 : new EnumerableIterator(wrapper._engine, (IEnumerable) wrapper.Target);
         }
         }
 
 
-        private static JsValue GetLength(JsValue thisObject, JsValue[] arguments)
+        private static JsNumber GetLength(JsValue thisObject, JsValue[] arguments)
         {
         {
             var wrapper = (ObjectWrapper) thisObject;
             var wrapper = (ObjectWrapper) thisObject;
             return JsNumber.Create((int) (wrapper._typeDescriptor.LengthProperty?.GetValue(wrapper.Target) ?? 0));
             return JsNumber.Create((int) (wrapper._typeDescriptor.LengthProperty?.GetValue(wrapper.Target) ?? 0));

+ 4 - 2
Jint/Runtime/Interop/TypeReference.cs

@@ -327,7 +327,7 @@ namespace Jint.Runtime.Interop
 
 
         public object Target => ReferenceType;
         public object Target => ReferenceType;
 
 
-        private static JsValue HasInstance(JsValue thisObject, JsValue[] arguments)
+        private static JsBoolean HasInstance(JsValue thisObject, JsValue[] arguments)
         {
         {
             var typeReference = thisObject as TypeReference;
             var typeReference = thisObject as TypeReference;
             var other = arguments.At(0);
             var other = arguments.At(0);
@@ -346,7 +346,9 @@ namespace Jint.Runtime.Interop
                 _ => null
                 _ => null
             };
             };
 
 
-            return derivedType != null && baseType != null && (derivedType == baseType || derivedType.IsSubclassOf(baseType));
+            return derivedType != null && baseType != null && (derivedType == baseType || derivedType.IsSubclassOf(baseType))
+                ? JsBoolean.True
+                : JsBoolean.False;
         }
         }
 
 
         public override string ToString()
         public override string ToString()

+ 1 - 1
Jint/Runtime/Interpreter/Expressions/JintCallExpression.cs

@@ -251,7 +251,7 @@ namespace Jint.Runtime.Interpreter.Expressions
             return value;
             return value;
         }
         }
 
 
-        private JsValue SuperCall(EvaluationContext context)
+        private ObjectInstance SuperCall(EvaluationContext context)
         {
         {
             var engine = context.Engine;
             var engine = context.Engine;
             var thisEnvironment = (FunctionEnvironmentRecord) engine.ExecutionContext.GetThisEnvironment();
             var thisEnvironment = (FunctionEnvironmentRecord) engine.ExecutionContext.GetThisEnvironment();

+ 1 - 1
Jint/Runtime/Interpreter/Expressions/JintMemberExpression.cs

@@ -140,7 +140,7 @@ namespace Jint.Runtime.Interpreter.Expressions
         /// <summary>
         /// <summary>
         /// https://tc39.es/ecma262/#sec-makeprivatereference
         /// https://tc39.es/ecma262/#sec-makeprivatereference
         /// </summary>
         /// </summary>
-        private static object MakePrivateReference(Engine engine, JsValue baseValue, JsValue privateIdentifier)
+        private static Reference MakePrivateReference(Engine engine, JsValue baseValue, JsValue privateIdentifier)
         {
         {
             var privEnv = engine.ExecutionContext.PrivateEnvironment;
             var privEnv = engine.ExecutionContext.PrivateEnvironment;
             var privateName = privEnv!.ResolvePrivateIdentifier(privateIdentifier.ToString());
             var privateName = privEnv!.ResolvePrivateIdentifier(privateIdentifier.ToString());

+ 1 - 1
Jint/Runtime/Interpreter/Expressions/JintObjectExpression.cs

@@ -134,7 +134,7 @@ namespace Jint.Runtime.Interpreter.Expressions
         /// <summary>
         /// <summary>
         /// Version that can safely build plain object with only normal init/data fields fast.
         /// Version that can safely build plain object with only normal init/data fields fast.
         /// </summary>
         /// </summary>
-        private object BuildObjectFast(EvaluationContext context)
+        private JsObject BuildObjectFast(EvaluationContext context)
         {
         {
             var obj = new JsObject(context.Engine);
             var obj = new JsObject(context.Engine);
             var properties = new PropertyDictionary(_properties.Length, checkExistingKeys: true);
             var properties = new PropertyDictionary(_properties.Length, checkExistingKeys: true);

+ 1 - 1
Jint/Runtime/Modules/DefaultModuleLoader.cs

@@ -151,6 +151,6 @@ public sealed class DefaultModuleLoader : IModuleLoader
 
 
     private static bool IsRelative(string specifier)
     private static bool IsRelative(string specifier)
     {
     {
-        return specifier.StartsWith(".", StringComparison.Ordinal) || specifier.StartsWith("/", StringComparison.Ordinal);
+        return specifier.StartsWith('.') || specifier.StartsWith('/');
     }
     }
 }
 }

+ 1 - 1
Jint/Runtime/Modules/ModuleRecord.cs

@@ -67,7 +67,7 @@ public abstract class ModuleRecord : JsValue, IScriptOrModule
     /// <summary>
     /// <summary>
     /// https://tc39.es/ecma262/#sec-modulenamespacecreate
     /// https://tc39.es/ecma262/#sec-modulenamespacecreate
     /// </summary>
     /// </summary>
-    private static ObjectInstance CreateModuleNamespace(ModuleRecord module, List<string> unambiguousNames)
+    private static ModuleNamespace CreateModuleNamespace(ModuleRecord module, List<string> unambiguousNames)
     {
     {
         var m = new ModuleNamespace(module._engine, module, unambiguousNames);
         var m = new ModuleNamespace(module._engine, module, unambiguousNames);
         module._namespace = m;
         module._namespace = m;