Skip to content

Commit

Permalink
Version 6.0.1: Improved support for IIS least-privilege accounts (Git…
Browse files Browse the repository at this point in the history
…Hub Issue microsoft#160); fixed 64-bit V8 initialization on Azure App Service (GitHub Issue microsoft#166); enabled DirectAccess for ComVisible .NET objects (GitHub Issue microsoft#161); added ScriptEngine.ExposeHostObjectStaticMembers (GitHub Issue microsoft#152); added ScriptEngine.UndefinedImportValue and made Undefined.Value public (GitHub Issue microsoft#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 microsoft#169); enabled the use of the application's root folder as a backup for its local data folder (GitHub Issue microsoft#171); reduced minimum CPU profile and heap size sampling intervals to 125 ms; updated deployment and API documentation, resolving GitHub Issues microsoft#158 and microsoft#159. Tested with V8 8.1.307.28.
  • Loading branch information
ClearScriptLib committed Apr 13, 2020
1 parent d2ff7ca commit 19ca67c
Show file tree
Hide file tree
Showing 739 changed files with 4,126 additions and 3,075 deletions.
2 changes: 2 additions & 0 deletions ClearScript.NoV8.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=dispid/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=dispids/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=DISPPARAMS/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=ELEMDESC/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=excep/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=EXCEPINFO/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Exprs/@EntryIndexedValue">True</s:Boolean>
Expand Down Expand Up @@ -162,6 +163,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=Steptype/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=sunspider/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=TYPEATTR/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=TYPEDESC/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=TYPEFLAGS/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=TYPEKIND/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=TYPELIBATTR/@EntryIndexedValue">True</s:Boolean>
Expand Down
2 changes: 2 additions & 0 deletions ClearScript.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=dispid/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=dispids/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=DISPPARAMS/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=ELEMDESC/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=excep/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=EXCEPINFO/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Exprs/@EntryIndexedValue">True</s:Boolean>
Expand Down Expand Up @@ -162,6 +163,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=Steptype/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=sunspider/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=TYPEATTR/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=TYPEDESC/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=TYPEFLAGS/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=TYPEKIND/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=TYPELIBATTR/@EntryIndexedValue">True</s:Boolean>
Expand Down
4 changes: 2 additions & 2 deletions ClearScript/ByRefArg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ public override object DynamicInvokeTarget
get { return target.DynamicInvokeTarget; }
}

public override HostTargetFlags Flags
public override HostTargetFlags GetFlags(IHostInvokeContext context)
{
get { return target.Flags; }
return target.GetFlags(context);
}

public override string[] GetAuxMethodNames(IHostInvokeContext context, BindingFlags bindFlags)
Expand Down
1 change: 1 addition & 0 deletions ClearScript/ClearScript.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
<Compile Include="Util\COM\DispatchMember.cs" />
<Compile Include="Util\COM\DispatchWrappers.cs" />
<Compile Include="Util\COM\HResult.cs" />
<Compile Include="Util\COM\StructHelpers.cs" />
<Compile Include="Util\COM\TypeInfoHelpers.cs" />
<Compile Include="Util\COM\TypeInfoHelpers.NetFramework.cs" />
<Compile Include="Util\COM\TypeLibHelpers.cs" />
Expand Down
2 changes: 1 addition & 1 deletion ClearScript/DocumentInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ internal UniqueDocumentInfo MakeUnique(IUniqueNameManager manager, DocumentFlags
}

var uniqueName = manager.GetUniqueName(Name, Category.DefaultName);
if (Flags.GetValueOrDefault().HasFlag(DocumentFlags.IsTransient))
if (info.Flags.GetValueOrDefault().HasFlag(DocumentFlags.IsTransient))
{
uniqueName += " [temp]";
}
Expand Down
12 changes: 5 additions & 7 deletions ClearScript/DocumentSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Microsoft.ClearScript.JavaScript;
Expand Down Expand Up @@ -190,14 +189,13 @@ internal async Task<Document> LoadDocumentAsync(DocumentInfo? sourceInfo, string

private Document FindSystemDocument(string identifier, DocumentCategory category)
{
try
Document document;
if (systemDocumentMap.TryGetValue(Tuple.Create(identifier, category ?? DocumentCategory.Script), out document))
{
return systemDocumentMap[Tuple.Create(identifier, category ?? DocumentCategory.Script)];
}
catch (KeyNotFoundException)
{
return null;
return document;
}

return null;
}
}
}
4 changes: 2 additions & 2 deletions ClearScript/Exports/VersionSymbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

