Skip to content

Commit 19ca67c

Browse files
Version 6.0.1: Improved support for IIS least-privilege accounts (GitHub Issue #160); fixed 64-bit V8 initialization on Azure App Service (GitHub Issue #166); enabled DirectAccess for ComVisible .NET objects (GitHub Issue #161); added ScriptEngine.ExposeHostObjectStaticMembers (GitHub Issue #152); added ScriptEngine.UndefinedImportValue and made Undefined.Value public (GitHub Issue #154); enhanced ExtendedHostFunctions.typeLibEnums to pull in external enumerations; added thread affinity enforcement in WindowsScriptEngine.Dispose; eliminated KeyNotFoundException when checking for system documents (GitHub Issue #169); enabled the use of the application's root folder as a backup for its local data folder (GitHub Issue #171); reduced minimum CPU profile and heap size sampling intervals to 125 ms; updated deployment and API documentation, resolving GitHub Issues #158 and #159. Tested with V8 8.1.307.28.
1 parent d2ff7ca commit 19ca67c

739 files changed

Lines changed: 4126 additions & 3075 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ClearScript.NoV8.sln.DotSettings

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
<s:Boolean x:Key="/Default/UserDictionary/Words/=dispid/@EntryIndexedValue">True</s:Boolean>
124124
<s:Boolean x:Key="/Default/UserDictionary/Words/=dispids/@EntryIndexedValue">True</s:Boolean>
125125
<s:Boolean x:Key="/Default/UserDictionary/Words/=DISPPARAMS/@EntryIndexedValue">True</s:Boolean>
126+
<s:Boolean x:Key="/Default/UserDictionary/Words/=ELEMDESC/@EntryIndexedValue">True</s:Boolean>
126127
<s:Boolean x:Key="/Default/UserDictionary/Words/=excep/@EntryIndexedValue">True</s:Boolean>
127128
<s:Boolean x:Key="/Default/UserDictionary/Words/=EXCEPINFO/@EntryIndexedValue">True</s:Boolean>
128129
<s:Boolean x:Key="/Default/UserDictionary/Words/=Exprs/@EntryIndexedValue">True</s:Boolean>
@@ -162,6 +163,7 @@
162163
<s:Boolean x:Key="/Default/UserDictionary/Words/=Steptype/@EntryIndexedValue">True</s:Boolean>
163164
<s:Boolean x:Key="/Default/UserDictionary/Words/=sunspider/@EntryIndexedValue">True</s:Boolean>
164165
<s:Boolean x:Key="/Default/UserDictionary/Words/=TYPEATTR/@EntryIndexedValue">True</s:Boolean>
166+
<s:Boolean x:Key="/Default/UserDictionary/Words/=TYPEDESC/@EntryIndexedValue">True</s:Boolean>
165167
<s:Boolean x:Key="/Default/UserDictionary/Words/=TYPEFLAGS/@EntryIndexedValue">True</s:Boolean>
166168
<s:Boolean x:Key="/Default/UserDictionary/Words/=TYPEKIND/@EntryIndexedValue">True</s:Boolean>
167169
<s:Boolean x:Key="/Default/UserDictionary/Words/=TYPELIBATTR/@EntryIndexedValue">True</s:Boolean>

ClearScript.sln.DotSettings

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
<s:Boolean x:Key="/Default/UserDictionary/Words/=dispid/@EntryIndexedValue">True</s:Boolean>
124124
<s:Boolean x:Key="/Default/UserDictionary/Words/=dispids/@EntryIndexedValue">True</s:Boolean>
125125
<s:Boolean x:Key="/Default/UserDictionary/Words/=DISPPARAMS/@EntryIndexedValue">True</s:Boolean>
126+
<s:Boolean x:Key="/Default/UserDictionary/Words/=ELEMDESC/@EntryIndexedValue">True</s:Boolean>
126127
<s:Boolean x:Key="/Default/UserDictionary/Words/=excep/@EntryIndexedValue">True</s:Boolean>
127128
<s:Boolean x:Key="/Default/UserDictionary/Words/=EXCEPINFO/@EntryIndexedValue">True</s:Boolean>
128129
<s:Boolean x:Key="/Default/UserDictionary/Words/=Exprs/@EntryIndexedValue">True</s:Boolean>
@@ -162,6 +163,7 @@
162163
<s:Boolean x:Key="/Default/UserDictionary/Words/=Steptype/@EntryIndexedValue">True</s:Boolean>
163164
<s:Boolean x:Key="/Default/UserDictionary/Words/=sunspider/@EntryIndexedValue">True</s:Boolean>
164165
<s:Boolean x:Key="/Default/UserDictionary/Words/=TYPEATTR/@EntryIndexedValue">True</s:Boolean>
166+
<s:Boolean x:Key="/Default/UserDictionary/Words/=TYPEDESC/@EntryIndexedValue">True</s:Boolean>
165167
<s:Boolean x:Key="/Default/UserDictionary/Words/=TYPEFLAGS/@EntryIndexedValue">True</s:Boolean>
166168
<s:Boolean x:Key="/Default/UserDictionary/Words/=TYPEKIND/@EntryIndexedValue">True</s:Boolean>
167169
<s:Boolean x:Key="/Default/UserDictionary/Words/=TYPELIBATTR/@EntryIndexedValue">True</s:Boolean>

ClearScript/ByRefArg.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ public override object DynamicInvokeTarget
5858
get { return target.DynamicInvokeTarget; }
5959
}
6060

