doghappy / socket.io-client-csharp

socket.io-client implemention for .NET
MIT License
715 stars 124 forks source link

#344 Only include STJ for Net Standard 2 #367

Open thompson-tomo opened 3 months ago

thompson-tomo commented 3 months ago

Has added in Net 6 which has STJ so no need for dependency

Closes #344

doghappy commented 3 months ago

Thanks for you PR, but I don't know why need to change, could you please leave extra infos to explain it?

thompson-tomo commented 3 months ago

when a library is compiled for a particular framework ie Net 6 a number of dependencies are provided by the framework hence the developer/publisher is not needing to include them in their release for those frameworks. In this case System.text.Json is bundled in to the Framework starting with Net core 3 hence when compiling for those newer framework's ie Net 6 you don't need that dependency hence why the condition results in it only be included for Net standard 2 where isn't part of the framework.

doghappy commented 2 months ago

I have published 2 packages to local folder, and then make the folder as a nuget source.

the condition of alpha.1 is

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    ...
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="System.Text.Json" Version="8.0.3" />
  </ItemGroup>

the condition of alpha.2 is

  <PropertyGroup>
    <TargetFrameworks>netstandard2.0;net8.0</TargetFrameworks>
    ...
  </PropertyGroup>
  <ItemGroup Condition="'$(TargetFramework)'=='netstandard2.0'">
    <PackageReference Include="System.Text.Json" Version="8.0.3" />
  </ItemGroup>

next I created a .NET8 ConsoleApp and installed SocketIO.Serializer.SystemTextJson from local source instead of nuget.org, the following screenshot is alpha.1

ConsoleApp1 image

then I removed the alpha.1 and install the alpha.2

ConsoleApp1 image

How to test the differences between them?

commit: e9dcb3cb0ecfa875879a62d6de99176e8b3ac1f0