Skip to content

Commit

Permalink
Make sure type load error is caught, even when unexpected
Browse files Browse the repository at this point in the history
fixes #21
  • Loading branch information
jbtule committed Sep 18, 2017
1 parent 60ffece commit ba5d743
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
1 change: 1 addition & 0 deletions Dynamitey.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<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/CodeStyle/Naming/CSharpNaming/Abbreviations/=SL/@EntryIndexedValue">SL</s:String>
<s:String x:Key="/Default/FilterSettingsManager/CoverageFilterXml/@EntryValue">&lt;data&gt;&lt;IncludeFilters /&gt;&lt;ExcludeFilters /&gt;&lt;/data&gt;</s:String>
<s:String x:Key="/Default/FilterSettingsManager/AttributeFilterXml/@EntryValue">&lt;data /&gt;</s:String></wpf:ResourceDictionary>
38 changes: 24 additions & 14 deletions Dynamitey/Dynamic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,40 @@ public static void ClearCaches()
InvokeHelper.ClearAllCaches();
}

private static readonly Type ComObjectType;


private static readonly dynamic ComBinder
= new DynamicObjects.LateType("System.Dynamic.ComBinder, System.Dynamic, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");


internal static readonly dynamic Impromptu
= new DynamicObjects.LateType("ImpromptuInterface.Impromptu, ImpromptuInterface, PublicKeyToken=0b1781c923b2975b");

internal static readonly dynamic TypeDescriptor
= new DynamicObjects.LateType("System.ComponentModel.TypeDescriptor, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");


private static readonly dynamic ComBinder;
private static readonly Type ComObjectType;
internal static readonly Type TypeConverterAttributeSL;

static Dynamic()
{
try
{
ComObjectType = typeof(object).GetTypeInfo().Assembly.GetType("System.__ComObject");
ComBinder = new DynamicObjects.LateType(
"System.Dynamic.ComBinder, System.Dynamic, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
}
catch
{

ComObjectType = null;
}
try
{
TypeConverterAttributeSL
= Type.GetType("System.ComponentModel.TypeConverter, System, Version=5.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e", false);
}
catch
{
TypeConverterAttributeSL = null;
}
}
/// <summary>
Expand Down Expand Up @@ -796,15 +815,6 @@ public static IEnumerable<T> ConvertAll<T>(this System.Collections.IEnumerable e
return enumerable.Cast<Object>().Select(it => InvokeConvert(it, typeof (T), explict)).Cast<T>();
}

internal static readonly dynamic Impromptu
= new DynamicObjects.LateType("ImpromptuInterface.Impromptu, ImpromptuInterface, PublicKeyToken=0b1781c923b2975b");

internal static readonly dynamic TypeDescriptor
= new DynamicObjects.LateType("System.ComponentModel.TypeDescriptor, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");

internal static readonly Type TypeConverterAttributeSL
= Type.GetType("System.ComponentModel.TypeConverter, System, Version=5.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e", false);

/// <summary>
/// Goes the extra mile to convert target to type.
/// </summary>
Expand Down

0 comments on commit ba5d743

Please sign in to comment.