Skip to content

Commit 63e7a7b

Browse files
committed
VisualBasic Compiler updated and registered dynamically
1 parent ed2cad6 commit 63e7a7b

4 files changed

Lines changed: 32 additions & 16 deletions

File tree

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,26 +138,30 @@ protected virtual IEnumerable<Type> GetProviderCompilerContainers()
138138
typeof (DecimalCompilers),
139139
typeof (GuidCompilers),
140140
typeof (EnumCompilers),
141-
//typeof (VbStringsCompilers),
142-
//typeof (VbDateAndTimeCompilers),
141+
143142
};
144143
var result = basicCompilerContainers;
145-
var loadedAssemblies = AssemblyLoadContext.Default.Assemblies;
144+
var defaultLoadedAssemblies = AssemblyLoadContext.Default.Assemblies;
145+
var currentLoadedAssemblies = AssemblyLoadContext.CurrentContextualReflectionContext.Assemblies;
146146
// dynamic registration to not cause assembly loading
147-
if (loadedAssemblies.Any(a => a.GetName().Name.Equals("FSharp.Core", StringComparison.OrdinalIgnoreCase))) {
147+
if (defaultLoadedAssemblies.Any(static a => a.GetName().Name.Equals("FSharp.Core", StringComparison.OrdinalIgnoreCase))
148+
|| defaultLoadedAssemblies.Any(static a => a.GetName().Name.Equals("FSharp.Core", StringComparison.OrdinalIgnoreCase))) {
148149
result = result.Concat(new[] {
149150
typeof (FSharpMathOperationsCompilers),
150151
typeof (FSharpOperatorsCompilers),
151152
typeof (FSharpStringCompilers),
152153
typeof (FSharpConversionsCompilers),
153154
});
154155
}
155-
//if (loadedAssemblies.Any(a => a.GetName().Name.Equals("Microsoft.VisualBasic", StringComparison.OrdinalIgnoreCase)){
156-
// result = result.Concat(new[] {
157-
// typeof (VbStringsCompilers),
158-
// typeof (VbDateAndTimeCompilers),
159-
// });
160-
//}
156+
157+
if (defaultLoadedAssemblies.Any(static a => a.GetName().Name.Equals("Microsoft.VisualBasic", StringComparison.OrdinalIgnoreCase))
158+
|| defaultLoadedAssemblies.Any(static a => a.GetName().Name.Equals("Microsoft.VisualBasic", StringComparison.OrdinalIgnoreCase))) {
159+
result = result.Concat(new[] {
160+
typeof (VbConversionsCompilers),
161+
typeof (VbStringsCompilers),
162+
typeof (VbDateAndTimeCompilers),
163+
});
164+
}
161165

162166
return result;
163167
}

Orm/Xtensive.Orm/Orm/Providers/Expressions/MemberCompilers/VBStringsCompilers.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2003-2010 Xtensive LLC.
1+
// Copyright (C) 2003-2010 Xtensive LLC.
22
// All rights reserved.
33
// For conditions of distribution and use, see license.
44
// Created by: Aleksey Gamzov
@@ -13,7 +13,11 @@ namespace Xtensive.Orm.Providers
1313
[CompilerContainer(typeof(SqlExpression))]
1414
internal static class VbStringsCompilers
1515
{
16-
private const string VbStrings = "Microsoft.VisualBasic.Strings, Microsoft.VisualBasic, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
16+
#if NET10_0_OR_GREATER
17+
private const string VbStrings = "Microsoft.VisualBasic.Strings, Microsoft.VisualBasic.Core, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
18+
#else
19+
private const string VbStrings = "Microsoft.VisualBasic.Strings, Microsoft.VisualBasic.Core, Version=13.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
20+
#endif
1721

1822
[Compiler(VbStrings, "Trim", TargetKind.Static)]
1923
public static SqlExpression Trim(SqlExpression stringExpression)

Orm/Xtensive.Orm/Orm/Providers/Expressions/MemberCompilers/VbConversionsCompilers.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2003-2010 Xtensive LLC.
1+
// Copyright (C) 2003-2010 Xtensive LLC.
22
// All rights reserved.
33
// For conditions of distribution and use, see license.
44
// Created by: Aleksey Gamzov
@@ -17,7 +17,11 @@ namespace Xtensive.Orm.Providers
1717
[CompilerContainer(typeof(SqlExpression))]
1818
internal static class VbConversionsCompilers
1919
{
20-
private const string VbConversions = "Microsoft.VisualBasic.CompilerServices.Conversions, Microsoft.VisualBasic, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
20+
#if NET10_0_OR_GREATER
21+
private const string VbConversions = "Microsoft.VisualBasic.CompilerServices.Conversions, Microsoft.VisualBasic.Core, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
22+
#else
23+
private const string VbConversions = "Microsoft.VisualBasic.CompilerServices.Conversions, Microsoft.VisualBasic.Core, Version=13.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
24+
#endif
2125

2226
[Compiler(VbConversions, "ToBoolean", TargetKind.Static)]
2327
public static SqlExpression ToBoolean([Type(typeof(string))]SqlExpression stringExpression)

Orm/Xtensive.Orm/Orm/Providers/Expressions/MemberCompilers/VbDateAndTimeCompilers.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2003-2010 Xtensive LLC.
1+
// Copyright (C) 2003-2010 Xtensive LLC.
22
// All rights reserved.
33
// For conditions of distribution and use, see license.
44
// Created by: Aleksey Gamzov
@@ -17,7 +17,11 @@ namespace Xtensive.Orm.Providers
1717
[CompilerContainer(typeof(SqlExpression))]
1818
internal static class VbDateAndTimeCompilers
1919
{
20-
private const string VbDateAndTime = "Microsoft.VisualBasic.DateAndTime, Microsoft.VisualBasic, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
20+
#if NET10_0_OR_GREATER
21+
private const string VbDateAndTime = "Microsoft.VisualBasic.DateAndTime, Microsoft.VisualBasic.Core, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
22+
#else
23+
private const string VbDateAndTime = "Microsoft.VisualBasic.DateAndTime, Microsoft.VisualBasic.Core, Version=13.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
24+
#endif
2125

2226
[Compiler(VbDateAndTime, "Year", TargetKind.Static)]
2327
public static SqlExpression Year(SqlExpression dateExpression)

0 commit comments

Comments
 (0)