61-
public override HostTargetFlags Flags
61+
public override HostTargetFlags GetFlags(IHostInvokeContext context)
6262
{
63-
get { return target.Flags; }
63+
return target.GetFlags(context);
6464
}
6565

6666
public override string[] GetAuxMethodNames(IHostInvokeContext context, BindingFlags bindFlags)

ClearScript/ClearScript.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@
126126
<Compile Include="Util\COM\DispatchMember.cs" />
127127
<Compile Include="Util\COM\DispatchWrappers.cs" />
128128
<Compile Include="Util\COM\HResult.cs" />
129+
<Compile Include="Util\COM\StructHelpers.cs" />
129130
<Compile Include="Util\COM\TypeInfoHelpers.cs" />
130131
<Compile Include="Util\COM\TypeInfoHelpers.NetFramework.cs" />
131132
<Compile Include="Util\COM\TypeLibHelpers.cs" />

ClearScript/DocumentInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ internal UniqueDocumentInfo MakeUnique(IUniqueNameManager manager, DocumentFlags
136136
}
137137

138138
var uniqueName = manager.GetUniqueName(Name, Category.DefaultName);
139-
if (Flags.GetValueOrDefault().HasFlag(DocumentFlags.IsTransient))
139+
if (info.Flags.GetValueOrDefault().HasFlag(DocumentFlags.IsTransient))
140140
{
141141
uniqueName += " [temp]";
142142
}

ClearScript/DocumentSettings.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using System;
55
using System.Collections.Concurrent;
6-
using System.Collections.Generic;
76
using System.IO;
87
using System.Threading.Tasks;
98
using Microsoft.ClearScript.JavaScript;
@@ -190,14 +189,13 @@ internal async Task<Document> LoadDocumentAsync(DocumentInfo? sourceInfo, string
190189

191190
private Document FindSystemDocument(string identifier, DocumentCategory category)
192191
{
193-
try
192+
Document document;
193+
if (systemDocumentMap.TryGetValue(Tuple.Create(identifier, category ?? DocumentCategory.Script), out document))
194194
{
195-
return systemDocumentMap[Tuple.Create(identifier, category ?? DocumentCategory.Script)];
196-
}
197-
catch (KeyNotFoundException)
198-
{
199-
return null;
195+
return document;
200196
}
197+
198+
return null;
201199
}
202200
}
203201
}

