Press "Enter" to skip to content

Category: Misc Languages

Updates to Extensions in C# 14

The word miners in the NDepend blogging mines clue us in on an update to the C# language:

A few remarks:

  • If the extension is generic, the type parameter (if any) is specified immediately after the extension keyword.
  • The receiver ReadOnlySpan<T> span applies to one or more extension methods (or members) declared within the same extension block. This logical grouping is a core advantage of the new syntax, improving clarity and structure when extending a type.
  • As far as the C# compiler is concerned, the two methods Truncate() are strictly equivalent. Therefore, one must be commented out for the program to compile.
  • Notice the call to AsSpan() in the first line. Extension methods require the receiver type to match exactly ReadOnlySpan<T>, hence it doesn’t apply to string unless you explicitly cast. This is not specific to the new syntax but worth mentioning.

Read on for examples of how extension methods and extension members will open up opportunities to improve existing C# code.

Leave a Comment

Accessing Delta Lake via Spark Connect

Ed Elliott has some code for us:

I have just finished an update for the spark connect dotnet lib that contains the DeltaTable implementation so that we can now use .NET to maintain delta tables, over and above what we get out of the box by using DataFrame.Write.Format("delta"), this is an example of how to use the delta api from .NET:

Click through for the example, and you can learn more about Spark Connect from the Spark website and Ed has a .NET client for the task.

Comments closed

Importing PDF Contents into SQL Server

Sebastiao Pereira loads a PDF:

PDF forms are widely used for data collection, document processing, and digital workflows due to their versatility and consistency across different platforms and devices. They are essential in various industries, including healthcare, education, finance, government, and business. How do you retrieve data from PDF forms and insert into a SQL Server database table?

Read on for an answer using Visual Basic, which is a name I haven’t heard in quite some time.

Comments closed

Updates on the Spark Connect Dotnet Library

Ed Elliott has an update for us:

There have been quite a few changes in the last couple of months and I just wanted to give a quick update on the current state of the project. In terms of usage I am starting to hear from people using the library and submitting pr’s and requests so although usage is pretty low (which is expected from the fact that the Microsoft supported version usage wasn’t very high) it is growing which is interesting.

Read on for thoughts on production readiness, support for Spark 4.0, a couple of other updates, and some future plans.

Comments closed

Showing SSRS Reports in Modern .NET Apps

Sebastiao Pereira solves a problem:

Report Viewer was originally developed for the .NET Framework. As the industry shifts towards .NET Core, developers who have traditionally relied on this tool have faced challenges displaying reports within their applications due to compatibility issues. Is it possible to display a report from SQL Server Reporting Services (SSRS) in a .Net Core Application?

Click through for the answer. As a quick note, we had .NET Core, but then Microsoft renamed it to .NET with .NET 6, so instead we have to differentiate .NET Framework (Windows-only, heavy SDK) with .NET (nee .NET Core, cross-platform, less heavy). I’d rate Sebastiao’s solution a workaround, but one that I doubt Microsoft will ever provide a better solution for, given the heavy de-emphasis on Reporting Services over the past several years.

Comments closed

Updates in .NET 9

Ajay Jajoo tells us what’s new:

One of the standout features of .NET 9 is its focus on performance. With numerous optimizations across the runtime and libraries, applications can expect faster execution times and reduced memory usage. This is particularly beneficial for high-load applications, making .NET 9 an ideal choice for cloud-based solutions.

.NET 9 brings various performance optimizations, including improvements in garbage collection and just-in-time (JIT) compilation.

If you work at all with C#, you’ll see some quality of life improvements in .NET 9. But given Microsoft’s policy around short-term and long-term releases, you might wait until .NET 10 in many corporate environments to see them.

Comments closed

System.Data.SqlClient Deprecated

David Engel has an announcement:

We announced Microsoft.Data.SqlClient in the first half of 2019 and shipped the first stable package later that year. That release coincided with .NET Core 3.0. We’ve been developing Microsoft.Data.SqlClient in the dotnet/SqlClient repo since that time, over the last five years. It’s now time to start the deprecation process for the System.Data.SqlClient package. We plan to take a staged process to deprecation, with the intent to align support changes and associated code transition activities between these libraries to natural migration points between .NET major versions.

I haven’t used System.Data.SqlClient in a while, so I’m not sure how much is in that library that isn’t in Microsoft.Data.SqlClient.

Comments closed