Microsoft.SqlServer.Management.SqlParser.Native 172.0.1

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
dotnet add package Microsoft.SqlServer.Management.SqlParser.Native --version 172.0.1
NuGet\Install-Package Microsoft.SqlServer.Management.SqlParser.Native -Version 172.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Microsoft.SqlServer.Management.SqlParser.Native" Version="172.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Microsoft.SqlServer.Management.SqlParser.Native --version 172.0.1
#r "nuget: Microsoft.SqlServer.Management.SqlParser.Native, 172.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Microsoft.SqlServer.Management.SqlParser.Native as a Cake Addin
#addin nuget:?package=Microsoft.SqlServer.Management.SqlParser.Native&version=172.0.1

// Install Microsoft.SqlServer.Management.SqlParser.Native as a Cake Tool
#tool nuget:?package=Microsoft.SqlServer.Management.SqlParser.Native&version=172.0.1

Microsoft.SqlServer.Management.SqlParser.Native

Overview

This nuget package provides both MSIL and native Ahead-of-Time compiled (AoT) versions of Microsoft.SqlServer.Management.SqlParser for use by Net8.0 applications.

The AoT binaries can be consumed by AoT console applications.

There's one entrypoint exposed specifically for use by native callers such as C++ applications - Parse

This is the prototype

    [System.Text.Json.Serialization.JsonSourceGenerationOptions(PropertyNamingPolicy = System.Text.Json.Serialization.JsonKnownNamingPolicy.CamelCase)]
    [System.Text.Json.Serialization.JsonSerializable(typeof(ParseResultBase))]
    internal partial class ParseResultContext : System.Text.Json.Serialization.JsonSerializerContext
    { 
    }

    public static class NativeApi
    {
        /// <summary>
        /// Native API for parsing TSQL
        /// </summary>
        /// <param name="pString">The text to parse, encoded in UTF 8</param>
        /// <param name="pVersion">An identifier of the version, encoded in UTF8. Can be a number associated with a 
        /// SQL Server version like "160" or a member of the TransactSqlVersion enumeration</param>
        /// <returns></returns>
        [UnmanagedCallersOnly(EntryPoint = "Parse")]
        public static IntPtr Parse(IntPtr pString, IntPtr pVersion)
        {
        }
    }

Getting started

This is a sample C++ program listing to call Parse and print the result.

#include <windows.h>

typedef char* (*parse)(const char*, const char*);

int main()
{
    HMODULE h = ::LoadLibrary(L"win-x64\\native\\Microsoft.SqlServer.Management.SqlParser.dll");
    parse parser = (parse)::GetProcAddress(h, "Parse");
    char* result = parser("sel b from foo", "160");
    printf(result);
}

Output:

{"batchCount":1,"parseErrors":[{"message":"Incorrect syntax near \u0027from\u0027.","start":{"lineNumber":1,"columnNumber":7,"offset":6},"end":{"lineNumber":1,"columnNumber":11,"offset":10},"isWarning":false,"type":1}],"resultId":1}
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
172.0.1 186 3/21/2024

See CHANGELOG.md file in the package