ClearScript/Exports/VersionSymbols.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55

66
#pragma once
77

8-
#define CLEARSCRIPT_VERSION_STRING "6.0.0.0"
9-
#define CLEARSCRIPT_VERSION_COMMA_SEPARATED 6,0,0,0
8+
#define CLEARSCRIPT_VERSION_STRING "6.0.1.0"
9+
#define CLEARSCRIPT_VERSION_COMMA_SEPARATED 6,0,1,0

ClearScript/HostFunctions.cs

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the MIT license.
33

44
using System;
5-
using System.Diagnostics;
65
using System.Diagnostics.CodeAnalysis;
76
using System.Dynamic;
87
using System.Globalization;
@@ -1647,13 +1646,20 @@ public object newComObj(string progID, string serverName = null)
16471646
}
16481647

16491648
/// <summary>
1650-
/// Imports enumerations from a type library.
1649+
/// Imports enumerations defined within or referenced from a COM/ActiveX type library.
16511650
/// </summary>
1652-
/// <typeparam name="T">The imported type whose parent library is to be searched for enumerations.</typeparam>
1651+
/// <typeparam name="T">The imported type whose parent library is to be searched for relevant enumerations.</typeparam>
16531652
/// <param name="obj">An instance of the representative type.</param>
1654-
/// <returns>A collection of imported enumerations.</returns>
1655-
public IPropertyBag typeLibEnums<T>(T obj) where T : class
1653+
/// <param name="collection">An optional host type collection with which to merge the imported enumerations.</param>
1654+
/// <returns>A host type collection: <paramref name="collection"/> if it is not <c>null</c>, a new host type collection otherwise.</returns>
1655+
public HostTypeCollection typeLibEnums<T>(T obj, HostTypeCollection collection = null) where T : class
16561656
{
1657+
MiscHelpers.VerifyNonNullArgument(obj, "obj");
1658+
if (collection == null)
1659+
{
1660+
collection = new HostTypeCollection();
1661+
}
1662+
16571663
var type = typeof(T);
16581664
if (type.IsUnknownCOMObject())
16591665
{
@@ -1663,31 +1669,18 @@ public IPropertyBag typeLibEnums<T>(T obj) where T : class
16631669
var typeInfo = dispatch.GetTypeInfo();
16641670
if (typeInfo != null)
16651671
{
1666-
return typeInfo.GetTypeLibEnums();
1672+
typeInfo.GetContainingTypeLib().GetReferencedEnums().ForEach(collection.AddEnumTypeInfo);
1673+
return collection;
16671674
}
16681675
}
1669-
1670-
throw new ArgumentException("Object type is not imported", "obj");
1671-
}
1672-
1673-
if (!type.IsImport)
1674-
{
1675-
throw new ArgumentException("Object type is not imported", "obj");
16761676
}
1677-
1678-
var typeCollection = new HostTypeCollection();
1679-
1680-
var assembly = type.Assembly;
1681-
Debug.Assert(assembly.GetCustomAttribute(typeof(ImportedFromTypeLibAttribute)) != null);
1682-
foreach (var assemblyType in assembly.GetTypes())
1677+
else if (type.IsImport && (type.Assembly.GetCustomAttribute(typeof(ImportedFromTypeLibAttribute)) != null))
16831678
{
1684-
if (assemblyType.IsPublic && assemblyType.IsEnum)
1685-
{
1686-
typeCollection.AddType(assemblyType);
1687-
}
1679+
type.Assembly.GetReferencedEnums().ForEach(collection.AddType);
1680+
return collection;
16881681
}
16891682

1690-
return typeCollection;
1683+
throw new ArgumentException("Object type is not imported", "obj");
16911684
}
16921685

16931686
// ReSharper restore InconsistentNaming

ClearScript/HostIndexedProperty.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ public override object DynamicInvokeTarget
5151
get { return null; }
5252
}
5353

