Skip to content

Commit c6fa3b3

Browse files
committed
Dynamic definition of compiler containers
1 parent f7e74d3 commit c6fa3b3

1 file changed

Lines changed: 24 additions & 3 deletions

File tree

Orm/Xtensive.Orm/Orm/Providers/DomainHandler.cs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
using System;
88
using System.Collections.Generic;
9+
using System.Linq;
10+
using System.Runtime.Loader;
911
using Xtensive.Core;
1012
using Xtensive.Orm.Building.Builders;
1113
using Xtensive.Orm.Linq.MemberCompilation;
@@ -123,7 +125,7 @@ protected virtual IPostCompiler CreatePostCompiler(CompilerConfiguration configu
123125
/// <returns>Compiler containers for current provider.</returns>
124126
protected virtual IEnumerable<Type> GetProviderCompilerContainers()
125127
{
126-
return new[] {
128+
IEnumerable<Type> basicCompilerContainers = new[] {
127129
typeof (NullableCompilers),
128130
typeof (StringCompilers),
129131
typeof (DateTimeCompilers),
@@ -135,10 +137,29 @@ protected virtual IEnumerable<Type> GetProviderCompilerContainers()
135137
typeof (NumericCompilers),
136138
typeof (DecimalCompilers),
137139
typeof (GuidCompilers),
138-
//typeof (VbStringsCompilers),
139-
//typeof (VbDateAndTimeCompilers),
140140
typeof (EnumCompilers),
141141
};
142+
var result = basicCompilerContainers;
143+
var allLoadedAssemblies = AssemblyLoadContext.All.SelectMany(static c => c.Assemblies);
144+
// dynamic registration to not cause assembly loading
145+
if (allLoadedAssemblies.Any(static a => a.GetName().Name.Equals("FSharp.Core", StringComparison.OrdinalIgnoreCase))) {
146+
result = result.Concat(new[] {
147+
typeof (FSharpMathOperationsCompilers),
148+
typeof (FSharpOperatorsCompilers),
149+
typeof (FSharpStringCompilers),
150+
typeof (FSharpConversionsCompilers),
151+
});
152+
}
153+
154+
if (allLoadedAssemblies.Any(static a => a.GetName().Name.StartsWith("Microsoft.VisualBasic", StringComparison.OrdinalIgnoreCase))) {
155+
result = result.Concat(new[] {
156+
typeof (VbConversionsCompilers),
157+
typeof (VbStringsCompilers),
158+
typeof (VbDateAndTimeCompilers),
159+
});
160+
}
161+
162+
return result;
142163
}
143164

144165
protected virtual SearchConditionCompiler CreateSearchConditionVisitor()

0 commit comments

Comments
 (0)