Skip to content

Commit

Permalink
Improve LinqToVB for some VB features (#100)
Browse files Browse the repository at this point in the history
* LinqToVB - Support type conversion functions

* LinqToVB - Support VB String comparaison (Operators.CompareString)

* Imports Microsoft.VisualBasic in all genered files

* Minor code cleanup
  • Loading branch information
lorcQc authored Feb 24, 2024
1 parent c6c4de9 commit 0931b81
Show file tree
Hide file tree
Showing 41 changed files with 726 additions and 467 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
{
"System",
"System.Collections.Generic",
"Microsoft.EntityFrameworkCore"
"Microsoft.EntityFrameworkCore",
"Microsoft.VisualBasic"
};

var FullyQualifiedContextNamespace = code.FullyQualifiedNamespace(Options.RootNamespace, NamespaceHint);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
var importsList = new List<string>
{
"System",
"System.Collections.Generic"
"System.Collections.Generic",
"Microsoft.VisualBasic"
};

if (Options.UseDataAnnotations)
Expand Down
2 changes: 0 additions & 2 deletions EFCore.VisualBasic/Design/EFCoreVisualBasicServices.vb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Namespace Design
Implements IDesignTimeServices

Public Sub ConfigureDesignTimeServices(services As IServiceCollection) Implements IDesignTimeServices.ConfigureDesignTimeServices

With services
.AddSingleton(Of IVisualBasicHelper, VisualBasicHelper)()
.AddSingleton(Of IMigrationsCodeGenerator, VisualBasicMigrationsGenerator)()
Expand All @@ -21,7 +20,6 @@ Namespace Design
.AddSingleton(Of IVisualBasicRuntimeAnnotationCodeGenerator, VisualBasicRuntimeAnnotationCodeGenerator)
.AddSingleton(Of ICompiledModelCodeGenerator, VisualBasicRuntimeModelCodeGenerator)
End With

End Sub
End Class
End Namespace
8 changes: 4 additions & 4 deletions EFCore.VisualBasic/Design/Internal/VisualBasicHelper.vb
Original file line number Diff line number Diff line change
Expand Up @@ -509,26 +509,26 @@ Namespace Design.Internal
Return ArrayLitetal(GetType(T), values, vertical)
End Function

Private Function ArrayLitetal(Type As Type, values As IEnumerable, Optional vertical As Boolean = False) As String
Private Function ArrayLitetal(type As Type, values As IEnumerable, Optional vertical As Boolean = False) As String
Dim builder As New IndentedStringBuilder

Dim valuesList = values.Cast(Of Object)().ToList()

If valuesList.Count = 0 Then
builder.
Append("New ").
Append(Reference(Type)).
Append(Reference(type)).
Append("() {}")
Else

Dim byteArray As Boolean
Dim addingType As Boolean

If Type = GetType(Byte) Then
If type = GetType(Byte) Then
builder.Append("New Byte")
addingType = True
byteArray = True
ElseIf Type = GetType(Object) Then
ElseIf type = GetType(Object) Then
builder.Append("New Object")
addingType = True
End If
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,5 @@ Namespace Design.AnnotationCodeGeneratorProvider

MyBase.Generate(entityType, parameters)
End Sub

End Class
End Namespace
Loading

0 comments on commit 0931b81

Please sign in to comment.