54-
public override HostTargetFlags Flags
54+
public override HostTargetFlags GetFlags(IHostInvokeContext context)
5555
{
56-
get { return HostTargetFlags.None; }
56+
return HostTargetFlags.None;
5757
}
5858

5959
public override string[] GetAuxMethodNames(IHostInvokeContext context, BindingFlags bindFlags)

ClearScript/HostItem.InvokeMethod.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ private object InvokeMethod(string name, object[] args, object[] bindArgs)
5353
private object InvokeMethod(string name, Type[] typeArgs, object[] args, object[] bindArgs)
5454
{
5555
var bindResult = BindMethod(name, typeArgs, args, bindArgs);
56-
if ((bindResult is MethodBindFailure) && target.Flags.HasFlag(HostTargetFlags.AllowExtensionMethods))
56+
if ((bindResult is MethodBindFailure) && target.GetFlags(this).HasFlag(HostTargetFlags.AllowExtensionMethods))
5757
{
5858
var targetArg = target.Target.ToEnumerable();
5959
var extensionArgs = targetArg.Concat(args).ToArray();
@@ -108,17 +108,17 @@ private MethodBindResult BindMethod(string name, Type[] typeArgs, object[] args,
108108
// WARNING: BindSignature holds on to the specified typeArgs; subsequent modification
109109
// will result in bugs that are difficult to diagnose. Create a copy if necessary.
110110

111-
var signature = new BindSignature(accessContext, bindFlags, target, name, typeArgs, bindArgs);
111+
var signature = new BindSignature(AccessContext, bindFlags, target, name, typeArgs, bindArgs);
112112
MethodBindResult result;
113113

114114
object rawResult;
115115
if (engine.TryGetCachedBindResult(signature, out rawResult))
116116
{
117-
result = MethodBindResult.Create(name, rawResult, target, args);
117+
result = MethodBindResult.Create(name, bindFlags, rawResult, target, args);
118118
}
119119
else
120120
{
121-
result = BindMethodInternal(accessContext, bindFlags, target, name, typeArgs, args, bindArgs);
121+
result = BindMethodInternal(AccessContext, bindFlags, target, name, typeArgs, args, bindArgs);
122122
if (!result.IsPreferredMethod(this, name))
123123
{
124124
if (result is MethodBindSuccess)
@@ -128,7 +128,7 @@ private MethodBindResult BindMethod(string name, Type[] typeArgs, object[] args,
128128

129129
foreach (var altName in GetAltMethodNames(name, bindFlags))
130130
{
131-
var altResult = BindMethodInternal(accessContext, bindFlags, target, altName, typeArgs, args, bindArgs);
131+
var altResult = BindMethodInternal(AccessContext, bindFlags, target, altName, typeArgs, args, bindArgs);
132132
if (altResult.IsUnblockedMethod(this))
133133
{
134134
result = altResult;
@@ -163,7 +163,7 @@ private static MethodBindResult BindMethodInternal(Type bindContext, BindingFlag
163163
object rawResult;
164164
if (coreBindCache.TryGetValue(signature, out rawResult))
165165
{
166-
result = MethodBindResult.Create(name, rawResult, target, args);
166+
result = MethodBindResult.Create(name, bindFlags, rawResult, target, args);
167167
}
168168
else
169169
{
@@ -185,7 +185,7 @@ private static MethodBindResult BindMethodCore(Type bindContext, BindingFlags bi
185185
// perform default binding
186186
var rawResult = BindMethodRaw(bindFlags, binder, target, bindArgs);
187187

188-
var result = MethodBindResult.Create(name, rawResult, target, args);
188+
var result = MethodBindResult.Create(name, bindFlags, rawResult, target, args);
189189
if ((result is MethodBindFailure) && !(target is HostType) && target.Type.IsInterface)
190190
{
191191
// binding through interface failed; try base interfaces
@@ -194,7 +194,7 @@ private static MethodBindResult BindMethodCore(Type bindContext, BindingFlags bi
194194
var baseInterfaceTarget = HostObject.Wrap(target.InvokeTarget, interfaceType);
195195
rawResult = BindMethodRaw(bindFlags, binder, baseInterfaceTarget, bindArgs);
196196

197-
var baseInterfaceResult = MethodBindResult.Create(name, rawResult, target, args);
197+
var baseInterfaceResult = MethodBindResult.Create(name, bindFlags, rawResult, target, args);
198198
if (baseInterfaceResult is MethodBindSuccess)
199199
{
200200
return baseInterfaceResult;
@@ -205,7 +205,7 @@ private static MethodBindResult BindMethodCore(Type bindContext, BindingFlags bi
205205
var objectTarget = HostObject.Wrap(target.InvokeTarget, typeof(object));
206206
rawResult = BindMethodRaw(bindFlags, binder, objectTarget, bindArgs);
207207

208-
var objectResult = MethodBindResult.Create(name, rawResult, target, args);
208+
var objectResult = MethodBindResult.Create(name, bindFlags, rawResult, target, args);
209209
if (objectResult is MethodBindSuccess)
210210
{
211211
return objectResult;
@@ -259,7 +259,7 @@ private IEnumerable<string> GetAltMethodNames(string name, BindingFlags bindFlag
259259

260260
private IEnumerable<string> GetAltMethodNamesInternal(string name, BindingFlags bindFlags)
261261
{
262-
foreach (var method in target.Type.GetScriptableMethods(name, bindFlags, accessContext, defaultAccess))
262+
foreach (var method in target.Type.GetScriptableMethods(name, bindFlags, AccessContext, DefaultAccess))
263263
{
264264
var methodName = method.GetShortName();
265265
if (methodName != name)
@@ -326,7 +326,7 @@ private MethodBindResult BindMethodUsingReflection(BindingFlags bindFlags, HostT
326326
{
327327
object state;
328328
var rawResult = Type.DefaultBinder.BindToMethod(bindFlags, candidates, ref args, null, null, null, out state);
329-
return MethodBindResult.Create(name, rawResult, hostTarget, args);
329+
return MethodBindResult.Create(name, bindFlags, rawResult, hostTarget, args);
330330
}
331331
catch (MissingMethodException)
332332
{
@@ -368,7 +368,7 @@ private IEnumerable<MethodInfo> GetReflectionCandidates(BindingFlags bindFlags,
368368

369369
private IEnumerable<MethodInfo> GetReflectionCandidates(BindingFlags bindFlags, Type type, string name, Type[] typeArgs)
370370
{
371-
foreach (var method in type.GetScriptableMethods(name, bindFlags, accessContext, defaultAccess))
371+
foreach (var method in type.GetScriptableMethods(name, bindFlags, AccessContext, DefaultAccess))
372372
{
373373
MethodInfo tempMethod = null;
374374

@@ -420,12 +420,12 @@ internal static long GetCoreBindCount()
420420

421421
private abstract class MethodBindResult
422422
{
423-
public static MethodBindResult Create(string name, object rawResult, HostTarget hostTarget, object[] args)
423+
public static MethodBindResult Create(string name, BindingFlags bindFlags, object rawResult, HostTarget hostTarget, object[] args)
424424
{
425425
var method = rawResult as MethodInfo;
426426
if (method != null)
427427
{
428-
if ((method.IsStatic) && !hostTarget.Flags.HasFlag(HostTargetFlags.AllowStaticMembers))
428+
if (method.IsStatic && !bindFlags.HasFlag(BindingFlags.Static))
429429
{
430430
return new MethodBindFailure(() => new InvalidOperationException(MiscHelpers.FormatInvariant("Cannot access static method '{0}' in non-static context", method.Name)));
431431
}

0 commit comments

Comments
 (0)