Skip to content

Commit aa16a8a

Browse files
Version 5.3.11: Added support for building strong named assemblies (see ReadMe.txt), added AppDomain.AssemblyResolve hook for ClearScriptV8 (Issue ClearFoundry#34), added WindowsScriptEngineFlags.EnableStandardsMode, fixed parameterless invocation of Windows script items from VB.NET, fixed WindowsScriptEngine execution result variant leak, hardened assembly table I/O (Issue ClearFoundry#33), updates for breaking V8 API changes, added tests for bug fixes and new APIs. Tested with V8 3.24.17.
1 parent 133980c commit aa16a8a

37 files changed

Lines changed: 666 additions & 145 deletions

ClearScript.sln.DotSettings

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@
2525
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ID/@EntryIndexedValue">ID</s:String>
2626
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=JIT/@EntryIndexedValue">JIT</s:String>
2727
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=JS/@EntryIndexedValue">JS</s:String>
28+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=LCID/@EntryIndexedValue">LCID</s:String>
2829
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=URL/@EntryIndexedValue">URL</s:String>
2930
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=VB/@EntryIndexedValue">VB</s:String>
3031
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=VBS/@EntryIndexedValue">VBS</s:String>
3132
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateConstants/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
3233
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
3334
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
34-
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String></wpf:ResourceDictionary>
35+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
36+
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

ClearScript/ClearScript.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@
4848
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
4949
<Prefer32Bit>false</Prefer32Bit>
5050
</PropertyGroup>
51+
<PropertyGroup Condition="Exists('$(SolutionDir)ClearScript.snk')">
52+
<SignAssembly>true</SignAssembly>
53+
<AssemblyOriginatorKeyFile>$(SolutionDir)ClearScript.snk</AssemblyOriginatorKeyFile>
54+
</PropertyGroup>
5155
<ItemGroup>
5256
<Reference Include="System" />
5357
<Reference Include="System.Core" />

ClearScript/Exports/VersionSymbols.h

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

6464
#pragma once
6565

66-
#define CLEARSCRIPT_VERSION_STRING "5.3.10.0"
67-
#define CLEARSCRIPT_VERSION_COMMA_SEPARATED 5,3,10,0
66+
#define CLEARSCRIPT_VERSION_STRING "5.3.11.0"
67+
#define CLEARSCRIPT_VERSION_COMMA_SEPARATED 5,3,11,0

ClearScript/Properties/AssemblyInfo.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161

6262

6363

64+
65+
6466
using System.Reflection;
6567
using System.Runtime.CompilerServices;
6668
using System.Runtime.InteropServices;
@@ -73,5 +75,5 @@
7375
[assembly: InternalsVisibleTo("ClearScriptTest")]
7476

7577
[assembly: ComVisible(false)]
76-
[assembly: AssemblyVersion("5.3.10.0")]
77-
[assembly: AssemblyFileVersion("5.3.10.0")]
78+
[assembly: AssemblyVersion("5.3.11.0")]
79+
[assembly: AssemblyFileVersion("5.3.11.0")]

ClearScript/Properties/AssemblyInfo.tt

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,42 @@
5959
// fitness for a particular purpose and non-infringement.
6060
//
6161

62-
<#@ template debug="false" hostspecific="false" language="C#" #>
62+
<#@ template debug="false" hostspecific="true" language="C#" #>
6363
<#@ output extension=".cs" #>
6464
<#@ include file="..\..\Version.tt" #>
6565

66+
<#@ assembly name="EnvDTE" #>
67+
<#@ import namespace="EnvDTE" #>
68+
<#@ import namespace="System.IO" #>
69+
<#@ import namespace="System.Reflection" #>
70+
71+
<#
72+
var dte = (DTE)((IServiceProvider)Host).GetService(typeof(DTE));
73+
var keyFilePath = Path.Combine(Path.GetDirectoryName(dte.Solution.FullName), "ClearScript.snk");
74+
var publicKeySpec = string.Empty;
75+
try
76+
{
77+
using (var stream = new FileStream(keyFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
78+
{
79+
var keyPair = new StrongNameKeyPair(stream);
80+
publicKeySpec = ", PublicKey=" + BitConverter.ToString(keyPair.PublicKey).Replace("-", string.Empty);
81+
}
82+
}
83+
catch (Exception)
84+
{
85+
}
86+
#>
87+
6688
using System.Reflection;
6789
using System.Runtime.CompilerServices;
6890
using System.Runtime.InteropServices;
6991

7092
[assembly: AssemblyTitle("ClearScript Library")]
7193
[assembly: AssemblyProduct("ClearScript")]
7294
[assembly: AssemblyCopyright("(c) Microsoft Corporation")]
73-
[assembly: InternalsVisibleTo("ClearScriptV8-32")]
74-
[assembly: InternalsVisibleTo("ClearScriptV8-64")]
75-
[assembly: InternalsVisibleTo("ClearScriptTest")]
95+
[assembly: InternalsVisibleTo("<#= "ClearScriptV8-32" + publicKeySpec #>")]
96+
[assembly: InternalsVisibleTo("<#= "ClearScriptV8-64" + publicKeySpec #>")]
97+
[assembly: InternalsVisibleTo("<#= "ClearScriptTest" + publicKeySpec #>")]
7698

7799
[assembly: ComVisible(false)]
78100
[assembly: AssemblyVersion("<#= version #>")]

ClearScript/Util/AssemblyHelpers.cs

Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -90,36 +90,42 @@ public static string GetFullAssemblyName(string name)
9090

9191
private static void LoadAssemblyTable()
9292
{
93-
var dirPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
94-
dirPath = Path.Combine(dirPath, "Microsoft", "ClearScript", Environment.Is64BitProcess ? "x64" : "x86", GetRuntimeVersionDirectoryName());
95-
Directory.CreateDirectory(dirPath);
93+
// ReSharper disable EmptyGeneralCatchClause
9694

97-
var filePath = Path.Combine(dirPath, "AssemblyTable.bin");
98-
if (File.Exists(filePath))
95+
string filePath = null;
96+
try
9997
{
100-
// ReSharper disable EmptyGeneralCatchClause
101-
102-
try
98+
var dirPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
99+
if (!string.IsNullOrWhiteSpace(dirPath))
103100
{
104-
using (var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
101+
dirPath = Path.Combine(dirPath, "Microsoft", "ClearScript", Environment.Is64BitProcess ? "x64" : "x86", GetRuntimeVersionDirectoryName());
102+
Directory.CreateDirectory(dirPath);
103+
104+
filePath = Path.Combine(dirPath, "AssemblyTable.bin");
105+
if (File.Exists(filePath))
105106
{
106-
var formatter = new BinaryFormatter();
107-
table = (ConcurrentDictionary<string, string>)formatter.Deserialize(stream);
107+
try
108+
{
109+
using (var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
110+
{
111+
var formatter = new BinaryFormatter();
112+
table = (ConcurrentDictionary<string, string>)formatter.Deserialize(stream);
113+
}
114+
}
115+
catch (Exception)
116+
{
117+
}
108118
}
109119
}
110-
catch (Exception)
111-
{
112-
}
113-
114-
// ReSharper restore EmptyGeneralCatchClause
120+
}
121+
catch (Exception)
122+
{
115123
}
116124

117125
if (table == null)
118126
{
119-
// ReSharper disable EmptyGeneralCatchClause
120-
121127
BuildAssemblyTable();
122-
if (table != null)
128+
if ((table != null) && (filePath != null))
123129
{
124130
try
125131
{
@@ -133,35 +139,41 @@ private static void LoadAssemblyTable()
133139
{
134140
}
135141
}
136-
137-
// ReSharper restore EmptyGeneralCatchClause
138142
}
143+
144+
// ReSharper restore EmptyGeneralCatchClause
139145
}
140146

141147
private static void BuildAssemblyTable()
142148
{
143-
var key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\.NETFramework");
144-
if (key != null)
145-
{
146-
var dirPath = Path.Combine((string)key.GetValue("InstallRoot"), GetRuntimeVersionDirectoryName());
149+
// ReSharper disable EmptyGeneralCatchClause
147150

148-
table = new ConcurrentDictionary<string, string>();
149-
foreach (var filePath in Directory.EnumerateFiles(dirPath, "*.dll", SearchOption.AllDirectories))
151+
try
152+
{
153+
var key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\.NETFramework");
154+
if (key != null)
150155
{
151-
// ReSharper disable EmptyGeneralCatchClause
156+
var dirPath = Path.Combine((string)key.GetValue("InstallRoot"), GetRuntimeVersionDirectoryName());
152157

153-
try
154-
{
155-
var assemblyName = Assembly.ReflectionOnlyLoadFrom(filePath).GetName();
156-
table.TryAdd(assemblyName.Name, assemblyName.FullName);
157-
}
158-
catch (Exception)
158+
table = new ConcurrentDictionary<string, string>();
159+
foreach (var filePath in Directory.EnumerateFiles(dirPath, "*.dll", SearchOption.AllDirectories))
159160
{
161+
try
162+
{
163+
var assemblyName = Assembly.ReflectionOnlyLoadFrom(filePath).GetName();
164+
table.TryAdd(assemblyName.Name, assemblyName.FullName);
165+
}
166+
catch (Exception)
167+
{
168+
}
160169
}
161-
162-
// ReSharper restore EmptyGeneralCatchClause
163170
}
164171
}
172+
catch (Exception)
173+
{
174+
}
175+
176+
// ReSharper restore EmptyGeneralCatchClause
165177
}
166178

167179
private static string GetRuntimeVersionDirectoryName()

ClearScript/Util/DynamicHelpers.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,32 +121,32 @@ public static bool TryBindAndInvoke(DynamicMetaObjectBinder binder, object targe
121121
return true;
122122
}
123123
}
124-
else if ((args != null) && (args.Length > 0))
124+
else
125125
{
126-
var getIndexBinder = binder as GetIndexBinder;
127-
if (getIndexBinder != null)
126+
var invokeMemberBinder = binder as InvokeMemberBinder;
127+
if (invokeMemberBinder != null)
128128
{
129-
if (TryGetProperty(reflect, args[0].ToString(), false, args.Skip(1).ToArray(), out result))
129+
if (TryInvokeMethod(reflect, invokeMemberBinder.Name, false, args, out result))
130130
{
131131
return true;
132132
}
133133
}
134-
else
134+
else if ((args != null) && (args.Length > 0))
135135
{
136-
var setIndexBinder = binder as SetIndexBinder;
137-
if (setIndexBinder != null)
136+
var getIndexBinder = binder as GetIndexBinder;
137+
if (getIndexBinder != null)
138138
{
139-
if (TrySetProperty(reflect, args[0].ToString(), false, args.Skip(1).ToArray(), out result))
139+
if (TryGetProperty(reflect, args[0].ToString(), false, args.Skip(1).ToArray(), out result))
140140
{
141141
return true;
142142
}
143143
}
144144
else
145145
{
146-
var invokeMemberBinder = binder as InvokeMemberBinder;
147-
if (invokeMemberBinder != null)
146+
var setIndexBinder = binder as SetIndexBinder;
147+
if (setIndexBinder != null)
148148
{
149-
if (TryInvokeMethod(reflect, invokeMemberBinder.Name, false, args, out result))
149+
if (TrySetProperty(reflect, args[0].ToString(), false, args.Skip(1).ToArray(), out result))
150150
{
151151
return true;
152152
}

ClearScript/Util/UniqueNameManager.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public string GetUniqueName(string inputName, string alternate)
8686
map.TryGetValue(nonBlankName, out count);
8787

8888
map[nonBlankName] = ++count;
89-
return (count < 2) ? nonBlankName : MiscHelpers.FormatInvariant("{0} [{1}]", nonBlankName, count);
89+
return (count < 2) ? nonBlankName : string.Concat(nonBlankName, " [", count, "]");
9090
}
9191
}
9292

@@ -105,13 +105,13 @@ public string GetUniqueName(string inputName, string alternate)
105105
lock (mapLock)
106106
{
107107
var nonBlankName = MiscHelpers.EnsureNonBlank(Path.GetFileNameWithoutExtension(inputName), alternate);
108+
var extension = Path.GetExtension(inputName);
108109

109110
uint count;
110111
map.TryGetValue(nonBlankName, out count);
111112

112113
map[nonBlankName] = ++count;
113-
var uniqueName = (count < 2) ? nonBlankName : MiscHelpers.FormatInvariant("{0} [{1}]", nonBlankName, count);
114-
return Path.HasExtension(inputName) ? Path.ChangeExtension(uniqueName, Path.GetExtension(inputName)) : uniqueName;
114+
return (count < 2) ? string.Concat(nonBlankName, extension) : string.Concat(nonBlankName, " [", count, "]", extension);
115115
}
116116
}
117117

ClearScript/V8/ClearScriptV8/32/AssemblyInfo.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ using namespace System::Runtime::InteropServices;
6868
[assembly:AssemblyTitle("ClearScript V8 Interface (32-bit)")];
6969
[assembly:AssemblyProduct("ClearScript")];
7070
[assembly:AssemblyCopyright("(c) Microsoft Corporation")]
71-
[assembly:InternalsVisibleTo("ClearScript")];
7271

7372
[assembly:ComVisible(false)];
7473
[assembly:AssemblyVersion(CLEARSCRIPT_VERSION_STRING)];

ClearScript/V8/ClearScriptV8/32/ClearScriptV8-32.vcxproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
<LinkIncremental>false</LinkIncremental>
5454
<OutDir>$(SolutionDir)bin\$(Configuration)\</OutDir>
5555
</PropertyGroup>
56+
<PropertyGroup Condition="Exists('$(SolutionDir)ClearScript.snk')">
57+
<LinkKeyFile>$(SolutionDir)ClearScript.snk</LinkKeyFile>
58+
</PropertyGroup>
5659
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
5760
<ClCompile>
5861
<WarningLevel>Level4</WarningLevel>

0 commit comments

Comments
 (0)