#pragma once

#define CLEARSCRIPT_VERSION_STRING "6.0.0.0"
#define CLEARSCRIPT_VERSION_COMMA_SEPARATED 6,0,0,0
#define CLEARSCRIPT_VERSION_STRING "6.0.1.0"
#define CLEARSCRIPT_VERSION_COMMA_SEPARATED 6,0,1,0
41 changes: 17 additions & 24 deletions ClearScript/HostFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT license.

using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Dynamic;
using System.Globalization;
Expand Down Expand Up @@ -1647,13 +1646,20 @@ public object newComObj(string progID, string serverName = null)
}

/// <summary>
/// Imports enumerations from a type library.
/// Imports enumerations defined within or referenced from a COM/ActiveX type library.
/// </summary>
/// <typeparam name="T">The imported type whose parent library is to be searched for enumerations.</typeparam>
/// <typeparam name="T">The imported type whose parent library is to be searched for relevant enumerations.</typeparam>
/// <param name="obj">An instance of the representative type.</param>
/// <returns>A collection of imported enumerations.</returns>
public IPropertyBag typeLibEnums<T>(T obj) where T : class
/// <param name="collection">An optional host type collection with which to merge the imported enumerations.</param>
/// <returns>A host type collection: <paramref name="collection"/> if it is not <c>null</c>, a new host type collection otherwise.</returns>
public HostTypeCollection typeLibEnums<T>(T obj, HostTypeCollection collection = null) where T : class
{
MiscHelpers.VerifyNonNullArgument(obj, "obj");
if (collection == null)
{
collection = new HostTypeCollection();
}

var type = typeof(T);
if (type.IsUnknownCOMObject())
{
Expand All @@ -1663,31 +1669,18 @@ public IPropertyBag typeLibEnums<T>(T obj) where T : class
var typeInfo = dispatch.GetTypeInfo();
if (typeInfo != null)
{
return typeInfo.GetTypeLibEnums();
typeInfo.GetContainingTypeLib().GetReferencedEnums().ForEach(collection.AddEnumTypeInfo);
return collection;
}
}

throw new ArgumentException("Object type is not imported", "obj");
}

if (!type.IsImport)
{
throw new ArgumentException("Object type is not imported", "obj");
}

var typeCollection = new HostTypeCollection();

var assembly = type.Assembly;
Debug.Assert(assembly.GetCustomAttribute(typeof(ImportedFromTypeLibAttribute)) != null);
foreach (var assemblyType in assembly.GetTypes())
else if (type.IsImport && (type.Assembly.GetCustomAttribute(typeof(ImportedFromTypeLibAttribute)) != null))
{
if (assemblyType.IsPublic && assemblyType.IsEnum)
{
typeCollection.AddType(assemblyType);
}
type.Assembly.GetReferencedEnums().ForEach(collection.AddType);
return collection;
}

return typeCollection;
throw new ArgumentException("Object type is not imported", "obj");
}

// ReSharper restore InconsistentNaming
Expand Down
4 changes: 2 additions & 2 deletions ClearScript/HostIndexedProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public override object DynamicInvokeTarget
get { return null; }
}

public override HostTargetFlags Flags
public override HostTargetFlags GetFlags(IHostInvokeContext context)
{
get { return HostTargetFlags.None; }
return HostTargetFlags.None;
}

