Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native dependencies #37

Open
christophwille opened this issue Jan 26, 2025 · 8 comments
Open

Native dependencies #37

christophwille opened this issue Jan 26, 2025 · 8 comments

Comments

@christophwille
Copy link

christophwille commented Jan 26, 2025

You might remember the Linux question I asked during your talk in Vienna. I wanted to follow up here as I started looking at the code.

Question no1 is of course my VS complaining about netfw version used because I only have the newer target packs (it not being net48).

Question no2 is about SMO and 140 - is this for downlevel support, do newer versions no longer contain the necessary .dlls, do newer version not play nicely with older version of SQL Server? (by a strange coincidence that preview version has something to do with the very recent SqlClient 6.0.1 release)

https://www.nuget.org/packages/Microsoft.SqlServer.SqlManagementObjects/172.61.0-preview#versions-body-tab

Image

(I checked with ILSpy, eg Microsoft.SqlServer.Management.XEvent.dll is an AnyCPU assembly, location: C:\Users\username\.nuget\packages\microsoft.sqlserver.sqlmanagementobjects\172.61.0-preview\lib\net8.0)

It is just me trying to understand how hard it could be to get this off the ground for Linux. Because, we are using Smo (nuget) on Linux today for submitting GO-separated scripts to SQL Server.

@christophwille
Copy link
Author

Bonus question: https://www.nuget.org/packages/Microsoft.SqlServer.XEvent.XELite#readme-body-tab ever had a look at that?

@christophwille
Copy link
Author

I tried a quick & dirty net8.0 port of XESmartTarget.Core. The most problematic bits turn out to be the use of JavaScriptSerializer and its friends (SimpleTypeResolver, JavaScriptConverter - converting that to System.Text.Json might take some time). All other things are mostly easy to figure out (why is there an internal Logger class eg?), or replacing System.Data.SqlClient to Microsoft.Data.SqlClient. Some like QueryableXEventData needs someone more experienced with XE than me to figure out what the current equivalent is in Microsoft.SqlServer.Management.XEvent (the new namespace).

My csproj for reference:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="CsvHelper" Version="33.0.1" />
    <PackageReference Include="DouglasCrockford.JsMin" Version="2.1.0" />
    <PackageReference Include="InfluxDB.Client" Version="4.18.0" />
    <PackageReference Include="Microsoft.Data.SqlClient" Version="6.0.1" />
    <PackageReference Include="Microsoft.SqlServer.SqlManagementObjects" Version="172.61.0-preview" />
    <PackageReference Include="NLog" Version="5.3.4" />
    <PackageReference Include="SmartFormat.NET" Version="3.5.3" />
  </ItemGroup>
</Project>

@spaghettidba
Copy link
Owner

Hey Christoph! Thank you for your amazing work!
I am a very limited developer, there are things that you know much better than me for sure, so I will try to answer your questions, but I'm sure I don't have an answer for everything.

SMO 140 was used because it was the only version that was working at the time I released the tool. Later versions did not work. I never revisited this choice later, as everything was working smoothly and I didn't feel the need to upgrade.

I have never tried to use the streaming API with .NET core, sorry.

XELite seems very promising! Thanks for the pointer! That could be another way around the problem.

JavaScriptSerializer and its friends (SimpleTypeResolver, JavaScriptConverter

These are for loading the configuration from json files. I could try to replicate the same behavior with newer packages from nuget, like Newtonsoft.

Regarding QueryableXEventData , it's a brave new world. I should take the time to make it work in .NET core, I have no idea what is the equivalent, but I assume it is very much doable. If you want we can do this together.

@christophwille
Copy link
Author

Maybe the best approach is a super-simple command line app that includes SMO and MDS only, and there try to connect - before starting a bigger transformation process. Thing is the API shapes of SMO definitely have changed extensively, and to be honest the documentation is super-thin... eg https://stackoverflow.com/questions/60227557/infinite-iteration-with-sql-xevents-queryablexeventdata doesn't apply any more as QueryableXEventData isn't there any more.

Do you have contacts that could point you in the direction of the "current" patterns of the current version of SMO?

(side question: your samples from Friday are located where?)

@christophwille
Copy link
Author

I gave the XELite library a try: https://github.com/christophwille/poc-oh/blob/main/src/SqlXEventStreaming/Program.cs - that is really simple.

@spaghettidba
Copy link
Owner

Wow, ok, looks like you already did all the heavy lifting! That's phenomenal!
So the new .NET Core library has no native dependencies? That would be a breakthrough for sure.
I'm going to try to port it and then see what comes out of it

@christophwille
Copy link
Author

The dependencies of XELite are very thin, yes, I only added Microsoft.Data.SqlClient "for good measure" to be sure to use latest.

@christophwille
Copy link
Author

I went hunting a bit more, and found this: https://github.com/microsoft/sqltoolsservice/blob/main/src/Microsoft.SqlTools.ServiceLayer/Profiler/ProfilerService.cs - it is using XELite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants