logo WinWrap®
May 31, 2020

WinWrap® Basic WWB.NET/5 Scripts

Announcing the availablity of the WinWrap® Basic WWB.NET/5 Language Option enabling developer and end-user scripts to access and call the thousands of reusable classes from Microsoft's .NET 5.

The WinWrap® Basic WWB.NET/5 Scripting Language Option enables:

  • .NET Scripting for COM host applications
  • .NET Scripting for .NET 4 host applications
  • .NET Scripting for .NET 5 host applications
  • Simultaneous access to the Microsoft .NET 4 and .NET 5
  • Simultaneous access to 3rd Party .NET 4 and .NET 5 Code Assemblies

WWB.NET Scripting Language

Microsoft .NET 5

In May of 2019 Microsoft announced the release of .NET 5 for November, 2020. The naming of .NET 5 is a bit confusing. It will be a continuation of Microsoft's .NET Core v3 implementation of .NET. It is not a direct successor to Microsoft's .NET 4 Framework implementation of .NET. These two implementations of .NET have mostly similar types, but the implementation details are completely different. An instance of a .NET 4 type cannot be used by .NET 5. Similarly, an instance of a .NET 5 type cannot be used by .NET 4.

Microsoft .NET 5.0

Today, .NET 5 is still in preview. Install the latest preview from Microsoft to use WWB.NET/5 with .NET 5. (WWB.NET/5 will also work with .NET Core 3.1, but that support will not continue after .NET 5 has been offically released.)

WWB.NET/4 and WWB.NET/5

Two new "languages" have been added to WinWrap Basic: "WWB.NET/4" and "WWB.NET/5". These languages determine the primary implementation of .NET that the script can access. Since, accessing both .NET 4 and .NET 5 simultaneously may be a script requirement, the "other" implementation of .NET can be accessed using the new .NET other character (@) when specifying a type.

COM Host Application Developers

WinWrap's WWB.NET/5 Scripting Language Option enables developers and end-users to access and call the thousands of reusable classes in the .NET 5. In fact, adding the WinWrap® Scripting Engine with the WWB.NET Language Option to your COM application may be the most cost effective to add the entire power of the Microsoft .NET 5 to your existing COM application. The WWB.NET/5 language provides direct access to .NET 5 types while The WWB.NET/4 language provides direct access to .NET 4 types. With the WWB.NET/5 Scripting language option both .NET 4 and .NET 5 are accessible at the same time.

.NET 4 Host Application Developers

WinWrap's WWB.NET/5 Scripting Language Option will give developers and end-users the ability to access and call the many reusable classes, interfaces, and value types contained in Microsoft's .NET 5 Class Library. With the WWB.NET/5 Scripting language option both .NET 4 and .NET 5 are accessible at the same time.

WWB.NET/5 Script Examples

.NET 5 provides a Json assembly (System.Text.Json.dll) for working with JSON text. .NET 4 does not include this namespace/dll. The two sample scripts below show how to use this .NET 5 assemply.

The script below uses .NET 5 from a .NET 4 style script. The '#Language "WWB.NET" special comment indicates .NET 4 because all existing scripts are written for the .NET 4 implementation. Alternatively, '#Language "WWB.NET/4" can be use to be explicit about using the .NET 4 implemenation.

'#Reference @System.Text.Json, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 '#Language "WWB.NET" Imports System.Collections.Generic Imports @System.Text.Json Sub Main Debug.Clear Dim s As String = Format("Global+Ids", "SymbolInfo") Dim list As New List(Of String) Using doc As @JsonDocument = @JsonDocument.Parse(s) Dim root As @JsonElement = doc.RootElement Dim ids As @JsonElement = root.GetProperty("ids") For Each p As @JsonProperty In ids.EnumerateObject list.Add p.Name Next End Using For Each item As String In list Debug.Print item Next End Sub

Notice that the script references a .NET 5 assembly from a WWB.NET script. To access a .NET 5 type from a WWB.NET script a type name is prefixed with an @ character. The @ character means the type comes from the other .NET implementation which in this case is .NET 5 because .NET 4 is the primary .NET implementation.

The script below uses the .NET 5 to do the same thing, but in this case .NET 5 is the primary .NET implementation as indicated by the '#Language "WWB.NET/5" line. And, to demostract access to .NET 4, the list of strings is stored in a .NET 4 System.Collections.Generic.List(Of String). Here using the @ character before the type name means the type comes from the other .NET implementation which in this case is .NET 4 because .NET 5 is the primary .NET implementation.

'#Reference @System.Text.Json, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 '#Language "WWB.NET/5" Imports System.Text.Json Imports @System.Collections.Generic Sub Main Debug.Clear Dim s As String = Format("Global+Ids", "SymbolInfo") Dim list As New @List(Of String) Using doc As JsonDocument = JsonDocument.Parse(s) Dim root As JsonElement = doc.RootElement Dim ids As JsonElement = root.GetProperty("ids") For Each p As JsonProperty In ids.EnumerateObject list.Add p.Name Next End Using For Each item As String In list Debug.Print item Next End Sub

Conclusion

In summary, for both .NET and COM host applications, Polar Engineering's WinWrap® Basic Scripting Engine with the WWB.NET/5 Language Option enables developer and end-user scripts to access and call any .NET 5 Code Assembly.

Copyright Polar Engineering, Inc.