public override string[] GetAuxMethodNames(IHostInvokeContext context, BindingFlags bindFlags)
Expand Down
28 changes: 14 additions & 14 deletions ClearScript/HostItem.InvokeMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private object InvokeMethod(string name, object[] args, object[] bindArgs)
private object InvokeMethod(string name, Type[] typeArgs, object[] args, object[] bindArgs)
{
var bindResult = BindMethod(name, typeArgs, args, bindArgs);
if ((bindResult is MethodBindFailure) && target.Flags.HasFlag(HostTargetFlags.AllowExtensionMethods))
if ((bindResult is MethodBindFailure) && target.GetFlags(this).HasFlag(HostTargetFlags.AllowExtensionMethods))
{
var targetArg = target.Target.ToEnumerable();
var extensionArgs = targetArg.Concat(args).ToArray();
Expand Down Expand Up @@ -108,17 +108,17 @@ private MethodBindResult BindMethod(string name, Type[] typeArgs, object[] args,
// WARNING: BindSignature holds on to the specified typeArgs; subsequent modification
// will result in bugs that are difficult to diagnose. Create a copy if necessary.

var signature = new BindSignature(accessContext, bindFlags, target, name, typeArgs, bindArgs);
var signature = new BindSignature(AccessContext, bindFlags, target, name, typeArgs, bindArgs);
MethodBindResult result;

object rawResult;
if (engine.TryGetCachedBindResult(signature, out rawResult))
{
result = MethodBindResult.Create(name, rawResult, target, args);
result = MethodBindResult.Create(name, bindFlags, rawResult, target, args);
}
else
{
result = BindMethodInternal(accessContext, bindFlags, target, name, typeArgs, args, bindArgs);
result = BindMethodInternal(AccessContext, bindFlags, target, name, typeArgs, args, bindArgs);
if (!result.IsPreferredMethod(this, name))
{
if (result is MethodBindSuccess)
Expand All @@ -128,7 +128,7 @@ private MethodBindResult BindMethod(string name, Type[] typeArgs, object[] args,

foreach (var altName in GetAltMethodNames(name, bindFlags))
{
var altResult = BindMethodInternal(accessContext, bindFlags, target, altName, typeArgs, args, bindArgs);
var altResult = BindMethodInternal(AccessContext, bindFlags, target, altName, typeArgs, args, bindArgs);
if (altResult.IsUnblockedMethod(this))
{
result = altResult;
Expand Down Expand Up @@ -163,7 +163,7 @@ private static MethodBindResult BindMethodInternal(Type bindContext, BindingFlag
object rawResult;
if (coreBindCache.TryGetValue(signature, out rawResult))
{
result = MethodBindResult.Create(name, rawResult, target, args);
result = MethodBindResult.Create(name, bindFlags, rawResult, target, args);
}
else
{
Expand All @@ -185,7 +185,7 @@ private static MethodBindResult BindMethodCore(Type bindContext, BindingFlags bi
// perform default binding
var rawResult = BindMethodRaw(bindFlags, binder, target, bindArgs);

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

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

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

private IEnumerable<string> GetAltMethodNamesInternal(string name, BindingFlags bindFlags)
{
foreach (var method in target.Type.GetScriptableMethods(name, bindFlags, accessContext, defaultAccess))
foreach (var method in target.Type.GetScriptableMethods(name, bindFlags, AccessContext, DefaultAccess))
{
var methodName = method.GetShortName();
if (methodName != name)
Expand Down Expand Up @@ -326,7 +326,7 @@ private MethodBindResult BindMethodUsingReflection(BindingFlags bindFlags, HostT
{
object state;
var rawResult = Type.DefaultBinder.BindToMethod(bindFlags, candidates, ref args, null, null, null, out state);
return MethodBindResult.Create(name, rawResult, hostTarget, args);
return MethodBindResult.Create(name, bindFlags, rawResult, hostTarget, args);
}
catch (MissingMethodException)
{
Expand Down Expand Up @@ -368,7 +368,7 @@ private IEnumerable<MethodInfo> GetReflectionCandidates(BindingFlags bindFlags,

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

Expand Down Expand Up @@ -420,12 +420,12 @@ internal static long GetCoreBindCount()

private abstract class MethodBindResult
{
public static MethodBindResult Create(string name, object rawResult, HostTarget hostTarget, object[] args)
public static MethodBindResult Create(string name, BindingFlags bindFlags, object rawResult, HostTarget hostTarget, object[] args)
{
var method = rawResult as MethodInfo;
if (method != null)
{
if ((method.IsStatic) && !hostTarget.Flags.HasFlag(HostTargetFlags.AllowStaticMembers))
if (method.IsStatic && !bindFlags.HasFlag(BindingFlags.Static))
{
return new MethodBindFailure(() => new InvalidOperationException(MiscHelpers.FormatInvariant("Cannot access static method '{0}' in non-static context", method.Name)));
}
Expand Down
Loading

0 comments on commit 19ca67c

Please sign in to comment.