splunk / splunk-sdk-csharp-pcl

Splunk's next generation C# SDK
https://dev.splunk.com/enterprise/docs/csharp
Apache License 2.0
64 stars 46 forks source link

.NET CORE 2.0 Compatability #80

Closed jaeshort closed 1 year ago

jaeshort commented 6 years ago

It would be nice to have a .NET CORE 2.0 NuGet since new development in Visual Studio will be utilizing these standards.

martinmine commented 6 years ago

I just looked into compiling on .NET Standard 2.0 and turns out there is some work that needs to be done in addition to breaking API changes where most of the issues are related to use of dynamic.

jaeshort commented 6 years ago

I changed the framework just to .NET 4.6.1 and ran the tests with several failing against the new version of Splunk. I am guessing they are broken api changes like you are experiencing. I may have to just take some of the working code out for what I need until the SDK can be updated for the latest REST API.

martinmine commented 6 years ago

@jaeshort You can see on the master branch that there are failing builds: https://github.com/splunk/splunk-sdk-csharp-pcl/commits/master

And no, I was referring to compiler issues, not failing tests. Some of the output I get from dotnet build is:

ApplicationCollection.cs(113,26): error CS0656: Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.Binder.Convert' [\Splunk.Client\Splunk.Client\Splunk.Client.csproj]
Application.cs(176,26): error CS0656: Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.Binder.Convert' [\Splunk.Client\Splunk.Client\Splunk.Client.csproj]
ApplicationCollection.cs(119,26): error CS0656: Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.Binder.Convert' [\Splunk.Client\Splunk.Client\Splunk.Client.csproj]

This is because the SDK is implicitly casting a dynamic type to a concrete type, for example in ApplicationCollection.cs there is the following function:

public virtual ReadOnlyCollection<Message> Messages
{
    get { return this.Snapshot.GetValue("Messages") ?? NoMessages; }
}

The GetValue returns a dynamic type, and the compiler will then cast this implicitly to an ReadOnlyCollection on compile-time. This is fine even on .NET Core, but when compiling it as a .NET Standard project (which is what everyone is doing), things become a bit more complicated as apparently this kind of behavior is not supported in .NET Standard. This is further discussed in this thread: https://github.com/dotnet/roslyn/issues/16265#issuecomment-271525105 Looking at the source code where the compiler reports the errors, I don't really see the cause why dynamic is used instead of object casting/generic functions as I don't know this code-base well enough.

AshleyPoole commented 5 years ago

Any update on .NET Core (2.0) support??

mohsenvafa commented 5 years ago

@martinmine Do you guys have any plan to update this package to .Net Core 2.0?

martinmine commented 5 years ago

@mohsenvafa I'm not a maintainer of this package and I don't have any plans of porting it although I have looked into how much work it is to make the jump.

stefantinger commented 4 years ago

Are there still no plans to update it? An update to .NET Standard 2.0 would be quite nice...

ncanumalla-splunk commented 1 year ago

This SDK is deprecated and no longer under active development.