File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 11
11
12
12
using LINQPad . Extensibility . DataContext ;
13
13
using System . Reflection ;
14
+ using System . IO ;
14
15
15
16
namespace LinqToDB . LINQPad
16
17
{
@@ -190,5 +191,26 @@ public static void ConfigureRedirects()
190
191
return typeof ( DataContext ) . Assembly ;
191
192
} ;
192
193
}
194
+
195
+ public static void SapHanaSPS04Fixes ( )
196
+ {
197
+ // recent SAP HANA provider (SPS04) uses Assembly.GetEntryAssembly() calls during native dlls discovery, which
198
+ // leads to NRE as it returns null under NETFX, so we need to fake this method result to unblock HANA testing
199
+ // https://github.com/microsoft/vstest/issues/1834
200
+ // https://dejanstojanovic.net/aspnet/2015/january/set-entry-assembly-in-unit-testing-methods/
201
+ try
202
+ {
203
+ var assembly = Assembly . GetCallingAssembly ( ) ;
204
+
205
+ var manager = new AppDomainManager ( ) ;
206
+ var entryAssemblyfield = manager . GetType ( ) . GetField ( "m_entryAssembly" , BindingFlags . Instance | BindingFlags . NonPublic ) ;
207
+ entryAssemblyfield . SetValue ( manager , assembly ) ;
208
+
209
+ var domain = AppDomain . CurrentDomain ;
210
+ var domainManagerField = domain . GetType ( ) . GetField ( "_domainManager" , BindingFlags . Instance | BindingFlags . NonPublic ) ;
211
+ domainManagerField . SetValue ( domain , manager ) ;
212
+ }
213
+ catch { /* ne shmagla */ }
214
+ }
193
215
}
194
216
}
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ public class LinqToDBDriver : DynamicDataContextDriver
31
31
static LinqToDBDriver ( )
32
32
{
33
33
DriverHelper . ConfigureRedirects ( ) ;
34
+ DriverHelper . SapHanaSPS04Fixes ( ) ;
34
35
}
35
36
36
37
public override string GetConnectionDescription ( IConnectionInfo cxInfo )
You can’t perform that action at this time.
0 commit comments