Version 7.3.2: Switched from the standard .NET reflection binder to a custom algorithm, ensuring consistently enhanced behavior for all reflection binding scenarios; reviewed "dynamic" usage, eliminating it where possible and reducing it elsewhere (GitHub Issue #400); added ScriptEngine.DisableDynamicBinding; added IScriptEngineException.ScriptExceptionAsObject; fixed invocation of methods that have both optional parameters and parameter arrays; added implicit conversion support for constructor and indexed property arguments (GitHub Issue #396); extended canonical referencing to Guid and all readonly struct types; added ScriptObject.InvokeAsFunction; updated API and build documentation. Tested with V8 10.5.218.8.
This commit is contained in:
Родитель
784b83cf0e
Коммит
e13ac815f4
|
@ -1,5 +1,6 @@
|
|||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeInspection/CSharpLanguageProject/LanguageLevel/@EntryValue">CSharp73</s:String>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Ejs/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/Highlighting/CalculateUnusedTypeMembers/@EntryValue">False</s:Boolean>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeThisQualifier/@EntryIndexedValue">SUGGESTION</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=AssignNullToNotNullAttribute/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
|
@ -48,6 +49,7 @@
|
|||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Addr/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=ADODB/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=BADPARAMCOUNT/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Bindable/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=blittable/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Bytecode/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Cacheable/@EntryIndexedValue">True</s:Boolean>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeInspection/CSharpLanguageProject/LanguageLevel/@EntryValue">CSharp73</s:String>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Ejs/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/Highlighting/CalculateUnusedTypeMembers/@EntryValue">False</s:Boolean>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeThisQualifier/@EntryIndexedValue">SUGGESTION</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=AssignNullToNotNullAttribute/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
|
@ -48,6 +49,7 @@
|
|||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Addr/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=ADODB/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=BADPARAMCOUNT/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Bindable/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=blittable/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Bytecode/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Cacheable/@EntryIndexedValue">True</s:Boolean>
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
// Licensed under the MIT license.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using Microsoft.ClearScript.Util;
|
||||
|
||||
namespace Microsoft.ClearScript
|
||||
{
|
||||
|
@ -205,6 +207,7 @@ namespace Microsoft.ClearScript
|
|||
private enum ArgKind
|
||||
{
|
||||
Null,
|
||||
Zero,
|
||||
ByValue,
|
||||
Out,
|
||||
Ref
|
||||
|
@ -269,14 +272,22 @@ namespace Microsoft.ClearScript
|
|||
return;
|
||||
}
|
||||
|
||||
if (arg is HostTarget hostTarget)
|
||||
if (arg is HostObject hostObject)
|
||||
{
|
||||
kind = ArgKind.ByValue;
|
||||
type = hostTarget.Type;
|
||||
kind = hostObject.Target.IsZero() ? ArgKind.Zero : ArgKind.ByValue;
|
||||
type = hostObject.Type;
|
||||
return;
|
||||
}
|
||||
|
||||
kind = ArgKind.ByValue;
|
||||
if (arg is HostVariable hostVariable)
|
||||
{
|
||||
kind = hostVariable.Target.IsZero() ? ArgKind.Zero : ArgKind.ByValue;
|
||||
type = hostVariable.Type;
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.Assert(!(arg is HostTarget));
|
||||
kind = arg.IsZero() ? ArgKind.Zero : ArgKind.ByValue;
|
||||
type = arg.GetType();
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,10 @@ namespace Microsoft.ClearScript
|
|||
type == typeof(DateTime) ||
|
||||
type == typeof(DateTimeOffset) ||
|
||||
type == typeof(TimeSpan) ||
|
||||
type == typeof(Guid) ||
|
||||
#if NET471_OR_GREATER || NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
|
||||
type.GetOrLoadCustomAttributes<System.Runtime.CompilerServices.IsReadOnlyAttribute>(false).Any() ||
|
||||
#endif
|
||||
type.GetOrLoadCustomAttributes<ImmutableValueAttribute>(false).Any())
|
||||
{
|
||||
map = (ICanonicalRefMap)typeof(CanonicalRefMap<>).MakeGenericType(type).CreateInstance();
|
||||
|
|
|
@ -24,7 +24,6 @@ namespace Microsoft.ClearScript
|
|||
|
||||
// ReSharper restore EmptyConstructor
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Loads custom attributes of the specified type for the given resource.
|
||||
/// </summary>
|
||||
|
|
|
@ -36,7 +36,14 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
Invoke(() => ((dynamic)target)());
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
Invoke(() => scriptObject.InvokeAsFunction());
|
||||
}
|
||||
else
|
||||
{
|
||||
Invoke(() => ((dynamic)target)());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -85,7 +92,14 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(a1));
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
Invoke(() => scriptObject.InvokeAsFunction(a1));
|
||||
}
|
||||
else
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(a1));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -134,7 +148,14 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(a1, a2));
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
Invoke(() => scriptObject.InvokeAsFunction(a1, a2));
|
||||
}
|
||||
else
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(a1, a2));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -185,7 +206,14 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(a1, a2, a3));
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
Invoke(() => scriptObject.InvokeAsFunction(a1, a2, a3));
|
||||
}
|
||||
else
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(a1, a2, a3));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -238,7 +266,14 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(a1, a2, a3, a4));
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
Invoke(() => scriptObject.InvokeAsFunction(a1, a2, a3, a4));
|
||||
}
|
||||
else
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(a1, a2, a3, a4));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -293,7 +328,14 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(a1, a2, a3, a4, a5));
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
Invoke(() => scriptObject.InvokeAsFunction(a1, a2, a3, a4, a5));
|
||||
}
|
||||
else
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(a1, a2, a3, a4, a5));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -350,7 +392,14 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(a1, a2, a3, a4, a5, a6));
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
Invoke(() => scriptObject.InvokeAsFunction(a1, a2, a3, a4, a5, a6));
|
||||
}
|
||||
else
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(a1, a2, a3, a4, a5, a6));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -409,7 +458,14 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(a1, a2, a3, a4, a5, a6, a7));
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
Invoke(() => scriptObject.InvokeAsFunction(a1, a2, a3, a4, a5, a6, a7));
|
||||
}
|
||||
else
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(a1, a2, a3, a4, a5, a6, a7));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -470,7 +526,14 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(a1, a2, a3, a4, a5, a6, a7, a8));
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
Invoke(() => scriptObject.InvokeAsFunction(a1, a2, a3, a4, a5, a6, a7, a8));
|
||||
}
|
||||
else
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(a1, a2, a3, a4, a5, a6, a7, a8));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -533,7 +596,14 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(a1, a2, a3, a4, a5, a6, a7, a8, a9));
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
Invoke(() => scriptObject.InvokeAsFunction(a1, a2, a3, a4, a5, a6, a7, a8, a9));
|
||||
}
|
||||
else
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(a1, a2, a3, a4, a5, a6, a7, a8, a9));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -598,7 +668,14 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10));
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
Invoke(() => scriptObject.InvokeAsFunction(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10));
|
||||
}
|
||||
else
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -665,7 +742,14 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11));
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
Invoke(() => scriptObject.InvokeAsFunction(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11));
|
||||
}
|
||||
else
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -734,7 +818,14 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12));
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
Invoke(() => scriptObject.InvokeAsFunction(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12));
|
||||
}
|
||||
else
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -805,7 +896,14 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13));
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
Invoke(() => scriptObject.InvokeAsFunction(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13));
|
||||
}
|
||||
else
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -878,7 +976,14 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14));
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
Invoke(() => scriptObject.InvokeAsFunction(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14));
|
||||
}
|
||||
else
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -953,7 +1058,14 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15));
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
Invoke(() => scriptObject.InvokeAsFunction(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15));
|
||||
}
|
||||
else
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1030,7 +1142,14 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16));
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
Invoke(() => scriptObject.InvokeAsFunction(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16));
|
||||
}
|
||||
else
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1110,6 +1229,11 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
return Invoke(() => (TResult)scriptObject.InvokeAsFunction());
|
||||
}
|
||||
|
||||
return Invoke(() => (TResult)((dynamic)target)());
|
||||
}
|
||||
|
||||
|
@ -1157,6 +1281,11 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
return Invoke(() => (TResult)scriptObject.InvokeAsFunction(a1));
|
||||
}
|
||||
|
||||
return Invoke(() => (TResult)((dynamic)target)(a1));
|
||||
}
|
||||
|
||||
|
@ -1204,6 +1333,11 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
return Invoke(() => (TResult)scriptObject.InvokeAsFunction(a1, a2));
|
||||
}
|
||||
|
||||
return Invoke(() => (TResult)((dynamic)target)(a1, a2));
|
||||
}
|
||||
|
||||
|
@ -1253,6 +1387,11 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
return Invoke(() => (TResult)scriptObject.InvokeAsFunction(a1, a2, a3));
|
||||
}
|
||||
|
||||
return Invoke(() => (TResult)((dynamic)target)(a1, a2, a3));
|
||||
}
|
||||
|
||||
|
@ -1304,6 +1443,11 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
return Invoke(() => (TResult)scriptObject.InvokeAsFunction(a1, a2, a3, a4));
|
||||
}
|
||||
|
||||
return Invoke(() => (TResult)((dynamic)target)(a1, a2, a3, a4));
|
||||
}
|
||||
|
||||
|
@ -1357,6 +1501,11 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
return Invoke(() => (TResult)scriptObject.InvokeAsFunction(a1, a2, a3, a4, a5));
|
||||
}
|
||||
|
||||
return Invoke(() => (TResult)((dynamic)target)(a1, a2, a3, a4, a5));
|
||||
}
|
||||
|
||||
|
@ -1412,6 +1561,11 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
return Invoke(() => (TResult)scriptObject.InvokeAsFunction(a1, a2, a3, a4, a5, a6));
|
||||
}
|
||||
|
||||
return Invoke(() => (TResult)((dynamic)target)(a1, a2, a3, a4, a5, a6));
|
||||
}
|
||||
|
||||
|
@ -1469,6 +1623,11 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
return Invoke(() => (TResult)scriptObject.InvokeAsFunction(a1, a2, a3, a4, a5, a6, a7));
|
||||
}
|
||||
|
||||
return Invoke(() => (TResult)((dynamic)target)(a1, a2, a3, a4, a5, a6, a7));
|
||||
}
|
||||
|
||||
|
@ -1528,6 +1687,11 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
return Invoke(() => (TResult)scriptObject.InvokeAsFunction(a1, a2, a3, a4, a5, a6, a7, a8));
|
||||
}
|
||||
|
||||
return Invoke(() => (TResult)((dynamic)target)(a1, a2, a3, a4, a5, a6, a7, a8));
|
||||
}
|
||||
|
||||
|
@ -1589,6 +1753,11 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
return Invoke(() => (TResult)scriptObject.InvokeAsFunction(a1, a2, a3, a4, a5, a6, a7, a8, a9));
|
||||
}
|
||||
|
||||
return Invoke(() => (TResult)((dynamic)target)(a1, a2, a3, a4, a5, a6, a7, a8, a9));
|
||||
}
|
||||
|
||||
|
@ -1652,6 +1821,11 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
return Invoke(() => (TResult)scriptObject.InvokeAsFunction(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10));
|
||||
}
|
||||
|
||||
return Invoke(() => (TResult)((dynamic)target)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10));
|
||||
}
|
||||
|
||||
|
@ -1717,6 +1891,11 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
return Invoke(() => (TResult)scriptObject.InvokeAsFunction(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11));
|
||||
}
|
||||
|
||||
return Invoke(() => (TResult)((dynamic)target)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11));
|
||||
}
|
||||
|
||||
|
@ -1784,6 +1963,11 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
return Invoke(() => (TResult)scriptObject.InvokeAsFunction(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12));
|
||||
}
|
||||
|
||||
return Invoke(() => (TResult)((dynamic)target)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12));
|
||||
}
|
||||
|
||||
|
@ -1853,6 +2037,11 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
return Invoke(() => (TResult)scriptObject.InvokeAsFunction(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13));
|
||||
}
|
||||
|
||||
return Invoke(() => (TResult)((dynamic)target)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13));
|
||||
}
|
||||
|
||||
|
@ -1924,6 +2113,11 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
return Invoke(() => (TResult)scriptObject.InvokeAsFunction(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14));
|
||||
}
|
||||
|
||||
return Invoke(() => (TResult)((dynamic)target)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14));
|
||||
}
|
||||
|
||||
|
@ -1997,6 +2191,11 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
return Invoke(() => (TResult)scriptObject.InvokeAsFunction(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15));
|
||||
}
|
||||
|
||||
return Invoke(() => (TResult)((dynamic)target)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15));
|
||||
}
|
||||
|
||||
|
@ -2072,6 +2271,11 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
return Invoke(() => (TResult)scriptObject.InvokeAsFunction(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16));
|
||||
}
|
||||
|
||||
return Invoke(() => (TResult)((dynamic)target)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16));
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,14 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(<#= argList #>));
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
Invoke(() => scriptObject.InvokeAsFunction(<#= argList #>));
|
||||
}
|
||||
else
|
||||
{
|
||||
Invoke(() => ((dynamic)target)(<#= argList #>));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -116,6 +123,11 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (allByValue || Engine.EnableAutoHostVariables)
|
||||
{
|
||||
if (target is ScriptObject scriptObject)
|
||||
{
|
||||
return Invoke(() => (TResult)scriptObject.InvokeAsFunction(<#= argList #>));
|
||||
}
|
||||
|
||||
return Invoke(() => (TResult)((dynamic)target)(<#= argList #>));
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#define CLEARSCRIPT_VERSION_STRING "7.3.1"
|
||||
#define CLEARSCRIPT_VERSION_COMMA_SEPARATED 7,3,1
|
||||
#define CLEARSCRIPT_VERSION_STRING_INFORMATIONAL "7.3.1"
|
||||
#define CLEARSCRIPT_VERSION_STRING "7.3.2"
|
||||
#define CLEARSCRIPT_VERSION_COMMA_SEPARATED 7,3,2
|
||||
#define CLEARSCRIPT_VERSION_STRING_INFORMATIONAL "7.3.2"
|
||||
#define CLEARSCRIPT_FILE_FLAGS 0L
|
||||
|
|
|
@ -652,11 +652,11 @@ namespace Microsoft.ClearScript
|
|||
|
||||
try
|
||||
{
|
||||
return args.Aggregate(0UL, (flags, arg) => flags | Convert.ToUInt64(arg, CultureInfo.InvariantCulture)).DynamicCast<T>();
|
||||
return (T)Enum.ToObject(typeof(T), args.Aggregate(0UL, (flags, arg) => flags | Convert.ToUInt64(arg, CultureInfo.InvariantCulture)));
|
||||
}
|
||||
catch (OverflowException)
|
||||
{
|
||||
return args.Aggregate(0L, (flags, arg) => flags | Convert.ToInt64(arg, CultureInfo.InvariantCulture)).DynamicCast<T>();
|
||||
return (T)Enum.ToObject(typeof(T), args.Aggregate(0L, (flags, arg) => flags | Convert.ToInt64(arg, CultureInfo.InvariantCulture)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1305,12 +1305,12 @@ namespace Microsoft.ClearScript
|
|||
|
||||
try
|
||||
{
|
||||
((dynamic)tryFunc)();
|
||||
((ScriptObject)tryFunc).InvokeAsFunction();
|
||||
return true;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
if (!((dynamic)catchFunc)(exception))
|
||||
if (!Convert.ToBoolean(((ScriptObject)catchFunc).InvokeAsFunction(exception)))
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
@ -1321,7 +1321,7 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (finallyFunc != null)
|
||||
{
|
||||
((dynamic)finallyFunc)();
|
||||
((ScriptObject)finallyFunc).InvokeAsFunction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ namespace Microsoft.ClearScript
|
|||
|
||||
if (forceReflection)
|
||||
{
|
||||
result = new MethodBindFailure(() => new MissingMemberException(MiscHelpers.FormatInvariant("The object has no method named '{0}' that matches the specified arguments", name)));
|
||||
result = new MethodBindFailure(() => new MissingMethodException(MiscHelpers.FormatInvariant("The object has no method named '{0}' that matches the specified arguments", name)));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -130,7 +130,7 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if (result is MethodBindSuccess)
|
||||
{
|
||||
result = new MethodBindFailure(() => new MissingMemberException(MiscHelpers.FormatInvariant("The object has no method named '{0}' that matches the specified arguments", name)));
|
||||
result = new MethodBindFailure(() => new MissingMethodException(MiscHelpers.FormatInvariant("The object has no method named '{0}' that matches the specified arguments", name)));
|
||||
}
|
||||
|
||||
foreach (var altName in GetAltMethodNames(name, bindFlags))
|
||||
|
@ -147,8 +147,8 @@ namespace Microsoft.ClearScript
|
|||
|
||||
if ((result is MethodBindFailure) && (forceReflection || Engine.UseReflectionBindFallback))
|
||||
{
|
||||
var reflectionResult = BindMethodUsingReflection(bindFlags, Target, name, typeArgs, args);
|
||||
if (reflectionResult is MethodBindSuccess)
|
||||
var reflectionResult = BindMethodUsingReflection(bindFlags, Target, name, typeArgs, args, bindArgs);
|
||||
if ((reflectionResult is MethodBindSuccess) || forceReflection)
|
||||
{
|
||||
result = reflectionResult;
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ namespace Microsoft.ClearScript
|
|||
|
||||
if (expr == null)
|
||||
{
|
||||
return new Func<Exception>(() => new MissingMemberException(MiscHelpers.FormatInvariant("The object has no method named '{0}'", binder.Name)));
|
||||
return new Func<Exception>(() => new MissingMethodException(MiscHelpers.FormatInvariant("The object has no method named '{0}'", binder.Name)));
|
||||
}
|
||||
|
||||
// ReSharper restore HeuristicUnreachableCode
|
||||
|
@ -252,7 +252,7 @@ namespace Microsoft.ClearScript
|
|||
try
|
||||
{
|
||||
var method = target.Type.GetMethod(binder.Name, bindFlags);
|
||||
return (object)method ?? new Func<Exception>(() => new MissingMemberException(MiscHelpers.FormatInvariant("The object has no method named '{0}'", binder.Name)));
|
||||
return (object)method ?? new Func<Exception>(() => new MissingMethodException(MiscHelpers.FormatInvariant("The object has no method named '{0}'", binder.Name)));
|
||||
}
|
||||
catch (AmbiguousMatchException exception)
|
||||
{
|
||||
|
@ -303,7 +303,21 @@ namespace Microsoft.ClearScript
|
|||
if (arg != null)
|
||||
{
|
||||
flags |= CSharpArgumentInfoFlags.UseCompileTimeType;
|
||||
if (arg is int)
|
||||
if (arg is HostObject hostObject)
|
||||
{
|
||||
if ((hostObject.Type == typeof(int)) || (hostObject.Type.IsValueType && hostObject.Target.IsZero()))
|
||||
{
|
||||
flags |= CSharpArgumentInfoFlags.Constant;
|
||||
}
|
||||
}
|
||||
else if (arg is HostVariable hostVariable)
|
||||
{
|
||||
if ((hostVariable.Type == typeof(int)) || (hostVariable.Type.IsValueType && hostVariable.Target.IsZero()))
|
||||
{
|
||||
flags |= CSharpArgumentInfoFlags.Constant;
|
||||
}
|
||||
}
|
||||
else if (arg is int || arg.IsZero())
|
||||
{
|
||||
flags |= CSharpArgumentInfoFlags.Constant;
|
||||
}
|
||||
|
@ -325,27 +339,26 @@ namespace Microsoft.ClearScript
|
|||
return CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.IsStaticType, null);
|
||||
}
|
||||
|
||||
private MethodBindResult BindMethodUsingReflection(BindingFlags bindFlags, HostTarget hostTarget, string name, Type[] typeArgs, object[] args)
|
||||
private MethodBindResult BindMethodUsingReflection(BindingFlags bindFlags, HostTarget hostTarget, string name, Type[] typeArgs, object[] args, object[] bindArgs)
|
||||
{
|
||||
var candidates = GetReflectionCandidates(bindFlags, hostTarget, name, typeArgs).Distinct().ToArray();
|
||||
if (candidates.Length > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
// ReSharper disable once CoVariantArrayConversion
|
||||
var rawResult = Type.DefaultBinder.BindToMethod(bindFlags, candidates, ref args, null, null, null, out _);
|
||||
|
||||
return MethodBindResult.Create(name, bindFlags, rawResult, hostTarget, args);
|
||||
}
|
||||
catch (MissingMethodException)
|
||||
{
|
||||
var rawResult = TypeHelpers.BindToMember(candidates, bindFlags, args, bindArgs);
|
||||
if (rawResult != null)
|
||||
{
|
||||
return MethodBindResult.Create(name, bindFlags, rawResult, hostTarget, args);
|
||||
}
|
||||
}
|
||||
catch (AmbiguousMatchException)
|
||||
{
|
||||
return new MethodBindFailure(() => new AmbiguousMatchException(MiscHelpers.FormatInvariant("The object has multiple methods named '{0}' that match the specified arguments", name)));
|
||||
}
|
||||
}
|
||||
|
||||
return new MethodBindFailure(() => new MissingMemberException(MiscHelpers.FormatInvariant("The object has no method named '{0}' that matches the specified arguments", name)));
|
||||
return new MethodBindFailure(() => new MissingMethodException(MiscHelpers.FormatInvariant("The object has no method named '{0}' that matches the specified arguments", name)));
|
||||
}
|
||||
|
||||
private IEnumerable<MethodInfo> GetReflectionCandidates(BindingFlags bindFlags, HostTarget hostTarget, string name, Type[] typeArgs)
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Microsoft.ClearScript.Util;
|
||||
|
||||
namespace Microsoft.ClearScript
|
||||
|
@ -30,12 +31,23 @@ namespace Microsoft.ClearScript
|
|||
|
||||
private object CreateAsyncEnumerator()
|
||||
{
|
||||
if (BindSpecialTarget(out IEnumerable _))
|
||||
if ((Target is HostObject) || (Target is IHostVariable) || (Target is IByRefArg))
|
||||
{
|
||||
var enumerableHelpersHostItem = Wrap(Engine, EnumerableHelpers.HostType, HostItemFlags.PrivateAccess);
|
||||
if (MiscHelpers.Try(out var enumerator, () => ((IDynamic)enumerableHelpersHostItem).InvokeMethod("GetAsyncEnumerator", this, Engine)))
|
||||
if ((Target.InvokeTarget != null) && Target.Type.IsAssignableToGenericType(typeof(IEnumerable<>), out var typeArgs))
|
||||
{
|
||||
return enumerator;
|
||||
var enumerableHelpersHostItem = Wrap(Engine, typeof(EnumerableHelpers<>).MakeGenericType(typeArgs).InvokeMember("HostType", BindingFlags.Public | BindingFlags.Static | BindingFlags.GetField, null, null, null), HostItemFlags.PrivateAccess);
|
||||
if (MiscHelpers.Try(out var enumerator, () => ((IDynamic)enumerableHelpersHostItem).InvokeMethod("GetAsyncEnumerator", this, Engine)))
|
||||
{
|
||||
return enumerator;
|
||||
}
|
||||
}
|
||||
else if (BindSpecialTarget(out IEnumerable _))
|
||||
{
|
||||
var enumerableHelpersHostItem = Wrap(Engine, EnumerableHelpers.HostType, HostItemFlags.PrivateAccess);
|
||||
if (MiscHelpers.Try(out var enumerator, () => ((IDynamic)enumerableHelpersHostItem).InvokeMethod("GetAsyncEnumerator", this, Engine)))
|
||||
{
|
||||
return enumerator;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.InteropServices.Expando;
|
||||
using Microsoft.ClearScript.Util;
|
||||
|
@ -40,20 +41,31 @@ namespace Microsoft.ClearScript
|
|||
|
||||
private object CreateAsyncEnumerator()
|
||||
{
|
||||
if ((Target.InvokeTarget != null) && Target.Type.IsAssignableToGenericType(typeof(IAsyncEnumerable<>), out _))
|
||||
if ((Target is HostObject) || (Target is IHostVariable) || (Target is IByRefArg))
|
||||
{
|
||||
var enumerableHelpersHostItem = Wrap(Engine, EnumerableHelpers.HostType, HostItemFlags.PrivateAccess);
|
||||
if (MiscHelpers.Try(out var enumerator, () => ((IDynamic)enumerableHelpersHostItem).InvokeMethod("GetAsyncEnumerator", this, Engine)))
|
||||
if ((Target.InvokeTarget != null) && Target.Type.IsAssignableToGenericType(typeof(IAsyncEnumerable<>), out var typeArgs))
|
||||
{
|
||||
return enumerator;
|
||||
var enumerableHelpersHostItem = Wrap(Engine, typeof(EnumerableHelpers<>).MakeGenericType(typeArgs).InvokeMember("HostType", BindingFlags.Public | BindingFlags.Static | BindingFlags.GetField, null, null, null), HostItemFlags.PrivateAccess);
|
||||
if (MiscHelpers.Try(out var enumerator, () => ((IDynamic)enumerableHelpersHostItem).InvokeMethod("GetAsyncEnumerator", this, Engine)))
|
||||
{
|
||||
return enumerator;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (BindSpecialTarget(out IEnumerable _))
|
||||
{
|
||||
var enumerableHelpersHostItem = Wrap(Engine, EnumerableHelpers.HostType, HostItemFlags.PrivateAccess);
|
||||
if (MiscHelpers.Try(out var enumerator, () => ((IDynamic)enumerableHelpersHostItem).InvokeMethod("GetAsyncEnumerator", this, Engine)))
|
||||
else if ((Target.InvokeTarget != null) && Target.Type.IsAssignableToGenericType(typeof(IEnumerable<>), out typeArgs))
|
||||
{
|
||||
return enumerator;
|
||||
var enumerableHelpersHostItem = Wrap(Engine, typeof(EnumerableHelpers<>).MakeGenericType(typeArgs).InvokeMember("HostType", BindingFlags.Public | BindingFlags.Static | BindingFlags.GetField, null, null, null), HostItemFlags.PrivateAccess);
|
||||
if (MiscHelpers.Try(out var enumerator, () => ((IDynamic)enumerableHelpersHostItem).InvokeMethod("GetAsyncEnumerator", this, Engine)))
|
||||
{
|
||||
return enumerator;
|
||||
}
|
||||
}
|
||||
else if (BindSpecialTarget(out IEnumerable _))
|
||||
{
|
||||
var enumerableHelpersHostItem = Wrap(Engine, EnumerableHelpers.HostType, HostItemFlags.PrivateAccess);
|
||||
if (MiscHelpers.Try(out var enumerator, () => ((IDynamic)enumerableHelpersHostItem).InvokeMethod("GetAsyncEnumerator", this, Engine)))
|
||||
{
|
||||
return enumerator;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -982,7 +982,7 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
return TargetDynamic.Invoke(false, args);
|
||||
}
|
||||
catch (Exception)
|
||||
catch
|
||||
{
|
||||
if (invokeFlags.HasFlag(BindingFlags.GetField) && (args.Length < 1))
|
||||
{
|
||||
|
@ -997,7 +997,7 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
return TargetDynamic.InvokeMethod(name, args);
|
||||
}
|
||||
catch (Exception)
|
||||
catch
|
||||
{
|
||||
if (invokeFlags.HasFlag(BindingFlags.GetField))
|
||||
{
|
||||
|
@ -1222,6 +1222,7 @@ namespace Microsoft.ClearScript
|
|||
if (hostType != null)
|
||||
{
|
||||
args = args.Skip(typeArgs.Length).ToArray();
|
||||
bindArgs = bindArgs.Skip(typeArgs.Length).ToArray();
|
||||
|
||||
var specificType = hostType.GetSpecificType();
|
||||
if (typeof(Delegate).IsAssignableFrom(specificType))
|
||||
|
@ -1234,7 +1235,7 @@ namespace Microsoft.ClearScript
|
|||
return DelegateFactory.CreateDelegate(Engine, args[0], specificType);
|
||||
}
|
||||
|
||||
return specificType.CreateInstance(AccessContext, DefaultAccess, args);
|
||||
return specificType.CreateInstance(AccessContext, DefaultAccess, args, bindArgs);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1254,7 +1255,7 @@ namespace Microsoft.ClearScript
|
|||
return DelegateFactory.CreateDelegate(Engine, args[0], type);
|
||||
}
|
||||
|
||||
return type.CreateInstance(AccessContext, DefaultAccess, args);
|
||||
return type.CreateInstance(AccessContext, DefaultAccess, args, bindArgs);
|
||||
}
|
||||
|
||||
if (TargetDynamicMetaObject != null)
|
||||
|
@ -1334,7 +1335,7 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception)
|
||||
catch
|
||||
{
|
||||
// ReSharper disable EmptyGeneralCatchClause
|
||||
|
||||
|
@ -1350,7 +1351,7 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception)
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1365,7 +1366,7 @@ namespace Microsoft.ClearScript
|
|||
return GetHostProperty(name, invokeFlags, args, bindArgs, culture, true, out isCacheable);
|
||||
}
|
||||
|
||||
throw new MissingMemberException(MiscHelpers.FormatInvariant("The object has no suitable method named '{0}'", name));
|
||||
throw new MissingMethodException(MiscHelpers.FormatInvariant("The object has no suitable method named '{0}'", name));
|
||||
}
|
||||
|
||||
if (invokeFlags.HasFlag(BindingFlags.GetField))
|
||||
|
@ -1387,7 +1388,7 @@ namespace Microsoft.ClearScript
|
|||
|
||||
if (name == SpecialMemberNames.Default)
|
||||
{
|
||||
var defaultProperty = Target.Type.GetScriptableDefaultProperty(invokeFlags, bindArgs, AccessContext, DefaultAccess);
|
||||
var defaultProperty = Target.Type.GetScriptableDefaultProperty(invokeFlags, args, bindArgs, AccessContext, DefaultAccess);
|
||||
if (defaultProperty != null)
|
||||
{
|
||||
return GetHostProperty(defaultProperty, invokeFlags, args, culture);
|
||||
|
@ -1472,7 +1473,7 @@ namespace Microsoft.ClearScript
|
|||
}
|
||||
}
|
||||
|
||||
var property = Target.Type.GetScriptableProperty(name, invokeFlags, bindArgs, AccessContext, DefaultAccess);
|
||||
var property = Target.Type.GetScriptableProperty(name, invokeFlags, args, bindArgs, AccessContext, DefaultAccess);
|
||||
if (property != null)
|
||||
{
|
||||
return GetHostProperty(property, invokeFlags, args, culture);
|
||||
|
@ -1551,6 +1552,17 @@ namespace Microsoft.ClearScript
|
|||
throw new UnauthorizedAccessException("The property get method is unavailable or inaccessible");
|
||||
}
|
||||
|
||||
if (args.Length > 0)
|
||||
{
|
||||
args = (object[])args.Clone();
|
||||
var indexParams = property.GetIndexParameters();
|
||||
var length = Math.Min(args.Length, indexParams.Length);
|
||||
for (var index = 0; index < length; index++)
|
||||
{
|
||||
indexParams[index].ParameterType.IsAssignableFromValue(ref args[index]);
|
||||
}
|
||||
}
|
||||
|
||||
var result = property.GetValue(Target.InvokeTarget, invokeFlags, Type.DefaultBinder, args, culture);
|
||||
return Engine.PrepareResult(result, property.PropertyType, property.GetScriptMemberFlags(), false);
|
||||
}
|
||||
|
@ -1566,7 +1578,7 @@ namespace Microsoft.ClearScript
|
|||
|
||||
object result;
|
||||
|
||||
var defaultProperty = Target.Type.GetScriptableDefaultProperty(invokeFlags, bindArgs.Take(bindArgs.Length - 1).ToArray(), AccessContext, DefaultAccess);
|
||||
var defaultProperty = Target.Type.GetScriptableDefaultProperty(invokeFlags, args.Take(args.Length - 1).ToArray(), bindArgs.Take(bindArgs.Length - 1).ToArray(), AccessContext, DefaultAccess);
|
||||
if (defaultProperty != null)
|
||||
{
|
||||
return SetHostProperty(defaultProperty, invokeFlags, args, bindArgs, culture);
|
||||
|
@ -1621,7 +1633,7 @@ namespace Microsoft.ClearScript
|
|||
throw new InvalidOperationException("Invalid argument count");
|
||||
}
|
||||
|
||||
var property = Target.Type.GetScriptableProperty(name, invokeFlags, bindArgs.Take(bindArgs.Length - 1).ToArray(), AccessContext, DefaultAccess);
|
||||
var property = Target.Type.GetScriptableProperty(name, invokeFlags, args.Take(args.Length - 1).ToArray(), bindArgs.Take(bindArgs.Length - 1).ToArray(), AccessContext, DefaultAccess);
|
||||
if (property != null)
|
||||
{
|
||||
return SetHostProperty(property, invokeFlags, args, bindArgs, culture);
|
||||
|
@ -1638,7 +1650,7 @@ namespace Microsoft.ClearScript
|
|||
}
|
||||
|
||||
var value = args[0];
|
||||
if (field.FieldType.IsAssignableFrom(ref value))
|
||||
if (field.FieldType.IsAssignableFromValue(ref value))
|
||||
{
|
||||
field.SetValue(Target.InvokeTarget, value);
|
||||
return value;
|
||||
|
@ -1666,6 +1678,17 @@ namespace Microsoft.ClearScript
|
|||
throw new UnauthorizedAccessException("The property set method is unavailable or inaccessible");
|
||||
}
|
||||
|
||||
if (args.Length > 1)
|
||||
{
|
||||
args = (object[])args.Clone();
|
||||
var indexParams = property.GetIndexParameters();
|
||||
var length = Math.Min(args.Length - 1, indexParams.Length);
|
||||
for (var index = 0; index < length; index++)
|
||||
{
|
||||
indexParams[index].ParameterType.IsAssignableFromValue(ref args[index]);
|
||||
}
|
||||
}
|
||||
|
||||
var value = args[args.Length - 1];
|
||||
|
||||
// ReSharper disable once SuspiciousTypeConversion.Global
|
||||
|
@ -1693,7 +1716,7 @@ namespace Microsoft.ClearScript
|
|||
}
|
||||
}
|
||||
|
||||
if (property.PropertyType.IsAssignableFrom(ref value))
|
||||
if (property.PropertyType.IsAssignableFromValue(ref value))
|
||||
{
|
||||
property.SetValue(Target.InvokeTarget, value, invokeFlags, Type.DefaultBinder, args.Take(args.Length - 1).ToArray(), culture);
|
||||
return value;
|
||||
|
@ -1702,8 +1725,8 @@ namespace Microsoft.ClearScript
|
|||
// Some COM properties have setters where the final parameter type doesn't match
|
||||
// the property type. The latter has failed, so let's try the former.
|
||||
|
||||
var parameters = setMethod.GetParameters();
|
||||
if ((parameters.Length == args.Length) && (parameters[args.Length - 1].ParameterType.IsAssignableFrom(ref value)))
|
||||
var setParams = setMethod.GetParameters();
|
||||
if ((setParams.Length == args.Length) && (setParams[args.Length - 1].ParameterType.IsAssignableFromValue(ref value)))
|
||||
{
|
||||
property.SetValue(Target.InvokeTarget, value, invokeFlags, Type.DefaultBinder, args.Take(args.Length - 1).ToArray(), culture);
|
||||
return value;
|
||||
|
@ -1721,7 +1744,15 @@ namespace Microsoft.ClearScript
|
|||
{
|
||||
if ((Target is HostObject) || (Target is IHostVariable) || (Target is IByRefArg))
|
||||
{
|
||||
if (BindSpecialTarget(out IEnumerable _))
|
||||
if ((Target.InvokeTarget != null) && Target.Type.IsAssignableToGenericType(typeof(IEnumerable<>), out var typeArgs))
|
||||
{
|
||||
var enumerableHelpersHostItem = Wrap(Engine, typeof(EnumerableHelpers<>).MakeGenericType(typeArgs).InvokeMember("HostType", BindingFlags.Public | BindingFlags.Static | BindingFlags.GetField, null, null, null), HostItemFlags.PrivateAccess);
|
||||
if (MiscHelpers.Try(out var enumerator, () => ((IDynamic)enumerableHelpersHostItem).InvokeMethod("GetEnumerator", this)))
|
||||
{
|
||||
return enumerator;
|
||||
}
|
||||
}
|
||||
else if (BindSpecialTarget(out IEnumerable _))
|
||||
{
|
||||
var enumerableHelpersHostItem = Wrap(Engine, EnumerableHelpers.HostType, HostItemFlags.PrivateAccess);
|
||||
if (MiscHelpers.Try(out var enumerator, () => ((IDynamic)enumerableHelpersHostItem).InvokeMethod("GetEnumerator", this)))
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace Microsoft.ClearScript
|
|||
|
||||
set
|
||||
{
|
||||
if (!typeof(T).IsAssignableFrom(ref value))
|
||||
if (!typeof(T).IsAssignableFromValue(ref value))
|
||||
{
|
||||
throw new InvalidOperationException("Assignment invalid due to type mismatch");
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Microsoft.ClearScript
|
|||
object Value { get; set; }
|
||||
}
|
||||
|
||||
internal abstract class HostVariableBase : HostTarget
|
||||
internal abstract class HostVariable : HostTarget
|
||||
{
|
||||
private static readonly string[] auxPropertyNames = { "out", "ref", "value" };
|
||||
|
||||
|
@ -24,7 +24,7 @@ namespace Microsoft.ClearScript
|
|||
}
|
||||
}
|
||||
|
||||
internal sealed class HostVariable<T> : HostVariableBase, IHostVariable
|
||||
internal sealed class HostVariable<T> : HostVariable, IHostVariable
|
||||
{
|
||||
public HostVariable(T initValue)
|
||||
{
|
||||
|
@ -162,7 +162,7 @@ namespace Microsoft.ClearScript
|
|||
|
||||
set
|
||||
{
|
||||
if (!typeof(T).IsAssignableFrom(ref value))
|
||||
if (!typeof(T).IsAssignableFromValue(ref value))
|
||||
{
|
||||
throw new InvalidOperationException("Assignment invalid due to type mismatch");
|
||||
}
|
||||
|
|
|
@ -46,12 +46,8 @@ namespace Microsoft.ClearScript
|
|||
dynamic ScriptException { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the script exception object that caused the current exception to be thrown, or <c>null</c> if one was not specified.
|
||||
/// Gets the script exception that caused the current exception to be thrown, or <c>null</c> if one was not specified, without engaging the dynamic infrastructure.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This property returns the same object or value as <see cref="ScriptException"/>, but
|
||||
/// accessing it does not trigger the construction of a dynamic call site.
|
||||
/// </remarks>
|
||||
object ScriptExceptionAsObject { get; }
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -12,8 +12,9 @@ namespace Microsoft.ClearScript
|
|||
/// When this attribute is applied to a struct, ClearScript exposes the same object reference
|
||||
/// for all instances of the struct that satisfy equality comparison, giving script code the
|
||||
/// ability to use native equality operators to compare the exposed objects. This behavior is
|
||||
/// also enabled automatically for all enums, numeric types, <c><see cref="DateTime"/></c>,
|
||||
/// <c><see cref="DateTimeOffset"/></c>, and <c><see cref="TimeSpan"/></c>.
|
||||
/// also enabled automatically for all enums, <c>readonly</c> structs, numeric types,
|
||||
/// <c><see cref="DateTime"/></c>, <c><see cref="DateTimeOffset"/></c>,
|
||||
/// <c><see cref="TimeSpan"/></c>, and <c><see cref="Guid"></see></c>.
|
||||
/// </remarks>
|
||||
[AttributeUsage(AttributeTargets.Struct)]
|
||||
public sealed class ImmutableValueAttribute : Attribute
|
||||
|
|
|
@ -179,7 +179,7 @@ namespace Microsoft.ClearScript.JavaScript
|
|||
{
|
||||
invoked = true;
|
||||
var result = function.Invoke(false, module, exports, require);
|
||||
exports = ((dynamic)module).exports;
|
||||
exports = (module is CommonJSLegacyModule legacyModule) ? legacyModule.exports : ((ScriptObject)module).GetProperty("exports");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,15 +18,15 @@ using System.Runtime.InteropServices;
|
|||
[assembly: InternalsVisibleTo("ClearScriptTest")]
|
||||
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: AssemblyVersion("7.3.1")]
|
||||
[assembly: AssemblyFileVersion("7.3.1")]
|
||||
[assembly: AssemblyInformationalVersion("7.3.1")]
|
||||
[assembly: AssemblyVersion("7.3.2")]
|
||||
[assembly: AssemblyFileVersion("7.3.2")]
|
||||
[assembly: AssemblyInformationalVersion("7.3.2")]
|
||||
|
||||
namespace Microsoft.ClearScript.Properties
|
||||
{
|
||||
internal static class ClearScriptVersion
|
||||
{
|
||||
public const string Triad = "7.3.1";
|
||||
public const string Informational = "7.3.1";
|
||||
public const string Triad = "7.3.2";
|
||||
public const string Informational = "7.3.2";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,6 @@ using System.Runtime.InteropServices;
|
|||
[assembly: InternalsVisibleTo("ClearScript.V8")]
|
||||
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: AssemblyVersion("7.3.1")]
|
||||
[assembly: AssemblyFileVersion("7.3.1")]
|
||||
[assembly: AssemblyInformationalVersion("7.3.1")]
|
||||
[assembly: AssemblyVersion("7.3.2")]
|
||||
[assembly: AssemblyFileVersion("7.3.2")]
|
||||
[assembly: AssemblyInformationalVersion("7.3.2")]
|
||||
|
|
|
@ -15,6 +15,6 @@ using System.Runtime.InteropServices;
|
|||
[assembly: InternalsVisibleTo("ClearScriptTest")]
|
||||
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: AssemblyVersion("7.3.1")]
|
||||
[assembly: AssemblyFileVersion("7.3.1")]
|
||||
[assembly: AssemblyInformationalVersion("7.3.1")]
|
||||
[assembly: AssemblyVersion("7.3.2")]
|
||||
[assembly: AssemblyFileVersion("7.3.2")]
|
||||
[assembly: AssemblyInformationalVersion("7.3.2")]
|
||||
|
|
|
@ -16,6 +16,6 @@ using System.Runtime.InteropServices;
|
|||
[assembly: InternalsVisibleTo("ClearScriptTest")]
|
||||
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: AssemblyVersion("7.3.1")]
|
||||
[assembly: AssemblyFileVersion("7.3.1")]
|
||||
[assembly: AssemblyInformationalVersion("7.3.1")]
|
||||
[assembly: AssemblyVersion("7.3.2")]
|
||||
[assembly: AssemblyFileVersion("7.3.2")]
|
||||
[assembly: AssemblyInformationalVersion("7.3.2")]
|
||||
|
|
|
@ -15,6 +15,6 @@ using System.Runtime.InteropServices;
|
|||
[assembly: InternalsVisibleTo("ClearScriptTest")]
|
||||
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: AssemblyVersion("7.3.1")]
|
||||
[assembly: AssemblyFileVersion("7.3.1")]
|
||||
[assembly: AssemblyInformationalVersion("7.3.1")]
|
||||
[assembly: AssemblyVersion("7.3.2")]
|
||||
[assembly: AssemblyFileVersion("7.3.2")]
|
||||
[assembly: AssemblyInformationalVersion("7.3.2")]
|
||||
|
|
|
@ -270,8 +270,8 @@ namespace Microsoft.ClearScript
|
|||
/// <remarks>
|
||||
/// When this property is set to <c>true</c>, the script engine bypasses the default method
|
||||
/// binding algorithm and uses reflection-based method binding instead. This approach
|
||||
/// abandons support for generic methods and other features, but it avoids engaging the
|
||||
/// dynamic infrastructure.
|
||||
/// abandons support for generic type inference and other features, but it avoids engaging
|
||||
/// the dynamic infrastructure.
|
||||
/// </remarks>
|
||||
/// <seealso cref="UseReflectionBindFallback"/>
|
||||
public bool DisableDynamicBinding { get; set; }
|
||||
|
@ -1469,7 +1469,7 @@ namespace Microsoft.ClearScript
|
|||
public object Invoke(string funcName, params object[] args)
|
||||
{
|
||||
MiscHelpers.VerifyNonBlankArgument(funcName, nameof(funcName), "Invalid function name");
|
||||
return ((IDynamic)Script).InvokeMethod(funcName, args ?? ArrayHelpers.GetEmptyArray<object>());
|
||||
return Global.InvokeMethod(funcName, args ?? ArrayHelpers.GetEmptyArray<object>());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1812,7 +1812,7 @@ namespace Microsoft.ClearScript
|
|||
return GetOrCreateHostItemForHostObject(hostMethod, hostMethod, flags, createHostItem);
|
||||
}
|
||||
|
||||
if (target is HostVariableBase hostVariable)
|
||||
if (target is HostVariable hostVariable)
|
||||
{
|
||||
return GetOrCreateHostItemForHostObject(hostVariable, hostVariable, flags, createHostItem);
|
||||
}
|
||||
|
|
|
@ -124,12 +124,8 @@ namespace Microsoft.ClearScript
|
|||
public dynamic ScriptException => scriptException;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the script exception object that caused the current exception to be thrown, or <c>null</c> if one was not specified.
|
||||
/// Gets the script exception that caused the current exception to be thrown, or <c>null</c> if one was not specified, without engaging the dynamic infrastructure.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This property returns the same object or value as <see cref="ScriptException"/>, but
|
||||
/// accessing it does not trigger the construction of a dynamic call site.
|
||||
/// </remarks>
|
||||
public object ScriptExceptionAsObject => scriptException;
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -124,12 +124,8 @@ namespace Microsoft.ClearScript
|
|||
public dynamic ScriptException => scriptException;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the script exception object that caused the current exception to be thrown, or <c>null</c> if one was not specified.
|
||||
/// Gets the script exception that caused the current exception to be thrown, or <c>null</c> if one was not specified, without engaging the dynamic infrastructure.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This property returns the same object or value as <see cref="ScriptException"/>, but
|
||||
/// accessing it does not trigger the construction of a dynamic call site.
|
||||
/// </remarks>
|
||||
public object ScriptExceptionAsObject => scriptException;
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -115,5 +115,15 @@ namespace Microsoft.ClearScript
|
|||
/// <param name="args">Optional arguments for method invocation.</param>
|
||||
/// <returns>The invocation result value.</returns>
|
||||
public abstract object InvokeMethod(string name, params object[] args);
|
||||
|
||||
/// <summary>
|
||||
/// Invokes the script object as a function.
|
||||
/// </summary>
|
||||
/// <param name="args">Optional arguments for object invocation.</param>
|
||||
/// <returns>The invocation result value.</returns>
|
||||
public object InvokeAsFunction(params object[] args)
|
||||
{
|
||||
return Invoke(false, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace Microsoft.ClearScript.Util.COM
|
|||
var result = dispatch.GetProperty(name, args);
|
||||
return result;
|
||||
}
|
||||
catch (Exception)
|
||||
catch
|
||||
{
|
||||
if (args.Length < 1)
|
||||
{
|
||||
|
@ -160,7 +160,7 @@ namespace Microsoft.ClearScript.Util.COM
|
|||
var result = dispatchEx.GetProperty(name, false, args);
|
||||
return result;
|
||||
}
|
||||
catch (Exception)
|
||||
catch
|
||||
{
|
||||
if (args.Length < 1)
|
||||
{
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace Microsoft.ClearScript.Util.COM
|
|||
return name.Trim();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace Microsoft.ClearScript.Util.COM
|
|||
return name;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -174,6 +174,11 @@ namespace Microsoft.ClearScript.Util
|
|||
return TryDynamicOperation(() => target.DeleteIndex(indices), out result);
|
||||
}
|
||||
|
||||
public static bool TryConvert(this DynamicMetaObject target, Type type, bool @explicit, out object result)
|
||||
{
|
||||
return TryDynamicOperation(() => target.Convert(type, @explicit), out result);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region internal members
|
||||
|
@ -274,7 +279,7 @@ namespace Microsoft.ClearScript.Util
|
|||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception)
|
||||
catch
|
||||
{
|
||||
result = null;
|
||||
return false;
|
||||
|
@ -303,7 +308,7 @@ namespace Microsoft.ClearScript.Util
|
|||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception)
|
||||
catch
|
||||
{
|
||||
result = null;
|
||||
return false;
|
||||
|
@ -468,6 +473,13 @@ namespace Microsoft.ClearScript.Util
|
|||
}
|
||||
}
|
||||
|
||||
private static object Convert(this DynamicMetaObject target, Type type, bool @explicit)
|
||||
{
|
||||
var bindResult = target.BindConvert(new DynamicConvertBinder(type, @explicit));
|
||||
var block = Expression.Block(Expression.Label(CallSiteBinder.UpdateLabel), bindResult.Expression);
|
||||
return Invoke(block);
|
||||
}
|
||||
|
||||
private static DynamicMetaObject CreateDynamicTarget(object target)
|
||||
{
|
||||
if (target is IByRefArg byRefArg)
|
||||
|
@ -837,6 +849,30 @@ namespace Microsoft.ClearScript.Util
|
|||
|
||||
#endregion
|
||||
|
||||
#region Nested type: DynamicConvertBinder
|
||||
|
||||
private sealed class DynamicConvertBinder : ConvertBinder
|
||||
{
|
||||
public DynamicConvertBinder(Type type, bool @explicit)
|
||||
: base(type, @explicit)
|
||||
{
|
||||
}
|
||||
|
||||
public override DynamicMetaObject FallbackConvert(DynamicMetaObject target, DynamicMetaObject errorSuggestion)
|
||||
{
|
||||
if (errorSuggestion != null)
|
||||
{
|
||||
return errorSuggestion;
|
||||
}
|
||||
|
||||
// Construct an algorithm for dealing with unsuccessful dynamic conversion.
|
||||
// The block must return an expression of the target type.
|
||||
return new DynamicMetaObject(Expression.Block(CreateThrowExpr<InvalidDynamicOperationException>("Invalid dynamic conversion"), Expression.Default(Type)), BindingRestrictions.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Nested type: InvalidDynamicOperationException
|
||||
|
||||
[Serializable]
|
||||
|
|
|
@ -51,6 +51,14 @@ namespace Microsoft.ClearScript.Util
|
|||
}
|
||||
}
|
||||
|
||||
internal static partial class EnumerableHelpers<T>
|
||||
{
|
||||
public static IAsyncEnumeratorPromise<T> GetAsyncEnumerator(IEnumerable<T> source, ScriptEngine engine)
|
||||
{
|
||||
return source.GetEnumerator().ToAsyncEnumerator(engine);
|
||||
}
|
||||
}
|
||||
|
||||
internal abstract class AsyncEnumeratorPromiseBase
|
||||
{
|
||||
protected static readonly Task CompletedTask = Task.FromResult(0);
|
||||
|
|
|
@ -47,6 +47,19 @@ namespace Microsoft.ClearScript.Util
|
|||
}
|
||||
}
|
||||
|
||||
internal static partial class EnumerableHelpers<T>
|
||||
{
|
||||
public static IAsyncEnumeratorPromise<T> GetAsyncEnumerator(IAsyncEnumerable<T> source, ScriptEngine engine)
|
||||
{
|
||||
return new AsyncEnumeratorPromiseOnAsyncEnumerator<T>(engine, source.GetAsyncEnumerator());
|
||||
}
|
||||
|
||||
public static IAsyncEnumeratorPromise<T> GetAsyncEnumerator(IEnumerable<T> source, ScriptEngine engine)
|
||||
{
|
||||
return source.GetEnumerator().ToAsyncEnumerator(engine);
|
||||
}
|
||||
}
|
||||
|
||||
internal abstract class AsyncEnumeratorPromise<T> : IAsyncEnumeratorPromise<T>
|
||||
{
|
||||
private readonly ScriptEngine engine;
|
||||
|
|
|
@ -16,7 +16,6 @@ namespace Microsoft.ClearScript.Util
|
|||
{
|
||||
}
|
||||
|
||||
// ReSharper disable once PartialTypeWithSinglePart
|
||||
internal static partial class EnumerableHelpers
|
||||
{
|
||||
public static readonly HostType HostType = HostType.Wrap(typeof(EnumerableHelpers));
|
||||
|
@ -94,6 +93,16 @@ namespace Microsoft.ClearScript.Util
|
|||
}
|
||||
}
|
||||
|
||||
internal static partial class EnumerableHelpers<T>
|
||||
{
|
||||
public static readonly HostType HostType = HostType.Wrap(typeof(EnumerableHelpers<T>));
|
||||
|
||||
public static IEnumerator<T> GetEnumerator(IEnumerable<T> source)
|
||||
{
|
||||
return source.GetEnumerator();
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class DisposableEnumeratorOnEnumerator : IDisposableEnumerator
|
||||
{
|
||||
private readonly IEnumerator enumerator;
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace Microsoft.ClearScript.Util
|
|||
if ((index != (args.Length - 1)) || !param.ParameterType.IsInstanceOfType(args[index]))
|
||||
{
|
||||
var tailArgType = param.ParameterType.GetElementType();
|
||||
var tailArgs = Array.CreateInstance(tailArgType, args.Length - index);
|
||||
var tailArgs = Array.CreateInstance(tailArgType, Math.Max(args.Length - index, 0));
|
||||
for (var innerIndex = index; innerIndex < args.Length; innerIndex++)
|
||||
{
|
||||
var byRefArg = args[innerIndex] as IByRefArg;
|
||||
|
@ -178,7 +178,7 @@ namespace Microsoft.ClearScript.Util
|
|||
|
||||
private static object GetCompatibleArg(string paramName, Type type, object value)
|
||||
{
|
||||
if (!type.IsAssignableFrom(ref value))
|
||||
if (!type.IsAssignableFromValue(ref value))
|
||||
{
|
||||
throw new ArgumentException(MiscHelpers.FormatInvariant("Invalid argument specified for parameter '{0}'", paramName));
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
|
@ -21,7 +20,7 @@ namespace Microsoft.ClearScript.Util
|
|||
{
|
||||
return (x.Module == y.Module) && (x.MetadataToken == y.MetadataToken);
|
||||
}
|
||||
catch (Exception)
|
||||
catch
|
||||
{
|
||||
return x == y;
|
||||
}
|
||||
|
|
|
@ -329,7 +329,7 @@ namespace Microsoft.ClearScript.Util
|
|||
action();
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -342,7 +342,7 @@ namespace Microsoft.ClearScript.Util
|
|||
result = func();
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
catch
|
||||
{
|
||||
result = default;
|
||||
return false;
|
||||
|
@ -356,7 +356,7 @@ namespace Microsoft.ClearScript.Util
|
|||
await task.ConfigureAwait(false);
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -369,7 +369,7 @@ namespace Microsoft.ClearScript.Util
|
|||
holder.Value = await task.ConfigureAwait(false);
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,59 @@ namespace Microsoft.ClearScript.Util
|
|||
{
|
||||
internal static partial class ObjectHelpers
|
||||
{
|
||||
private static readonly object[] zeroes =
|
||||
{
|
||||
(sbyte)0,
|
||||
(byte)0,
|
||||
(short)0,
|
||||
(ushort)0,
|
||||
0,
|
||||
0U,
|
||||
0L,
|
||||
0UL,
|
||||
IntPtr.Zero,
|
||||
UIntPtr.Zero,
|
||||
0.0f,
|
||||
0.0d,
|
||||
0.0m
|
||||
};
|
||||
|
||||
public static bool IsZero(this object value) => Array.IndexOf(zeroes, value) >= 0;
|
||||
|
||||
public static bool IsWholeNumber(this object value)
|
||||
{
|
||||
// ReSharper disable CompareOfFloatsByEqualityOperator
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (value.GetType().IsIntegral())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (value is float floatValue)
|
||||
{
|
||||
return Math.Round(floatValue) == floatValue;
|
||||
}
|
||||
|
||||
if (value is double doubleValue)
|
||||
{
|
||||
return Math.Round(doubleValue) == doubleValue;
|
||||
}
|
||||
|
||||
if (value is decimal decimalValue)
|
||||
{
|
||||
return Math.Round(decimalValue) == decimalValue;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
// ReSharper restore CompareOfFloatsByEqualityOperator
|
||||
}
|
||||
|
||||
public static Type GetTypeOrTypeInfo(this object value)
|
||||
{
|
||||
if (!MiscHelpers.PlatformIsWindows())
|
||||
|
@ -128,7 +181,7 @@ namespace Microsoft.ClearScript.Util
|
|||
|
||||
return typeInfo.GetManagedType();
|
||||
}
|
||||
catch (Exception)
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -156,7 +209,7 @@ namespace Microsoft.ClearScript.Util
|
|||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -207,12 +260,7 @@ namespace Microsoft.ClearScript.Util
|
|||
|
||||
public static T DynamicCast<T>(this object value)
|
||||
{
|
||||
// ReSharper disable RedundantCast
|
||||
|
||||
// the cast to dynamic is not redundant; removing it breaks tests
|
||||
return (T)(dynamic)value;
|
||||
|
||||
// ReSharper restore RedundantCast
|
||||
return DynamicCaster<T>.Cast(value);
|
||||
}
|
||||
|
||||
public static object ToDynamicResult(this object result, ScriptEngine engine)
|
||||
|
@ -250,5 +298,61 @@ namespace Microsoft.ClearScript.Util
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Nested type: DynamicCaster<T>
|
||||
|
||||
private static class DynamicCaster<T>
|
||||
{
|
||||
public static T Cast(object value)
|
||||
{
|
||||
// ReSharper disable EmptyGeneralCatchClause
|
||||
|
||||
try
|
||||
{
|
||||
if (!typeof(T).IsValueType)
|
||||
{
|
||||
return (T)value;
|
||||
}
|
||||
|
||||
if (typeof(T).IsEnum)
|
||||
{
|
||||
return (T)Enum.ToObject(typeof(T), value);
|
||||
}
|
||||
|
||||
if (typeof(T).IsNullable())
|
||||
{
|
||||
return (T)CastToNullable(value);
|
||||
}
|
||||
|
||||
if (value is IConvertible)
|
||||
{
|
||||
return (T)Convert.ChangeType(value, typeof(T));
|
||||
}
|
||||
|
||||
return (T)value;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
return (T)(dynamic)value;
|
||||
|
||||
// ReSharper restore EmptyGeneralCatchClause
|
||||
}
|
||||
|
||||
private static object CastToNullable(object value)
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
var valueCastType = typeof(DynamicCaster<>).MakeGenericType(Nullable.GetUnderlyingType(typeof(T)));
|
||||
value = valueCastType.InvokeMember("Cast", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Static, null, null, new[] { value });
|
||||
return typeof(T).CreateInstance(value);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,24 +32,31 @@ namespace Microsoft.ClearScript.Util
|
|||
// ReSharper restore StringLiteralTypo
|
||||
};
|
||||
|
||||
private static readonly HashSet<Type> nullableNumericTypes = new HashSet<Type>
|
||||
{
|
||||
typeof(char?),
|
||||
typeof(sbyte?),
|
||||
typeof(byte?),
|
||||
typeof(short?),
|
||||
typeof(ushort?),
|
||||
typeof(int?),
|
||||
typeof(uint?),
|
||||
typeof(long?),
|
||||
typeof(ulong?),
|
||||
typeof(float?),
|
||||
typeof(double?),
|
||||
typeof(decimal?)
|
||||
};
|
||||
|
||||
private static readonly ConcurrentDictionary<Tuple<Type, BindingFlags, Type, ScriptAccess, bool>, Invocability> invocabilityMap = new ConcurrentDictionary<Tuple<Type, BindingFlags, Type, ScriptAccess, bool>, Invocability>();
|
||||
|
||||
private static readonly NumericTypes[] numericConversions =
|
||||
{
|
||||
// https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/numeric-conversions
|
||||
|
||||
// IMPORTANT: maintain NumericType order
|
||||
|
||||
/* None */ NumericTypes.None,
|
||||
/* Char */ NumericTypes.UInt16 | NumericTypes.Int32 | NumericTypes.UInt32 | NumericTypes.Int64 | NumericTypes.UInt64 | NumericTypes.Single | NumericTypes.Double | NumericTypes.Decimal | NumericTypes.IntPtr | NumericTypes.UIntPtr,
|
||||
/* SByte */ NumericTypes.Int16 | NumericTypes.Int32 | NumericTypes.Int64 | NumericTypes.Single | NumericTypes.Double | NumericTypes.Decimal | NumericTypes.IntPtr,
|
||||
/* Byte */ NumericTypes.Int16 | NumericTypes.UInt16 | NumericTypes.Int32 | NumericTypes.UInt32 | NumericTypes.Int64 | NumericTypes.UInt64 | NumericTypes.Single | NumericTypes.Double | NumericTypes.Decimal | NumericTypes.IntPtr | NumericTypes.UIntPtr,
|
||||
/* Int16 */ NumericTypes.Int32 | NumericTypes.Int64 | NumericTypes.Single | NumericTypes.Double | NumericTypes.Decimal | NumericTypes.IntPtr,
|
||||
/* UInt16 */ NumericTypes.Int32 | NumericTypes.UInt32 | NumericTypes.Int64 | NumericTypes.UInt64 | NumericTypes.Single | NumericTypes.Double | NumericTypes.Decimal | NumericTypes.IntPtr | NumericTypes.UIntPtr,
|
||||
/* Int32 */ NumericTypes.Int64 | NumericTypes.Single | NumericTypes.Double | NumericTypes.Decimal | NumericTypes.IntPtr,
|
||||
/* UInt32 */ NumericTypes.Int64 | NumericTypes.UInt64 | NumericTypes.Single | NumericTypes.Double | NumericTypes.Decimal | NumericTypes.UIntPtr,
|
||||
/* Int64 */ NumericTypes.Single | NumericTypes.Double | NumericTypes.Decimal,
|
||||
/* UInt64 */ NumericTypes.Single | NumericTypes.Double | NumericTypes.Decimal,
|
||||
/* IntPtr */ NumericTypes.Int64 | NumericTypes.Single | NumericTypes.Double | NumericTypes.Decimal,
|
||||
/* UIntPtr */ NumericTypes.UInt64 | NumericTypes.Single | NumericTypes.Double | NumericTypes.Decimal,
|
||||
/* Single */ NumericTypes.Double,
|
||||
/* Double */ NumericTypes.None,
|
||||
/* Decimal */ NumericTypes.None
|
||||
};
|
||||
|
||||
public static bool IsStatic(this Type type)
|
||||
{
|
||||
return type.IsAbstract && type.IsSealed;
|
||||
|
@ -116,31 +123,30 @@ namespace Microsoft.ClearScript.Util
|
|||
public static bool IsIntegral(this Type type)
|
||||
{
|
||||
return
|
||||
(type == typeof(char)) ||
|
||||
(type == typeof(sbyte)) ||
|
||||
(type == typeof(byte)) ||
|
||||
(type == typeof(short)) ||
|
||||
(type == typeof(ushort)) ||
|
||||
(type == typeof(char)) ||
|
||||
(type == typeof(int)) ||
|
||||
(type == typeof(uint)) ||
|
||||
(type == typeof(long)) ||
|
||||
(type == typeof(ulong));
|
||||
(type == typeof(ulong)) ||
|
||||
(type == typeof(IntPtr)) ||
|
||||
(type == typeof(UIntPtr));
|
||||
}
|
||||
|
||||
public static bool IsFloatingPoint(this Type type)
|
||||
{
|
||||
return
|
||||
(type == typeof(float)) ||
|
||||
(type == typeof(double));
|
||||
(type == typeof(double)) ||
|
||||
(type == typeof(decimal));
|
||||
}
|
||||
|
||||
public static bool IsNumeric(this Type type, out bool isIntegral)
|
||||
{
|
||||
isIntegral = type.IsIntegral();
|
||||
return
|
||||
isIntegral ||
|
||||
type.IsFloatingPoint() ||
|
||||
type == typeof(decimal);
|
||||
return (isIntegral = type.IsIntegral()) || type.IsFloatingPoint();
|
||||
}
|
||||
|
||||
public static bool IsNumeric(this Type type)
|
||||
|
@ -155,7 +161,21 @@ namespace Microsoft.ClearScript.Util
|
|||
|
||||
public static bool IsNullableNumeric(this Type type)
|
||||
{
|
||||
return nullableNumericTypes.Contains(type);
|
||||
return
|
||||
(type == typeof(char?)) ||
|
||||
(type == typeof(sbyte?)) ||
|
||||
(type == typeof(byte?)) ||
|
||||
(type == typeof(short?)) ||
|
||||
(type == typeof(ushort?)) ||
|
||||
(type == typeof(int?)) ||
|
||||
(type == typeof(uint?)) ||
|
||||
(type == typeof(long?)) ||
|
||||
(type == typeof(ulong?)) ||
|
||||
(type == typeof(IntPtr?)) ||
|
||||
(type == typeof(UIntPtr?)) ||
|
||||
(type == typeof(float?)) ||
|
||||
(type == typeof(double?)) ||
|
||||
(type == typeof(decimal?));
|
||||
}
|
||||
|
||||
public static bool IsUnknownCOMObject(this Type type)
|
||||
|
@ -163,92 +183,9 @@ namespace Microsoft.ClearScript.Util
|
|||
return type.IsCOMObject && (type.GetInterfaces().Length < 1);
|
||||
}
|
||||
|
||||
public static bool IsAssignableFrom(this Type type, ref object value)
|
||||
public static bool IsAssignableFromValue(this Type type, ref object value)
|
||||
{
|
||||
if (type.IsByRef)
|
||||
{
|
||||
type = type.GetElementType();
|
||||
}
|
||||
|
||||
if (type.IsNullable())
|
||||
{
|
||||
return (value == null) || (Nullable.GetUnderlyingType(type).IsAssignableFrom(ref value));
|
||||
}
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
return !type.IsValueType;
|
||||
}
|
||||
|
||||
var valueType = value.GetType();
|
||||
if ((valueType == type) || type.IsAssignableFrom(valueType))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (type.IsImplicitlyConvertibleFrom(valueType, ref value))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!type.IsValueType)
|
||||
{
|
||||
if (type.IsInterface && type.IsImport && valueType.IsCOMObject)
|
||||
{
|
||||
var result = false;
|
||||
var pUnknown = Marshal.GetIUnknownForObject(value);
|
||||
|
||||
var iid = type.GUID;
|
||||
if (iid != Guid.Empty)
|
||||
{
|
||||
if (HResult.Succeeded(Marshal.QueryInterface(pUnknown, ref iid, out var pInterface)))
|
||||
{
|
||||
Marshal.Release(pInterface);
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
Marshal.Release(pUnknown);
|
||||
return result;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!valueType.IsValueType)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (type.IsEnum)
|
||||
{
|
||||
return Enum.GetUnderlyingType(type).IsAssignableFrom(ref value) && (value.DynamicCast<int>() == 0);
|
||||
}
|
||||
|
||||
if (valueType.IsEnum)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (type.IsNumeric(out var typeIsIntegral))
|
||||
{
|
||||
if (typeIsIntegral)
|
||||
{
|
||||
if (!valueType.IsIntegral())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (!valueType.IsNumeric())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
value = Convert.ChangeType(value, type);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return type.IsAssignableFromValueInternal(ref value, null, null);
|
||||
}
|
||||
|
||||
public static bool IsAssignableToGenericType(this Type type, Type genericTypeDefinition, out Type[] typeArgs)
|
||||
|
@ -275,6 +212,16 @@ namespace Microsoft.ClearScript.Util
|
|||
return false;
|
||||
}
|
||||
|
||||
public static bool IsImplicitlyConvertibleFromValue(this Type type, Type sourceType, ref object value)
|
||||
{
|
||||
return IsImplicitlyConvertibleFromValueInternal(type, sourceType, type, ref value) || IsImplicitlyConvertibleFromValueInternal(sourceType, sourceType, type, ref value);
|
||||
}
|
||||
|
||||
public static bool IsNumericallyConvertibleFrom(this Type type, Type valueType)
|
||||
{
|
||||
return numericConversions[(int)valueType.GetNumericType()].HasFlag(GetNumericTypes(type.GetNumericType()));
|
||||
}
|
||||
|
||||
public static bool HasExtensionMethods(this Type type)
|
||||
{
|
||||
return type.HasCustomAttributes<ExtensionAttribute>(false);
|
||||
|
@ -491,7 +438,7 @@ namespace Microsoft.ClearScript.Util
|
|||
}
|
||||
}
|
||||
|
||||
public static PropertyInfo GetScriptableProperty(this Type type, string name, BindingFlags bindFlags, object[] bindArgs, Type accessContext, ScriptAccess defaultAccess)
|
||||
public static PropertyInfo GetScriptableProperty(this Type type, string name, BindingFlags bindFlags, object[] args, object[] bindArgs, Type accessContext, ScriptAccess defaultAccess)
|
||||
{
|
||||
if (bindArgs.Length < 1)
|
||||
{
|
||||
|
@ -509,13 +456,13 @@ namespace Microsoft.ClearScript.Util
|
|||
}
|
||||
|
||||
var candidates = type.GetScriptableProperties(name, bindFlags, accessContext, defaultAccess).Distinct(PropertySignatureComparer.Instance).ToArray();
|
||||
return SelectProperty(candidates, bindFlags, bindArgs);
|
||||
return BindToMember(candidates, bindFlags, args, bindArgs);
|
||||
}
|
||||
|
||||
public static PropertyInfo GetScriptableDefaultProperty(this Type type, BindingFlags bindFlags, object[] bindArgs, Type accessContext, ScriptAccess defaultAccess)
|
||||
public static PropertyInfo GetScriptableDefaultProperty(this Type type, BindingFlags bindFlags, object[] args, object[] bindArgs, Type accessContext, ScriptAccess defaultAccess)
|
||||
{
|
||||
var candidates = type.GetScriptableDefaultProperties(bindFlags, accessContext, defaultAccess).Distinct(PropertySignatureComparer.Instance).ToArray();
|
||||
return SelectProperty(candidates, bindFlags, bindArgs);
|
||||
return BindToMember(candidates, bindFlags, args, bindArgs);
|
||||
}
|
||||
|
||||
public static IEnumerable<Type> GetScriptableNestedTypes(this Type type, BindingFlags bindFlags, Type accessContext, ScriptAccess defaultAccess)
|
||||
|
@ -535,10 +482,10 @@ namespace Microsoft.ClearScript.Util
|
|||
|
||||
public static object CreateInstance(this Type type, BindingFlags flags, params object[] args)
|
||||
{
|
||||
return type.InvokeMember(null, BindingFlags.CreateInstance | BindingFlags.Instance | (flags & ~BindingFlags.Static), null, null, args, CultureInfo.InvariantCulture);
|
||||
return type.InvokeMember(string.Empty, BindingFlags.CreateInstance | BindingFlags.Instance | (flags & ~BindingFlags.Static), null, null, args, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
public static object CreateInstance(this Type type, Type accessContext, ScriptAccess defaultAccess, params object[] args)
|
||||
public static object CreateInstance(this Type type, Type accessContext, ScriptAccess defaultAccess, object[] args, object[] bindArgs)
|
||||
{
|
||||
if (type.IsCOMObject || (type.IsValueType && (args.Length < 1)))
|
||||
{
|
||||
|
@ -552,22 +499,24 @@ namespace Microsoft.ClearScript.Util
|
|||
throw new MissingMethodException(MiscHelpers.FormatInvariant("Type '{0}' has no constructor that matches the specified arguments", type.GetFullFriendlyName()));
|
||||
}
|
||||
|
||||
ConstructorInfo constructor = null;
|
||||
|
||||
try
|
||||
{
|
||||
// ReSharper disable once CoVariantArrayConversion
|
||||
constructor = Type.DefaultBinder.BindToMethod(flags, candidates, ref args, null, null, null, out _) as ConstructorInfo;
|
||||
}
|
||||
catch (MissingMethodException)
|
||||
{
|
||||
}
|
||||
ConstructorInfo constructor = BindToMember(candidates, flags, args, bindArgs);
|
||||
|
||||
if (constructor == null)
|
||||
{
|
||||
throw new MissingMethodException(MiscHelpers.FormatInvariant("Type '{0}' has no constructor that matches the specified arguments", type.GetFullFriendlyName()));
|
||||
}
|
||||
|
||||
if (args.Length > 0)
|
||||
{
|
||||
args = (object[])args.Clone();
|
||||
var indexParams = constructor.GetParameters();
|
||||
var length = Math.Min(args.Length, indexParams.Length);
|
||||
for (var index = 0; index < length; index++)
|
||||
{
|
||||
indexParams[index].ParameterType.IsAssignableFromValue(ref args[index]);
|
||||
}
|
||||
}
|
||||
|
||||
return constructor.Invoke(args);
|
||||
}
|
||||
|
||||
|
@ -602,9 +551,43 @@ namespace Microsoft.ClearScript.Util
|
|||
return type;
|
||||
}
|
||||
|
||||
public static bool IsValidLocator(string name)
|
||||
public static T BindToMember<T>(T[] candidates, BindingFlags bindFlags, object[] args, object[] bindArgs) where T : MethodBase
|
||||
{
|
||||
return !string.IsNullOrWhiteSpace(name) && name.All(IsValidLocatorChar);
|
||||
T result = null;
|
||||
|
||||
if (candidates.Length > 0)
|
||||
{
|
||||
var bindCandidates = GetBindCandidates(candidates, args, bindArgs.Select(GetBindArgType).ToArray()).ToArray();
|
||||
result = SelectBindCandidate(bindCandidates);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static PropertyInfo BindToMember(PropertyInfo[] candidates, BindingFlags bindFlags, object[] args, object[] bindArgs)
|
||||
{
|
||||
PropertyInfo result = null;
|
||||
|
||||
if (candidates.Length > 0)
|
||||
{
|
||||
var bindCandidates = GetBindCandidates(candidates, args, bindArgs.Select(GetBindArgType).ToArray()).ToArray();
|
||||
result = SelectBindCandidate(bindCandidates);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
// the default binder fails to bind to some COM properties because of by-ref parameter types
|
||||
if (candidates.Length == 1)
|
||||
{
|
||||
var parameters = candidates[0].GetIndexParameters();
|
||||
if ((bindArgs.Length == parameters.Length) || ((bindArgs.Length > 0) && (parameters.Length >= bindArgs.Length)))
|
||||
{
|
||||
result = candidates[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static HostType ImportType(string typeName, string assemblyName, bool useAssemblyName, object[] hostTypeArgs)
|
||||
|
@ -743,17 +726,19 @@ namespace Microsoft.ClearScript.Util
|
|||
|
||||
private static Invocability GetInvocabilityInternal(Tuple<Type, BindingFlags, Type, ScriptAccess, bool> args)
|
||||
{
|
||||
if (typeof(Delegate).IsAssignableFrom(args.Item1))
|
||||
var (type, bindFlags, accessContext, defaultAccess, ignoreDynamic) = args;
|
||||
|
||||
if (typeof(Delegate).IsAssignableFrom(type))
|
||||
{
|
||||
return Invocability.Delegate;
|
||||
}
|
||||
|
||||
if (!args.Item5 && typeof(IDynamicMetaObjectProvider).IsAssignableFrom(args.Item1))
|
||||
if (!ignoreDynamic && typeof(IDynamicMetaObjectProvider).IsAssignableFrom(type))
|
||||
{
|
||||
return Invocability.Dynamic;
|
||||
}
|
||||
|
||||
if (args.Item1.GetScriptableDefaultProperties(args.Item2, args.Item3, args.Item4).Any())
|
||||
if (type.GetScriptableDefaultProperties(bindFlags, accessContext, defaultAccess).Any())
|
||||
{
|
||||
return Invocability.DefaultProperty;
|
||||
}
|
||||
|
@ -761,6 +746,11 @@ namespace Microsoft.ClearScript.Util
|
|||
return Invocability.None;
|
||||
}
|
||||
|
||||
private static bool IsValidLocator(string name)
|
||||
{
|
||||
return !string.IsNullOrWhiteSpace(name) && name.All(IsValidLocatorChar);
|
||||
}
|
||||
|
||||
private static bool IsValidLocatorChar(char ch)
|
||||
{
|
||||
return char.IsLetterOrDigit(ch) || (ch == '_') || (ch == '.');
|
||||
|
@ -773,53 +763,187 @@ namespace Microsoft.ClearScript.Util
|
|||
return (index >= 0) ? name.Substring(0, index) : name;
|
||||
}
|
||||
|
||||
private static Type GetPropertyIndexType(object bindArg)
|
||||
private static bool IsBindableFromArg(this Type type, object value, Type valueType, out BindArgCost cost)
|
||||
{
|
||||
if (bindArg is HostTarget hostTarget)
|
||||
{
|
||||
return hostTarget.Type;
|
||||
}
|
||||
|
||||
if (bindArg != null)
|
||||
{
|
||||
return bindArg.GetType();
|
||||
}
|
||||
|
||||
throw new InvalidOperationException("The property index value must not be null");
|
||||
cost = new BindArgCost();
|
||||
return type.IsAssignableFromValueInternal(ref value, valueType, cost);
|
||||
}
|
||||
|
||||
private static PropertyInfo SelectProperty(PropertyInfo[] candidates, BindingFlags bindFlags, object[] bindArgs)
|
||||
private static bool IsAssignableFromValueInternal(this Type type, ref object value, Type valueType, BindArgCost cost)
|
||||
{
|
||||
if (candidates.Length < 1)
|
||||
var typeIsByRef = type.IsByRef;
|
||||
if (typeIsByRef)
|
||||
{
|
||||
return null;
|
||||
type = type.GetElementType();
|
||||
}
|
||||
|
||||
var result = Type.DefaultBinder.SelectProperty(bindFlags, candidates, null, bindArgs.Select(GetPropertyIndexType).ToArray(), null);
|
||||
if (result != null)
|
||||
var valueIsByRef = (valueType != null) && valueType.IsByRef;
|
||||
if (valueIsByRef)
|
||||
{
|
||||
return result;
|
||||
valueType = valueType.GetElementType();
|
||||
}
|
||||
|
||||
// the default binder fails to bind to some COM properties because of by-ref parameter types
|
||||
if (candidates.Length == 1)
|
||||
if ((cost != null) && (typeIsByRef != valueIsByRef))
|
||||
{
|
||||
var parameters = candidates[0].GetIndexParameters();
|
||||
if ((bindArgs.Length == parameters.Length) || ((bindArgs.Length > 0) && (parameters.Length >= bindArgs.Length)))
|
||||
cost.Flags |= BindArgFlags.ByRefMismatch;
|
||||
}
|
||||
|
||||
if ((value == null) && (valueType == null))
|
||||
{
|
||||
if (type.IsNullable())
|
||||
{
|
||||
return candidates[0];
|
||||
if (cost != null)
|
||||
{
|
||||
cost.NumericType = Nullable.GetUnderlyingType(type).GetNumericType();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return !type.IsValueType;
|
||||
}
|
||||
|
||||
if (valueType == null)
|
||||
{
|
||||
valueType = value.GetType();
|
||||
}
|
||||
|
||||
if (valueType == type)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (type.IsAssignableFrom(valueType))
|
||||
{
|
||||
if (cost != null)
|
||||
{
|
||||
if (type.IsNullable())
|
||||
{
|
||||
cost.Flags |= BindArgFlags.NullableTransition;
|
||||
cost.NumericType = Nullable.GetUnderlyingType(type).GetNumericType();
|
||||
}
|
||||
else if (TypeNode.TryGetUpcastCount(valueType, type, out var count))
|
||||
{
|
||||
cost.UpcastCount = count;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (type.IsImplicitlyConvertibleFromValue(valueType, ref value))
|
||||
{
|
||||
if (cost != null)
|
||||
{
|
||||
cost.Flags |= BindArgFlags.ImplicitConversion;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (type.IsNullable())
|
||||
{
|
||||
var underlyingType = Nullable.GetUnderlyingType(type);
|
||||
if (underlyingType.IsAssignableFromValueInternal(ref value, valueType, cost))
|
||||
{
|
||||
if (cost != null)
|
||||
{
|
||||
cost.Flags |= BindArgFlags.NullableTransition;
|
||||
cost.NumericType = underlyingType.GetNumericType();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!type.IsValueType)
|
||||
{
|
||||
if (type.IsInterface && type.IsImport && valueType.IsCOMObject)
|
||||
{
|
||||
var result = false;
|
||||
var pUnknown = Marshal.GetIUnknownForObject(value);
|
||||
|
||||
var iid = type.GUID;
|
||||
if (iid != Guid.Empty)
|
||||
{
|
||||
if (HResult.Succeeded(Marshal.QueryInterface(pUnknown, ref iid, out var pInterface)))
|
||||
{
|
||||
Marshal.Release(pInterface);
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
Marshal.Release(pUnknown);
|
||||
return result;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!valueType.IsValueType)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (type.IsEnum)
|
||||
{
|
||||
return Enum.GetUnderlyingType(type).IsAssignableFromValueInternal(ref value, valueType, cost) && value.IsZero();
|
||||
}
|
||||
|
||||
if (valueType.IsEnum)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (type.IsNumeric(out var typeIsIntegral))
|
||||
{
|
||||
if (typeIsIntegral)
|
||||
{
|
||||
if (!valueType.IsIntegral() && !value.IsWholeNumber())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!valueType.IsNumeric(out var valueTypeIsIntegral))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// special case for method binding only
|
||||
|
||||
if ((cost != null) && !valueTypeIsIntegral && !type.IsNumericallyConvertibleFrom(valueType))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
var tempValue = value;
|
||||
if (MiscHelpers.Try(out var tempResult, () => Convert.ChangeType(tempValue, type)))
|
||||
{
|
||||
if (cost != null)
|
||||
{
|
||||
cost.Flags |= BindArgFlags.NumericConversion;
|
||||
cost.NumericType = type.GetNumericType();
|
||||
}
|
||||
|
||||
value = tempResult;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool IsImplicitlyConvertibleFrom(this Type type, Type sourceType, ref object value)
|
||||
{
|
||||
return IsImplicitlyConvertibleInternal(type, sourceType, type, ref value) || IsImplicitlyConvertibleInternal(sourceType, sourceType, type, ref value);
|
||||
}
|
||||
|
||||
private static bool IsImplicitlyConvertibleInternal(Type definingType, Type sourceType, Type targetType, ref object value)
|
||||
private static bool IsImplicitlyConvertibleFromValueInternal(Type definingType, Type sourceType, Type targetType, ref object value)
|
||||
{
|
||||
foreach (var converter in definingType.GetMethods(BindingFlags.Public | BindingFlags.Static).Where(method => method.Name == "op_Implicit"))
|
||||
{
|
||||
|
@ -838,6 +962,222 @@ namespace Microsoft.ClearScript.Util
|
|||
return false;
|
||||
}
|
||||
|
||||
private static NumericType GetNumericType(this Type type)
|
||||
{
|
||||
if (type == typeof(char)) return NumericType.Char;
|
||||
if (type == typeof(sbyte)) return NumericType.SByte;
|
||||
if (type == typeof(byte)) return NumericType.Byte;
|
||||
if (type == typeof(short)) return NumericType.Int16;
|
||||
if (type == typeof(ushort)) return NumericType.UInt16;
|
||||
if (type == typeof(int)) return NumericType.Int32;
|
||||
if (type == typeof(uint)) return NumericType.UInt32;
|
||||
if (type == typeof(long)) return NumericType.Int64;
|
||||
if (type == typeof(ulong)) return NumericType.UInt64;
|
||||
if (type == typeof(IntPtr)) return NumericType.IntPtr;
|
||||
if (type == typeof(UIntPtr)) return NumericType.UIntPtr;
|
||||
if (type == typeof(float)) return NumericType.Single;
|
||||
if (type == typeof(double)) return NumericType.Double;
|
||||
if (type == typeof(decimal)) return NumericType.Decimal;
|
||||
return NumericType.None;
|
||||
}
|
||||
|
||||
private static NumericTypes GetNumericTypes(NumericType numericType)
|
||||
{
|
||||
return (numericType == NumericType.None) ? NumericTypes.None : (NumericTypes)(1 << (int)numericType);
|
||||
}
|
||||
|
||||
private static Type GetBindArgType(object bindArg)
|
||||
{
|
||||
if (bindArg is HostTarget hostTarget)
|
||||
{
|
||||
return hostTarget.Type;
|
||||
}
|
||||
|
||||
if (bindArg != null)
|
||||
{
|
||||
return bindArg.GetType();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static IEnumerable<BindCandidate<T>> GetBindCandidates<T>(T[] candidates, object[] args, Type[] argTypes) where T : MethodBase
|
||||
{
|
||||
return GetBindCandidates(candidates, candidate => candidate.GetParameters(), args, argTypes);
|
||||
}
|
||||
|
||||
private static IEnumerable<BindCandidate<PropertyInfo>> GetBindCandidates(PropertyInfo[] candidates, object[] args, Type[] argTypes)
|
||||
{
|
||||
return GetBindCandidates(candidates, candidate => candidate.GetIndexParameters(), args, argTypes);
|
||||
}
|
||||
|
||||
private static IEnumerable<BindCandidate<T>> GetBindCandidates<T>(T[] candidates, Func<T, ParameterInfo[]> getParameters, object[] args, Type[] argTypes) where T : MemberInfo
|
||||
{
|
||||
foreach (var candidate in candidates)
|
||||
{
|
||||
if (MiscHelpers.Try(out var bindCandidate, () => new BindCandidate<T>(candidate, getParameters(candidate), args, argTypes)))
|
||||
{
|
||||
yield return bindCandidate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static T SelectBindCandidate<T>(BindCandidate<T>[] bindCandidates) where T : MemberInfo
|
||||
{
|
||||
if (bindCandidates.Length < 1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (bindCandidates.Length < 2)
|
||||
{
|
||||
return bindCandidates[0].Candidate;
|
||||
}
|
||||
|
||||
Array.Sort(bindCandidates, Comparer<BindCandidate<T>>.Default);
|
||||
|
||||
if (bindCandidates[0].CompareTo(bindCandidates[1]) == 0)
|
||||
{
|
||||
throw new AmbiguousMatchException("Ambiguous match found for the specified arguments");
|
||||
}
|
||||
|
||||
return bindCandidates[0].Candidate;
|
||||
}
|
||||
|
||||
#region Nested type: NumericType
|
||||
|
||||
private enum NumericType
|
||||
{
|
||||
// IMPORTANT: maintain order and numeric mapping
|
||||
|
||||
None,
|
||||
Char,
|
||||
SByte,
|
||||
Byte,
|
||||
Int16,
|
||||
UInt16,
|
||||
Int32,
|
||||
UInt32,
|
||||
Int64,
|
||||
UInt64,
|
||||
IntPtr,
|
||||
UIntPtr,
|
||||
Single,
|
||||
Double,
|
||||
Decimal
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Nested type: NumericTypes
|
||||
|
||||
[Flags]
|
||||
private enum NumericTypes
|
||||
{
|
||||
// ReSharper disable UnusedMember.Local
|
||||
|
||||
None = 0,
|
||||
Char = 1 << NumericType.Char,
|
||||
SByte = 1 << NumericType.SByte,
|
||||
Byte = 1 << NumericType.Byte,
|
||||
Int16 = 1 << NumericType.Int16,
|
||||
UInt16 = 1 << NumericType.UInt16,
|
||||
Int32 = 1 << NumericType.Int32,
|
||||
UInt32 = 1 << NumericType.UInt32,
|
||||
Int64 = 1 << NumericType.Int64,
|
||||
UInt64 = 1 << NumericType.UInt64,
|
||||
IntPtr = 1 << NumericType.IntPtr,
|
||||
UIntPtr = 1 << NumericType.UIntPtr,
|
||||
Single = 1 << NumericType.Single,
|
||||
Double = 1 << NumericType.Double,
|
||||
Decimal = 1 << NumericType.Decimal
|
||||
|
||||
// ReSharper restore UnusedMember.Local
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Nested type: TypeNode
|
||||
|
||||
private sealed class TypeNode
|
||||
{
|
||||
private static readonly ConcurrentDictionary<Type, TypeNode> typeNodeMap = new ConcurrentDictionary<Type, TypeNode>();
|
||||
|
||||
private readonly Type type;
|
||||
|
||||
private readonly TypeNode baseNode;
|
||||
|
||||
private readonly IReadOnlyCollection<TypeNode> interfaceNodes;
|
||||
|
||||
public static bool TryGetUpcastCount(Type sourceType, Type targetType, out uint count)
|
||||
{
|
||||
count = uint.MaxValue;
|
||||
|
||||
if (targetType != typeof(object))
|
||||
{
|
||||
GetOrCreate(sourceType).GetUpcastCountInternal(targetType, 0U, ref count);
|
||||
return count < uint.MaxValue;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private TypeNode(Type type, TypeNode baseNode, IReadOnlyCollection<TypeNode> interfaceNodes)
|
||||
{
|
||||
this.type = type;
|
||||
this.baseNode = baseNode;
|
||||
this.interfaceNodes = interfaceNodes;
|
||||
}
|
||||
|
||||
private static TypeNode GetOrCreate(Type type) => typeNodeMap.GetOrAdd(type, Create);
|
||||
|
||||
private static TypeNode Create(Type type)
|
||||
{
|
||||
TypeNode baseNode = null;
|
||||
var redundantInterfaces = new List<Type>();
|
||||
|
||||
var baseType = type.BaseType;
|
||||
if (baseType != null)
|
||||
{
|
||||
redundantInterfaces.AddRange(baseType.GetInterfaces());
|
||||
baseNode = GetOrCreate(baseType);
|
||||
}
|
||||
|
||||
var allInterfaces = type.GetInterfaces();
|
||||
foreach (var interfaceType in allInterfaces)
|
||||
{
|
||||
redundantInterfaces.AddRange(interfaceType.GetInterfaces());
|
||||
}
|
||||
|
||||
var interfaces = allInterfaces.Except(redundantInterfaces.Distinct());
|
||||
return new TypeNode(type, baseNode, interfaces.Select(GetOrCreate).ToArray());
|
||||
}
|
||||
|
||||
private void GetUpcastCountInternal(Type targetType, uint count, ref uint lowestCount)
|
||||
{
|
||||
if (type == targetType)
|
||||
{
|
||||
if (count < lowestCount)
|
||||
{
|
||||
lowestCount = count;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
baseNode?.GetUpcastCountInternal(targetType, count + 1, ref lowestCount);
|
||||
if (targetType.IsInterface)
|
||||
{
|
||||
foreach (var interfaceNode in interfaceNodes)
|
||||
{
|
||||
interfaceNode.GetUpcastCountInternal(targetType, count + 1, ref lowestCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Nested type: PropertySignatureComparer
|
||||
|
||||
private sealed class PropertySignatureComparer : IEqualityComparer<PropertyInfo>
|
||||
|
@ -870,5 +1210,183 @@ namespace Microsoft.ClearScript.Util
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Nested Type: BindArgFlag
|
||||
|
||||
private enum BindArgFlag
|
||||
{
|
||||
// IMPORTANT: ascending cost order
|
||||
|
||||
IsParamArrayArg,
|
||||
NullableTransition,
|
||||
NumericConversion,
|
||||
ImplicitConversion,
|
||||
ByRefMismatch
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Nested type: BindArgFlags
|
||||
|
||||
[Flags]
|
||||
private enum BindArgFlags : uint
|
||||
{
|
||||
IsParamArrayArg = 1 << BindArgFlag.IsParamArrayArg,
|
||||
NullableTransition = 1 << BindArgFlag.NullableTransition,
|
||||
NumericConversion = 1 << BindArgFlag.NumericConversion,
|
||||
ImplicitConversion = 1 << BindArgFlag.ImplicitConversion,
|
||||
ByRefMismatch = 1 << BindArgFlag.ByRefMismatch
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Nested type: BindArgCost
|
||||
|
||||
private sealed class BindArgCost : IComparable<BindArgCost>
|
||||
{
|
||||
public BindArgFlags Flags;
|
||||
public NumericType NumericType;
|
||||
public uint UpcastCount;
|
||||
|
||||
public int CompareTo(BindArgCost other)
|
||||
{
|
||||
var result = Flags.CompareTo(other.Flags);
|
||||
if (result != 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
if ((NumericType != NumericType.None) && (other.NumericType != NumericType.None))
|
||||
{
|
||||
result = NumericType.CompareTo(other.NumericType);
|
||||
if (result != 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return UpcastCount.CompareTo(other.UpcastCount);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Nested type: BindCandidate
|
||||
|
||||
private sealed class BindCandidate<T> : IComparable<BindCandidate<T>> where T : MemberInfo
|
||||
{
|
||||
private bool paramArray;
|
||||
private readonly List<BindArgCost> argCosts = new List<BindArgCost>();
|
||||
|
||||
public T Candidate { get; }
|
||||
|
||||
public BindCandidate(T candidate, ParameterInfo[] parameters, object[] args, Type[] argTypes)
|
||||
{
|
||||
Candidate = candidate;
|
||||
Initialize(parameters, args, argTypes);
|
||||
}
|
||||
|
||||
public int CompareTo(BindCandidate<T> other)
|
||||
{
|
||||
Debug.Assert(argCosts.Count == other.argCosts.Count);
|
||||
int result;
|
||||
|
||||
for (var index = 0; index < argCosts.Count; index++)
|
||||
{
|
||||
result = argCosts[index].CompareTo(other.argCosts[index]);
|
||||
if (result != 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
result = paramArray.CompareTo(other.paramArray);
|
||||
if (result != 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
var declType = Candidate.DeclaringType;
|
||||
var otherDeclType = other.Candidate.DeclaringType;
|
||||
|
||||
if (otherDeclType == declType)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return TypeNode.TryGetUpcastCount(Candidate.DeclaringType, other.Candidate.DeclaringType, out _) ? -1 : 1;
|
||||
}
|
||||
|
||||
private void Initialize(ParameterInfo[] parameters, object[] args, Type[] argTypes)
|
||||
{
|
||||
var paramIndex = 0;
|
||||
var argIndex = 0;
|
||||
|
||||
Type paramType = null;
|
||||
BindArgCost cost;
|
||||
|
||||
for (; paramIndex < parameters.Length; paramIndex++)
|
||||
{
|
||||
var param = parameters[paramIndex];
|
||||
paramType = param.ParameterType;
|
||||
|
||||
if ((paramIndex == (parameters.Length - 1)) && paramType.IsArray && CustomAttributes.Has<ParamArrayAttribute>(param, false))
|
||||
{
|
||||
paramArray = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (argIndex >= args.Length)
|
||||
{
|
||||
if (!param.IsOptional && !param.HasDefaultValue)
|
||||
{
|
||||
throw new OperationCanceledException();
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!paramType.IsBindableFromArg(args[argIndex], argTypes[argIndex], out cost))
|
||||
{
|
||||
throw new OperationCanceledException();
|
||||
}
|
||||
|
||||
argCosts.Add(cost);
|
||||
++argIndex;
|
||||
}
|
||||
|
||||
if (paramArray)
|
||||
{
|
||||
if (argIndex >= args.Length)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((argIndex == (args.Length - 1)) && paramType.IsBindableFromArg(args[argIndex], argTypes[argIndex], out cost))
|
||||
{
|
||||
argCosts.Add(cost);
|
||||
return;
|
||||
}
|
||||
|
||||
paramType = paramType.GetElementType();
|
||||
for (; argIndex < args.Length; argIndex++)
|
||||
{
|
||||
if (!paramType.IsBindableFromArg(args[argIndex], argTypes[argIndex], out cost))
|
||||
{
|
||||
throw new OperationCanceledException();
|
||||
}
|
||||
|
||||
cost.Flags |= BindArgFlags.IsParamArrayArg;
|
||||
argCosts.Add(cost);
|
||||
}
|
||||
}
|
||||
else if (argIndex < args.Length)
|
||||
{
|
||||
throw new OperationCanceledException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ namespace Microsoft.ClearScript.Util.Web
|
|||
|
||||
return new WebContext(socket, uri, headers);
|
||||
}
|
||||
catch (Exception)
|
||||
catch
|
||||
{
|
||||
Abort(socket, 400);
|
||||
throw;
|
||||
|
|
|
@ -127,8 +127,8 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
|
||||
#region V8 isolate methods
|
||||
|
||||
V8Isolate.Handle V8Isolate_Create(string name, int maxNewSpaceSize, int maxOldSpaceSize, double heapExpansionMultiplier, ulong maxArrayBufferAllocation, bool enableDebugging, bool enableRemoteDebugging, bool enableDynamicModuleImports, int debugPort);
|
||||
V8Context.Handle V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, bool enableDebugging, bool enableRemoteDebugging, bool disableGlobalMembers, bool enableDateTimeConversion, bool enableDynamicModuleImports, bool hideHostExceptions, int debugPort);
|
||||
V8Isolate.Handle V8Isolate_Create(string name, int maxNewSpaceSize, int maxOldSpaceSize, double heapExpansionMultiplier, ulong maxArrayBufferAllocation, V8RuntimeFlags flags, int debugPort);
|
||||
V8Context.Handle V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort);
|
||||
UIntPtr V8Isolate_GetMaxHeapSize(V8Isolate.Handle hIsolate);
|
||||
void V8Isolate_SetMaxHeapSize(V8Isolate.Handle hIsolate, UIntPtr size);
|
||||
double V8Isolate_GetHeapSizeSampleInterval(V8Isolate.Handle hIsolate);
|
||||
|
|
|
@ -23,9 +23,7 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
constraints?.MaxOldSpaceSize ?? -1,
|
||||
constraints?.HeapExpansionMultiplier ?? 0,
|
||||
constraints?.MaxArrayBufferAllocation ?? ulong.MaxValue,
|
||||
flags.HasFlag(V8RuntimeFlags.EnableDebugging),
|
||||
flags.HasFlag(V8RuntimeFlags.EnableRemoteDebugging),
|
||||
flags.HasFlag(V8RuntimeFlags.EnableDynamicModuleImports),
|
||||
flags,
|
||||
debugPort
|
||||
)));
|
||||
}
|
||||
|
@ -35,12 +33,7 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
return V8SplitProxyNative.Invoke(instance => instance.V8Isolate_CreateContext(
|
||||
Handle,
|
||||
name,
|
||||
flags.HasFlag(V8ScriptEngineFlags.EnableDebugging),
|
||||
flags.HasFlag(V8ScriptEngineFlags.EnableRemoteDebugging),
|
||||
flags.HasFlag(V8ScriptEngineFlags.DisableGlobalMembers),
|
||||
flags.HasFlag(V8ScriptEngineFlags.EnableDateTimeConversion),
|
||||
flags.HasFlag(V8ScriptEngineFlags.EnableDynamicModuleImports),
|
||||
flags.HasFlag(V8ScriptEngineFlags.HideHostExceptions),
|
||||
flags,
|
||||
debugPort
|
||||
));
|
||||
}
|
||||
|
|
|
@ -422,8 +422,9 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
|
||||
for (var index = 0; index < methodCount; index++)
|
||||
{
|
||||
Marshal.WriteIntPtr(pDelegatePtrs, index * IntPtr.Size, methodPairs[index].Item1);
|
||||
Marshal.WriteIntPtr(pFunctionPtrs, index * IntPtr.Size, methodPairs[index].Item2);
|
||||
var (pDelegate, pFunction) = methodPairs[index];
|
||||
Marshal.WriteIntPtr(pDelegatePtrs, index * IntPtr.Size, pDelegate);
|
||||
Marshal.WriteIntPtr(pFunctionPtrs, index * IntPtr.Size, pFunction);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -442,19 +442,19 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
|
||||
#region V8 isolate methods
|
||||
|
||||
V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpaceSize, int maxOldSpaceSize, double heapExpansionMultiplier, ulong maxArrayBufferAllocation, bool enableDebugging, bool enableRemoteDebugging, bool enableDynamicModuleImports, int debugPort)
|
||||
V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpaceSize, int maxOldSpaceSize, double heapExpansionMultiplier, ulong maxArrayBufferAllocation, V8RuntimeFlags flags, int debugPort)
|
||||
{
|
||||
using (var nameScope = StdString.CreateScope(name))
|
||||
{
|
||||
return V8Isolate_Create(nameScope.Value, maxNewSpaceSize, maxOldSpaceSize, heapExpansionMultiplier, maxArrayBufferAllocation, enableDebugging, enableRemoteDebugging, enableDynamicModuleImports, debugPort);
|
||||
return V8Isolate_Create(nameScope.Value, maxNewSpaceSize, maxOldSpaceSize, heapExpansionMultiplier, maxArrayBufferAllocation, flags, debugPort);
|
||||
}
|
||||
}
|
||||
|
||||
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, bool enableDebugging, bool enableRemoteDebugging, bool disableGlobalMembers, bool enableDateTimeConversion, bool enableDynamicModuleImports, bool hideHostExceptions, int debugPort)
|
||||
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort)
|
||||
{
|
||||
using (var nameScope = StdString.CreateScope(name))
|
||||
{
|
||||
return V8Isolate_CreateContext(hIsolate, nameScope.Value, enableDebugging, enableRemoteDebugging, disableGlobalMembers, enableDateTimeConversion, enableDynamicModuleImports, hideHostExceptions, debugPort);
|
||||
return V8Isolate_CreateContext(hIsolate, nameScope.Value, flags, debugPort);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1492,9 +1492,7 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
[In] int maxOldSpaceSize,
|
||||
[In] double heapExpansionMultiplier,
|
||||
[In] ulong maxArrayBufferAllocation,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableRemoteDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDynamicModuleImports,
|
||||
[In] V8RuntimeFlags flags,
|
||||
[In] int debugPort
|
||||
);
|
||||
|
||||
|
@ -1502,12 +1500,7 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
private static extern V8Context.Handle V8Isolate_CreateContext(
|
||||
[In] V8Isolate.Handle hIsolate,
|
||||
[In] StdString.Ptr pName,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableRemoteDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool disableGlobalMembers,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDateTimeConversion,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDynamicModuleImports,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool hideHostExceptions,
|
||||
[In] V8ScriptEngineFlags flags,
|
||||
[In] int debugPort
|
||||
);
|
||||
|
||||
|
|
|
@ -484,19 +484,19 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
|
||||
#region V8 isolate methods
|
||||
|
||||
V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpaceSize, int maxOldSpaceSize, double heapExpansionMultiplier, ulong maxArrayBufferAllocation, bool enableDebugging, bool enableRemoteDebugging, bool enableDynamicModuleImports, int debugPort)
|
||||
V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpaceSize, int maxOldSpaceSize, double heapExpansionMultiplier, ulong maxArrayBufferAllocation, V8RuntimeFlags flags, int debugPort)
|
||||
{
|
||||
using (var nameScope = StdString.CreateScope(name))
|
||||
{
|
||||
return V8Isolate_Create(nameScope.Value, maxNewSpaceSize, maxOldSpaceSize, heapExpansionMultiplier, maxArrayBufferAllocation, enableDebugging, enableRemoteDebugging, enableDynamicModuleImports, debugPort);
|
||||
return V8Isolate_Create(nameScope.Value, maxNewSpaceSize, maxOldSpaceSize, heapExpansionMultiplier, maxArrayBufferAllocation, flags, debugPort);
|
||||
}
|
||||
}
|
||||
|
||||
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, bool enableDebugging, bool enableRemoteDebugging, bool disableGlobalMembers, bool enableDateTimeConversion, bool enableDynamicModuleImports, bool hideHostExceptions, int debugPort)
|
||||
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort)
|
||||
{
|
||||
using (var nameScope = StdString.CreateScope(name))
|
||||
{
|
||||
return V8Isolate_CreateContext(hIsolate, nameScope.Value, enableDebugging, enableRemoteDebugging, disableGlobalMembers, enableDateTimeConversion, enableDynamicModuleImports, hideHostExceptions, debugPort);
|
||||
return V8Isolate_CreateContext(hIsolate, nameScope.Value, flags, debugPort);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1534,9 +1534,7 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
[In] int maxOldSpaceSize,
|
||||
[In] double heapExpansionMultiplier,
|
||||
[In] ulong maxArrayBufferAllocation,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableRemoteDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDynamicModuleImports,
|
||||
[In] V8RuntimeFlags flags,
|
||||
[In] int debugPort
|
||||
);
|
||||
|
||||
|
@ -1544,12 +1542,7 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
private static extern V8Context.Handle V8Isolate_CreateContext(
|
||||
[In] V8Isolate.Handle hIsolate,
|
||||
[In] StdString.Ptr pName,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableRemoteDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool disableGlobalMembers,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDateTimeConversion,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDynamicModuleImports,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool hideHostExceptions,
|
||||
[In] V8ScriptEngineFlags flags,
|
||||
[In] int debugPort
|
||||
);
|
||||
|
||||
|
@ -2518,19 +2511,19 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
|
||||
#region V8 isolate methods
|
||||
|
||||
V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpaceSize, int maxOldSpaceSize, double heapExpansionMultiplier, ulong maxArrayBufferAllocation, bool enableDebugging, bool enableRemoteDebugging, bool enableDynamicModuleImports, int debugPort)
|
||||
V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpaceSize, int maxOldSpaceSize, double heapExpansionMultiplier, ulong maxArrayBufferAllocation, V8RuntimeFlags flags, int debugPort)
|
||||
{
|
||||
using (var nameScope = StdString.CreateScope(name))
|
||||
{
|
||||
return V8Isolate_Create(nameScope.Value, maxNewSpaceSize, maxOldSpaceSize, heapExpansionMultiplier, maxArrayBufferAllocation, enableDebugging, enableRemoteDebugging, enableDynamicModuleImports, debugPort);
|
||||
return V8Isolate_Create(nameScope.Value, maxNewSpaceSize, maxOldSpaceSize, heapExpansionMultiplier, maxArrayBufferAllocation, flags, debugPort);
|
||||
}
|
||||
}
|
||||
|
||||
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, bool enableDebugging, bool enableRemoteDebugging, bool disableGlobalMembers, bool enableDateTimeConversion, bool enableDynamicModuleImports, bool hideHostExceptions, int debugPort)
|
||||
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort)
|
||||
{
|
||||
using (var nameScope = StdString.CreateScope(name))
|
||||
{
|
||||
return V8Isolate_CreateContext(hIsolate, nameScope.Value, enableDebugging, enableRemoteDebugging, disableGlobalMembers, enableDateTimeConversion, enableDynamicModuleImports, hideHostExceptions, debugPort);
|
||||
return V8Isolate_CreateContext(hIsolate, nameScope.Value, flags, debugPort);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3568,9 +3561,7 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
[In] int maxOldSpaceSize,
|
||||
[In] double heapExpansionMultiplier,
|
||||
[In] ulong maxArrayBufferAllocation,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableRemoteDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDynamicModuleImports,
|
||||
[In] V8RuntimeFlags flags,
|
||||
[In] int debugPort
|
||||
);
|
||||
|
||||
|
@ -3578,12 +3569,7 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
private static extern V8Context.Handle V8Isolate_CreateContext(
|
||||
[In] V8Isolate.Handle hIsolate,
|
||||
[In] StdString.Ptr pName,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableRemoteDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool disableGlobalMembers,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDateTimeConversion,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDynamicModuleImports,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool hideHostExceptions,
|
||||
[In] V8ScriptEngineFlags flags,
|
||||
[In] int debugPort
|
||||
);
|
||||
|
||||
|
@ -4552,19 +4538,19 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
|
||||
#region V8 isolate methods
|
||||
|
||||
V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpaceSize, int maxOldSpaceSize, double heapExpansionMultiplier, ulong maxArrayBufferAllocation, bool enableDebugging, bool enableRemoteDebugging, bool enableDynamicModuleImports, int debugPort)
|
||||
V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpaceSize, int maxOldSpaceSize, double heapExpansionMultiplier, ulong maxArrayBufferAllocation, V8RuntimeFlags flags, int debugPort)
|
||||
{
|
||||
using (var nameScope = StdString.CreateScope(name))
|
||||
{
|
||||
return V8Isolate_Create(nameScope.Value, maxNewSpaceSize, maxOldSpaceSize, heapExpansionMultiplier, maxArrayBufferAllocation, enableDebugging, enableRemoteDebugging, enableDynamicModuleImports, debugPort);
|
||||
return V8Isolate_Create(nameScope.Value, maxNewSpaceSize, maxOldSpaceSize, heapExpansionMultiplier, maxArrayBufferAllocation, flags, debugPort);
|
||||
}
|
||||
}
|
||||
|
||||
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, bool enableDebugging, bool enableRemoteDebugging, bool disableGlobalMembers, bool enableDateTimeConversion, bool enableDynamicModuleImports, bool hideHostExceptions, int debugPort)
|
||||
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort)
|
||||
{
|
||||
using (var nameScope = StdString.CreateScope(name))
|
||||
{
|
||||
return V8Isolate_CreateContext(hIsolate, nameScope.Value, enableDebugging, enableRemoteDebugging, disableGlobalMembers, enableDateTimeConversion, enableDynamicModuleImports, hideHostExceptions, debugPort);
|
||||
return V8Isolate_CreateContext(hIsolate, nameScope.Value, flags, debugPort);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5602,9 +5588,7 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
[In] int maxOldSpaceSize,
|
||||
[In] double heapExpansionMultiplier,
|
||||
[In] ulong maxArrayBufferAllocation,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableRemoteDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDynamicModuleImports,
|
||||
[In] V8RuntimeFlags flags,
|
||||
[In] int debugPort
|
||||
);
|
||||
|
||||
|
@ -5612,12 +5596,7 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
private static extern V8Context.Handle V8Isolate_CreateContext(
|
||||
[In] V8Isolate.Handle hIsolate,
|
||||
[In] StdString.Ptr pName,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableRemoteDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool disableGlobalMembers,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDateTimeConversion,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDynamicModuleImports,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool hideHostExceptions,
|
||||
[In] V8ScriptEngineFlags flags,
|
||||
[In] int debugPort
|
||||
);
|
||||
|
||||
|
@ -6586,19 +6565,19 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
|
||||
#region V8 isolate methods
|
||||
|
||||
V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpaceSize, int maxOldSpaceSize, double heapExpansionMultiplier, ulong maxArrayBufferAllocation, bool enableDebugging, bool enableRemoteDebugging, bool enableDynamicModuleImports, int debugPort)
|
||||
V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpaceSize, int maxOldSpaceSize, double heapExpansionMultiplier, ulong maxArrayBufferAllocation, V8RuntimeFlags flags, int debugPort)
|
||||
{
|
||||
using (var nameScope = StdString.CreateScope(name))
|
||||
{
|
||||
return V8Isolate_Create(nameScope.Value, maxNewSpaceSize, maxOldSpaceSize, heapExpansionMultiplier, maxArrayBufferAllocation, enableDebugging, enableRemoteDebugging, enableDynamicModuleImports, debugPort);
|
||||
return V8Isolate_Create(nameScope.Value, maxNewSpaceSize, maxOldSpaceSize, heapExpansionMultiplier, maxArrayBufferAllocation, flags, debugPort);
|
||||
}
|
||||
}
|
||||
|
||||
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, bool enableDebugging, bool enableRemoteDebugging, bool disableGlobalMembers, bool enableDateTimeConversion, bool enableDynamicModuleImports, bool hideHostExceptions, int debugPort)
|
||||
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort)
|
||||
{
|
||||
using (var nameScope = StdString.CreateScope(name))
|
||||
{
|
||||
return V8Isolate_CreateContext(hIsolate, nameScope.Value, enableDebugging, enableRemoteDebugging, disableGlobalMembers, enableDateTimeConversion, enableDynamicModuleImports, hideHostExceptions, debugPort);
|
||||
return V8Isolate_CreateContext(hIsolate, nameScope.Value, flags, debugPort);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7636,9 +7615,7 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
[In] int maxOldSpaceSize,
|
||||
[In] double heapExpansionMultiplier,
|
||||
[In] ulong maxArrayBufferAllocation,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableRemoteDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDynamicModuleImports,
|
||||
[In] V8RuntimeFlags flags,
|
||||
[In] int debugPort
|
||||
);
|
||||
|
||||
|
@ -7646,12 +7623,7 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
private static extern V8Context.Handle V8Isolate_CreateContext(
|
||||
[In] V8Isolate.Handle hIsolate,
|
||||
[In] StdString.Ptr pName,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableRemoteDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool disableGlobalMembers,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDateTimeConversion,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDynamicModuleImports,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool hideHostExceptions,
|
||||
[In] V8ScriptEngineFlags flags,
|
||||
[In] int debugPort
|
||||
);
|
||||
|
||||
|
@ -8620,19 +8592,19 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
|
||||
#region V8 isolate methods
|
||||
|
||||
V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpaceSize, int maxOldSpaceSize, double heapExpansionMultiplier, ulong maxArrayBufferAllocation, bool enableDebugging, bool enableRemoteDebugging, bool enableDynamicModuleImports, int debugPort)
|
||||
V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpaceSize, int maxOldSpaceSize, double heapExpansionMultiplier, ulong maxArrayBufferAllocation, V8RuntimeFlags flags, int debugPort)
|
||||
{
|
||||
using (var nameScope = StdString.CreateScope(name))
|
||||
{
|
||||
return V8Isolate_Create(nameScope.Value, maxNewSpaceSize, maxOldSpaceSize, heapExpansionMultiplier, maxArrayBufferAllocation, enableDebugging, enableRemoteDebugging, enableDynamicModuleImports, debugPort);
|
||||
return V8Isolate_Create(nameScope.Value, maxNewSpaceSize, maxOldSpaceSize, heapExpansionMultiplier, maxArrayBufferAllocation, flags, debugPort);
|
||||
}
|
||||
}
|
||||
|
||||
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, bool enableDebugging, bool enableRemoteDebugging, bool disableGlobalMembers, bool enableDateTimeConversion, bool enableDynamicModuleImports, bool hideHostExceptions, int debugPort)
|
||||
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort)
|
||||
{
|
||||
using (var nameScope = StdString.CreateScope(name))
|
||||
{
|
||||
return V8Isolate_CreateContext(hIsolate, nameScope.Value, enableDebugging, enableRemoteDebugging, disableGlobalMembers, enableDateTimeConversion, enableDynamicModuleImports, hideHostExceptions, debugPort);
|
||||
return V8Isolate_CreateContext(hIsolate, nameScope.Value, flags, debugPort);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9670,9 +9642,7 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
[In] int maxOldSpaceSize,
|
||||
[In] double heapExpansionMultiplier,
|
||||
[In] ulong maxArrayBufferAllocation,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableRemoteDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDynamicModuleImports,
|
||||
[In] V8RuntimeFlags flags,
|
||||
[In] int debugPort
|
||||
);
|
||||
|
||||
|
@ -9680,12 +9650,7 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
private static extern V8Context.Handle V8Isolate_CreateContext(
|
||||
[In] V8Isolate.Handle hIsolate,
|
||||
[In] StdString.Ptr pName,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableRemoteDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool disableGlobalMembers,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDateTimeConversion,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDynamicModuleImports,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool hideHostExceptions,
|
||||
[In] V8ScriptEngineFlags flags,
|
||||
[In] int debugPort
|
||||
);
|
||||
|
||||
|
@ -10654,19 +10619,19 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
|
||||
#region V8 isolate methods
|
||||
|
||||
V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpaceSize, int maxOldSpaceSize, double heapExpansionMultiplier, ulong maxArrayBufferAllocation, bool enableDebugging, bool enableRemoteDebugging, bool enableDynamicModuleImports, int debugPort)
|
||||
V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpaceSize, int maxOldSpaceSize, double heapExpansionMultiplier, ulong maxArrayBufferAllocation, V8RuntimeFlags flags, int debugPort)
|
||||
{
|
||||
using (var nameScope = StdString.CreateScope(name))
|
||||
{
|
||||
return V8Isolate_Create(nameScope.Value, maxNewSpaceSize, maxOldSpaceSize, heapExpansionMultiplier, maxArrayBufferAllocation, enableDebugging, enableRemoteDebugging, enableDynamicModuleImports, debugPort);
|
||||
return V8Isolate_Create(nameScope.Value, maxNewSpaceSize, maxOldSpaceSize, heapExpansionMultiplier, maxArrayBufferAllocation, flags, debugPort);
|
||||
}
|
||||
}
|
||||
|
||||
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, bool enableDebugging, bool enableRemoteDebugging, bool disableGlobalMembers, bool enableDateTimeConversion, bool enableDynamicModuleImports, bool hideHostExceptions, int debugPort)
|
||||
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort)
|
||||
{
|
||||
using (var nameScope = StdString.CreateScope(name))
|
||||
{
|
||||
return V8Isolate_CreateContext(hIsolate, nameScope.Value, enableDebugging, enableRemoteDebugging, disableGlobalMembers, enableDateTimeConversion, enableDynamicModuleImports, hideHostExceptions, debugPort);
|
||||
return V8Isolate_CreateContext(hIsolate, nameScope.Value, flags, debugPort);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11704,9 +11669,7 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
[In] int maxOldSpaceSize,
|
||||
[In] double heapExpansionMultiplier,
|
||||
[In] ulong maxArrayBufferAllocation,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableRemoteDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDynamicModuleImports,
|
||||
[In] V8RuntimeFlags flags,
|
||||
[In] int debugPort
|
||||
);
|
||||
|
||||
|
@ -11714,12 +11677,7 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
private static extern V8Context.Handle V8Isolate_CreateContext(
|
||||
[In] V8Isolate.Handle hIsolate,
|
||||
[In] StdString.Ptr pName,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableRemoteDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool disableGlobalMembers,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDateTimeConversion,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDynamicModuleImports,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool hideHostExceptions,
|
||||
[In] V8ScriptEngineFlags flags,
|
||||
[In] int debugPort
|
||||
);
|
||||
|
||||
|
@ -12688,19 +12646,19 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
|
||||
#region V8 isolate methods
|
||||
|
||||
V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpaceSize, int maxOldSpaceSize, double heapExpansionMultiplier, ulong maxArrayBufferAllocation, bool enableDebugging, bool enableRemoteDebugging, bool enableDynamicModuleImports, int debugPort)
|
||||
V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpaceSize, int maxOldSpaceSize, double heapExpansionMultiplier, ulong maxArrayBufferAllocation, V8RuntimeFlags flags, int debugPort)
|
||||
{
|
||||
using (var nameScope = StdString.CreateScope(name))
|
||||
{
|
||||
return V8Isolate_Create(nameScope.Value, maxNewSpaceSize, maxOldSpaceSize, heapExpansionMultiplier, maxArrayBufferAllocation, enableDebugging, enableRemoteDebugging, enableDynamicModuleImports, debugPort);
|
||||
return V8Isolate_Create(nameScope.Value, maxNewSpaceSize, maxOldSpaceSize, heapExpansionMultiplier, maxArrayBufferAllocation, flags, debugPort);
|
||||
}
|
||||
}
|
||||
|
||||
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, bool enableDebugging, bool enableRemoteDebugging, bool disableGlobalMembers, bool enableDateTimeConversion, bool enableDynamicModuleImports, bool hideHostExceptions, int debugPort)
|
||||
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort)
|
||||
{
|
||||
using (var nameScope = StdString.CreateScope(name))
|
||||
{
|
||||
return V8Isolate_CreateContext(hIsolate, nameScope.Value, enableDebugging, enableRemoteDebugging, disableGlobalMembers, enableDateTimeConversion, enableDynamicModuleImports, hideHostExceptions, debugPort);
|
||||
return V8Isolate_CreateContext(hIsolate, nameScope.Value, flags, debugPort);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13738,9 +13696,7 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
[In] int maxOldSpaceSize,
|
||||
[In] double heapExpansionMultiplier,
|
||||
[In] ulong maxArrayBufferAllocation,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableRemoteDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDynamicModuleImports,
|
||||
[In] V8RuntimeFlags flags,
|
||||
[In] int debugPort
|
||||
);
|
||||
|
||||
|
@ -13748,12 +13704,7 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
private static extern V8Context.Handle V8Isolate_CreateContext(
|
||||
[In] V8Isolate.Handle hIsolate,
|
||||
[In] StdString.Ptr pName,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableRemoteDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool disableGlobalMembers,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDateTimeConversion,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDynamicModuleImports,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool hideHostExceptions,
|
||||
[In] V8ScriptEngineFlags flags,
|
||||
[In] int debugPort
|
||||
);
|
||||
|
||||
|
@ -14722,19 +14673,19 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
|
||||
#region V8 isolate methods
|
||||
|
||||
V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpaceSize, int maxOldSpaceSize, double heapExpansionMultiplier, ulong maxArrayBufferAllocation, bool enableDebugging, bool enableRemoteDebugging, bool enableDynamicModuleImports, int debugPort)
|
||||
V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpaceSize, int maxOldSpaceSize, double heapExpansionMultiplier, ulong maxArrayBufferAllocation, V8RuntimeFlags flags, int debugPort)
|
||||
{
|
||||
using (var nameScope = StdString.CreateScope(name))
|
||||
{
|
||||
return V8Isolate_Create(nameScope.Value, maxNewSpaceSize, maxOldSpaceSize, heapExpansionMultiplier, maxArrayBufferAllocation, enableDebugging, enableRemoteDebugging, enableDynamicModuleImports, debugPort);
|
||||
return V8Isolate_Create(nameScope.Value, maxNewSpaceSize, maxOldSpaceSize, heapExpansionMultiplier, maxArrayBufferAllocation, flags, debugPort);
|
||||
}
|
||||
}
|
||||
|
||||
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, bool enableDebugging, bool enableRemoteDebugging, bool disableGlobalMembers, bool enableDateTimeConversion, bool enableDynamicModuleImports, bool hideHostExceptions, int debugPort)
|
||||
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort)
|
||||
{
|
||||
using (var nameScope = StdString.CreateScope(name))
|
||||
{
|
||||
return V8Isolate_CreateContext(hIsolate, nameScope.Value, enableDebugging, enableRemoteDebugging, disableGlobalMembers, enableDateTimeConversion, enableDynamicModuleImports, hideHostExceptions, debugPort);
|
||||
return V8Isolate_CreateContext(hIsolate, nameScope.Value, flags, debugPort);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15772,9 +15723,7 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
[In] int maxOldSpaceSize,
|
||||
[In] double heapExpansionMultiplier,
|
||||
[In] ulong maxArrayBufferAllocation,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableRemoteDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDynamicModuleImports,
|
||||
[In] V8RuntimeFlags flags,
|
||||
[In] int debugPort
|
||||
);
|
||||
|
||||
|
@ -15782,12 +15731,7 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
private static extern V8Context.Handle V8Isolate_CreateContext(
|
||||
[In] V8Isolate.Handle hIsolate,
|
||||
[In] StdString.Ptr pName,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableRemoteDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool disableGlobalMembers,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDateTimeConversion,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDynamicModuleImports,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool hideHostExceptions,
|
||||
[In] V8ScriptEngineFlags flags,
|
||||
[In] int debugPort
|
||||
);
|
||||
|
||||
|
|
|
@ -440,19 +440,19 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
|
||||
#region V8 isolate methods
|
||||
|
||||
V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpaceSize, int maxOldSpaceSize, double heapExpansionMultiplier, ulong maxArrayBufferAllocation, bool enableDebugging, bool enableRemoteDebugging, bool enableDynamicModuleImports, int debugPort)
|
||||
V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpaceSize, int maxOldSpaceSize, double heapExpansionMultiplier, ulong maxArrayBufferAllocation, V8RuntimeFlags flags, int debugPort)
|
||||
{
|
||||
using (var nameScope = StdString.CreateScope(name))
|
||||
{
|
||||
return V8Isolate_Create(nameScope.Value, maxNewSpaceSize, maxOldSpaceSize, heapExpansionMultiplier, maxArrayBufferAllocation, enableDebugging, enableRemoteDebugging, enableDynamicModuleImports, debugPort);
|
||||
return V8Isolate_Create(nameScope.Value, maxNewSpaceSize, maxOldSpaceSize, heapExpansionMultiplier, maxArrayBufferAllocation, flags, debugPort);
|
||||
}
|
||||
}
|
||||
|
||||
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, bool enableDebugging, bool enableRemoteDebugging, bool disableGlobalMembers, bool enableDateTimeConversion, bool enableDynamicModuleImports, bool hideHostExceptions, int debugPort)
|
||||
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort)
|
||||
{
|
||||
using (var nameScope = StdString.CreateScope(name))
|
||||
{
|
||||
return V8Isolate_CreateContext(hIsolate, nameScope.Value, enableDebugging, enableRemoteDebugging, disableGlobalMembers, enableDateTimeConversion, enableDynamicModuleImports, hideHostExceptions, debugPort);
|
||||
return V8Isolate_CreateContext(hIsolate, nameScope.Value, flags, debugPort);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1490,9 +1490,7 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
[In] int maxOldSpaceSize,
|
||||
[In] double heapExpansionMultiplier,
|
||||
[In] ulong maxArrayBufferAllocation,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableRemoteDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDynamicModuleImports,
|
||||
[In] V8RuntimeFlags flags,
|
||||
[In] int debugPort
|
||||
);
|
||||
|
||||
|
@ -1500,12 +1498,7 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
private static extern V8Context.Handle V8Isolate_CreateContext(
|
||||
[In] V8Isolate.Handle hIsolate,
|
||||
[In] StdString.Ptr pName,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableRemoteDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool disableGlobalMembers,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDateTimeConversion,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDynamicModuleImports,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool hideHostExceptions,
|
||||
[In] V8ScriptEngineFlags flags,
|
||||
[In] int debugPort
|
||||
);
|
||||
|
||||
|
@ -2474,19 +2467,19 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
|
||||
#region V8 isolate methods
|
||||
|
||||
V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpaceSize, int maxOldSpaceSize, double heapExpansionMultiplier, ulong maxArrayBufferAllocation, bool enableDebugging, bool enableRemoteDebugging, bool enableDynamicModuleImports, int debugPort)
|
||||
V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpaceSize, int maxOldSpaceSize, double heapExpansionMultiplier, ulong maxArrayBufferAllocation, V8RuntimeFlags flags, int debugPort)
|
||||
{
|
||||
using (var nameScope = StdString.CreateScope(name))
|
||||
{
|
||||
return V8Isolate_Create(nameScope.Value, maxNewSpaceSize, maxOldSpaceSize, heapExpansionMultiplier, maxArrayBufferAllocation, enableDebugging, enableRemoteDebugging, enableDynamicModuleImports, debugPort);
|
||||
return V8Isolate_Create(nameScope.Value, maxNewSpaceSize, maxOldSpaceSize, heapExpansionMultiplier, maxArrayBufferAllocation, flags, debugPort);
|
||||
}
|
||||
}
|
||||
|
||||
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, bool enableDebugging, bool enableRemoteDebugging, bool disableGlobalMembers, bool enableDateTimeConversion, bool enableDynamicModuleImports, bool hideHostExceptions, int debugPort)
|
||||
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort)
|
||||
{
|
||||
using (var nameScope = StdString.CreateScope(name))
|
||||
{
|
||||
return V8Isolate_CreateContext(hIsolate, nameScope.Value, enableDebugging, enableRemoteDebugging, disableGlobalMembers, enableDateTimeConversion, enableDynamicModuleImports, hideHostExceptions, debugPort);
|
||||
return V8Isolate_CreateContext(hIsolate, nameScope.Value, flags, debugPort);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3524,9 +3517,7 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
[In] int maxOldSpaceSize,
|
||||
[In] double heapExpansionMultiplier,
|
||||
[In] ulong maxArrayBufferAllocation,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableRemoteDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDynamicModuleImports,
|
||||
[In] V8RuntimeFlags flags,
|
||||
[In] int debugPort
|
||||
);
|
||||
|
||||
|
@ -3534,12 +3525,7 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
private static extern V8Context.Handle V8Isolate_CreateContext(
|
||||
[In] V8Isolate.Handle hIsolate,
|
||||
[In] StdString.Ptr pName,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableRemoteDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool disableGlobalMembers,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDateTimeConversion,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDynamicModuleImports,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool hideHostExceptions,
|
||||
[In] V8ScriptEngineFlags flags,
|
||||
[In] int debugPort
|
||||
);
|
||||
|
||||
|
@ -4508,19 +4494,19 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
|
||||
#region V8 isolate methods
|
||||
|
||||
V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpaceSize, int maxOldSpaceSize, double heapExpansionMultiplier, ulong maxArrayBufferAllocation, bool enableDebugging, bool enableRemoteDebugging, bool enableDynamicModuleImports, int debugPort)
|
||||
V8Isolate.Handle IV8SplitProxyNative.V8Isolate_Create(string name, int maxNewSpaceSize, int maxOldSpaceSize, double heapExpansionMultiplier, ulong maxArrayBufferAllocation, V8RuntimeFlags flags, int debugPort)
|
||||
{
|
||||
using (var nameScope = StdString.CreateScope(name))
|
||||
{
|
||||
return V8Isolate_Create(nameScope.Value, maxNewSpaceSize, maxOldSpaceSize, heapExpansionMultiplier, maxArrayBufferAllocation, enableDebugging, enableRemoteDebugging, enableDynamicModuleImports, debugPort);
|
||||
return V8Isolate_Create(nameScope.Value, maxNewSpaceSize, maxOldSpaceSize, heapExpansionMultiplier, maxArrayBufferAllocation, flags, debugPort);
|
||||
}
|
||||
}
|
||||
|
||||
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, bool enableDebugging, bool enableRemoteDebugging, bool disableGlobalMembers, bool enableDateTimeConversion, bool enableDynamicModuleImports, bool hideHostExceptions, int debugPort)
|
||||
V8Context.Handle IV8SplitProxyNative.V8Isolate_CreateContext(V8Isolate.Handle hIsolate, string name, V8ScriptEngineFlags flags, int debugPort)
|
||||
{
|
||||
using (var nameScope = StdString.CreateScope(name))
|
||||
{
|
||||
return V8Isolate_CreateContext(hIsolate, nameScope.Value, enableDebugging, enableRemoteDebugging, disableGlobalMembers, enableDateTimeConversion, enableDynamicModuleImports, hideHostExceptions, debugPort);
|
||||
return V8Isolate_CreateContext(hIsolate, nameScope.Value, flags, debugPort);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5558,9 +5544,7 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
[In] int maxOldSpaceSize,
|
||||
[In] double heapExpansionMultiplier,
|
||||
[In] ulong maxArrayBufferAllocation,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableRemoteDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDynamicModuleImports,
|
||||
[In] V8RuntimeFlags flags,
|
||||
[In] int debugPort
|
||||
);
|
||||
|
||||
|
@ -5568,12 +5552,7 @@ namespace Microsoft.ClearScript.V8.SplitProxy
|
|||
private static extern V8Context.Handle V8Isolate_CreateContext(
|
||||
[In] V8Isolate.Handle hIsolate,
|
||||
[In] StdString.Ptr pName,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableRemoteDebugging,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool disableGlobalMembers,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDateTimeConversion,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool enableDynamicModuleImports,
|
||||
[In] [MarshalAs(UnmanagedType.I1)] bool hideHostExceptions,
|
||||
[In] V8ScriptEngineFlags flags,
|
||||
[In] int debugPort
|
||||
);
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace Microsoft.ClearScript.V8
|
|||
hNativeAssembly = LoadNativeAssembly();
|
||||
loadedNativeAssembly = true;
|
||||
}
|
||||
catch (Exception)
|
||||
catch
|
||||
{
|
||||
initializedICU = MiscHelpers.Try(InitializeICU);
|
||||
if (!initializedICU)
|
||||
|
|
|
@ -11,6 +11,8 @@ namespace Microsoft.ClearScript.V8
|
|||
[Flags]
|
||||
public enum V8RuntimeFlags
|
||||
{
|
||||
// IMPORTANT: maintain bitwise equivalence with unmanaged enum V8Isolate::Flags
|
||||
|
||||
/// <summary>
|
||||
/// Specifies that no options are selected.
|
||||
/// </summary>
|
||||
|
|
|
@ -9,6 +9,6 @@ namespace Microsoft.ClearScript.V8
|
|||
{
|
||||
public sealed partial class V8ScriptEngine
|
||||
{
|
||||
private const string initScript = "Object.defineProperty(this,'EngineInternal',{value:(b=>{let a=a=>a.bind();function d(){return new this(...arguments)}let e=b.isHostObjectKey;delete b.isHostObjectKey;let c=a=>!!a&& !0===a[e],f=Promise,g=Symbol(),h=b.toJson;return delete b.toJson,Object.freeze({commandHolder:{},getCommandResult:a(a=>null==a?a:'function'!=typeof a.hasOwnProperty?'Module'===a[Symbol.toStringTag]?'[module]':'[external]':!0===a[e]?a:'function'!=typeof a.toString?'['+typeof a+']':a.toString()),invokeConstructor:a((a,b)=>{if('function'!=typeof a)throw new Error('Function expected');return d.apply(a,Array.from(b))}),invokeMethod:a((b,a,c)=>{if('function'!=typeof a)throw new Error('Function expected');return a.apply(b,Array.from(c))}),createPromise:a(function(){return new f(...arguments)}),isPromise:a(a=>a instanceof f),isHostObject:a(c),completePromiseWithResult:a((a,b,c)=>{try{b(a())}catch(d){c(d)}}),completePromise:a((a,b,c)=>{try{a(),b()}catch(d){c(d)}}),throwValue:a(a=>{throw a}),getStackTrace:a(()=>{try{throw new Error('[stack trace]')}catch(a){return a.stack}}),toIterator:a(function*(a){try{for(;a.MoveNext();)yield a.Current}finally{a.Dispose()}}),toAsyncIterator:a(async function*(a){try{for(;await a.MoveNextPromise();)yield a.Current}finally{await a.DisposePromise()}}),checkpoint:a(()=>{let a=b[g];if(a)throw a}),toJson:a((b,a)=>h?JSON.parse(h(b,a)):a)})})(this)})";
|
||||
private const string initScript = "Object.defineProperty(this,'EngineInternal',{value:(t=>{let e=t=>t.bind();function o(){return new this(...arguments)}let r=t.isHostObjectKey;delete t.isHostObjectKey;let n=t=>!!t&&!0===t[r],i=Promise,c=Symbol(),s=t.toJson;return delete t.toJson,Object.freeze({commandHolder:{},getCommandResult:e(t=>null==t?t:'function'!=typeof t.hasOwnProperty?'Module'===t[Symbol.toStringTag]?'[module]':'[external]':!0===t[r]?t:'function'!=typeof t.toString?'['+typeof t+']':t.toString()),invokeConstructor:e((t,e)=>{if('function'!=typeof t)throw Error('Function expected');return o.apply(t,Array.from(e))}),invokeMethod:e((t,e,o)=>{if('function'!=typeof e)throw Error('Function expected');return e.apply(t,Array.from(o))}),createPromise:e(function(){return new i(...arguments)}),isPromise:e(t=>t instanceof i),isHostObject:e(n),completePromiseWithResult:e((t,e,o)=>{try{e(t())}catch(r){o(r)}}),completePromise:e((t,e,o)=>{try{t(),e()}catch(r){o(r)}}),throwValue:e(t=>{throw t}),getStackTrace:e(()=>{try{throw Error('[stack trace]')}catch(t){return t.stack}}),toIterator:e(function*(t){try{for(;t.MoveNext();)yield t.Current}finally{t.Dispose()}}),toAsyncIterator:e(async function*(t){try{for(;await t.MoveNextPromise();)yield t.Current}finally{await t.DisposePromise()}}),checkpoint:e(()=>{let e=t[c];if(e)throw e}),toJson:e((t,e)=>s?JSON.parse(s(t,e)):e)})})(this)});";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,13 +16,15 @@ namespace Microsoft.ClearScript.V8
|
|||
private void CompletePromise<T>(ValueTask<T> valueTask, object resolve, object reject)
|
||||
{
|
||||
Func<T> getResult = () => valueTask.Result;
|
||||
Script.EngineInternal.completePromiseWithResult(getResult, resolve, reject);
|
||||
var engineInternal = (ScriptObject)script.GetProperty("EngineInternal");
|
||||
engineInternal.InvokeMethod("completePromiseWithResult", getResult, resolve, reject);
|
||||
}
|
||||
|
||||
private void CompletePromise(ValueTask valueTask, object resolve, object reject)
|
||||
{
|
||||
Action wait = () => WaitForValueTask(valueTask);
|
||||
Script.EngineInternal.completePromise(wait, resolve, reject);
|
||||
var engineInternal = (ScriptObject)script.GetProperty("EngineInternal");
|
||||
engineInternal.InvokeMethod("completePromise", wait, resolve, reject);
|
||||
}
|
||||
|
||||
private static void WaitForValueTask(ValueTask valueTask)
|
||||
|
|
|
@ -1126,13 +1126,15 @@ namespace Microsoft.ClearScript.V8
|
|||
private void CompletePromise<T>(Task<T> task, object resolve, object reject)
|
||||
{
|
||||
Func<T> getResult = () => task.Result;
|
||||
Script.EngineInternal.completePromiseWithResult(getResult, resolve, reject);
|
||||
var engineInternal = (ScriptObject)script.GetProperty("EngineInternal");
|
||||
engineInternal.InvokeMethod("completePromiseWithResult", getResult, resolve, reject);
|
||||
}
|
||||
|
||||
private void CompletePromise(Task task, object resolve, object reject)
|
||||
{
|
||||
Action wait = task.Wait;
|
||||
Script.EngineInternal.completePromise(wait, resolve, reject);
|
||||
var engineInternal = (ScriptObject)script.GetProperty("EngineInternal");
|
||||
engineInternal.InvokeMethod("completePromise", wait, resolve, reject);
|
||||
}
|
||||
|
||||
partial void TryConvertValueTaskToPromise(object obj, Action<object> setResult);
|
||||
|
@ -1206,7 +1208,9 @@ namespace Microsoft.ClearScript.V8
|
|||
{
|
||||
return ScriptInvoke(() =>
|
||||
{
|
||||
Script.EngineInternal.commandHolder.command = command;
|
||||
var engineInternal = (ScriptObject)script.GetProperty("EngineInternal");
|
||||
var commandHolder = (ScriptObject)engineInternal.GetProperty("commandHolder");
|
||||
commandHolder.SetProperty("command", command);
|
||||
return base.ExecuteCommand("EngineInternal.getCommandResult(eval(EngineInternal.commandHolder.command))");
|
||||
});
|
||||
}
|
||||
|
@ -1221,7 +1225,8 @@ namespace Microsoft.ClearScript.V8
|
|||
/// </remarks>
|
||||
public override string GetStackTrace()
|
||||
{
|
||||
string stackTrace = Script.EngineInternal.getStackTrace();
|
||||
var engineInternal = (ScriptObject)script.GetProperty("EngineInternal");
|
||||
var stackTrace = (string)engineInternal.InvokeMethod("getStackTrace");
|
||||
var lines = stackTrace.Split('\n');
|
||||
return string.Join("\n", lines.Skip(2));
|
||||
}
|
||||
|
@ -1616,7 +1621,8 @@ namespace Microsoft.ClearScript.V8
|
|||
{
|
||||
try
|
||||
{
|
||||
Script.EngineInternal.throwValue(error);
|
||||
var engineInternal = (ScriptObject)script.GetProperty("EngineInternal");
|
||||
engineInternal.InvokeMethod("throwValue", error);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
@ -1682,9 +1688,10 @@ namespace Microsoft.ClearScript.V8
|
|||
private readonly HashSet<object> cycleDetectionSet = new HashSet<object>();
|
||||
|
||||
/// <exclude/>
|
||||
public JsonHelper(ScriptEngine engine)
|
||||
public JsonHelper(V8ScriptEngine engine)
|
||||
{
|
||||
stringify = engine.Script.JSON.stringify;
|
||||
var json = (ScriptObject)engine.script.GetProperty("JSON");
|
||||
stringify = (ScriptObject)json.GetProperty("stringify");
|
||||
}
|
||||
|
||||
/// <exclude/>
|
||||
|
|
|
@ -12,6 +12,8 @@ namespace Microsoft.ClearScript.V8
|
|||
[Flags]
|
||||
public enum V8ScriptEngineFlags
|
||||
{
|
||||
// IMPORTANT: maintain bitwise equivalence with unmanaged enum V8Context::Flags
|
||||
|
||||
/// <summary>
|
||||
/// Specifies that no options are selected.
|
||||
/// </summary>
|
||||
|
|
|
@ -271,7 +271,8 @@ namespace Microsoft.ClearScript.V8
|
|||
return engine.MarshalToHost(engine.ScriptInvoke(() => target.Invoke(asConstructor, engine.MarshalToScript(args))), false);
|
||||
}
|
||||
|
||||
return engine.Script.EngineInternal.invokeMethod(holder, this, args);
|
||||
var engineInternal = (ScriptObject)engine.Global.GetProperty("EngineInternal");
|
||||
return engineInternal.InvokeMethod("invokeMethod", holder, this, args);
|
||||
}
|
||||
|
||||
public override object InvokeMethod(string name, params object[] args)
|
||||
|
|
|
@ -9,6 +9,6 @@ namespace Microsoft.ClearScript.Windows.Core
|
|||
{
|
||||
public partial class JScriptEngine
|
||||
{
|
||||
internal const string InitScript = "EngineInternal=function(){var a=this;function b(b){var c=[];if(b.GetValue)for(var d=b.Length,a=0;a<d;a++)c.push(b[a]);else for(var d=(b=new VBArray(b)).ubound(1)+1,a=0;a<d;a++)c.push(b.getItem(a));return c}function c(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p){return new this(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p)}return{getCommandResult:function(a){return null!==a&&('object'==typeof a||'function'==typeof a)&&'function'==typeof a.toString?a.toString():a},invokeConstructor:function(a,d){if('function'!=typeof a)throw new Error('Function expected');return c.apply(a,b(d))},invokeMethod:function(c,a,d){if('function'!=typeof a)throw new Error('Function expected');return a.apply(c,b(d))},isPromise:function(a){return!1},isHostObject:function(b){return!!b&&'function'!=typeof b.constructor&&b!==a},throwValue:function(a){throw a}}}()";
|
||||
internal const string InitScript = "EngineInternal=function(){var t=this;function n(t){var n=[];if(t.GetValue)for(var o=t.Length,e=0;e<o;e++)n.push(t[e]);else for(var o=(t=new VBArray(t)).ubound(1)+1,e=0;e<o;e++)n.push(t.getItem(e));return n}function o(t,n,o,e,u,r,i,f,c,p,s,h,a,l,y,v){return new this(t,n,o,e,u,r,i,f,c,p,s,h,a,l,y,v)}return{getCommandResult:function(t){return null!==t&&('object'==typeof t||'function'==typeof t)&&'function'==typeof t.toString?t.toString():t},invokeConstructor:function(t,e){if('function'!=typeof t)throw Error('Function expected');return o.apply(t,n(e))},invokeMethod:function(t,o,e){if('function'!=typeof o)throw Error('Function expected');return o.apply(t,n(e))},isPromise:function(t){return!1},isHostObject:function(n){return!!n&&'function'!=typeof n.constructor&&n!==t},throwValue:function(t){throw t}}}();";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -202,7 +202,8 @@ namespace Microsoft.ClearScript.Windows.Core
|
|||
/// </remarks>
|
||||
public override string ExecuteCommand(string command)
|
||||
{
|
||||
Script.EngineInternal.command = command;
|
||||
var engineInternal = (ScriptObject)Global.GetProperty("EngineInternal");
|
||||
engineInternal.SetProperty("command", command);
|
||||
return base.ExecuteCommand("EngineInternal.getCommandResult(eval(EngineInternal.command))");
|
||||
}
|
||||
|
||||
|
|
|
@ -364,7 +364,7 @@ namespace Microsoft.ClearScript.Windows.Core
|
|||
|
||||
if (engineFlags.HasFlag(WindowsScriptEngineFlags.MarshalArraysByValue))
|
||||
{
|
||||
if ((obj is Array array) && ((hostTarget == null) || (typeof(Array).IsAssignableFrom(hostTarget.Type))))
|
||||
if ((obj is Array array) && ((hostTarget == null) || hostTarget.Type.IsArray))
|
||||
{
|
||||
bool alreadyMarshaled;
|
||||
if (marshaledArraySet != null)
|
||||
|
@ -628,7 +628,7 @@ namespace Microsoft.ClearScript.Windows.Core
|
|||
{
|
||||
activeScript.AddNamedItem(itemName, nativeFlags);
|
||||
}
|
||||
catch (Exception)
|
||||
catch
|
||||
{
|
||||
if (oldItem != null)
|
||||
{
|
||||
|
|
|
@ -249,12 +249,14 @@ namespace Microsoft.ClearScript.Windows.Core
|
|||
{
|
||||
VerifyNotDisposed();
|
||||
|
||||
var engineInternal = (ScriptObject)engine.Global.GetProperty("EngineInternal");
|
||||
|
||||
if (asConstructor)
|
||||
{
|
||||
return engine.Script.EngineInternal.invokeConstructor(this, args);
|
||||
return engineInternal.InvokeMethod("invokeConstructor", this, args);
|
||||
}
|
||||
|
||||
return engine.Script.EngineInternal.invokeMethod(holder, this, args);
|
||||
return engineInternal.InvokeMethod("invokeMethod", holder, this, args);
|
||||
}
|
||||
|
||||
public override object InvokeMethod(string name, params object[] args)
|
||||
|
|
|
@ -122,7 +122,8 @@ namespace Microsoft.ClearScript.Windows
|
|||
/// </remarks>
|
||||
public override string ExecuteCommand(string command)
|
||||
{
|
||||
Script.EngineInternal.command = command;
|
||||
var engineInternal = (ScriptObject)Global.GetProperty("EngineInternal");
|
||||
engineInternal.SetProperty("command", command);
|
||||
return base.ExecuteCommand("EngineInternal.getCommandResult(eval(EngineInternal.command))");
|
||||
}
|
||||
|
||||
|
|
Двоичные данные
ClearScript/doc/Build.docx
Двоичные данные
ClearScript/doc/Build.docx
Двоичный файл не отображается.
Двоичные данные
ClearScript/doc/Reference.chm
Двоичные данные
ClearScript/doc/Reference.chm
Двоичный файл не отображается.
|
@ -11,6 +11,6 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCopyright("(c) Microsoft Corporation")]
|
||||
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: AssemblyVersion("7.3.1")]
|
||||
[assembly: AssemblyFileVersion("7.3.1")]
|
||||
[assembly: AssemblyInformationalVersion("7.3.1")]
|
||||
[assembly: AssemblyVersion("7.3.2")]
|
||||
[assembly: AssemblyFileVersion("7.3.2")]
|
||||
[assembly: AssemblyInformationalVersion("7.3.2")]
|
||||
|
|
|
@ -11,6 +11,6 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCopyright("(c) Microsoft Corporation")]
|
||||
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: AssemblyVersion("7.3.1")]
|
||||
[assembly: AssemblyFileVersion("7.3.1")]
|
||||
[assembly: AssemblyInformationalVersion("7.3.1")]
|
||||
[assembly: AssemblyVersion("7.3.2")]
|
||||
[assembly: AssemblyFileVersion("7.3.2")]
|
||||
[assembly: AssemblyInformationalVersion("7.3.2")]
|
||||
|
|
|
@ -5,7 +5,6 @@ using System;
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Microsoft.ClearScript.V8;
|
||||
using Microsoft.CSharp.RuntimeBinder;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Microsoft.ClearScript.Test
|
||||
|
@ -77,7 +76,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("BaseInterfaceMemberAccess")]
|
||||
public void BaseInterfaceMemberAccess_Property_Scalar_Overflow()
|
||||
{
|
||||
TestUtil.AssertException<OverflowException>(() => engine.Execute("testObject.BaseInterfaceScalarProperty = 54321"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("testObject.BaseInterfaceScalarProperty = 54321"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("BaseInterfaceMemberAccess")]
|
||||
|
@ -155,7 +154,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("BaseInterfaceMemberAccess")]
|
||||
public void BaseInterfaceMemberAccess_Method_NoMatchingOverload()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.BaseInterfaceMethod('foo', TestEnum.Second)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.BaseInterfaceMethod('foo', TestEnum.Second)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("BaseInterfaceMemberAccess")]
|
||||
|
@ -167,7 +166,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("BaseInterfaceMemberAccess")]
|
||||
public void BaseInterfaceMemberAccess_Method_Generic_TypeArgConstraintFailure()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.BaseInterfaceMethod('foo', 4, testObject)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.BaseInterfaceMethod('foo', 4, testObject)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("BaseInterfaceMemberAccess")]
|
||||
|
@ -179,7 +178,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("BaseInterfaceMemberAccess")]
|
||||
public void BaseInterfaceMemberAccess_Method_GenericRedundant_MismatchedTypeArg()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.BaseInterfaceMethod(System.Int32, 'foo', 4, TestEnum.Second)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.BaseInterfaceMethod(System.Int32, 'foo', 4, TestEnum.Second)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("BaseInterfaceMemberAccess")]
|
||||
|
@ -191,7 +190,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("BaseInterfaceMemberAccess")]
|
||||
public void BaseInterfaceMemberAccess_Method_GenericExplicit_MissingTypeArg()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.BaseInterfaceMethod(4)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.BaseInterfaceMethod(4)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("BaseInterfaceMemberAccess")]
|
||||
|
@ -219,7 +218,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("BaseInterfaceMemberAccess")]
|
||||
public void BaseInterfaceMemberAccess_ExtensionMethod_NoMatchingOverload()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.BaseInterfaceExtensionMethod('foo', TestEnum.Second)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.BaseInterfaceExtensionMethod('foo', TestEnum.Second)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("BaseInterfaceMemberAccess")]
|
||||
|
@ -231,7 +230,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("BaseInterfaceMemberAccess")]
|
||||
public void BaseInterfaceMemberAccess_ExtensionMethod_Generic_TypeArgConstraintFailure()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.BaseInterfaceExtensionMethod('foo', 4, testObject)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.BaseInterfaceExtensionMethod('foo', 4, testObject)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("BaseInterfaceMemberAccess")]
|
||||
|
@ -243,7 +242,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("BaseInterfaceMemberAccess")]
|
||||
public void BaseInterfaceMemberAccess_ExtensionMethod_GenericRedundant_MismatchedTypeArg()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.BaseInterfaceExtensionMethod(System.Int32, 'foo', 4, TestEnum.Second)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.BaseInterfaceExtensionMethod(System.Int32, 'foo', 4, TestEnum.Second)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("BaseInterfaceMemberAccess")]
|
||||
|
@ -255,7 +254,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("BaseInterfaceMemberAccess")]
|
||||
public void BaseInterfaceMemberAccess_ExtensionMethod_GenericExplicit_MissingTypeArg()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.BaseInterfaceExtensionMethod(4)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.BaseInterfaceExtensionMethod(4)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("BaseInterfaceMemberAccess")]
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Microsoft.CSharp.RuntimeBinder;
|
||||
using Microsoft.ClearScript.V8;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
|
@ -77,7 +76,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("BaseMemberAccess")]
|
||||
public void BaseMemberAccess_Field_Scalar_Overflow()
|
||||
{
|
||||
TestUtil.AssertException<OverflowException>(() => engine.Execute("testObject.BaseScalarField = 54321"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("testObject.BaseScalarField = 54321"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("BaseMemberAccess")]
|
||||
|
@ -157,7 +156,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("BaseMemberAccess")]
|
||||
public void BaseMemberAccess_Property_Scalar_Overflow()
|
||||
{
|
||||
TestUtil.AssertException<OverflowException>(() => engine.Execute("testObject.BaseScalarProperty = 54321"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("testObject.BaseScalarProperty = 54321"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("BaseMemberAccess")]
|
||||
|
@ -235,7 +234,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("BaseMemberAccess")]
|
||||
public void BaseMemberAccess_Method_NoMatchingOverload()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.BaseMethod('foo', TestEnum.Second)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.BaseMethod('foo', TestEnum.Second)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("BaseMemberAccess")]
|
||||
|
@ -247,7 +246,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("BaseMemberAccess")]
|
||||
public void BaseMemberAccess_Method_Generic_TypeArgConstraintFailure()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.BaseMethod('foo', 4, testObject)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.BaseMethod('foo', 4, testObject)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("BaseMemberAccess")]
|
||||
|
@ -259,7 +258,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("BaseMemberAccess")]
|
||||
public void BaseMemberAccess_Method_GenericRedundant_MismatchedTypeArg()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.BaseMethod(System.Int32, 'foo', 4, TestEnum.Second)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.BaseMethod(System.Int32, 'foo', 4, TestEnum.Second)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("BaseMemberAccess")]
|
||||
|
@ -271,7 +270,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("BaseMemberAccess")]
|
||||
public void BaseMemberAccess_Method_GenericExplicit_MissingTypeArg()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.BaseMethod(4)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.BaseMethod(4)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("BaseMemberAccess")]
|
||||
|
@ -299,7 +298,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("BaseMemberAccess")]
|
||||
public void BaseMemberAccess_ExtensionMethod_NoMatchingOverload()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.BaseExtensionMethod('foo', TestEnum.Second)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.BaseExtensionMethod('foo', TestEnum.Second)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("BaseMemberAccess")]
|
||||
|
@ -311,7 +310,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("BaseMemberAccess")]
|
||||
public void BaseMemberAccess_ExtensionMethod_Generic_TypeArgConstraintFailure()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.BaseExtensionMethod('foo', 4, testObject)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.BaseExtensionMethod('foo', 4, testObject)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("BaseMemberAccess")]
|
||||
|
@ -323,7 +322,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("BaseMemberAccess")]
|
||||
public void BaseMemberAccess_ExtensionMethod_GenericRedundant_MismatchedTypeArg()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.BaseExtensionMethod(System.Int32, 'foo', 4, TestEnum.Second)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.BaseExtensionMethod(System.Int32, 'foo', 4, TestEnum.Second)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("BaseMemberAccess")]
|
||||
|
@ -335,7 +334,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("BaseMemberAccess")]
|
||||
public void BaseMemberAccess_ExtensionMethod_GenericExplicit_MissingTypeArg()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.BaseExtensionMethod(4)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.BaseExtensionMethod(4)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("BaseMemberAccess")]
|
||||
|
|
|
@ -68,7 +68,7 @@ namespace Microsoft.ClearScript.Test
|
|||
public void BugFix_NullArgBinding_Ambiguous()
|
||||
{
|
||||
engine.AddHostObject("lib", new HostTypeCollection("mscorlib"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("lib.System.Console.WriteLine(null)"));
|
||||
TestUtil.AssertException<RuntimeBinderException, AmbiguousMatchException>(() => engine.Execute("lib.System.Console.WriteLine(null)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("BugFix")]
|
||||
|
@ -311,10 +311,11 @@ namespace Microsoft.ClearScript.Test
|
|||
Assert.AreEqual('A', engine.Evaluate("host.toChar(65)"));
|
||||
Assert.AreEqual(0.0F, engine.Evaluate("host.toSingle(0)"));
|
||||
Assert.AreEqual(1.0F, engine.Evaluate("host.toSingle(1)"));
|
||||
Assert.AreEqual(123.0F, engine.Evaluate("host.toSingle(123)"));
|
||||
}
|
||||
}
|
||||
|
||||
Assert.AreEqual(2L, HostItem.GetCoreBindCount());
|
||||
Assert.AreEqual(3L, HostItem.GetCoreBindCount());
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("BugFix")]
|
||||
|
@ -581,6 +582,38 @@ namespace Microsoft.ClearScript.Test
|
|||
Assert.IsNull(engine.Evaluate("indexer.Item(DayOfWeek.Tuesday)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("BugFix")]
|
||||
public void BugFix_AmbiguousIndexer_ImplicitConversion()
|
||||
{
|
||||
IAmbiguousIndexer indexer = new AmbiguousIndexer();
|
||||
engine.AddRestrictedHostObject("indexer", indexer);
|
||||
engine.AddHostType("DayOfWeek", typeof(MyDayOfWeek));
|
||||
|
||||
engine.Execute("indexer.Item.set(123, 456)");
|
||||
Assert.AreEqual(456, engine.Evaluate("indexer.Item(123)"));
|
||||
Assert.IsNull(engine.Evaluate("indexer.Item(789)"));
|
||||
|
||||
engine.Execute("indexer.Item.set(DayOfWeek.Thursday, DayOfWeek.Sunday)");
|
||||
Assert.AreEqual(MyDayOfWeek.Sunday, engine.Evaluate("indexer.Item(DayOfWeek.Thursday)"));
|
||||
Assert.IsNull(engine.Evaluate("indexer.Item(DayOfWeek.Tuesday)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("BugFix")]
|
||||
public void BugFix_AmbiguousIndexer_ImplicitConversion_Nullable()
|
||||
{
|
||||
IAmbiguousIndexer2 indexer = new AmbiguousIndexer();
|
||||
engine.AddRestrictedHostObject("indexer", indexer);
|
||||
engine.AddHostType("DayOfWeek", typeof(MyDayOfWeek));
|
||||
|
||||
engine.Execute("indexer.Item.set(123, 456)");
|
||||
Assert.AreEqual(456, engine.Evaluate("indexer.Item(123)"));
|
||||
Assert.IsNull(engine.Evaluate("indexer.Item(789)"));
|
||||
|
||||
engine.Execute("indexer.Item.set(DayOfWeek.Thursday, DayOfWeek.Sunday)");
|
||||
Assert.AreEqual(MyDayOfWeek.Sunday, engine.Evaluate("indexer.Item(DayOfWeek.Thursday)"));
|
||||
Assert.IsNull(engine.Evaluate("indexer.Item(DayOfWeek.Tuesday)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("BugFix")]
|
||||
public void BugFix_InaccessiblePropertyAccessors()
|
||||
{
|
||||
|
@ -665,7 +698,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("BugFix")]
|
||||
public void BugFix_FinalizerHang_V8ScriptItem()
|
||||
{
|
||||
engine.Script.foo = new Action<object>(arg => {});
|
||||
engine.Script.foo = new Action<object>(_ => {});
|
||||
engine.Script.bar = new Action(() =>
|
||||
{
|
||||
GC.Collect();
|
||||
|
@ -789,13 +822,13 @@ namespace Microsoft.ClearScript.Test
|
|||
engine.Script.nullableDecimalFunc = new Func<decimal?, decimal?>(arg => arg);
|
||||
|
||||
Assert.AreEqual(123, engine.Evaluate("sbyteFunc(123)"));
|
||||
TestUtil.AssertException<OverflowException>(() => engine.Execute("sbyteFunc(234)"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("sbyteFunc(234)"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("sbyteFunc(123.5)"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("sbyteFunc(Math.PI)"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("sbyteFunc(host.toDecimal(Math.PI))"));
|
||||
|
||||
Assert.AreEqual(123, engine.Evaluate("nullableSByteFunc(123)"));
|
||||
TestUtil.AssertException<OverflowException>(() => engine.Execute("nullableSByteFunc(234)"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("nullableSByteFunc(234)"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("nullableSByteFunc(123.5)"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("nullableSByteFunc(Math.PI)"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("nullableSByteFunc(host.toDecimal(Math.PI))"));
|
||||
|
@ -842,13 +875,13 @@ namespace Microsoft.ClearScript.Test
|
|||
engine.Script.test = new NumericArgConversionTest();
|
||||
|
||||
Assert.AreEqual(123, engine.Evaluate("test.SByteField = 123; test.SByteField"));
|
||||
TestUtil.AssertException<OverflowException>(() => engine.Execute("test.SByteField = 234"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("test.SByteField = 234"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("test.SByteField = 123.5"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("test.SByteField = Math.PI"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("test.SByteField = host.toDecimal(Math.PI)"));
|
||||
|
||||
Assert.AreEqual(123, engine.Evaluate("test.NullableSByteField = 123; test.NullableSByteField"));
|
||||
TestUtil.AssertException<OverflowException>(() => engine.Execute("test.NullableSByteField = 234"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("test.NullableSByteField = 234"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("test.NullableSByteField = 123.5"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("test.NullableSByteField = Math.PI"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("test.NullableSByteField = host.toDecimal(Math.PI)"));
|
||||
|
@ -895,48 +928,48 @@ namespace Microsoft.ClearScript.Test
|
|||
engine.Script.test = new NumericArgConversionTest();
|
||||
|
||||
Assert.AreEqual(123, engine.Evaluate("test.SByteMethod(123)"));
|
||||
TestUtil.AssertException<OverflowException>(() => engine.Execute("test.SByteMethod(234)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("test.SByteMethod(123.5)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("test.SByteMethod(Math.PI)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("test.SByteMethod(host.toDecimal(Math.PI))"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("test.SByteMethod(234)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("test.SByteMethod(123.5)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("test.SByteMethod(Math.PI)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("test.SByteMethod(host.toDecimal(Math.PI))"));
|
||||
|
||||
Assert.AreEqual(123, engine.Evaluate("test.NullableSByteMethod(123)"));
|
||||
TestUtil.AssertException<OverflowException>(() => engine.Execute("test.NullableSByteMethod(234)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("test.NullableSByteMethod(123.5)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("test.NullableSByteMethod(Math.PI)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("test.NullableSByteMethod(host.toDecimal(Math.PI))"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("test.NullableSByteMethod(234)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("test.NullableSByteMethod(123.5)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("test.NullableSByteMethod(Math.PI)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("test.NullableSByteMethod(host.toDecimal(Math.PI))"));
|
||||
Assert.IsNull(engine.Evaluate("test.NullableSByteMethod(null)"));
|
||||
|
||||
Assert.AreEqual(123, engine.Evaluate("test.FloatMethod(123)"));
|
||||
Assert.AreEqual(123.5f, engine.Evaluate("test.FloatMethod(123.5)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("test.FloatMethod(Math.PI)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("test.FloatMethod(host.toDecimal(Math.PI))"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("test.FloatMethod(Math.PI)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("test.FloatMethod(host.toDecimal(Math.PI))"));
|
||||
|
||||
Assert.AreEqual(123, engine.Evaluate("test.NullableFloatMethod(123)"));
|
||||
Assert.AreEqual(123.5f, engine.Evaluate("test.NullableFloatMethod(123.5)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("test.NullableFloatMethod(Math.PI)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("test.NullableFloatMethod(host.toDecimal(Math.PI))"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("test.NullableFloatMethod(Math.PI)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("test.NullableFloatMethod(host.toDecimal(Math.PI))"));
|
||||
Assert.IsNull(engine.Evaluate("test.NullableFloatMethod(null)"));
|
||||
|
||||
Assert.AreEqual(123, engine.Evaluate("test.DoubleMethod(123)"));
|
||||
Assert.AreEqual(123.5f, engine.Evaluate("test.DoubleMethod(123.5)"));
|
||||
Assert.AreEqual(Math.PI, engine.Evaluate("test.DoubleMethod(Math.PI)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("test.DoubleMethod(host.toDecimal(Math.PI))"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("test.DoubleMethod(host.toDecimal(Math.PI))"));
|
||||
|
||||
Assert.AreEqual(123, engine.Evaluate("test.NullableDoubleMethod(123)"));
|
||||
Assert.AreEqual(123.5f, engine.Evaluate("test.NullableDoubleMethod(123.5)"));
|
||||
Assert.AreEqual(Math.PI, engine.Evaluate("test.NullableDoubleMethod(Math.PI)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("test.NullableDoubleMethod(host.toDecimal(Math.PI))"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("test.NullableDoubleMethod(host.toDecimal(Math.PI))"));
|
||||
Assert.IsNull(engine.Evaluate("test.NullableDoubleMethod(null)"));
|
||||
|
||||
Assert.AreEqual(123, engine.Evaluate("test.DecimalMethod(123)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("test.DecimalMethod(123.5)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("test.DecimalMethod(Math.PI)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("test.DecimalMethod(123.5)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("test.DecimalMethod(Math.PI)"));
|
||||
Assert.AreEqual((double)(decimal)Math.PI, engine.Evaluate("test.DecimalMethod(host.toDecimal(Math.PI))"));
|
||||
|
||||
Assert.AreEqual(123, engine.Evaluate("test.NullableDecimalMethod(123)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("test.NullableDecimalMethod(123.5)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("test.NullableDecimalMethod(Math.PI)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("test.NullableDecimalMethod(123.5)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("test.NullableDecimalMethod(Math.PI)"));
|
||||
Assert.AreEqual((double)(decimal)Math.PI, engine.Evaluate("test.NullableDecimalMethod(host.toDecimal(Math.PI))"));
|
||||
Assert.IsNull(engine.Evaluate("test.NullableDecimalMethod(null)"));
|
||||
}
|
||||
|
@ -948,13 +981,13 @@ namespace Microsoft.ClearScript.Test
|
|||
engine.Script.test = new NumericArgConversionTest();
|
||||
|
||||
Assert.AreEqual(123, engine.Evaluate("test.SByteProperty = 123; test.SByteProperty"));
|
||||
TestUtil.AssertException<OverflowException>(() => engine.Execute("test.SByteProperty = 234"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("test.SByteProperty = 234"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("test.SByteProperty = 123.5"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("test.SByteProperty = Math.PI"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("test.SByteProperty = host.toDecimal(Math.PI)"));
|
||||
|
||||
Assert.AreEqual(123, engine.Evaluate("test.NullableSByteProperty = 123; test.NullableSByteProperty"));
|
||||
TestUtil.AssertException<OverflowException>(() => engine.Execute("test.NullableSByteProperty = 234"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("test.NullableSByteProperty = 234"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("test.NullableSByteProperty = 123.5"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("test.NullableSByteProperty = Math.PI"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("test.NullableSByteProperty = host.toDecimal(Math.PI)"));
|
||||
|
@ -1138,7 +1171,7 @@ namespace Microsoft.ClearScript.Test
|
|||
{
|
||||
foo();
|
||||
}
|
||||
catch (Exception)
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1351,6 +1384,29 @@ namespace Microsoft.ClearScript.Test
|
|||
Assert.AreEqual("<foo>bar</foo>", engine.Evaluate("doc.Root.Elements(new XmlName('foo')).First().ToString()"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("BugFix")]
|
||||
public void BugFix_ImplicitConversion_Constructor()
|
||||
{
|
||||
engine.AddHostType(typeof(ImplicitConversionTest));
|
||||
engine.AddHostType(typeof(MyDayOfWeek));
|
||||
engine.Execute("test = new ImplicitConversionTest(123)");
|
||||
Assert.AreEqual(123, engine.Evaluate("test.Data"));
|
||||
engine.Execute("test = new ImplicitConversionTest(MyDayOfWeek.Thursday)");
|
||||
Assert.AreEqual(DayOfWeek.Thursday, engine.Evaluate("test.Data"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("BugFix")]
|
||||
public void BugFix_ImplicitConversion_ReflectionBoundMethod()
|
||||
{
|
||||
engine.DisableDynamicBinding = true;
|
||||
engine.Script.test = new ImplicitConversionTest(0);
|
||||
engine.AddHostType(typeof(MyDayOfWeek));
|
||||
engine.Execute("test.SetData(123)");
|
||||
Assert.AreEqual(123, engine.Evaluate("test.Data"));
|
||||
engine.Execute("test.SetData(MyDayOfWeek.Thursday)");
|
||||
Assert.AreEqual(DayOfWeek.Thursday, engine.Evaluate("test.Data"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("BugFix")]
|
||||
public void BugFix_ImplicitConversion_Invalid()
|
||||
{
|
||||
|
@ -1585,6 +1641,70 @@ namespace Microsoft.ClearScript.Test
|
|||
Assert.IsNull(engine.Evaluate("new SystemException().TargetSite"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("BugFix")]
|
||||
public void BugFix_EnumBindings_ZeroFirst()
|
||||
{
|
||||
engine.Script.test = new BindingTestObject();
|
||||
Assert.AreEqual(DayOfWeek.Sunday, engine.Evaluate("test.GetDay(0)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Evaluate("test.GetDay(1)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("BugFix")]
|
||||
public void BugFix_EnumBindings_NonZeroFirst()
|
||||
{
|
||||
engine.Script.test = new BindingTestObject();
|
||||
TestUtil.AssertMethodBindException(() => engine.Evaluate("test.GetDay(1)"));
|
||||
Assert.AreEqual(DayOfWeek.Sunday, engine.Evaluate("test.GetDay(0)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("BugFix")]
|
||||
public void BugFix_EnumBindings_ManyZeroes()
|
||||
{
|
||||
engine.Script.test = new BindingTestObject();
|
||||
engine.Script.host = new HostFunctions();
|
||||
Assert.AreEqual(DayOfWeek.Sunday, engine.Evaluate("test.GetDay(0)"));
|
||||
Assert.AreEqual(DayOfWeek.Sunday, engine.Evaluate("test.GetDay(host.toSByte(0))"));
|
||||
Assert.AreEqual(DayOfWeek.Sunday, engine.Evaluate("test.GetDay(host.toByte(0))"));
|
||||
Assert.AreEqual(DayOfWeek.Sunday, engine.Evaluate("test.GetDay(host.toInt16(0))"));
|
||||
Assert.AreEqual(DayOfWeek.Sunday, engine.Evaluate("test.GetDay(host.toUInt16(0))"));
|
||||
Assert.AreEqual(DayOfWeek.Sunday, engine.Evaluate("test.GetDay(host.toInt32(0))"));
|
||||
Assert.AreEqual(DayOfWeek.Sunday, engine.Evaluate("test.GetDay(host.toUInt32(0))"));
|
||||
Assert.AreEqual(DayOfWeek.Sunday, engine.Evaluate("test.GetDay(host.toInt64(0))"));
|
||||
Assert.AreEqual(DayOfWeek.Sunday, engine.Evaluate("test.GetDay(host.toUInt64(0))"));
|
||||
Assert.AreEqual(DayOfWeek.Sunday, engine.Evaluate("test.GetDay(host.toSingle(0))"));
|
||||
Assert.AreEqual(DayOfWeek.Sunday, engine.Evaluate("test.GetDay(host.toDouble(0))"));
|
||||
Assert.AreEqual(DayOfWeek.Sunday, engine.Evaluate("test.GetDay(host.toDecimal(0))"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("BugFix")]
|
||||
public void BugFix_EnumBindings_ManyNonZeroes()
|
||||
{
|
||||
engine.Script.test = new BindingTestObject();
|
||||
engine.Script.host = new HostFunctions();
|
||||
TestUtil.AssertMethodBindException(() => engine.Evaluate("test.GetDay(1)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Evaluate("test.GetDay(host.toSByte(1))"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Evaluate("test.GetDay(host.toByte(1))"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Evaluate("test.GetDay(host.toInt16(1))"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Evaluate("test.GetDay(host.toUInt16(1))"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Evaluate("test.GetDay(host.toInt32(1))"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Evaluate("test.GetDay(host.toUInt32(1))"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Evaluate("test.GetDay(host.toInt64(1))"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Evaluate("test.GetDay(host.toUInt64(1))"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Evaluate("test.GetDay(host.toSingle(1))"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Evaluate("test.GetDay(host.toDouble(1))"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Evaluate("test.GetDay(host.toDecimal(1))"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("BugFix")]
|
||||
public void BugFix_Binding_DefaultArgsAndParamArray()
|
||||
{
|
||||
engine.Script.test = new BindingTestObject();
|
||||
Assert.AreEqual("123, 456, ", engine.Evaluate("test.Format(123)"));
|
||||
Assert.AreEqual("123, 789, ", engine.Evaluate("test.Format(123, 789)"));
|
||||
Assert.AreEqual("123, 789, 456", engine.Evaluate("test.Format(123, 789, 456)"));
|
||||
Assert.AreEqual("123, 789, 456, 987", engine.Evaluate("test.Format(123, 789, 456, 987)"));
|
||||
}
|
||||
|
||||
// ReSharper restore InconsistentNaming
|
||||
|
||||
#endregion
|
||||
|
@ -1650,23 +1770,27 @@ namespace Microsoft.ClearScript.Test
|
|||
object this[DayOfWeek d] { get; set; }
|
||||
}
|
||||
|
||||
// ReSharper disable PossibleInterfaceMemberAmbiguity
|
||||
public interface IAmbiguousIndexerBase3
|
||||
{
|
||||
object this[int i] { get; set; }
|
||||
object this[char? c] { get; set; }
|
||||
}
|
||||
|
||||
public interface IAmbiguousIndexer : IAmbiguousIndexerBase1, IAmbiguousIndexerBase2
|
||||
{
|
||||
#pragma warning disable 109 // The keyword 'new' is redundant because indexer 'this' hides nothing
|
||||
|
||||
new object this[int i] { get; set; }
|
||||
|
||||
#pragma warning restore 109 // The keyword 'new' is redundant because indexer 'this' hides nothing
|
||||
}
|
||||
|
||||
// ReSharper restore PossibleInterfaceMemberAmbiguity
|
||||
public interface IAmbiguousIndexer2 : IAmbiguousIndexerBase1, IAmbiguousIndexerBase3
|
||||
{
|
||||
new object this[int i] { get; set; }
|
||||
}
|
||||
|
||||
public class AmbiguousIndexer : IAmbiguousIndexer
|
||||
public class AmbiguousIndexer : IAmbiguousIndexer, IAmbiguousIndexer2
|
||||
{
|
||||
private readonly IDictionary byInteger = new ListDictionary();
|
||||
private readonly IDictionary byDayOfWeek = new ListDictionary();
|
||||
private readonly IDictionary byNullableChar = new ListDictionary();
|
||||
|
||||
public object this[int key]
|
||||
{
|
||||
|
@ -1679,6 +1803,61 @@ namespace Microsoft.ClearScript.Test
|
|||
get => byDayOfWeek[key];
|
||||
set => byDayOfWeek[key] = value;
|
||||
}
|
||||
|
||||
public object this[char? key]
|
||||
{
|
||||
get => byNullableChar[key];
|
||||
set => byNullableChar[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[ImmutableValue]
|
||||
public struct MyDayOfWeek
|
||||
{
|
||||
private readonly DayOfWeek day;
|
||||
|
||||
public static MyDayOfWeek Sunday => DayOfWeek.Sunday;
|
||||
public static MyDayOfWeek Monday => DayOfWeek.Monday;
|
||||
public static MyDayOfWeek Tuesday => DayOfWeek.Tuesday;
|
||||
public static MyDayOfWeek Wednesday => DayOfWeek.Wednesday;
|
||||
public static MyDayOfWeek Thursday => DayOfWeek.Thursday;
|
||||
public static MyDayOfWeek Friday => DayOfWeek.Friday;
|
||||
public static MyDayOfWeek Saturday => DayOfWeek.Saturday;
|
||||
|
||||
private MyDayOfWeek(DayOfWeek day) => this.day = day;
|
||||
|
||||
public static implicit operator DayOfWeek(MyDayOfWeek self) => self.day;
|
||||
|
||||
public static implicit operator MyDayOfWeek(DayOfWeek day) => new MyDayOfWeek(day);
|
||||
|
||||
public static implicit operator char?(MyDayOfWeek self) => (self.day == DayOfWeek.Sunday) ? null : (char?)self.day;
|
||||
|
||||
public static implicit operator MyDayOfWeek(char? value) => new MyDayOfWeek((DayOfWeek)value.GetValueOrDefault());
|
||||
}
|
||||
|
||||
public class ImplicitConversionTest
|
||||
{
|
||||
public object Data { get; private set; }
|
||||
|
||||
public ImplicitConversionTest(int data)
|
||||
{
|
||||
Data = data;
|
||||
}
|
||||
|
||||
public ImplicitConversionTest(DayOfWeek data)
|
||||
{
|
||||
Data = data;
|
||||
}
|
||||
|
||||
public void SetData(int data)
|
||||
{
|
||||
Data = data;
|
||||
}
|
||||
|
||||
public void SetData(DayOfWeek data)
|
||||
{
|
||||
Data = data;
|
||||
}
|
||||
}
|
||||
|
||||
public class InaccessiblePropertyAccessors
|
||||
|
@ -1969,6 +2148,7 @@ namespace Microsoft.ClearScript.Test
|
|||
{
|
||||
private delegate void TestEventHandler(int value);
|
||||
|
||||
// ReSharper disable once EventNeverSubscribedTo.Local
|
||||
private event TestEventHandler TestEvent;
|
||||
|
||||
public void FireTestEvent(int value)
|
||||
|
@ -1977,6 +2157,17 @@ namespace Microsoft.ClearScript.Test
|
|||
}
|
||||
}
|
||||
|
||||
public class BindingTestObject
|
||||
{
|
||||
public DayOfWeek GetDay(DayOfWeek day) => day;
|
||||
|
||||
public string Format(int a, int b = 456, params int[] args)
|
||||
{
|
||||
var argsString = string.Join(", ", args);
|
||||
return $"{a}, {b}, {argsString}";
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Microsoft.CSharp.RuntimeBinder;
|
||||
using Microsoft.ClearScript.V8;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
|
@ -79,7 +78,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("ExplicitBaseInterfaceMemberAccess")]
|
||||
public void ExplicitBaseInterfaceMemberAccess_Property_Scalar_Overflow()
|
||||
{
|
||||
TestUtil.AssertException<OverflowException>(() => engine.Execute("testInterface.ExplicitBaseInterfaceScalarProperty = 54321"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("testInterface.ExplicitBaseInterfaceScalarProperty = 54321"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("ExplicitBaseInterfaceMemberAccess")]
|
||||
|
@ -157,7 +156,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("ExplicitBaseInterfaceMemberAccess")]
|
||||
public void ExplicitBaseInterfaceMemberAccess_Method_NoMatchingOverload()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testInterface.ExplicitBaseInterfaceMethod('foo', TestEnum.Second)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testInterface.ExplicitBaseInterfaceMethod('foo', TestEnum.Second)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("ExplicitBaseInterfaceMemberAccess")]
|
||||
|
@ -169,7 +168,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("ExplicitBaseInterfaceMemberAccess")]
|
||||
public void ExplicitBaseInterfaceMemberAccess_Method_Generic_TypeArgConstraintFailure()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testInterface.ExplicitBaseInterfaceMethod('foo', 4, testInterface)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testInterface.ExplicitBaseInterfaceMethod('foo', 4, testInterface)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("ExplicitBaseInterfaceMemberAccess")]
|
||||
|
@ -181,7 +180,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("ExplicitBaseInterfaceMemberAccess")]
|
||||
public void ExplicitBaseInterfaceMemberAccess_Method_GenericRedundant_MismatchedTypeArg()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testInterface.ExplicitBaseInterfaceMethod(System.Int32, 'foo', 4, TestEnum.Second)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testInterface.ExplicitBaseInterfaceMethod(System.Int32, 'foo', 4, TestEnum.Second)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("ExplicitBaseInterfaceMemberAccess")]
|
||||
|
@ -193,7 +192,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("ExplicitBaseInterfaceMemberAccess")]
|
||||
public void ExplicitBaseInterfaceMemberAccess_Method_GenericExplicitBase_MissingTypeArg()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testInterface.ExplicitBaseInterfaceMethod(4)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testInterface.ExplicitBaseInterfaceMethod(4)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("ExplicitBaseInterfaceMemberAccess")]
|
||||
|
@ -221,7 +220,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("ExplicitBaseInterfaceMemberAccess")]
|
||||
public void ExplicitBaseInterfaceMemberAccess_ExtensionMethod_NoMatchingOverload()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testInterface.ExplicitBaseInterfaceExtensionMethod('foo', TestEnum.Second)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testInterface.ExplicitBaseInterfaceExtensionMethod('foo', TestEnum.Second)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("ExplicitBaseInterfaceMemberAccess")]
|
||||
|
@ -233,7 +232,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("ExplicitBaseInterfaceMemberAccess")]
|
||||
public void ExplicitBaseInterfaceMemberAccess_ExtensionMethod_Generic_TypeArgConstraintFailure()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testInterface.ExplicitBaseInterfaceExtensionMethod('foo', 4, testInterface)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testInterface.ExplicitBaseInterfaceExtensionMethod('foo', 4, testInterface)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("ExplicitBaseInterfaceMemberAccess")]
|
||||
|
@ -245,7 +244,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("ExplicitBaseInterfaceMemberAccess")]
|
||||
public void ExplicitBaseInterfaceMemberAccess_ExtensionMethod_GenericRedundant_MismatchedTypeArg()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testInterface.ExplicitBaseInterfaceExtensionMethod(System.Int32, 'foo', 4, TestEnum.Second)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testInterface.ExplicitBaseInterfaceExtensionMethod(System.Int32, 'foo', 4, TestEnum.Second)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("ExplicitBaseInterfaceMemberAccess")]
|
||||
|
@ -257,7 +256,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("ExplicitBaseInterfaceMemberAccess")]
|
||||
public void ExplicitBaseInterfaceMemberAccess_ExtensionMethod_GenericExplicitBase_MissingTypeArg()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testInterface.ExplicitBaseInterfaceExtensionMethod(4)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testInterface.ExplicitBaseInterfaceExtensionMethod(4)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("ExplicitBaseInterfaceMemberAccess")]
|
||||
|
@ -311,7 +310,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("ExplicitBaseInterfaceMemberAccess")]
|
||||
public void ExplicitBaseInterfaceMemberAccess_ExtensionMethod_NoMatchingOverload_OnObject()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.ExplicitBaseInterfaceExtensionMethod('foo', TestEnum.Second)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.ExplicitBaseInterfaceExtensionMethod('foo', TestEnum.Second)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("ExplicitBaseInterfaceMemberAccess")]
|
||||
|
@ -323,7 +322,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("ExplicitBaseInterfaceMemberAccess")]
|
||||
public void ExplicitBaseInterfaceMemberAccess_ExtensionMethod_Generic_TypeArgConstraintFailure_OnObject()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.ExplicitBaseInterfaceExtensionMethod('foo', 4, testObject)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.ExplicitBaseInterfaceExtensionMethod('foo', 4, testObject)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("ExplicitBaseInterfaceMemberAccess")]
|
||||
|
@ -335,7 +334,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("ExplicitBaseInterfaceMemberAccess")]
|
||||
public void ExplicitBaseInterfaceMemberAccess_ExtensionMethod_GenericRedundant_MismatchedTypeArg_OnObject()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.ExplicitBaseInterfaceExtensionMethod(System.Int32, 'foo', 4, TestEnum.Second)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.ExplicitBaseInterfaceExtensionMethod(System.Int32, 'foo', 4, TestEnum.Second)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("ExplicitBaseInterfaceMemberAccess")]
|
||||
|
@ -347,7 +346,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("ExplicitBaseInterfaceMemberAccess")]
|
||||
public void ExplicitBaseInterfaceMemberAccess_ExtensionMethod_GenericExplicitBase_MissingTypeArg_OnObject()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.ExplicitBaseInterfaceExtensionMethod(4)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.ExplicitBaseInterfaceExtensionMethod(4)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("ExplicitBaseInterfaceMemberAccess")]
|
||||
|
|
|
@ -5,7 +5,6 @@ using System;
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Microsoft.ClearScript.V8;
|
||||
using Microsoft.CSharp.RuntimeBinder;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Microsoft.ClearScript.Test
|
||||
|
@ -79,7 +78,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("ExplicitInterfaceMemberAccess")]
|
||||
public void ExplicitInterfaceMemberAccess_Property_Scalar_Overflow()
|
||||
{
|
||||
TestUtil.AssertException<OverflowException>(() => engine.Execute("testInterface.ExplicitInterfaceScalarProperty = 54321"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("testInterface.ExplicitInterfaceScalarProperty = 54321"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("ExplicitInterfaceMemberAccess")]
|
||||
|
@ -157,7 +156,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("ExplicitInterfaceMemberAccess")]
|
||||
public void ExplicitInterfaceMemberAccess_Method_NoMatchingOverload()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testInterface.ExplicitInterfaceMethod('foo', TestEnum.Second)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testInterface.ExplicitInterfaceMethod('foo', TestEnum.Second)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("ExplicitInterfaceMemberAccess")]
|
||||
|
@ -169,7 +168,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("ExplicitInterfaceMemberAccess")]
|
||||
public void ExplicitInterfaceMemberAccess_Method_Generic_TypeArgConstraintFailure()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testInterface.ExplicitInterfaceMethod('foo', 4, testInterface)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testInterface.ExplicitInterfaceMethod('foo', 4, testInterface)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("ExplicitInterfaceMemberAccess")]
|
||||
|
@ -181,7 +180,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("ExplicitInterfaceMemberAccess")]
|
||||
public void ExplicitInterfaceMemberAccess_Method_GenericRedundant_MismatchedTypeArg()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testInterface.ExplicitInterfaceMethod(System.Int32, 'foo', 4, TestEnum.Second)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testInterface.ExplicitInterfaceMethod(System.Int32, 'foo', 4, TestEnum.Second)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("ExplicitInterfaceMemberAccess")]
|
||||
|
@ -193,7 +192,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("ExplicitInterfaceMemberAccess")]
|
||||
public void ExplicitInterfaceMemberAccess_Method_GenericExplicit_MissingTypeArg()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testInterface.ExplicitInterfaceMethod(4)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testInterface.ExplicitInterfaceMethod(4)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("ExplicitInterfaceMemberAccess")]
|
||||
|
@ -221,7 +220,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("ExplicitInterfaceMemberAccess")]
|
||||
public void ExplicitInterfaceMemberAccess_ExtensionMethod_NoMatchingOverload()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testInterface.ExplicitInterfaceExtensionMethod('foo', TestEnum.Second)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testInterface.ExplicitInterfaceExtensionMethod('foo', TestEnum.Second)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("ExplicitInterfaceMemberAccess")]
|
||||
|
@ -233,7 +232,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("ExplicitInterfaceMemberAccess")]
|
||||
public void ExplicitInterfaceMemberAccess_ExtensionMethod_Generic_TypeArgConstraintFailure()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testInterface.ExplicitInterfaceExtensionMethod('foo', 4, testInterface)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testInterface.ExplicitInterfaceExtensionMethod('foo', 4, testInterface)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("ExplicitInterfaceMemberAccess")]
|
||||
|
@ -245,7 +244,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("ExplicitInterfaceMemberAccess")]
|
||||
public void ExplicitInterfaceMemberAccess_ExtensionMethod_GenericRedundant_MismatchedTypeArg()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testInterface.ExplicitInterfaceExtensionMethod(System.Int32, 'foo', 4, TestEnum.Second)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testInterface.ExplicitInterfaceExtensionMethod(System.Int32, 'foo', 4, TestEnum.Second)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("ExplicitInterfaceMemberAccess")]
|
||||
|
@ -257,7 +256,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("ExplicitInterfaceMemberAccess")]
|
||||
public void ExplicitInterfaceMemberAccess_ExtensionMethod_GenericExplicit_MissingTypeArg()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testInterface.ExplicitInterfaceExtensionMethod(4)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testInterface.ExplicitInterfaceExtensionMethod(4)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("ExplicitInterfaceMemberAccess")]
|
||||
|
@ -311,7 +310,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("ExplicitInterfaceMemberAccess")]
|
||||
public void ExplicitInterfaceMemberAccess_ExtensionMethod_NoMatchingOverload_OnObject()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.ExplicitInterfaceExtensionMethod('foo', TestEnum.Second)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.ExplicitInterfaceExtensionMethod('foo', TestEnum.Second)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("ExplicitInterfaceMemberAccess")]
|
||||
|
@ -323,7 +322,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("ExplicitInterfaceMemberAccess")]
|
||||
public void ExplicitInterfaceMemberAccess_ExtensionMethod_Generic_TypeArgConstraintFailure_OnObject()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.ExplicitInterfaceExtensionMethod('foo', 4, testObject)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.ExplicitInterfaceExtensionMethod('foo', 4, testObject)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("ExplicitInterfaceMemberAccess")]
|
||||
|
@ -335,7 +334,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("ExplicitInterfaceMemberAccess")]
|
||||
public void ExplicitInterfaceMemberAccess_ExtensionMethod_GenericRedundant_MismatchedTypeArg_OnObject()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.ExplicitInterfaceExtensionMethod(System.Int32, 'foo', 4, TestEnum.Second)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.ExplicitInterfaceExtensionMethod(System.Int32, 'foo', 4, TestEnum.Second)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("ExplicitInterfaceMemberAccess")]
|
||||
|
@ -347,7 +346,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("ExplicitInterfaceMemberAccess")]
|
||||
public void ExplicitInterfaceMemberAccess_ExtensionMethod_GenericExplicit_MissingTypeArg_OnObject()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.ExplicitInterfaceExtensionMethod(4)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.ExplicitInterfaceExtensionMethod(4)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("ExplicitInterfaceMemberAccess")]
|
||||
|
|
|
@ -89,7 +89,7 @@ namespace Microsoft.ClearScript.Test
|
|||
var value = Enumerable.Range(1, 5).ToArray();
|
||||
CastVerifier<IList>.VerifySymmetric(host, value);
|
||||
CastVerifier<Array>.VerifySymmetric(host, value);
|
||||
CastVerifier<Object>.VerifySymmetric(host, value);
|
||||
CastVerifier<object>.VerifySymmetric(host, value);
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("HostFunctions")]
|
||||
|
@ -106,7 +106,7 @@ namespace Microsoft.ClearScript.Test
|
|||
const double value = 123.75;
|
||||
CastVerifier<IComparable>.VerifySymmetric(host, value);
|
||||
CastVerifier<ValueType>.VerifySymmetric(host, value);
|
||||
CastVerifier<Object>.VerifySymmetric(host, value);
|
||||
CastVerifier<object>.VerifySymmetric(host, value);
|
||||
CastVerifier<int>.VerifyAsymmetric(host, value);
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ namespace Microsoft.ClearScript.Test
|
|||
CastVerifier<IComparable>.VerifySymmetric(host, value);
|
||||
CastVerifier<Enum>.VerifySymmetric(host, value);
|
||||
CastVerifier<ValueType>.VerifySymmetric(host, value);
|
||||
CastVerifier<Object>.VerifySymmetric(host, value);
|
||||
CastVerifier<object>.VerifySymmetric(host, value);
|
||||
CastVerifier<int>.VerifySymmetric(host, value);
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ namespace Microsoft.ClearScript.Test
|
|||
var value = new DateTime(2007, 5, 22, 6, 15, 43);
|
||||
CastVerifier<IComparable>.VerifySymmetric(host, value);
|
||||
CastVerifier<ValueType>.VerifySymmetric(host, value);
|
||||
CastVerifier<Object>.VerifySymmetric(host, value);
|
||||
CastVerifier<object>.VerifySymmetric(host, value);
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("HostFunctions")]
|
||||
|
@ -589,7 +589,7 @@ namespace Microsoft.ClearScript.Test
|
|||
{
|
||||
engine.AddHostType("UnsignedFlags", HostItemFlags.PrivateAccess, typeof(UnsignedFlags));
|
||||
engine.AddHostType("SignedFlags", HostItemFlags.PrivateAccess, typeof(SignedFlags));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("host.flags(SignedFlags.Second, SignedFlags.Fourth, UnsignedFlags.Sixth, UnsignedFlags.Eighth)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("host.flags(SignedFlags.Second, SignedFlags.Fourth, UnsignedFlags.Sixth, UnsignedFlags.Eighth)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("HostFunctions")]
|
||||
|
@ -797,7 +797,7 @@ namespace Microsoft.ClearScript.Test
|
|||
{
|
||||
var value = (Array)host.newArr<T>(lengths);
|
||||
Assert.IsInstanceOfType(value, typeof(T).MakeArrayType(lengths.Length));
|
||||
lengths.ForEach((length, index) => Assert.AreEqual(lengths[index], value.GetLength(index)));
|
||||
lengths.ForEach((_, index) => Assert.AreEqual(lengths[index], value.GetLength(index)));
|
||||
}
|
||||
|
||||
private void VerifyNewArr(params int[] lengths)
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace Microsoft.ClearScript.Test
|
|||
|
||||
#region miscellaneous
|
||||
|
||||
private static readonly Predicate<Type> defaultFilter = type => true;
|
||||
private static readonly Predicate<Type> defaultFilter = _ => true;
|
||||
|
||||
private static bool ReflectionFilter(Type type)
|
||||
{
|
||||
|
|
|
@ -5,7 +5,6 @@ using System;
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Microsoft.ClearScript.V8;
|
||||
using Microsoft.CSharp.RuntimeBinder;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Microsoft.ClearScript.Test
|
||||
|
@ -77,7 +76,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("InterfaceMemberAccess")]
|
||||
public void InterfaceMemberAccess_Property_Scalar_Overflow()
|
||||
{
|
||||
TestUtil.AssertException<OverflowException>(() => engine.Execute("testObject.InterfaceScalarProperty = 54321"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("testObject.InterfaceScalarProperty = 54321"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("InterfaceMemberAccess")]
|
||||
|
@ -155,7 +154,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("InterfaceMemberAccess")]
|
||||
public void InterfaceMemberAccess_Method_NoMatchingOverload()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.InterfaceMethod('foo', TestEnum.Second)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.InterfaceMethod('foo', TestEnum.Second)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("InterfaceMemberAccess")]
|
||||
|
@ -167,7 +166,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("InterfaceMemberAccess")]
|
||||
public void InterfaceMemberAccess_Method_Generic_TypeArgConstraintFailure()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.InterfaceMethod('foo', 4, testObject)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.InterfaceMethod('foo', 4, testObject)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("InterfaceMemberAccess")]
|
||||
|
@ -179,7 +178,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("InterfaceMemberAccess")]
|
||||
public void InterfaceMemberAccess_Method_GenericRedundant_MismatchedTypeArg()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.InterfaceMethod(System.Int32, 'foo', 4, TestEnum.Second)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.InterfaceMethod(System.Int32, 'foo', 4, TestEnum.Second)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("InterfaceMemberAccess")]
|
||||
|
@ -191,7 +190,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("InterfaceMemberAccess")]
|
||||
public void InterfaceMemberAccess_Method_GenericExplicit_MissingTypeArg()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.InterfaceMethod(4)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.InterfaceMethod(4)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("InterfaceMemberAccess")]
|
||||
|
@ -219,7 +218,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("InterfaceMemberAccess")]
|
||||
public void InterfaceMemberAccess_ExtensionMethod_NoMatchingOverload()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.InterfaceExtensionMethod('foo', TestEnum.Second)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.InterfaceExtensionMethod('foo', TestEnum.Second)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("InterfaceMemberAccess")]
|
||||
|
@ -231,7 +230,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("InterfaceMemberAccess")]
|
||||
public void InterfaceMemberAccess_ExtensionMethod_Generic_TypeArgConstraintFailure()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.InterfaceExtensionMethod('foo', 4, testObject)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.InterfaceExtensionMethod('foo', 4, testObject)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("InterfaceMemberAccess")]
|
||||
|
@ -243,7 +242,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("InterfaceMemberAccess")]
|
||||
public void InterfaceMemberAccess_ExtensionMethod_GenericRedundant_MismatchedTypeArg()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.InterfaceExtensionMethod(System.Int32, 'foo', 4, TestEnum.Second)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.InterfaceExtensionMethod(System.Int32, 'foo', 4, TestEnum.Second)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("InterfaceMemberAccess")]
|
||||
|
@ -255,7 +254,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("InterfaceMemberAccess")]
|
||||
public void InterfaceMemberAccess_ExtensionMethod_GenericExplicit_MissingTypeArg()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.InterfaceExtensionMethod(4)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.InterfaceExtensionMethod(4)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("InterfaceMemberAccess")]
|
||||
|
|
|
@ -426,7 +426,7 @@ namespace Microsoft.ClearScript.Test
|
|||
public void JScriptCoreEngine_Interrupt()
|
||||
{
|
||||
var checkpoint = new ManualResetEvent(false);
|
||||
ThreadPool.QueueUserWorkItem(state =>
|
||||
ThreadPool.QueueUserWorkItem(_ =>
|
||||
{
|
||||
checkpoint.WaitOne();
|
||||
engine.Interrupt();
|
||||
|
@ -807,7 +807,7 @@ namespace Microsoft.ClearScript.Test
|
|||
Assert.IsNotNull(exception.InnerException);
|
||||
|
||||
var hostException = exception.InnerException;
|
||||
Assert.IsInstanceOfType(hostException, typeof(RuntimeBinderException));
|
||||
Assert.IsTrue((hostException is RuntimeBinderException) || (hostException is MissingMethodException));
|
||||
TestUtil.AssertValidException(hostException);
|
||||
Assert.IsNull(hostException.InnerException);
|
||||
|
||||
|
@ -908,7 +908,7 @@ namespace Microsoft.ClearScript.Test
|
|||
Assert.IsNotNull(nestedException.InnerException);
|
||||
|
||||
var nestedHostException = nestedException.InnerException;
|
||||
Assert.IsInstanceOfType(nestedHostException, typeof(RuntimeBinderException));
|
||||
Assert.IsTrue((nestedHostException is RuntimeBinderException) || (nestedHostException is MissingMethodException));
|
||||
TestUtil.AssertValidException(nestedHostException);
|
||||
Assert.IsNull(nestedHostException.InnerException);
|
||||
|
||||
|
@ -2031,7 +2031,7 @@ namespace Microsoft.ClearScript.Test
|
|||
|
||||
Assert.AreSame(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
Assert.IsNull(engine.Evaluate("foo.Method(foo.WrappedNullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException, AmbiguousMatchException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
|
||||
engine.EnableNullResultWrapping = true;
|
||||
Assert.AreSame(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
|
@ -2041,7 +2041,7 @@ namespace Microsoft.ClearScript.Test
|
|||
engine.EnableNullResultWrapping = false;
|
||||
Assert.AreSame(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
Assert.IsNull(engine.Evaluate("foo.Method(foo.WrappedNullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException, AmbiguousMatchException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("JScriptCoreEngine")]
|
||||
|
@ -2060,7 +2060,7 @@ namespace Microsoft.ClearScript.Test
|
|||
|
||||
Assert.AreEqual(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
Assert.IsNull(engine.Evaluate("foo.Method(foo.WrappedNullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException, AmbiguousMatchException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
|
||||
engine.EnableNullResultWrapping = true;
|
||||
Assert.AreEqual(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
|
@ -2070,7 +2070,7 @@ namespace Microsoft.ClearScript.Test
|
|||
engine.EnableNullResultWrapping = false;
|
||||
Assert.AreEqual(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
Assert.IsNull(engine.Evaluate("foo.Method(foo.WrappedNullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException, AmbiguousMatchException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("JScriptCoreEngine")]
|
||||
|
@ -2089,7 +2089,7 @@ namespace Microsoft.ClearScript.Test
|
|||
|
||||
Assert.AreEqual(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
Assert.IsNull(engine.Evaluate("foo.Method(foo.WrappedNullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException, AmbiguousMatchException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
|
||||
engine.EnableNullResultWrapping = true;
|
||||
Assert.AreEqual(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
|
@ -2099,7 +2099,7 @@ namespace Microsoft.ClearScript.Test
|
|||
engine.EnableNullResultWrapping = false;
|
||||
Assert.AreEqual(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
Assert.IsNull(engine.Evaluate("foo.Method(foo.WrappedNullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException, AmbiguousMatchException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("JScriptCoreEngine")]
|
||||
|
@ -2303,7 +2303,7 @@ namespace Microsoft.ClearScript.Test
|
|||
|
||||
engine.Script.listDict = new ListDictionary { { "abc", 123 }, { "def", 456 }, { "ghi", 789 } };
|
||||
Assert.AreEqual(3, engine.Evaluate("listDict.Count"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("listDict.Count()"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Evaluate("listDict.Count()"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("JScriptCoreEngine")]
|
||||
|
@ -2390,7 +2390,7 @@ namespace Microsoft.ClearScript.Test
|
|||
Assert.AreEqual("baz", engine.Evaluate("foo(0) = 'baz'"));
|
||||
|
||||
engine.Script.bar = new List<string>();
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("bar.Add(foo(0))"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("bar.Add(foo(0))"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("JScriptCoreEngine")]
|
||||
|
@ -2951,7 +2951,7 @@ namespace Microsoft.ClearScript.Test
|
|||
{
|
||||
public override T[] LoadCustomAttributes<T>(ICustomAttributeProvider resource, bool inherit)
|
||||
{
|
||||
if (typeof(T) == typeof(ScriptMemberAttribute) && (resource is MemberInfo member))
|
||||
if (typeof(T) == typeof(ScriptMemberAttribute) && (resource is MemberInfo member) && !member.DeclaringType.IsArray && (member.DeclaringType != typeof(Array)))
|
||||
{
|
||||
var name = char.ToLowerInvariant(member.Name[0]) + member.Name.Substring(1);
|
||||
return new[] { new ScriptMemberAttribute(name) } as T[];
|
||||
|
|
|
@ -806,7 +806,7 @@ namespace Microsoft.ClearScript.Test
|
|||
Assert.IsNotNull(exception.InnerException);
|
||||
|
||||
var hostException = exception.InnerException;
|
||||
Assert.IsInstanceOfType(hostException, typeof(RuntimeBinderException));
|
||||
Assert.IsTrue((hostException is RuntimeBinderException) || (hostException is MissingMethodException));
|
||||
TestUtil.AssertValidException(hostException);
|
||||
Assert.IsNull(hostException.InnerException);
|
||||
|
||||
|
@ -907,7 +907,7 @@ namespace Microsoft.ClearScript.Test
|
|||
Assert.IsNotNull(nestedException.InnerException);
|
||||
|
||||
var nestedHostException = nestedException.InnerException;
|
||||
Assert.IsInstanceOfType(nestedHostException, typeof(RuntimeBinderException));
|
||||
Assert.IsTrue((nestedHostException is RuntimeBinderException) || (nestedHostException is MissingMethodException));
|
||||
TestUtil.AssertValidException(nestedHostException);
|
||||
Assert.IsNull(nestedHostException.InnerException);
|
||||
|
||||
|
@ -2082,7 +2082,7 @@ namespace Microsoft.ClearScript.Test
|
|||
|
||||
Assert.AreSame(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
Assert.IsNull(engine.Evaluate("foo.Method(foo.WrappedNullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException, AmbiguousMatchException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
|
||||
engine.EnableNullResultWrapping = true;
|
||||
Assert.AreSame(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
|
@ -2092,7 +2092,7 @@ namespace Microsoft.ClearScript.Test
|
|||
engine.EnableNullResultWrapping = false;
|
||||
Assert.AreSame(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
Assert.IsNull(engine.Evaluate("foo.Method(foo.WrappedNullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException, AmbiguousMatchException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("JScriptEngine")]
|
||||
|
@ -2111,7 +2111,7 @@ namespace Microsoft.ClearScript.Test
|
|||
|
||||
Assert.AreEqual(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
Assert.IsNull(engine.Evaluate("foo.Method(foo.WrappedNullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException, AmbiguousMatchException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
|
||||
engine.EnableNullResultWrapping = true;
|
||||
Assert.AreEqual(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
|
@ -2121,7 +2121,7 @@ namespace Microsoft.ClearScript.Test
|
|||
engine.EnableNullResultWrapping = false;
|
||||
Assert.AreEqual(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
Assert.IsNull(engine.Evaluate("foo.Method(foo.WrappedNullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException, AmbiguousMatchException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("JScriptEngine")]
|
||||
|
@ -2140,7 +2140,7 @@ namespace Microsoft.ClearScript.Test
|
|||
|
||||
Assert.AreEqual(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
Assert.IsNull(engine.Evaluate("foo.Method(foo.WrappedNullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException, AmbiguousMatchException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
|
||||
engine.EnableNullResultWrapping = true;
|
||||
Assert.AreEqual(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
|
@ -2150,7 +2150,7 @@ namespace Microsoft.ClearScript.Test
|
|||
engine.EnableNullResultWrapping = false;
|
||||
Assert.AreEqual(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
Assert.IsNull(engine.Evaluate("foo.Method(foo.WrappedNullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException, AmbiguousMatchException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("JScriptEngine")]
|
||||
|
@ -2354,7 +2354,7 @@ namespace Microsoft.ClearScript.Test
|
|||
|
||||
engine.Script.listDict = new ListDictionary { { "abc", 123 }, { "def", 456 }, { "ghi", 789 } };
|
||||
Assert.AreEqual(3, engine.Evaluate("listDict.Count"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("listDict.Count()"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Evaluate("listDict.Count()"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("JScriptEngine")]
|
||||
|
@ -2441,7 +2441,7 @@ namespace Microsoft.ClearScript.Test
|
|||
Assert.AreEqual("baz", engine.Evaluate("foo(0) = 'baz'"));
|
||||
|
||||
engine.Script.bar = new List<string>();
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("bar.Add(foo(0))"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("bar.Add(foo(0))"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("JScriptEngine")]
|
||||
|
@ -3002,7 +3002,7 @@ namespace Microsoft.ClearScript.Test
|
|||
{
|
||||
public override T[] LoadCustomAttributes<T>(ICustomAttributeProvider resource, bool inherit)
|
||||
{
|
||||
if (typeof(T) == typeof(ScriptMemberAttribute) && (resource is MemberInfo member))
|
||||
if (typeof(T) == typeof(ScriptMemberAttribute) && (resource is MemberInfo member) && !member.DeclaringType.IsArray && (member.DeclaringType != typeof(Array)))
|
||||
{
|
||||
var name = char.ToLowerInvariant(member.Name[0]) + member.Name.Substring(1);
|
||||
return new[] { new ScriptMemberAttribute(name) } as T[];
|
||||
|
|
|
@ -5,7 +5,6 @@ using System;
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using Microsoft.CSharp.RuntimeBinder;
|
||||
using Microsoft.ClearScript.V8;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
|
@ -78,7 +77,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("MemberAccess")]
|
||||
public void MemberAccess_Field_Scalar_Overflow()
|
||||
{
|
||||
TestUtil.AssertException<OverflowException>(() => engine.Execute("testObject.ScalarField = 54321"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("testObject.ScalarField = 54321"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("MemberAccess")]
|
||||
|
@ -158,7 +157,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("MemberAccess")]
|
||||
public void MemberAccess_Property_Scalar_Overflow()
|
||||
{
|
||||
TestUtil.AssertException<OverflowException>(() => engine.Execute("testObject.ScalarProperty = 54321"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("testObject.ScalarProperty = 54321"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("MemberAccess")]
|
||||
|
@ -242,7 +241,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("MemberAccess")]
|
||||
public void MemberAccess_Method_NoMatchingOverload()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.Method('foo', TestEnum.Second)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.Method('foo', TestEnum.Second)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("MemberAccess")]
|
||||
|
@ -254,7 +253,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("MemberAccess")]
|
||||
public void MemberAccess_Method_Generic_TypeArgConstraintFailure()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.Method('foo', 4, testObject)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.Method('foo', 4, testObject)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("MemberAccess")]
|
||||
|
@ -266,7 +265,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("MemberAccess")]
|
||||
public void MemberAccess_Method_GenericRedundant_MismatchedTypeArg()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.Method(System.Int32, 'foo', 4, TestEnum.Second)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.Method(System.Int32, 'foo', 4, TestEnum.Second)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("MemberAccess")]
|
||||
|
@ -278,7 +277,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("MemberAccess")]
|
||||
public void MemberAccess_Method_GenericExplicit_MissingTypeArg()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.Method(4)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.Method(4)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("MemberAccess")]
|
||||
|
@ -348,7 +347,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("MemberAccess")]
|
||||
public void MemberAccess_ExtensionMethod_NoMatchingOverload()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.ExtensionMethod('foo', TestEnum.Second)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.ExtensionMethod('foo', TestEnum.Second)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("MemberAccess")]
|
||||
|
@ -360,7 +359,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("MemberAccess")]
|
||||
public void MemberAccess_ExtensionMethod_Generic_TypeArgConstraintFailure()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.ExtensionMethod('foo', 4, testObject)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.ExtensionMethod('foo', 4, testObject)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("MemberAccess")]
|
||||
|
@ -372,7 +371,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("MemberAccess")]
|
||||
public void MemberAccess_ExtensionMethod_GenericRedundant_MismatchedTypeArg()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.ExtensionMethod(System.Int32, 'foo', 4, TestEnum.Second)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.ExtensionMethod(System.Int32, 'foo', 4, TestEnum.Second)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("MemberAccess")]
|
||||
|
@ -384,7 +383,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("MemberAccess")]
|
||||
public void MemberAccess_ExtensionMethod_GenericExplicit_MissingTypeArg()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("testObject.ExtensionMethod(4)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("testObject.ExtensionMethod(4)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("MemberAccess")]
|
||||
|
|
|
@ -10,6 +10,7 @@ using System.Linq;
|
|||
using System.Runtime.InteropServices;
|
||||
using Microsoft.ClearScript.Util;
|
||||
using Microsoft.ClearScript.Util.COM;
|
||||
using Microsoft.CSharp.RuntimeBinder;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Microsoft.ClearScript.Test
|
||||
|
@ -164,6 +165,48 @@ namespace Microsoft.ClearScript.Test
|
|||
Assert.IsTrue(gotExpectedException, message);
|
||||
}
|
||||
|
||||
public static void AssertException<T1, T2>(Action action, bool checkScriptStackTrace = true) where T1 : Exception where T2 : Exception
|
||||
{
|
||||
Exception caughtException = null;
|
||||
var gotExpectedException = false;
|
||||
|
||||
try
|
||||
{
|
||||
action();
|
||||
}
|
||||
catch (T1 exception)
|
||||
{
|
||||
caughtException = exception;
|
||||
gotExpectedException = true;
|
||||
AssertValidExceptionChain(exception, checkScriptStackTrace);
|
||||
}
|
||||
catch (T2 exception)
|
||||
{
|
||||
caughtException = exception;
|
||||
gotExpectedException = true;
|
||||
AssertValidExceptionChain(exception, checkScriptStackTrace);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
caughtException = exception;
|
||||
gotExpectedException = (exception.GetBaseException() is T1) || (exception.GetBaseException() is T2);
|
||||
AssertValidExceptionChain(exception, checkScriptStackTrace);
|
||||
}
|
||||
|
||||
var message = "Expected " + typeof(T1).Name + " or " + typeof(T2).Name + " was not thrown.";
|
||||
if (caughtException != null)
|
||||
{
|
||||
message += " " + caughtException.GetType().Name + " was thrown instead.";
|
||||
}
|
||||
|
||||
Assert.IsTrue(gotExpectedException, message);
|
||||
}
|
||||
|
||||
public static void AssertMethodBindException(Action action, bool checkScriptStackTrace = true)
|
||||
{
|
||||
AssertException<RuntimeBinderException, MissingMethodException>(action, checkScriptStackTrace);
|
||||
}
|
||||
|
||||
public static void AssertValidException(Exception exception)
|
||||
{
|
||||
Assert.IsFalse(string.IsNullOrWhiteSpace(exception.Message));
|
||||
|
|
|
@ -11,6 +11,6 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCopyright("(c) Microsoft Corporation")]
|
||||
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: AssemblyVersion("7.3.1")]
|
||||
[assembly: AssemblyFileVersion("7.3.1")]
|
||||
[assembly: AssemblyInformationalVersion("7.3.1")]
|
||||
[assembly: AssemblyVersion("7.3.2")]
|
||||
[assembly: AssemblyFileVersion("7.3.2")]
|
||||
[assembly: AssemblyInformationalVersion("7.3.2")]
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[ClassInitialize]
|
||||
public static void ClassInitialize(TestContext context)
|
||||
{
|
||||
guids = Enumerable.Range(0, 16).Select(index => Guid.NewGuid()).ToArray();
|
||||
guids = Enumerable.Range(0, 16).Select(_ => Guid.NewGuid()).ToArray();
|
||||
}
|
||||
|
||||
[TestInitialize]
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Microsoft.CSharp.RuntimeBinder;
|
||||
using Microsoft.ClearScript.V8;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
|
@ -74,7 +73,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("StaticMemberAccess")]
|
||||
public void StaticMemberAccess_Field_Scalar_Overflow()
|
||||
{
|
||||
TestUtil.AssertException<OverflowException>(() => engine.Execute("StaticTestClass.StaticScalarField = 54321"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("StaticTestClass.StaticScalarField = 54321"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("StaticMemberAccess")]
|
||||
|
@ -154,7 +153,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("StaticMemberAccess")]
|
||||
public void StaticMemberAccess_Property_Scalar_Overflow()
|
||||
{
|
||||
TestUtil.AssertException<OverflowException>(() => engine.Execute("StaticTestClass.StaticScalarProperty = 54321"));
|
||||
TestUtil.AssertException<ArgumentException>(() => engine.Execute("StaticTestClass.StaticScalarProperty = 54321"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("StaticMemberAccess")]
|
||||
|
@ -232,7 +231,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("StaticMemberAccess")]
|
||||
public void StaticMemberAccess_Method_NoMatchingOverload()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("StaticTestClass.StaticMethod('foo', TestEnum.Second)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("StaticTestClass.StaticMethod('foo', TestEnum.Second)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("StaticMemberAccess")]
|
||||
|
@ -244,7 +243,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("StaticMemberAccess")]
|
||||
public void StaticMemberAccess_Method_Generic_TypeArgConstraintFailure()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("StaticTestClass.StaticMethod('foo', 4, StaticTestClass)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("StaticTestClass.StaticMethod('foo', 4, StaticTestClass)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("StaticMemberAccess")]
|
||||
|
@ -256,7 +255,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("StaticMemberAccess")]
|
||||
public void StaticMemberAccess_Method_GenericRedundant_MismatchedTypeArg()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("StaticTestClass.StaticMethod(System.Int32, 'foo', 4, TestEnum.Second)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("StaticTestClass.StaticMethod(System.Int32, 'foo', 4, TestEnum.Second)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("StaticMemberAccess")]
|
||||
|
@ -268,7 +267,7 @@ namespace Microsoft.ClearScript.Test
|
|||
[TestMethod, TestCategory("StaticMemberAccess")]
|
||||
public void StaticMemberAccess_Method_GenericExplicit_MissingTypeArg()
|
||||
{
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("StaticTestClass.StaticMethod(4)"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("StaticTestClass.StaticMethod(4)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("StaticMemberAccess")]
|
||||
|
|
|
@ -468,7 +468,7 @@ namespace Microsoft.ClearScript.Test
|
|||
public void V8ScriptEngine_Interrupt()
|
||||
{
|
||||
var checkpoint = new ManualResetEvent(false);
|
||||
ThreadPool.QueueUserWorkItem(state =>
|
||||
ThreadPool.QueueUserWorkItem(_ =>
|
||||
{
|
||||
checkpoint.WaitOne();
|
||||
engine.Interrupt();
|
||||
|
@ -501,7 +501,7 @@ namespace Microsoft.ClearScript.Test
|
|||
engine.Dispose();
|
||||
engine = new V8ScriptEngine(V8ScriptEngineFlags.EnableDebugging | V8ScriptEngineFlags.AwaitDebuggerAndPauseOnStart);
|
||||
|
||||
ThreadPool.QueueUserWorkItem(state =>
|
||||
ThreadPool.QueueUserWorkItem(_ =>
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
engine.Interrupt();
|
||||
|
@ -815,7 +815,7 @@ namespace Microsoft.ClearScript.Test
|
|||
engine.Execute("list.RemoveAt(0); if (list.Count == 0) { stopEvent.Set(); }");
|
||||
};
|
||||
|
||||
var threads = Enumerable.Range(0, threadCount).Select(index => new Thread(body)).ToArray();
|
||||
var threads = Enumerable.Range(0, threadCount).Select(_ => new Thread(body)).ToArray();
|
||||
threads.ForEach(thread => thread.Start());
|
||||
|
||||
startEvent.Set();
|
||||
|
@ -1349,7 +1349,7 @@ namespace Microsoft.ClearScript.Test
|
|||
Assert.IsNotNull(exception.InnerException);
|
||||
|
||||
var hostException = exception.InnerException;
|
||||
Assert.IsInstanceOfType(hostException, typeof(RuntimeBinderException));
|
||||
Assert.IsTrue((hostException is RuntimeBinderException) || (hostException is MissingMethodException));
|
||||
TestUtil.AssertValidException(hostException);
|
||||
Assert.IsNull(hostException.InnerException);
|
||||
|
||||
|
@ -1524,7 +1524,7 @@ namespace Microsoft.ClearScript.Test
|
|||
Assert.IsNotNull(nestedException.InnerException);
|
||||
|
||||
var nestedHostException = nestedException.InnerException;
|
||||
Assert.IsInstanceOfType(nestedHostException, typeof(RuntimeBinderException));
|
||||
Assert.IsTrue((nestedHostException is RuntimeBinderException) || (nestedHostException is MissingMethodException));
|
||||
TestUtil.AssertValidException(nestedHostException);
|
||||
Assert.IsNull(nestedHostException.InnerException);
|
||||
|
||||
|
@ -2203,7 +2203,7 @@ namespace Microsoft.ClearScript.Test
|
|||
|
||||
Assert.AreSame(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
Assert.IsNull(engine.Evaluate("foo.Method(foo.WrappedNullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException, AmbiguousMatchException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
|
||||
engine.EnableNullResultWrapping = true;
|
||||
Assert.AreSame(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
|
@ -2213,7 +2213,7 @@ namespace Microsoft.ClearScript.Test
|
|||
engine.EnableNullResultWrapping = false;
|
||||
Assert.AreSame(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
Assert.IsNull(engine.Evaluate("foo.Method(foo.WrappedNullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException, AmbiguousMatchException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("V8ScriptEngine")]
|
||||
|
@ -2232,7 +2232,7 @@ namespace Microsoft.ClearScript.Test
|
|||
|
||||
Assert.AreEqual(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
Assert.IsNull(engine.Evaluate("foo.Method(foo.WrappedNullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException, AmbiguousMatchException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
|
||||
engine.EnableNullResultWrapping = true;
|
||||
Assert.AreEqual(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
|
@ -2242,7 +2242,7 @@ namespace Microsoft.ClearScript.Test
|
|||
engine.EnableNullResultWrapping = false;
|
||||
Assert.AreEqual(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
Assert.IsNull(engine.Evaluate("foo.Method(foo.WrappedNullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException, AmbiguousMatchException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("V8ScriptEngine")]
|
||||
|
@ -2261,7 +2261,7 @@ namespace Microsoft.ClearScript.Test
|
|||
|
||||
Assert.AreEqual(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
Assert.IsNull(engine.Evaluate("foo.Method(foo.WrappedNullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException, AmbiguousMatchException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
|
||||
engine.EnableNullResultWrapping = true;
|
||||
Assert.AreEqual(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
|
@ -2271,7 +2271,7 @@ namespace Microsoft.ClearScript.Test
|
|||
engine.EnableNullResultWrapping = false;
|
||||
Assert.AreEqual(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
Assert.IsNull(engine.Evaluate("foo.Method(foo.WrappedNullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException, AmbiguousMatchException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("V8ScriptEngine")]
|
||||
|
@ -2845,7 +2845,7 @@ namespace Microsoft.ClearScript.Test
|
|||
Assert.AreEqual("bar", engine.Evaluate("foo(0)"));
|
||||
|
||||
engine.Script.bar = new List<string>();
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("bar.Add(foo(0))"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("bar.Add(foo(0))"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("V8ScriptEngine")]
|
||||
|
@ -3509,7 +3509,7 @@ namespace Microsoft.ClearScript.Test
|
|||
engine.Dispose();
|
||||
engine = new V8ScriptEngine(V8ScriptEngineFlags.EnableDebugging | V8ScriptEngineFlags.AwaitDebuggerAndPauseOnStart);
|
||||
|
||||
ThreadPool.QueueUserWorkItem(state =>
|
||||
ThreadPool.QueueUserWorkItem(_ =>
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
engine.CancelAwaitDebugger();
|
||||
|
|
|
@ -447,7 +447,7 @@ namespace Microsoft.ClearScript.Test
|
|||
public void VBScriptCoreEngine_Interrupt()
|
||||
{
|
||||
var checkpoint = new ManualResetEvent(false);
|
||||
ThreadPool.QueueUserWorkItem(state =>
|
||||
ThreadPool.QueueUserWorkItem(_ =>
|
||||
{
|
||||
checkpoint.WaitOne();
|
||||
engine.Interrupt();
|
||||
|
@ -719,7 +719,7 @@ namespace Microsoft.ClearScript.Test
|
|||
Assert.IsNotNull(exception.InnerException);
|
||||
|
||||
var hostException = exception.InnerException;
|
||||
Assert.IsInstanceOfType(hostException, typeof(RuntimeBinderException));
|
||||
Assert.IsTrue((hostException is RuntimeBinderException) || (hostException is MissingMethodException));
|
||||
TestUtil.AssertValidException(hostException);
|
||||
Assert.IsNull(hostException.InnerException);
|
||||
|
||||
|
@ -820,7 +820,7 @@ namespace Microsoft.ClearScript.Test
|
|||
Assert.IsNotNull(nestedException.InnerException);
|
||||
|
||||
var nestedHostException = nestedException.InnerException;
|
||||
Assert.IsInstanceOfType(nestedHostException, typeof(RuntimeBinderException));
|
||||
Assert.IsTrue((nestedHostException is RuntimeBinderException) || (nestedHostException is MissingMethodException));
|
||||
TestUtil.AssertValidException(nestedHostException);
|
||||
Assert.IsNull(nestedHostException.InnerException);
|
||||
|
||||
|
@ -2167,7 +2167,7 @@ namespace Microsoft.ClearScript.Test
|
|||
|
||||
Assert.AreSame(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
Assert.IsNull(engine.Evaluate("foo.Method(foo.WrappedNullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException, AmbiguousMatchException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
|
||||
engine.EnableNullResultWrapping = true;
|
||||
Assert.AreSame(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
|
@ -2177,7 +2177,7 @@ namespace Microsoft.ClearScript.Test
|
|||
engine.EnableNullResultWrapping = false;
|
||||
Assert.AreSame(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
Assert.IsNull(engine.Evaluate("foo.Method(foo.WrappedNullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException, AmbiguousMatchException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("VBScriptCoreEngine")]
|
||||
|
@ -2196,7 +2196,7 @@ namespace Microsoft.ClearScript.Test
|
|||
|
||||
Assert.AreEqual(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
Assert.IsNull(engine.Evaluate("foo.Method(foo.WrappedNullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException, AmbiguousMatchException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
|
||||
engine.EnableNullResultWrapping = true;
|
||||
Assert.AreEqual(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
|
@ -2206,7 +2206,7 @@ namespace Microsoft.ClearScript.Test
|
|||
engine.EnableNullResultWrapping = false;
|
||||
Assert.AreEqual(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
Assert.IsNull(engine.Evaluate("foo.Method(foo.WrappedNullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException, AmbiguousMatchException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("VBScriptCoreEngine")]
|
||||
|
@ -2225,7 +2225,7 @@ namespace Microsoft.ClearScript.Test
|
|||
|
||||
Assert.AreEqual(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
Assert.IsNull(engine.Evaluate("foo.Method(foo.WrappedNullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException, AmbiguousMatchException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
|
||||
engine.EnableNullResultWrapping = true;
|
||||
Assert.AreEqual(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
|
@ -2235,7 +2235,7 @@ namespace Microsoft.ClearScript.Test
|
|||
engine.EnableNullResultWrapping = false;
|
||||
Assert.AreEqual(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
Assert.IsNull(engine.Evaluate("foo.Method(foo.WrappedNullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException, AmbiguousMatchException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("VBScriptCoreEngine")]
|
||||
|
@ -2455,7 +2455,7 @@ namespace Microsoft.ClearScript.Test
|
|||
|
||||
engine.Script.listDict = new ListDictionary { { "abc", 123 }, { "def", 456 }, { "ghi", 789 } };
|
||||
Assert.AreEqual(3, engine.Evaluate("listDict.Count"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("listDict.Count()"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Evaluate("listDict.Count()"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("VBScriptCoreEngine")]
|
||||
|
@ -2554,7 +2554,7 @@ namespace Microsoft.ClearScript.Test
|
|||
Assert.AreEqual("baz", engine.Evaluate("foo(0)"));
|
||||
|
||||
engine.Script.bar = new List<string>();
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("bar.Add(foo(0))"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("bar.Add(foo(0))"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("VBScriptCoreEngine")]
|
||||
|
|
|
@ -718,7 +718,7 @@ namespace Microsoft.ClearScript.Test
|
|||
Assert.IsNotNull(exception.InnerException);
|
||||
|
||||
var hostException = exception.InnerException;
|
||||
Assert.IsInstanceOfType(hostException, typeof(RuntimeBinderException));
|
||||
Assert.IsTrue((hostException is RuntimeBinderException) || (hostException is MissingMethodException));
|
||||
TestUtil.AssertValidException(hostException);
|
||||
Assert.IsNull(hostException.InnerException);
|
||||
|
||||
|
@ -819,7 +819,7 @@ namespace Microsoft.ClearScript.Test
|
|||
Assert.IsNotNull(nestedException.InnerException);
|
||||
|
||||
var nestedHostException = nestedException.InnerException;
|
||||
Assert.IsInstanceOfType(nestedHostException, typeof(RuntimeBinderException));
|
||||
Assert.IsTrue((nestedHostException is RuntimeBinderException) || (nestedHostException is MissingMethodException));
|
||||
TestUtil.AssertValidException(nestedHostException);
|
||||
Assert.IsNull(nestedHostException.InnerException);
|
||||
|
||||
|
@ -2227,7 +2227,7 @@ namespace Microsoft.ClearScript.Test
|
|||
|
||||
Assert.AreSame(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
Assert.IsNull(engine.Evaluate("foo.Method(foo.WrappedNullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException, AmbiguousMatchException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
|
||||
engine.EnableNullResultWrapping = true;
|
||||
Assert.AreSame(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
|
@ -2237,7 +2237,7 @@ namespace Microsoft.ClearScript.Test
|
|||
engine.EnableNullResultWrapping = false;
|
||||
Assert.AreSame(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
Assert.IsNull(engine.Evaluate("foo.Method(foo.WrappedNullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException, AmbiguousMatchException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("VBScriptEngine")]
|
||||
|
@ -2256,7 +2256,7 @@ namespace Microsoft.ClearScript.Test
|
|||
|
||||
Assert.AreEqual(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
Assert.IsNull(engine.Evaluate("foo.Method(foo.WrappedNullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException, AmbiguousMatchException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
|
||||
engine.EnableNullResultWrapping = true;
|
||||
Assert.AreEqual(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
|
@ -2266,7 +2266,7 @@ namespace Microsoft.ClearScript.Test
|
|||
engine.EnableNullResultWrapping = false;
|
||||
Assert.AreEqual(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
Assert.IsNull(engine.Evaluate("foo.Method(foo.WrappedNullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException, AmbiguousMatchException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("VBScriptEngine")]
|
||||
|
@ -2285,7 +2285,7 @@ namespace Microsoft.ClearScript.Test
|
|||
|
||||
Assert.AreEqual(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
Assert.IsNull(engine.Evaluate("foo.Method(foo.WrappedNullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException, AmbiguousMatchException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
|
||||
engine.EnableNullResultWrapping = true;
|
||||
Assert.AreEqual(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
|
@ -2295,7 +2295,7 @@ namespace Microsoft.ClearScript.Test
|
|||
engine.EnableNullResultWrapping = false;
|
||||
Assert.AreEqual(testValue, engine.Evaluate("foo.Method(foo.Value)"));
|
||||
Assert.IsNull(engine.Evaluate("foo.Method(foo.WrappedNullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
TestUtil.AssertException<RuntimeBinderException, AmbiguousMatchException>(() => engine.Evaluate("foo.Method(foo.NullValue)"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("VBScriptEngine")]
|
||||
|
@ -2515,7 +2515,7 @@ namespace Microsoft.ClearScript.Test
|
|||
|
||||
engine.Script.listDict = new ListDictionary { { "abc", 123 }, { "def", 456 }, { "ghi", 789 } };
|
||||
Assert.AreEqual(3, engine.Evaluate("listDict.Count"));
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Evaluate("listDict.Count()"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Evaluate("listDict.Count()"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("VBScriptEngine")]
|
||||
|
@ -2614,7 +2614,7 @@ namespace Microsoft.ClearScript.Test
|
|||
Assert.AreEqual("baz", engine.Evaluate("foo(0)"));
|
||||
|
||||
engine.Script.bar = new List<string>();
|
||||
TestUtil.AssertException<RuntimeBinderException>(() => engine.Execute("bar.Add(foo(0))"));
|
||||
TestUtil.AssertMethodBindException(() => engine.Execute("bar.Add(foo(0))"));
|
||||
}
|
||||
|
||||
[TestMethod, TestCategory("VBScriptEngine")]
|
||||
|
|
|
@ -11,14 +11,28 @@ class V8Context: public WeakRefTarget<V8Context>, public IV8Entity
|
|||
{
|
||||
public:
|
||||
|
||||
enum class Flags : int32_t
|
||||
{
|
||||
// IMPORTANT: maintain bitwise equivalence with managed enum V8.V8ScriptEngineFlags
|
||||
None = 0,
|
||||
EnableDebugging = 0x00000001,
|
||||
DisableGlobalMembers = 0x00000002,
|
||||
EnableRemoteDebugging = 0x00000004,
|
||||
AwaitDebuggerAndPauseOnStart = 0x00000008,
|
||||
EnableDateTimeConversion = 0x00000010,
|
||||
EnableDynamicModuleImports = 0x00000020,
|
||||
MarshalUnsafeLongAsBigInt = 0x00000040,
|
||||
MarshalAllLongAsBigInt = 0x00000080,
|
||||
EnableTaskPromiseConversion = 0x00000100,
|
||||
EnableValueTaskPromiseConversion = 0x00000200,
|
||||
UseCaseInsensitiveMemberBinding = 0x00000400,
|
||||
EnableStringifyEnhancements = 0x00000800,
|
||||
HideHostExceptions = 0x00001000
|
||||
};
|
||||
|
||||
struct Options final
|
||||
{
|
||||
bool EnableDebugging = false;
|
||||
bool EnableRemoteDebugging = false;
|
||||
bool DisableGlobalMembers = true;
|
||||
bool EnableDateTimeConversion = false;
|
||||
bool EnableDynamicModuleImports = false;
|
||||
bool HideHostExceptions = false;
|
||||
Flags Flags = Flags::None;
|
||||
int DebugPort = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -229,8 +229,8 @@ V8ContextImpl::V8ContextImpl(V8IsolateImpl* pIsolateImpl, const StdString& name)
|
|||
V8ContextImpl::V8ContextImpl(SharedPtr<V8IsolateImpl>&& spIsolateImpl, const StdString& name, const Options& options):
|
||||
m_Name(name),
|
||||
m_spIsolateImpl(std::move(spIsolateImpl)),
|
||||
m_DateTimeConversionEnabled(options.EnableDateTimeConversion),
|
||||
m_HideHostExceptions(options.HideHostExceptions),
|
||||
m_DateTimeConversionEnabled(HasFlag(options.Flags, Flags::EnableDateTimeConversion)),
|
||||
m_HideHostExceptions(HasFlag(options.Flags, Flags::HideHostExceptions)),
|
||||
m_pvV8ObjectCache(nullptr),
|
||||
m_AllowHostObjectConstructorCall(false)
|
||||
{
|
||||
|
@ -239,7 +239,7 @@ V8ContextImpl::V8ContextImpl(SharedPtr<V8IsolateImpl>&& spIsolateImpl, const Std
|
|||
BEGIN_ISOLATE_SCOPE
|
||||
FROM_MAYBE_TRY
|
||||
|
||||
if (options.DisableGlobalMembers)
|
||||
if (HasFlag(options.Flags, Flags::DisableGlobalMembers))
|
||||
{
|
||||
m_hContext = CreatePersistent(CreateContext());
|
||||
}
|
||||
|
|
|
@ -22,13 +22,20 @@ public:
|
|||
Count
|
||||
};
|
||||
|
||||
enum class Flags : int32_t
|
||||
{
|
||||
// IMPORTANT: maintain bitwise equivalence with managed enum V8.V8RuntimeFlags
|
||||
None = 0,
|
||||
EnableDebugging = 0x00000001,
|
||||
EnableRemoteDebugging = 0x00000002,
|
||||
EnableDynamicModuleImports = 0x00000004
|
||||
};
|
||||
|
||||
struct Options final
|
||||
{
|
||||
double HeapExpansionMultiplier = 0;
|
||||
size_t MaxArrayBufferAllocation = SIZE_MAX;
|
||||
bool EnableDebugging = false;
|
||||
bool EnableRemoteDebugging = false;
|
||||
bool EnableDynamicModuleImports = false;
|
||||
Flags Flags = Flags::None;
|
||||
int DebugPort = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -55,7 +55,6 @@ void V8Platform::EnsureInitialized()
|
|||
m_InitializationFlag.CallOnce([this]
|
||||
{
|
||||
v8::V8::InitializePlatform(&ms_Instance);
|
||||
ASSERT_EVAL(v8::V8::Initialize());
|
||||
|
||||
m_GlobalFlags = V8_SPLIT_PROXY_MANAGED_INVOKE_NOTHROW(V8GlobalFlags, GetGlobalFlags);
|
||||
std::vector<std::string> flagStrings;
|
||||
|
@ -68,17 +67,22 @@ void V8Platform::EnsureInitialized()
|
|||
}
|
||||
|
||||
#endif // CLEARSCRIPT_TOP_LEVEL_AWAIT_CONTROL
|
||||
|
||||
|
||||
#if defined(__APPLE__) && defined(__arm64__)
|
||||
|
||||
// WORKAROUND: On Apple M1 only, our lone WebAssembly test crashes consistently unless this
|
||||
// option is disabled. The crash is indicative of corruption within the SplitProxyManaged
|
||||
// pointer table or of its address in thread-local storage.
|
||||
|
||||
// UPDATE: The crash is probably not due to method table corruption but V8's use of
|
||||
// pthread_jit_write_protect_np in its WebAssembly code. If the thread's JIT protection
|
||||
// state is writable (vs. executable) when V8 calls the embedder, any attempt to invoke
|
||||
// managed code will trigger a bus error.
|
||||
|
||||
flagStrings.push_back("--no_wasm_async_compilation");
|
||||
|
||||
#endif // defined(__APPLE__) && defined(__arm64__)
|
||||
|
||||
|
||||
if (HasFlag(m_GlobalFlags, V8GlobalFlags::DisableJITCompilation))
|
||||
{
|
||||
flagStrings.push_back("--jitless");
|
||||
|
@ -100,6 +104,8 @@ void V8Platform::EnsureInitialized()
|
|||
|
||||
v8::V8::SetFlagsFromString(flagsString.c_str(), flagsString.length());
|
||||
}
|
||||
|
||||
ASSERT_EVAL(v8::V8::Initialize());
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -507,13 +513,13 @@ V8IsolateImpl::V8IsolateImpl(const StdString& name, const v8::ResourceConstraint
|
|||
|
||||
m_hHostObjectHolderKey = CreatePersistent(CreatePrivate());
|
||||
|
||||
if (options.EnableDebugging)
|
||||
if (HasFlag(options.Flags, Flags::EnableDebugging))
|
||||
{
|
||||
EnableDebugging(options.DebugPort, options.EnableRemoteDebugging);
|
||||
EnableDebugging(options.DebugPort, HasFlag(options.Flags, Flags::EnableRemoteDebugging));
|
||||
}
|
||||
|
||||
m_upIsolate->SetHostInitializeImportMetaObjectCallback(ImportMetaInitializeCallback);
|
||||
if (options.EnableDynamicModuleImports)
|
||||
if (HasFlag(options.Flags, Flags::EnableDynamicModuleImports))
|
||||
{
|
||||
m_upIsolate->SetHostImportModuleDynamicallyCallback(ModuleImportCallback);
|
||||
}
|
||||
|
@ -546,17 +552,17 @@ void V8IsolateImpl::AddContext(V8ContextImpl* pContextImpl, const V8Context::Opt
|
|||
{
|
||||
_ASSERTE(IsCurrent() && IsLocked());
|
||||
|
||||
if (!options.EnableDebugging)
|
||||
if (!HasFlag(options.Flags, V8Context::Flags::EnableDebugging))
|
||||
{
|
||||
m_ContextEntries.emplace_back(pContextImpl);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ContextEntries.emplace_front(pContextImpl);
|
||||
EnableDebugging(options.DebugPort, options.EnableRemoteDebugging);
|
||||
EnableDebugging(options.DebugPort, HasFlag(options.Flags, V8Context::Flags::EnableRemoteDebugging));
|
||||
}
|
||||
|
||||
if (options.EnableDynamicModuleImports)
|
||||
if (HasFlag(options.Flags, V8Context::Flags::EnableDynamicModuleImports))
|
||||
{
|
||||
m_upIsolate->SetHostImportModuleDynamicallyCallback(ModuleImportCallback);
|
||||
}
|
||||
|
|
|
@ -684,7 +684,7 @@ NATIVE_ENTRY_POINT(const v8::CpuProfileNode*) V8CpuProfileNode_GetChildNode(cons
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
NATIVE_ENTRY_POINT(V8IsolateHandle*) V8Isolate_Create(const StdString& name, int32_t maxNewSpaceSize, int32_t maxOldSpaceSize, double heapExpansionMultiplier, uint64_t maxArrayBufferAllocation, StdBool enableDebugging, StdBool enableRemoteDebugging, StdBool enableDynamicModuleImports, int32_t debugPort) noexcept
|
||||
NATIVE_ENTRY_POINT(V8IsolateHandle*) V8Isolate_Create(const StdString& name, int32_t maxNewSpaceSize, int32_t maxOldSpaceSize, double heapExpansionMultiplier, uint64_t maxArrayBufferAllocation, V8Isolate::Flags flags, int32_t debugPort) noexcept
|
||||
{
|
||||
v8::ResourceConstraints* pConstraints = nullptr;
|
||||
|
||||
|
@ -698,9 +698,7 @@ NATIVE_ENTRY_POINT(V8IsolateHandle*) V8Isolate_Create(const StdString& name, int
|
|||
|
||||
V8Isolate::Options options;
|
||||
options.HeapExpansionMultiplier = heapExpansionMultiplier;
|
||||
options.EnableDebugging = enableDebugging;
|
||||
options.EnableRemoteDebugging = enableRemoteDebugging;
|
||||
options.EnableDynamicModuleImports = enableDynamicModuleImports;
|
||||
options.Flags = flags;
|
||||
options.DebugPort = debugPort;
|
||||
|
||||
if (maxArrayBufferAllocation < SIZE_MAX)
|
||||
|
@ -721,18 +719,13 @@ NATIVE_ENTRY_POINT(V8IsolateHandle*) V8Isolate_Create(const StdString& name, int
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
NATIVE_ENTRY_POINT(V8ContextHandle*) V8Isolate_CreateContext(const V8IsolateHandle& handle, const StdString& name, StdBool enableDebugging, StdBool enableRemoteDebugging, StdBool disableGlobalMembers, StdBool enableDateTimeConversion, StdBool enableDynamicModuleImports, StdBool hideHostExceptions, int32_t debugPort) noexcept
|
||||
NATIVE_ENTRY_POINT(V8ContextHandle*) V8Isolate_CreateContext(const V8IsolateHandle& handle, const StdString& name, V8Context::Flags flags, int32_t debugPort) noexcept
|
||||
{
|
||||
auto spIsolate = handle.GetEntity();
|
||||
if (!spIsolate.IsEmpty())
|
||||
{
|
||||
V8Context::Options options;
|
||||
options.EnableDebugging = enableDebugging;
|
||||
options.EnableRemoteDebugging = enableRemoteDebugging;
|
||||
options.DisableGlobalMembers = disableGlobalMembers;
|
||||
options.EnableDateTimeConversion = enableDateTimeConversion;
|
||||
options.EnableDynamicModuleImports = enableDynamicModuleImports;
|
||||
options.HideHostExceptions = hideHostExceptions;
|
||||
options.Flags = flags;
|
||||
options.DebugPort = debugPort;
|
||||
|
||||
try
|
||||
|
|
|
@ -229,8 +229,8 @@ NATIVE_ENTRY_POINT(void) V8CpuProfileNode_GetInfo(const v8::CpuProfileNode& node
|
|||
NATIVE_ENTRY_POINT(StdBool) V8CpuProfileNode_GetHitLines(const v8::CpuProfileNode& node, std::vector<int32_t>& lineNumbers, std::vector<uint32_t>& hitCounts) noexcept;
|
||||
NATIVE_ENTRY_POINT(const v8::CpuProfileNode*) V8CpuProfileNode_GetChildNode(const v8::CpuProfileNode& node, int32_t index) noexcept;
|
||||
|
||||
NATIVE_ENTRY_POINT(V8IsolateHandle*) V8Isolate_Create(const StdString& name, int32_t maxNewSpaceSize, int32_t maxOldSpaceSize, double heapExpansionMultiplier, uint64_t maxArrayBufferAllocation, StdBool enableDebugging, StdBool enableRemoteDebugging, StdBool enableDynamicModuleImports, int32_t debugPort) noexcept;
|
||||
NATIVE_ENTRY_POINT(V8ContextHandle*) V8Isolate_CreateContext(const V8IsolateHandle& handle, const StdString& name, StdBool enableDebugging, StdBool enableRemoteDebugging, StdBool disableGlobalMembers, StdBool enableDateTimeConversion, StdBool enableDynamicModuleImports, StdBool hideHostExceptions, int32_t debugPort) noexcept;
|
||||
NATIVE_ENTRY_POINT(V8IsolateHandle*) V8Isolate_Create(const StdString& name, int32_t maxNewSpaceSize, int32_t maxOldSpaceSize, double heapExpansionMultiplier, uint64_t maxArrayBufferAllocation, V8Isolate::Flags flags, int32_t debugPort) noexcept;
|
||||
NATIVE_ENTRY_POINT(V8ContextHandle*) V8Isolate_CreateContext(const V8IsolateHandle& handle, const StdString& name, V8Context::Flags flags, int32_t debugPort) noexcept;
|
||||
NATIVE_ENTRY_POINT(size_t) V8Isolate_GetMaxHeapSize(const V8IsolateHandle& handle) noexcept;
|
||||
NATIVE_ENTRY_POINT(void) V8Isolate_SetMaxHeapSize(const V8IsolateHandle& handle, size_t size) noexcept;
|
||||
NATIVE_ENTRY_POINT(double) V8Isolate_GetHeapSizeSampleInterval(const V8IsolateHandle& handle) noexcept;
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:schemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeInspection/CSharpLanguageProject/LanguageLevel/@EntryValue">Default</s:String></wpf:ResourceDictionary>
|
|
@ -1,2 +0,0 @@
|
|||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:schemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeInspection/CSharpLanguageProject/LanguageLevel/@EntryValue">Default</s:String></wpf:ResourceDictionary>
|
|
@ -1,2 +0,0 @@
|
|||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:schemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeInspection/CSharpLanguageProject/LanguageLevel/@EntryValue">Default</s:String></wpf:ResourceDictionary>
|
|
@ -1,2 +0,0 @@
|
|||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:schemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeInspection/CSharpLanguageProject/LanguageLevel/@EntryValue">Default</s:String></wpf:ResourceDictionary>
|
|
@ -1,2 +0,0 @@
|
|||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:schemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeInspection/CSharpLanguageProject/LanguageLevel/@EntryValue">Default</s:String></wpf:ResourceDictionary>
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
v8testedrev=10.3.174.17
|
||||
v8testedrev=10.5.218.8
|
||||
v8testedcommit=
|
||||
v8cherrypicks=
|
||||
v8linuxbuildcommit=3d9590754d5d23e62d15472c5baf6777ca59df20
|
||||
|
|
143
V8/V8Patch.txt
143
V8/V8Patch.txt
|
@ -1,8 +1,8 @@
|
|||
diff --git a/BUILD.gn b/BUILD.gn
|
||||
index 9ddff70ab9..10cbbd27e2 100644
|
||||
index 686fac5385..1193982dba 100644
|
||||
--- a/BUILD.gn
|
||||
+++ b/BUILD.gn
|
||||
@@ -1021,7 +1021,7 @@ config("toolchain") {
|
||||
@@ -1057,7 +1057,7 @@ config("toolchain") {
|
||||
visibility = [ "./*" ]
|
||||
|
||||
defines = []
|
||||
|
@ -11,8 +11,21 @@ index 9ddff70ab9..10cbbd27e2 100644
|
|||
ldflags = []
|
||||
|
||||
if (v8_current_cpu == "arm") {
|
||||
diff --git a/include/cppgc/internal/write-barrier.h b/include/cppgc/internal/write-barrier.h
|
||||
index d68269dd4f..4d4fde6873 100644
|
||||
--- a/include/cppgc/internal/write-barrier.h
|
||||
+++ b/include/cppgc/internal/write-barrier.h
|
||||
@@ -92,7 +92,7 @@ class V8_EXPORT WriteBarrier final {
|
||||
#else // !CPPGC_YOUNG_GENERATION
|
||||
template <GenerationalBarrierType>
|
||||
static V8_INLINE void GenerationalBarrier(const Params& params,
|
||||
- const void* slot){};
|
||||
+ const void* slot){}
|
||||
#endif // CPPGC_YOUNG_GENERATION
|
||||
|
||||
#if V8_ENABLE_CHECKS
|
||||
diff --git a/include/v8-initialization.h b/include/v8-initialization.h
|
||||
index 48c7fb6b48..31e1668098 100644
|
||||
index 66adf98c17..4f7f157372 100644
|
||||
--- a/include/v8-initialization.h
|
||||
+++ b/include/v8-initialization.h
|
||||
@@ -139,6 +139,7 @@ class V8_EXPORT V8 {
|
||||
|
@ -24,10 +37,10 @@ index 48c7fb6b48..31e1668098 100644
|
|||
/**
|
||||
* Initialize the ICU library bundled with V8. The embedder should only
|
||||
diff --git a/include/v8-template.h b/include/v8-template.h
|
||||
index 0afdccaafb..3d2893e43e 100644
|
||||
index 669012a981..b19ea9c824 100644
|
||||
--- a/include/v8-template.h
|
||||
+++ b/include/v8-template.h
|
||||
@@ -975,6 +975,9 @@ class V8_EXPORT ObjectTemplate : public Template {
|
||||
@@ -937,6 +937,9 @@ class V8_EXPORT ObjectTemplate : public Template {
|
||||
*/
|
||||
void SetImmutableProto();
|
||||
|
||||
|
@ -38,10 +51,10 @@ index 0afdccaafb..3d2893e43e 100644
|
|||
* Support for TC39 "dynamic code brand checks" proposal.
|
||||
*
|
||||
diff --git a/src/api/api-natives.cc b/src/api/api-natives.cc
|
||||
index 29b94d8dea..5d8a605958 100644
|
||||
index 562b7849b4..f585106ffd 100644
|
||||
--- a/src/api/api-natives.cc
|
||||
+++ b/src/api/api-natives.cc
|
||||
@@ -446,6 +446,9 @@ MaybeHandle<JSObject> InstantiateObject(Isolate* isolate,
|
||||
@@ -443,6 +443,9 @@ MaybeHandle<JSObject> InstantiateObject(Isolate* isolate,
|
||||
if (info->immutable_proto()) {
|
||||
JSObject::SetImmutableProto(object);
|
||||
}
|
||||
|
@ -52,10 +65,10 @@ index 29b94d8dea..5d8a605958 100644
|
|||
// Keep prototypes in slow-mode. Let them be lazily turned fast later on.
|
||||
// TODO(dcarney): is this necessary?
|
||||
diff --git a/src/api/api.cc b/src/api/api.cc
|
||||
index 8423f288ef..aabaef39d3 100644
|
||||
index bbab4c72ac..6aeaa320dd 100644
|
||||
--- a/src/api/api.cc
|
||||
+++ b/src/api/api.cc
|
||||
@@ -2000,6 +2000,17 @@ void ObjectTemplate::SetImmutableProto() {
|
||||
@@ -1964,6 +1964,17 @@ void ObjectTemplate::SetImmutableProto() {
|
||||
self->set_immutable_proto(true);
|
||||
}
|
||||
|
||||
|
@ -73,7 +86,7 @@ index 8423f288ef..aabaef39d3 100644
|
|||
bool ObjectTemplate::IsCodeLike() const {
|
||||
return Utils::OpenHandle(this)->code_like();
|
||||
}
|
||||
@@ -6198,6 +6209,10 @@ bool v8::V8::InitializeICU(const char* icu_data_file) {
|
||||
@@ -6236,6 +6247,10 @@ bool v8::V8::InitializeICU(const char* icu_data_file) {
|
||||
return i::InitializeICU(icu_data_file);
|
||||
}
|
||||
|
||||
|
@ -114,24 +127,24 @@ index ac010509bd..2da5a0ae61 100644
|
|||
#if V8_CC_MSVC && V8_HOST_ARCH_IA32
|
||||
// __readfsdword is supposed to be declared in intrin.h but it is missing from
|
||||
diff --git a/src/builtins/builtins-async-module.cc b/src/builtins/builtins-async-module.cc
|
||||
index 1d7b6fc766..a085edec59 100644
|
||||
index 417e6f1dfa..108dc20972 100644
|
||||
--- a/src/builtins/builtins-async-module.cc
|
||||
+++ b/src/builtins/builtins-async-module.cc
|
||||
@@ -15,7 +15,8 @@ BUILTIN(CallAsyncModuleFulfilled) {
|
||||
SourceTextModule::cast(isolate->context().get(
|
||||
SourceTextModule::ExecuteAsyncModuleContextSlots::kModule)),
|
||||
isolate);
|
||||
- SourceTextModule::AsyncModuleExecutionFulfilled(isolate, module);
|
||||
- if (SourceTextModule::AsyncModuleExecutionFulfilled(isolate, module)
|
||||
+ Handle<Object> result(args.at(1));
|
||||
+ SourceTextModule::AsyncModuleExecutionFulfilled(isolate, module, result);
|
||||
return ReadOnlyRoots(isolate).undefined_value();
|
||||
}
|
||||
|
||||
+ if (SourceTextModule::AsyncModuleExecutionFulfilled(isolate, module, result)
|
||||
.IsNothing()) {
|
||||
// The evaluation of async module can not throwing a JavaScript observable
|
||||
// exception.
|
||||
diff --git a/src/codegen/code-stub-assembler.cc b/src/codegen/code-stub-assembler.cc
|
||||
index 5df5842692..6da81107da 100644
|
||||
index a984d2ce73..be78caa6b1 100644
|
||||
--- a/src/codegen/code-stub-assembler.cc
|
||||
+++ b/src/codegen/code-stub-assembler.cc
|
||||
@@ -1898,6 +1898,10 @@ TNode<Uint32T> CodeStubAssembler::LoadMapBitField3(TNode<Map> map) {
|
||||
@@ -1841,6 +1841,10 @@ TNode<Uint32T> CodeStubAssembler::LoadMapBitField3(TNode<Map> map) {
|
||||
return LoadObjectField<Uint32T>(map, Map::kBitField3Offset);
|
||||
}
|
||||
|
||||
|
@ -142,7 +155,7 @@ index 5df5842692..6da81107da 100644
|
|||
TNode<Uint16T> CodeStubAssembler::LoadMapInstanceType(TNode<Map> map) {
|
||||
return LoadObjectField<Uint16T>(map, Map::kInstanceTypeOffset);
|
||||
}
|
||||
@@ -13644,6 +13648,11 @@ TNode<String> CodeStubAssembler::Typeof(TNode<Object> value) {
|
||||
@@ -13638,6 +13642,11 @@ TNode<String> CodeStubAssembler::Typeof(TNode<Object> value) {
|
||||
|
||||
GotoIf(InstanceTypeEqual(instance_type, ODDBALL_TYPE), &if_oddball);
|
||||
|
||||
|
@ -155,10 +168,10 @@ index 5df5842692..6da81107da 100644
|
|||
Word32And(LoadMapBitField(map),
|
||||
Int32Constant(Map::Bits1::IsCallableBit::kMask |
|
||||
diff --git a/src/codegen/code-stub-assembler.h b/src/codegen/code-stub-assembler.h
|
||||
index 30bbd9c732..ecfc83d732 100644
|
||||
index 9633ba5333..26dde448bb 100644
|
||||
--- a/src/codegen/code-stub-assembler.h
|
||||
+++ b/src/codegen/code-stub-assembler.h
|
||||
@@ -1404,6 +1404,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
|
||||
@@ -1388,6 +1388,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
|
||||
TNode<Int32T> LoadMapBitField2(TNode<Map> map);
|
||||
// Load bit field 3 of a map.
|
||||
TNode<Uint32T> LoadMapBitField3(TNode<Map> map);
|
||||
|
@ -167,8 +180,21 @@ index 30bbd9c732..ecfc83d732 100644
|
|||
// Load the instance type of a map.
|
||||
TNode<Uint16T> LoadMapInstanceType(TNode<Map> map);
|
||||
// Load the ElementsKind of a map.
|
||||
diff --git a/src/common/globals.h b/src/common/globals.h
|
||||
index b17792f6e0..957795294f 100644
|
||||
--- a/src/common/globals.h
|
||||
+++ b/src/common/globals.h
|
||||
@@ -193,7 +193,7 @@ using CodeT = Code;
|
||||
//
|
||||
#if V8_HAS_PTHREAD_JIT_WRITE_PROTECT && \
|
||||
!(defined(V8_COMPRESS_POINTERS) && !defined(V8_EXTERNAL_CODE_SPACE))
|
||||
-#define V8_HEAP_USE_PTHREAD_JIT_WRITE_PROTECT true
|
||||
+#define V8_HEAP_USE_PTHREAD_JIT_WRITE_PROTECT false
|
||||
#else
|
||||
#define V8_HEAP_USE_PTHREAD_JIT_WRITE_PROTECT false
|
||||
#endif
|
||||
diff --git a/src/diagnostics/unwinding-info-win64.cc b/src/diagnostics/unwinding-info-win64.cc
|
||||
index d50767421a..f3fa0f3a70 100644
|
||||
index 4a70a28478..420eff5a33 100644
|
||||
--- a/src/diagnostics/unwinding-info-win64.cc
|
||||
+++ b/src/diagnostics/unwinding-info-win64.cc
|
||||
@@ -463,6 +463,14 @@ void InitUnwindingRecord(Record* record, size_t code_size_in_bytes) {
|
||||
|
@ -247,10 +273,10 @@ index d50767421a..f3fa0f3a70 100644
|
|||
// Unprotect reserved page.
|
||||
DWORD old_protect;
|
||||
diff --git a/src/execution/isolate.h b/src/execution/isolate.h
|
||||
index f075555ba4..f48edc88a0 100644
|
||||
index 1b6e86c7c0..79dc89f0d6 100644
|
||||
--- a/src/execution/isolate.h
|
||||
+++ b/src/execution/isolate.h
|
||||
@@ -635,7 +635,6 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory {
|
||||
@@ -667,7 +667,6 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory {
|
||||
// Returns the isolate inside which the current thread is running.
|
||||
V8_INLINE static Isolate* Current() {
|
||||
Isolate* isolate = TryGetCurrent();
|
||||
|
@ -275,10 +301,10 @@ index 90e46ea793..cf38c2d7f4 100644
|
|||
set_jslimit(SimulatorStack::JsLimitFromCLimit(isolate, limit));
|
||||
real_climit_ = limit;
|
||||
diff --git a/src/heap/factory.cc b/src/heap/factory.cc
|
||||
index 32e5309881..8fcacabb42 100644
|
||||
index 3d7a767c0c..3012071ee7 100644
|
||||
--- a/src/heap/factory.cc
|
||||
+++ b/src/heap/factory.cc
|
||||
@@ -1874,6 +1874,7 @@ Map Factory::InitializeMap(Map map, InstanceType type, int instance_size,
|
||||
@@ -2056,6 +2056,7 @@ Map Factory::InitializeMap(Map map, InstanceType type, int instance_size,
|
||||
Map::Bits3::ConstructionCounterBits::encode(Map::kNoSlackTracking) |
|
||||
Map::Bits3::IsExtensibleBit::encode(true);
|
||||
map.set_bit_field3(bit_field3);
|
||||
|
@ -287,7 +313,7 @@ index 32e5309881..8fcacabb42 100644
|
|||
ReadOnlyRoots ro_roots(roots);
|
||||
HeapObject raw_null_value = ro_roots.null_value();
|
||||
diff --git a/src/heap/setup-heap-internal.cc b/src/heap/setup-heap-internal.cc
|
||||
index 2b005732e8..7fd32c09ee 100644
|
||||
index 0e86540d0a..2f6a1df2b1 100644
|
||||
--- a/src/heap/setup-heap-internal.cc
|
||||
+++ b/src/heap/setup-heap-internal.cc
|
||||
@@ -181,6 +181,7 @@ AllocationResult Heap::AllocatePartialMap(InstanceType instance_type,
|
||||
|
@ -351,10 +377,10 @@ index e127e75f10..b0e4bd2d68 100644
|
|||
// Like above, but using the default icudt[lb].dat location if icu_data_file is
|
||||
// not specified.
|
||||
diff --git a/src/init/v8.cc b/src/init/v8.cc
|
||||
index 87baefd277..50a27d3b4d 100644
|
||||
index e45a79c079..45c9bc445c 100644
|
||||
--- a/src/init/v8.cc
|
||||
+++ b/src/init/v8.cc
|
||||
@@ -89,7 +89,6 @@ V8_DECLARE_ONCE(init_snapshot_once);
|
||||
@@ -92,7 +92,6 @@ V8_DECLARE_ONCE(init_snapshot_once);
|
||||
|
||||
void V8::InitializePlatform(v8::Platform* platform) {
|
||||
AdvanceStartupState(V8StartupState::kPlatformInitializing);
|
||||
|
@ -363,7 +389,7 @@ index 87baefd277..50a27d3b4d 100644
|
|||
platform_ = platform;
|
||||
v8::base::SetPrintStackTrace(platform_->GetStackTracePrinter());
|
||||
diff --git a/src/objects/intl-objects.h b/src/objects/intl-objects.h
|
||||
index c136479388..2ce7e172f7 100644
|
||||
index 4fbfe349da..30c3df9db2 100644
|
||||
--- a/src/objects/intl-objects.h
|
||||
+++ b/src/objects/intl-objects.h
|
||||
@@ -285,7 +285,7 @@ class Intl {
|
||||
|
@ -376,7 +402,7 @@ index c136479388..2ce7e172f7 100644
|
|||
std::vector<std::string> all_locales;
|
||||
const char* loc;
|
||||
diff --git a/src/objects/js-date-time-format.cc b/src/objects/js-date-time-format.cc
|
||||
index 955370b7ba..f501148e16 100644
|
||||
index 2aeb62e668..61531327d6 100644
|
||||
--- a/src/objects/js-date-time-format.cc
|
||||
+++ b/src/objects/js-date-time-format.cc
|
||||
@@ -1583,8 +1583,12 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::New(
|
||||
|
@ -394,10 +420,10 @@ index 955370b7ba..f501148e16 100644
|
|||
if (maybe_resolve_locale.IsNothing()) {
|
||||
THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kIcuError),
|
||||
diff --git a/src/objects/js-objects.cc b/src/objects/js-objects.cc
|
||||
index b606f87633..b4f4379ac6 100644
|
||||
index aa185c71c0..1196d88987 100644
|
||||
--- a/src/objects/js-objects.cc
|
||||
+++ b/src/objects/js-objects.cc
|
||||
@@ -5069,6 +5069,13 @@ void JSObject::SetImmutableProto(Handle<JSObject> object) {
|
||||
@@ -5095,6 +5095,13 @@ void JSObject::SetImmutableProto(Handle<JSObject> object) {
|
||||
object->set_map(*new_map, kReleaseStore);
|
||||
}
|
||||
|
||||
|
@ -412,10 +438,10 @@ index b606f87633..b4f4379ac6 100644
|
|||
JavaScriptArguments* args,
|
||||
uint32_t arg_count,
|
||||
diff --git a/src/objects/js-objects.h b/src/objects/js-objects.h
|
||||
index 0a2773b127..79a2edada4 100644
|
||||
index 002c9d0500..1be07053b7 100644
|
||||
--- a/src/objects/js-objects.h
|
||||
+++ b/src/objects/js-objects.h
|
||||
@@ -730,6 +730,8 @@ class JSObject : public TorqueGeneratedJSObject<JSObject, JSReceiver> {
|
||||
@@ -732,6 +732,8 @@ class JSObject : public TorqueGeneratedJSObject<JSObject, JSReceiver> {
|
||||
// Never called from JavaScript
|
||||
static void SetImmutableProto(Handle<JSObject> object);
|
||||
|
||||
|
@ -425,7 +451,7 @@ index 0a2773b127..79a2edada4 100644
|
|||
// the caller to initialize object header. Fill the pre-allocated fields with
|
||||
// undefined_value and the rest with filler_map.
|
||||
diff --git a/src/objects/map-inl.h b/src/objects/map-inl.h
|
||||
index 4e65b2f746..56063e17a0 100644
|
||||
index 7355e70533..1a999a1e8b 100644
|
||||
--- a/src/objects/map-inl.h
|
||||
+++ b/src/objects/map-inl.h
|
||||
@@ -114,6 +114,9 @@ BIT_FIELD_ACCESSORS(Map, bit_field3, may_have_interesting_symbols,
|
||||
|
@ -439,10 +465,10 @@ index 4e65b2f746..56063e17a0 100644
|
|||
DCHECK(has_named_interceptor());
|
||||
FunctionTemplateInfo info = GetFunctionTemplateInfo(cage_base);
|
||||
diff --git a/src/objects/map.cc b/src/objects/map.cc
|
||||
index f8bd209dcf..bb23f90e44 100644
|
||||
index 0db0b71104..7df72dafea 100644
|
||||
--- a/src/objects/map.cc
|
||||
+++ b/src/objects/map.cc
|
||||
@@ -1169,6 +1169,7 @@ Handle<Map> Map::RawCopy(Isolate* isolate, Handle<Map> src_handle,
|
||||
@@ -1173,6 +1173,7 @@ Handle<Map> Map::RawCopy(Isolate* isolate, Handle<Map> src_handle,
|
||||
}
|
||||
// Same as bit_field comment above.
|
||||
raw.set_bit_field3(new_bit_field3);
|
||||
|
@ -450,7 +476,7 @@ index f8bd209dcf..bb23f90e44 100644
|
|||
raw.clear_padding();
|
||||
}
|
||||
Handle<HeapObject> prototype(src_handle->prototype(), isolate);
|
||||
@@ -1293,6 +1294,12 @@ Handle<Map> Map::TransitionToImmutableProto(Isolate* isolate, Handle<Map> map) {
|
||||
@@ -1297,6 +1298,12 @@ Handle<Map> Map::TransitionToImmutableProto(Isolate* isolate, Handle<Map> map) {
|
||||
return new_map;
|
||||
}
|
||||
|
||||
|
@ -464,11 +490,11 @@ index f8bd209dcf..bb23f90e44 100644
|
|||
void EnsureInitialMap(Isolate* isolate, Handle<Map> map) {
|
||||
#ifdef DEBUG
|
||||
diff --git a/src/objects/map.h b/src/objects/map.h
|
||||
index cc38d4e694..6fd89c8711 100644
|
||||
index 0fe14ffcec..9a306e515a 100644
|
||||
--- a/src/objects/map.h
|
||||
+++ b/src/objects/map.h
|
||||
@@ -313,6 +313,11 @@ class Map : public TorqueGeneratedMap<Map, HeapObject> {
|
||||
STATIC_ASSERT(kSlackTrackingCounterStart <=
|
||||
@@ -318,6 +318,11 @@ class Map : public TorqueGeneratedMap<Map, HeapObject> {
|
||||
static_assert(kSlackTrackingCounterStart <=
|
||||
Bits3::ConstructionCounterBits::kMax);
|
||||
|
||||
+ // Bit positions for |host_bits|.
|
||||
|
@ -479,7 +505,7 @@ index cc38d4e694..6fd89c8711 100644
|
|||
// Inobject slack tracking is the way to reclaim unused inobject space.
|
||||
//
|
||||
// The instance size is initially determined by adding some slack to
|
||||
@@ -646,6 +651,8 @@ class Map : public TorqueGeneratedMap<Map, HeapObject> {
|
||||
@@ -650,6 +655,8 @@ class Map : public TorqueGeneratedMap<Map, HeapObject> {
|
||||
|
||||
DECL_BOOLEAN_ACCESSORS(is_immutable_proto)
|
||||
|
||||
|
@ -488,7 +514,7 @@ index cc38d4e694..6fd89c8711 100644
|
|||
// This counter is used for in-object slack tracking.
|
||||
// The in-object slack tracking is considered enabled when the counter is
|
||||
// non zero. The counter only has a valid count for initial maps. For
|
||||
@@ -814,6 +821,8 @@ class Map : public TorqueGeneratedMap<Map, HeapObject> {
|
||||
@@ -818,6 +825,8 @@ class Map : public TorqueGeneratedMap<Map, HeapObject> {
|
||||
static Handle<Map> TransitionToImmutableProto(Isolate* isolate,
|
||||
Handle<Map> map);
|
||||
|
||||
|
@ -496,7 +522,7 @@ index cc38d4e694..6fd89c8711 100644
|
|||
+
|
||||
static const int kMaxPreAllocatedPropertyFields = 255;
|
||||
|
||||
STATIC_ASSERT(kInstanceTypeOffset == Internals::kMapInstanceTypeOffset);
|
||||
static_assert(kInstanceTypeOffset == Internals::kMapInstanceTypeOffset);
|
||||
diff --git a/src/objects/map.tq b/src/objects/map.tq
|
||||
index a8b367ff82..98637087ee 100644
|
||||
--- a/src/objects/map.tq
|
||||
|
@ -524,10 +550,10 @@ index a8b367ff82..98637087ee 100644
|
|||
prototype: JSReceiver|Null;
|
||||
constructor_or_back_pointer_or_native_context: Object;
|
||||
diff --git a/src/objects/objects.cc b/src/objects/objects.cc
|
||||
index b3404cadfc..dd201f7ee9 100644
|
||||
index 02889457f9..3a68c6ca23 100644
|
||||
--- a/src/objects/objects.cc
|
||||
+++ b/src/objects/objects.cc
|
||||
@@ -882,6 +882,12 @@ Handle<String> Object::TypeOf(Isolate* isolate, Handle<Object> object) {
|
||||
@@ -886,6 +886,12 @@ Handle<String> Object::TypeOf(Isolate* isolate, Handle<Object> object) {
|
||||
if (object->IsString()) return isolate->factory()->string_string();
|
||||
if (object->IsSymbol()) return isolate->factory()->symbol_string();
|
||||
if (object->IsBigInt()) return isolate->factory()->bigint_string();
|
||||
|
@ -541,7 +567,7 @@ index b3404cadfc..dd201f7ee9 100644
|
|||
return isolate->factory()->object_string();
|
||||
}
|
||||
diff --git a/src/objects/source-text-module.cc b/src/objects/source-text-module.cc
|
||||
index 532fbab4b9..c2ee45cd4a 100644
|
||||
index eac227b7a5..b04523843b 100644
|
||||
--- a/src/objects/source-text-module.cc
|
||||
+++ b/src/objects/source-text-module.cc
|
||||
@@ -737,7 +737,7 @@ MaybeHandle<Object> SourceTextModule::Evaluate(
|
||||
|
@ -556,13 +582,13 @@ index 532fbab4b9..c2ee45cd4a 100644
|
|||
@@ -750,7 +750,7 @@ MaybeHandle<Object> SourceTextModule::Evaluate(
|
||||
}
|
||||
|
||||
void SourceTextModule::AsyncModuleExecutionFulfilled(
|
||||
Maybe<bool> SourceTextModule::AsyncModuleExecutionFulfilled(
|
||||
- Isolate* isolate, Handle<SourceTextModule> module) {
|
||||
+ Isolate* isolate, Handle<SourceTextModule> module, Handle<Object> result) {
|
||||
// 1. If module.[[Status]] is evaluated, then
|
||||
if (module->status() == kErrored) {
|
||||
// a. Assert: module.[[EvaluationError]] is not empty.
|
||||
@@ -774,7 +774,7 @@ void SourceTextModule::AsyncModuleExecutionFulfilled(
|
||||
@@ -774,7 +774,7 @@ Maybe<bool> SourceTextModule::AsyncModuleExecutionFulfilled(
|
||||
// «undefined»).
|
||||
Handle<JSPromise> capability(
|
||||
JSPromise::cast(module->top_level_capability()), isolate);
|
||||
|
@ -571,7 +597,7 @@ index 532fbab4b9..c2ee45cd4a 100644
|
|||
.ToHandleChecked();
|
||||
}
|
||||
|
||||
@@ -838,7 +838,7 @@ void SourceTextModule::AsyncModuleExecutionFulfilled(
|
||||
@@ -840,7 +840,7 @@ Maybe<bool> SourceTextModule::AsyncModuleExecutionFulfilled(
|
||||
// undefined, «undefined»).
|
||||
Handle<JSPromise> capability(
|
||||
JSPromise::cast(m->top_level_capability()), isolate);
|
||||
|
@ -581,16 +607,15 @@ index 532fbab4b9..c2ee45cd4a 100644
|
|||
}
|
||||
}
|
||||
diff --git a/src/objects/source-text-module.h b/src/objects/source-text-module.h
|
||||
index c91accba0c..987d1e2a4e 100644
|
||||
index e9e79152ae..6ca03eca97 100644
|
||||
--- a/src/objects/source-text-module.h
|
||||
+++ b/src/objects/source-text-module.h
|
||||
@@ -57,7 +57,8 @@ class SourceTextModule
|
||||
// Used by builtins to fulfill or reject the promise associated
|
||||
// with async SourceTextModules.
|
||||
static void AsyncModuleExecutionFulfilled(Isolate* isolate,
|
||||
- Handle<SourceTextModule> module);
|
||||
+ Handle<SourceTextModule> module,
|
||||
+ Handle<Object> result);
|
||||
@@ -58,7 +58,7 @@ class SourceTextModule
|
||||
// with async SourceTextModules. Return Nothing if the execution is
|
||||
// terminated.
|
||||
static Maybe<bool> AsyncModuleExecutionFulfilled(
|
||||
- Isolate* isolate, Handle<SourceTextModule> module);
|
||||
+ Isolate* isolate, Handle<SourceTextModule> module, Handle<Object> result);
|
||||
static void AsyncModuleExecutionRejected(Isolate* isolate,
|
||||
Handle<SourceTextModule> module,
|
||||
Handle<Object> exception);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
@echo off
|
||||
setlocal
|
||||
|
||||
set v8testedrev=10.3.174.17
|
||||
set v8testedrev=10.5.218.8
|
||||
set v8testedcommit=
|
||||
|
||||
if not "%v8testedcommit%"=="" goto ProcessArgs
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<#
|
||||
var version = new Version(7, 3, 1);
|
||||
var version = new Version(7, 3, 2);
|
||||
var versionSuffix = string.Empty;
|
||||
new Random(versionSuffix.Length); // suppress "versionSuffix not used" warning
|
||||
#>
|
||||
|
|
|
@ -199,7 +199,7 @@ href="https://docs.microsoft.com/en-us/previous-versions/windows/internet-explor
|
|||
|
||||
<h1 style='margin-top:14.0pt;margin-right:0in;margin-bottom:0in;margin-left:
|
||||
.5in;margin-bottom:.0001pt;text-indent:-.5in'><span style='font:7.0pt "Times New Roman"'> </span>II.
|
||||
ClearScript NuGet package</h1>
|
||||
ClearScript NuGet packages</h1>
|
||||
|
||||
<p class=MsoNormal style='margin-left:.25in'>Now that official ClearScript
|
||||
NuGet packages are available, you can simply add one to your project and skip
|
||||
|
@ -245,6 +245,7 @@ href="https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-add-package"><b>
|
|||
style='font-size:10.0pt;line-height:115%;font-family:Consolas'>dotnet add
|
||||
package</span></b></a> to add the <a
|
||||
href="https://www.nuget.org/packages/Microsoft.ClearScript.osx-x64">Microsoft.ClearScript.osx-x64</a>
|
||||
or <a href="https://www.nuget.org/packages/Microsoft.ClearScript.osx-arm64">Microsoft.ClearScript.osx-arm64</a>
|
||||
package to your project. Remember to use the <b><span style='font-size:10.0pt;
|
||||
line-height:115%;font-family:Consolas'>-v</span></b> option on the <b><span
|
||||
style='font-size:10.0pt;line-height:115%;font-family:Consolas'>dotnet</span></b>
|
||||
|
@ -285,13 +286,13 @@ files support <a href="https://visualstudio.microsoft.com/downloads/">Visual
|
|||
Studio 2022</a> and <a
|
||||
href="https://visualstudio.microsoft.com/vs/older-downloads/">Visual Studio 2019</a>
|
||||
Version 16.4 or later. They produce architecture-neutral managed libraries that
|
||||
target .NET Framework 4.5, .NET Framework 4.7.1, .NET Core 3.1, and .NET 5.0.
|
||||
target .NET 5.0+, .NET Framework 4.5+, .NET Core 3.1, and .NET Standard 2.1.
|
||||
ClearScript does not support older environments. The output directory is <b><span
|
||||
style='font-size:10.0pt;line-height:115%;font-family:Consolas'>bin\[Debug|Release]</span></b>.</p>
|
||||
|
||||
<p class=MsoNormal style='margin-left:.25in'><b><span style='color:red'>Important:
|
||||
</span></b>Ensure that <a
|
||||
href="https://dotnet.microsoft.com/download/visual-studio-sdks">.NET 5.0 SDK</a>
|
||||
href="https://dotnet.microsoft.com/en-us/download/dotnet/6.0">.NET 6.0 SDK</a>
|
||||
is installed before building ClearScript.</p>
|
||||
|
||||
<p class=MsoNormal style='margin-left:.25in'>There are two ways to build
|
||||
|
@ -307,8 +308,7 @@ support, you must first acquire and build V8:</p>
|
|||
style='font:7.0pt "Times New Roman"'> </span><b><span
|
||||
style='color:red'>Important:</span></b> This procedure currently requires <a
|
||||
href="https://visualstudio.microsoft.com/downloads/">Visual Studio 2022</a> or <a
|
||||
href="https://visualstudio.microsoft.com/vs/older-downloads/">Visual Studio
|
||||
2019</a>. The V8 build does not yet support newer versions.</p>
|
||||
href="https://visualstudio.microsoft.com/vs/older-downloads/">Visual Studio 2019</a>.</p>
|
||||
|
||||
<p class=MsoListParagraph style='margin-left:.75in;text-indent:-.25in'>2.<span
|
||||
style='font:7.0pt "Times New Roman"'> </span><b><span
|
||||
|
@ -325,9 +325,14 @@ ARM build tools </b>and<b> C++ ARM64</b> <b>build tools</b> components.</p>
|
|||
<p class=MsoListParagraph style='margin-left:.75in;text-indent:-.25in'>4.<span
|
||||
style='font:7.0pt "Times New Roman"'> </span><b><span
|
||||
style='color:red'>Important:</span></b> The V8 build also requires <a
|
||||
href="https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk/">Windows
|
||||
10 SDK</a> version 10.0.19041.0 or later. Your Windows SDK installation must
|
||||
include the <b>Debugging Tools for Windows</b> feature.</p>
|
||||
href="https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/"><span
|
||||
style='font-size:10.5pt;line-height:115%;font-family:"Segoe UI",sans-serif;
|
||||
background:white'>Windows 10 SDK</span></a><span style='font-size:10.5pt;
|
||||
line-height:115%;font-family:"Segoe UI",sans-serif;color:#171717;background:
|
||||
white'> version </span><a href="https://go.microsoft.com/fwlink/?linkid=2164145"><span
|
||||
style='font-size:10.5pt;line-height:115%;font-family:"Segoe UI",sans-serif;
|
||||
background:white'>2104 (10.0.20348.0)</span></a>. Your Windows SDK installation
|
||||
must include the <b>Debugging Tools for Windows</b> feature.</p>
|
||||
|
||||
<p class=MsoListParagraph style='margin-left:.75in;text-indent:-.25in'>5.<span
|
||||
style='font:7.0pt "Times New Roman"'> </span>Open
|
||||
|
@ -415,31 +420,25 @@ and ClearScript on Linux:</p>
|
|||
<p class=MsoListParagraph style='margin-left:.75in;text-indent:-.25in'>1.<span
|
||||
style='font:7.0pt "Times New Roman"'> </span>Install
|
||||
the following packages: <a href="https://www.git-scm.com/download/linux">Git</a>,
|
||||
<a href="https://dotnet.microsoft.com/download/dotnet/5.0">.NET 5.0 SDK</a>, <a
|
||||
href="https://clang.llvm.org/">Clang</a>, <a
|
||||
href="https://www.gnu.org/software/make/">GNU Make</a>, <a
|
||||
href="https://www.python.org/downloads/release/python-2718/">Python 2</a>, and <a
|
||||
<a href="https://dotnet.microsoft.com/en-us/download/dotnet/6.0">.NET 6.0 SDK</a>,
|
||||
<a href="https://clang.llvm.org/">Clang</a>, <a
|
||||
href="https://www.gnu.org/software/make/">GNU Make</a>, and <a
|
||||
href="http://pkgconf.org/">pkgconf</a>. For each of these, check your package
|
||||
manager first, and then the official website.</p>
|
||||
|
||||
<p class=MsoListParagraph style='margin-left:.75in;text-indent:-.25in'>2.<span
|
||||
style='font:7.0pt "Times New Roman"'> </span><b><span
|
||||
style='color:red'>Important:</span></b> To avoid V8 build issues, ensure that
|
||||
the <b>python</b> command launches Python 2.</p>
|
||||
|
||||
<p class=MsoListParagraph style='margin-left:.75in;text-indent:-.25in'>3.<span
|
||||
style='font:7.0pt "Times New Roman"'> </span>Use
|
||||
<a href="https://git-scm.com/docs/git-clone"><b><span style='font-size:10.0pt;
|
||||
line-height:115%;font-family:Consolas'>git-clone</span></b></a> to download the
|
||||
<a href="https://github.com/Microsoft/ClearScript">ClearScript source code</a>
|
||||
into a convenient directory. Avoid very long directory paths.</p>
|
||||
|
||||
<p class=MsoListParagraph style='margin-left:.75in;text-indent:-.25in'>4.<span
|
||||
<p class=MsoListParagraph style='margin-left:.75in;text-indent:-.25in'>3.<span
|
||||
style='font:7.0pt "Times New Roman"'> </span><b><span
|
||||
style='color:red'>Important:</span></b> Ensure that the path to your
|
||||
ClearScript root directory does not contain spaces or non-ASCII characters.</p>
|
||||
|
||||
<p class=MsoListParagraph style='margin-left:.75in;text-indent:-.25in'>5.<span
|
||||
<p class=MsoListParagraph style='margin-left:.75in;text-indent:-.25in'>4.<span
|
||||
style='font:7.0pt "Times New Roman"'> </span>Run
|
||||
the following command from your ClearScript root directory:</p>
|
||||
|
||||
|
@ -465,7 +464,7 @@ on Ubuntu.</p>
|
|||
<p class=MsoNormal style='margin-left:.75in'>Specify <b><span style='font-size:
|
||||
10.0pt;line-height:115%;font-family:Consolas'>CPU=arm64</span></b> to
|
||||
cross-build for the arm64 architecture. This requires arm64 C++ cross-build tools,
|
||||
such as <a href="https://packages.ubuntu.com/focal/g++-aarch64-linux-gnu">g++-aarch64-linux-gnu</a>
|
||||
such as <a href="https://packages.ubuntu.com/focal/g++-10-aarch64-linux-gnu">g++-10-aarch64-linux-gnu</a>
|
||||
on Ubuntu.</p>
|
||||
|
||||
<h2 style='margin-top:6.0pt;margin-right:0in;margin-bottom:0in;margin-left:
|
||||
|
@ -477,26 +476,21 @@ and ClearScript on macOS:</p>
|
|||
<p class=MsoListParagraph style='margin-left:.75in;text-indent:-.25in'>1.<span
|
||||
style='font:7.0pt "Times New Roman"'> </span>Install
|
||||
<a href="https://developer.apple.com/xcode/">Xcode</a> and <a
|
||||
href="https://dotnet.microsoft.com/download/dotnet/5.0">.NET 5.0 SDK</a>.</p>
|
||||
href="https://dotnet.microsoft.com/en-us/download/dotnet/6.0">.NET 6.0 SDK</a>.</p>
|
||||
|
||||
<p class=MsoListParagraph style='margin-left:.75in;text-indent:-.25in'>2.<span
|
||||
style='font:7.0pt "Times New Roman"'> </span><b><span
|
||||
style='color:red'>Important:</span></b> To avoid V8 build issues, ensure that
|
||||
the <b>python</b> command launches Python 2.</p>
|
||||
|
||||
<p class=MsoListParagraph style='margin-left:.75in;text-indent:-.25in'>3.<span
|
||||
style='font:7.0pt "Times New Roman"'> </span>Use
|
||||
<a href="https://git-scm.com/docs/git-clone"><b><span style='font-size:10.0pt;
|
||||
line-height:115%;font-family:Consolas'>git-clone</span></b></a> to download the
|
||||
<a href="https://github.com/Microsoft/ClearScript">ClearScript source code</a>
|
||||
into a convenient directory. Avoid very long directory paths.</p>
|
||||
|
||||
<p class=MsoListParagraph style='margin-left:.75in;text-indent:-.25in'>4.<span
|
||||
<p class=MsoListParagraph style='margin-left:.75in;text-indent:-.25in'>3.<span
|
||||
style='font:7.0pt "Times New Roman"'> </span><b><span
|
||||
style='color:red'>Important:</span></b> Ensure that the path to your
|
||||
ClearScript root directory does not contain spaces or non-ASCII characters.</p>
|
||||
|
||||
<p class=MsoListParagraph style='margin-left:.75in;text-indent:-.25in'>5.<span
|
||||
<p class=MsoListParagraph style='margin-left:.75in;text-indent:-.25in'>4.<span
|
||||
style='font:7.0pt "Times New Roman"'> </span>Launch
|
||||
the <a href="https://en.wikipedia.org/wiki/Terminal_(macOS)">Terminal</a> app
|
||||
and run the following command from your ClearScript root directory:</p>
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
activesupport (6.0.5)
|
||||
activesupport (6.0.6)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (>= 0.7, < 2)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
zeitwerk (~> 2.2, >= 2.2.2)
|
||||
addressable (2.8.0)
|
||||
public_suffix (>= 2.0.2, < 5.0)
|
||||
addressable (2.8.1)
|
||||
public_suffix (>= 2.0.2, < 6.0)
|
||||
coffee-script (2.4.1)
|
||||
coffee-script-source
|
||||
execjs
|
||||
|
@ -25,14 +25,14 @@ GEM
|
|||
ffi (>= 1.15.0)
|
||||
eventmachine (1.2.7)
|
||||
execjs (2.8.1)
|
||||
faraday (2.3.0)
|
||||
faraday-net_http (~> 2.0)
|
||||
faraday (2.5.2)
|
||||
faraday-net_http (>= 2.0, < 3.1)
|
||||
ruby2_keywords (>= 0.0.4)
|
||||
faraday-net_http (2.0.3)
|
||||
faraday-net_http (3.0.0)
|
||||
ffi (1.15.5)
|
||||
forwardable-extended (2.6.0)
|
||||
gemoji (3.0.1)
|
||||
github-pages (226)
|
||||
github-pages (227)
|
||||
github-pages-health-check (= 1.17.9)
|
||||
jekyll (= 3.9.2)
|
||||
jekyll-avatar (= 0.7.0)
|
||||
|
@ -74,7 +74,7 @@ GEM
|
|||
liquid (= 4.0.3)
|
||||
mercenary (~> 0.3)
|
||||
minima (= 2.5.1)
|
||||
nokogiri (>= 1.13.4, < 2.0)
|
||||
nokogiri (>= 1.13.6, < 2.0)
|
||||
rouge (= 3.26.0)
|
||||
terminal-table (~> 1.4)
|
||||
github-pages-health-check (1.17.9)
|
||||
|
@ -210,17 +210,17 @@ GEM
|
|||
jekyll (>= 3.5, < 5.0)
|
||||
jekyll-feed (~> 0.9)
|
||||
jekyll-seo-tag (~> 2.1)
|
||||
minitest (5.16.0)
|
||||
nokogiri (1.13.6-x86_64-linux)
|
||||
minitest (5.16.3)
|
||||
nokogiri (1.13.8-x86_64-linux)
|
||||
racc (~> 1.4)
|
||||
octokit (4.25.0)
|
||||
octokit (4.25.1)
|
||||
faraday (>= 1, < 3)
|
||||
sawyer (~> 0.9)
|
||||
pathutil (0.16.2)
|
||||
forwardable-extended (~> 2.6)
|
||||
public_suffix (4.0.7)
|
||||
racc (1.6.0)
|
||||
rb-fsevent (0.11.1)
|
||||
rb-fsevent (0.11.2)
|
||||
rb-inotify (0.10.1)
|
||||
ffi (~> 1.0)
|
||||
rexml (3.2.5)
|
||||
|
@ -259,4 +259,4 @@ DEPENDENCIES
|
|||
jekyll-paginate
|
||||
|
||||
BUNDLED WITH
|
||||
2.2.32
|
||||
2.3.22
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
// System : Sandcastle Help File Builder
|
||||
// File : SearchHelp.aspx
|
||||
// Author : Eric Woodruff (Eric@EWoodruff.us)
|
||||
// Updated : 05/15/2014
|
||||
// Note : Copyright 2007-2015, Eric Woodruff, All rights reserved
|
||||
// Updated : 08/13/2022
|
||||
// Note : Copyright 2007-2022, Eric Woodruff, All rights reserved
|
||||
//
|
||||
// This file contains the code used to search for keywords within the help topics using the full-text index
|
||||
// files created by the help file builder.
|
||||
|
@ -119,7 +119,7 @@ private List<string> ParseKeywords(string keywords)
|
|||
{
|
||||
checkWord = word.ToLower(CultureInfo.InvariantCulture);
|
||||
|
||||
if(checkWord.Length > 2 && !Char.IsDigit(checkWord[0]) && !keywordList.Contains(checkWord))
|
||||
if(checkWord.Length >= 2 && !Char.IsDigit(checkWord[0]) && !keywordList.Contains(checkWord))
|
||||
keywordList.Add(checkWord);
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,8 @@ private string Search(List<string> keywords, List<string> fileInfo,
|
|||
StringBuilder sb = new StringBuilder(10240);
|
||||
Dictionary<string, List<long>> matches = new Dictionary<string, List<long>>();
|
||||
List<long> occurrences;
|
||||
List<int> matchingFileIndices = new List<int>(), occurrenceIndices = new List<int>();
|
||||
HashSet<int> matchingFileIndices = new HashSet<int>();
|
||||
List<int> occurrenceIndices = new List<int>();
|
||||
List<Ranking> rankings = new List<Ranking>();
|
||||
|
||||
string filename, title;
|
||||
|
@ -150,7 +151,13 @@ private string Search(List<string> keywords, List<string> fileInfo,
|
|||
|
||||
foreach(string word in keywords)
|
||||
{
|
||||
if(!wordDictionary.TryGetValue(word, out occurrences))
|
||||
occurrences = new List<long>();
|
||||
|
||||
foreach(KeyValuePair<string, List<long>> kv in wordDictionary)
|
||||
if(kv.Key.Contains(word))
|
||||
occurrences.AddRange(kv.Value);
|
||||
|
||||
if(occurrences.Count == 0)
|
||||
return "<strong>Nothing found</strong>";
|
||||
|
||||
matches.Add(word, occurrences);
|
||||
|
@ -163,18 +170,14 @@ private string Search(List<string> keywords, List<string> fileInfo,
|
|||
if(isFirst)
|
||||
{
|
||||
isFirst = false;
|
||||
matchingFileIndices.AddRange(occurrenceIndices);
|
||||
matchingFileIndices.UnionWith(occurrenceIndices);
|
||||
}
|
||||
else
|
||||
{
|
||||
// After the first match, remove files that do not appear for
|
||||
// all found keywords.
|
||||
for(idx = 0; idx < matchingFileIndices.Count; idx++)
|
||||
if(!occurrenceIndices.Contains(matchingFileIndices[idx]))
|
||||
{
|
||||
matchingFileIndices.RemoveAt(idx);
|
||||
idx--;
|
||||
}
|
||||
// After the first match, remove files that do not appear for all found keywords
|
||||
foreach(int i in matchingFileIndices.ToArray())
|
||||
if(!occurrenceIndices.Contains(i))
|
||||
matchingFileIndices.Remove(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -217,7 +220,7 @@ private string Search(List<string> keywords, List<string> fileInfo,
|
|||
});
|
||||
|
||||
// Format the file list and return the results
|
||||
sb.Append("<ol>");
|
||||
sb.Append("<ol>");
|
||||
|
||||
foreach(Ranking r in rankings)
|
||||
sb.AppendFormat("<li><a href=\"{0}\" target=\"_blank\">{1}</a></li>", r.Filename, r.PageTitle);
|
||||
|
|
|
@ -30,7 +30,7 @@ function ParseKeywords($keywords)
|
|||
{
|
||||
$checkWord = strtolower($word);
|
||||
$first = substr($checkWord, 0, 1);
|
||||
if(strlen($checkWord) > 2 && !ctype_digit($first) && !in_array($checkWord, $keywordList))
|
||||
if(strlen($checkWord) >= 2 && !ctype_digit($first) && !in_array($checkWord, $keywordList))
|
||||
{
|
||||
array_push($keywordList, $checkWord);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
<add namespace="System.Collections.Generic"/>
|
||||
<add namespace="System.Globalization"/>
|
||||
<add namespace="System.IO"/>
|
||||
<add namespace="System.Linq"/>
|
||||
<add namespace="System.Text"/>
|
||||
<add namespace="System.Text.RegularExpressions"/>
|
||||
<add namespace="System.Web"/>
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче