Skip to content

Commit

Permalink
Merge pull request #1814 from MessagePack-CSharp/depUpdates
Browse files Browse the repository at this point in the history
Merge master and dependency updates into develop
  • Loading branch information
AArnott committed May 13, 2024
2 parents 3d80df1 + f619b89 commit caed65b
Show file tree
Hide file tree
Showing 18 changed files with 1,350 additions and 59 deletions.
40 changes: 21 additions & 19 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>

<BenchmarkDotNetVersion>0.13.12</BenchmarkDotNetVersion>

<!-- https://learn.microsoft.com/en-us/visualstudio/extensibility/roslyn-version-support?view=vs-2022 -->
<MicrosoftCodeAnalysisVersion>4.8.0</MicrosoftCodeAnalysisVersion>
<MicrosoftCodeAnalysisVersion Condition="'$(IsAnalyzerProject)'=='true'">4.3.0</MicrosoftCodeAnalysisVersion>
Expand All @@ -24,7 +22,6 @@
<PackageVersion Include="Jil" version="2.17.0" />
<PackageVersion Include="MessagePack" Version="2.1.90" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="7.0.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" version="3.3.4" />
<PackageVersion Include="Microsoft.CodeAnalysis.Common" version="$(MicrosoftCodeAnalysisVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.XUnit" Version="$(MicrosoftCodeAnalysisTestingVersion)" />
Expand Down Expand Up @@ -52,16 +49,7 @@
<PackageVersion Include="ReactiveProperty" Version="9.5.0" />
<PackageVersion Include="Required" Version="1.0.0" />
<PackageVersion Include="Sigil" version="5.0.0" />
<PackageVersion Include="SpanJson" Version="4.0.1" />
<PackageVersion Include="System.CodeDom" Version="8.0.0" />
<PackageVersion Include="System.Collections.Immutable" Version="8.0.0" />
<PackageVersion Include="System.Reflection.Emit.Lightweight" Version="4.7.0" />
<PackageVersion Include="System.Reflection.Emit" Version="4.7.0" />
<PackageVersion Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
<PackageVersion Include="System.Text.Json" Version="6.0.0" />
<PackageVersion Include="System.Text.Encodings.Web" Version="6.0.0" />
<PackageVersion Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
<PackageVersion Include="System.ValueTuple" Version="4.5.0" />
<PackageVersion Include="SpanJson" Version="4.0.0" />
<PackageVersion Include="Utf8Json" Version="1.3.7" />
<PackageVersion Include="Xunit.Combinatorial" Version="1.6.24" />
<PackageVersion Include="xunit.runner.console" Version="2.7.0" />
Expand All @@ -70,13 +58,27 @@
<PackageVersion Include="xunit" Version="2.7.0" />
<PackageVersion Include="ZeroFormatter" Version="1.6.4" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'net472'">
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" />
<PackageVersion Include="System.CodeDom" Version="6.0.0" />
<PackageVersion Include="System.Collections.Immutable" Version="6.0.0" />
<PackageVersion Include="System.Memory" Version="4.5.5" />
<PackageVersion Include="System.Reflection.Emit.Lightweight" Version="4.7.0" />
<PackageVersion Include="System.Reflection.Emit" Version="4.7.0" />
<PackageVersion Include="System.Reflection.Metadata" Version="6.0.0" />
<PackageVersion Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
<PackageVersion Include="System.Text.Json" Version="6.0.0" />
<PackageVersion Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
</ItemGroup>
<ItemGroup Condition="'$(IsAnalyzerProject)'=='true'">
<PackageVersion Update="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" />
<PackageVersion Update="System.Collections.Immutable" Version="6.0.0" />
<PackageVersion Update="System.Memory" Version="4.5.5" />
<PackageVersion Update="System.Reflection.Metadata" Version="6.0.0" />
<PackageVersion Update="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
<PackageVersion Update="System.Text.Json" Version="6.0.0" />
<PackageVersion Update="Microsoft.Bcl.AsyncInterfaces" Version="7.0.0" />
<PackageVersion Update="System.Collections.Immutable" Version="7.0.0" />
<PackageVersion Update="System.Reflection.Metadata" Version="7.0.0" />
</ItemGroup>
<ItemGroup Condition="'$(NonShipping)'=='true'">
<PackageVersion Update="Microsoft.Bcl.AsyncInterfaces" Version="7.0.0" />
<PackageVersion Update="System.Collections.Immutable" Version="7.0.0" />
<PackageVersion Update="System.Reflection.Metadata" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<GlobalPackageReference Include="CSharpIsNullAnalyzer" Version="0.1.495" />
Expand Down
1 change: 0 additions & 1 deletion benchmark/SerializerBenchmark/SerializerBenchmark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
<PackageReference Include="MsgPack.Cli" />
<PackageReference Include="protobuf-net" />
<PackageReference Include="SpanJson" />
<PackageReference Include="System.Text.Json" />
<PackageReference Include="Utf8Json" />
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="Newtonsoft.Json.Bson" />
Expand Down
3 changes: 2 additions & 1 deletion sandbox/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove($(MSBuildThisFile), $(MSBuildThisFileDirectory)..))" />
<PropertyGroup>
<NonShipping>true</NonShipping>
<IsPackable>false</IsPackable>
</PropertyGroup>
<Import Project="$([MSBuild]::GetPathOfFileAbove($(MSBuildThisFile), $(MSBuildThisFileDirectory)..))" />
</Project>
4 changes: 0 additions & 4 deletions sandbox/MessagePack.Internal/MessagePack.Internal.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
</Description>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\..\src\MessagePack.UnityClient\Assets\Scripts\MessagePack\BufferWriter.cs" />
<Compile Include="..\..\src\MessagePack.UnityClient\Assets\Scripts\MessagePack\ExtensionHeader.cs" />
Expand Down
2 changes: 0 additions & 2 deletions sandbox/TestData2/TestData2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
<ItemGroup>
<PackageReference Include="MessagePack" />
<PackageReference Include="IsExternalInit" />
<PackageReference Include="System.Threading.Tasks.Extensions" />
<PackageReference Include="System.ValueTuple" />
</ItemGroup>
<ItemGroup>
<Using Include="System.Collections.Generic" />
Expand Down
1 change: 1 addition & 0 deletions src/MessagePack.Analyzers/MessagePack.Analyzers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
<IncludeSymbols>false</IncludeSymbols>
<DevelopmentDependency>true</DevelopmentDependency>
<IsAnalyzerProject>true</IsAnalyzerProject>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,24 +78,26 @@ public void Serialize(ref MessagePackWriter writer, TDictionary? value, MessageP
}
else
{
IFormatterResolver resolver = options.Resolver;
IMessagePackFormatter<TKey>? keyFormatter = resolver.GetFormatterWithVerify<TKey>();
IMessagePackFormatter<TValue>? valueFormatter = resolver.GetFormatterWithVerify<TValue>();

var len = reader.ReadMapHeader();

TIntermediate dict = this.Create(len, options);
options.Security.DepthStep(ref reader);
try
{
for (int i = 0; i < len; i++)
if (len > 0)
{
reader.CancellationToken.ThrowIfCancellationRequested();
TKey key = keyFormatter.Deserialize(ref reader, options);
IFormatterResolver resolver = options.Resolver;
IMessagePackFormatter<TKey>? keyFormatter = resolver.GetFormatterWithVerify<TKey>();
IMessagePackFormatter<TValue>? valueFormatter = resolver.GetFormatterWithVerify<TValue>();
for (int i = 0; i < len; i++)
{
reader.CancellationToken.ThrowIfCancellationRequested();
TKey key = keyFormatter.Deserialize(ref reader, options);

TValue value = valueFormatter.Deserialize(ref reader, options);
TValue value = valueFormatter.Deserialize(ref reader, options);

this.Add(dict, i, key, value, options);
this.Add(dict, i, key, value, options);
}
}
}
finally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public DynamicAssembly(string moduleName)

#if NETFRAMEWORK

public AssemblyBuilder Save()
internal AssemblyBuilder Save()
{
this.assemblyBuilder.Save(this.moduleName + ".dll");
return this.assemblyBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static DynamicEnumResolver()
}

#if NETFRAMEWORK
public AssemblyBuilder Save()
internal AssemblyBuilder Save()
{
return DynamicAssembly.Value.Save();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private DynamicObjectResolver()
}

#if NETFRAMEWORK
public AssemblyBuilder Save()
internal AssemblyBuilder Save()
{
return DynamicAssembly.Value.Save();
}
Expand Down Expand Up @@ -193,7 +193,7 @@ static DynamicContractlessObjectResolver()
}

#if NETFRAMEWORK
public AssemblyBuilder Save()
internal AssemblyBuilder Save()
{
return DynamicAssembly.Value.Save();
}
Expand Down Expand Up @@ -1766,7 +1766,7 @@ bool AddEmittableMemberOrIgnore(bool isIntKeyMode, EmittableMember member, bool

EmittableMember? CreateEmittableMember(MemberInfo m)
{
if (m.IsDefined(typeof(IgnoreMemberAttribute), true) || m.IsDefined(typeof(IgnoreDataMemberAttribute), true))
if (m.IsDefined(typeof(IgnoreMemberAttribute), true) || m.IsDefined(typeof(IgnoreDataMemberAttribute), true) || m.IsDefined(typeof(NonSerializedAttribute), true))
{
return null;
}
Expand Down Expand Up @@ -2019,19 +2019,6 @@ bool AddEmittableMemberOrIgnore(bool isIntKeyMode, EmittableMember member, bool

if (len != 0)
{
if (len != 1)
{
if (ctorEnumerator != null)
{
ctor = null;
break;
}
else
{
throw new MessagePackDynamicObjectResolverException("duplicate matched constructor parameter name:" + type.FullName + " parameterName:" + item.Name + " parameterType:" + item.ParameterType.Name);
}
}

paramMember = hasKey.First().Value;
if (item.ParameterType.IsAssignableFrom(paramMember.Type) && paramMember.IsReadable)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private DynamicUnionResolver()
}

#if NETFRAMEWORK
public AssemblyBuilder Save()
internal AssemblyBuilder Save()
{
return DynamicAssembly.Value.Save();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,33 @@ public class Detail : IEquatable<Detail>
public bool Equals(Detail other) => other != null && this.B1 == other.B1 && this.B2 == other.B2;
}

[Fact]
public void Serialize_WithNonSerializedAttribute()
{
var mc = new ClassWithOldSchoolNonSerializedAttribute
{
PublicField = 1,
IgnoredPublicField = 2,
};

var options = ContractlessStandardResolverAllowPrivate.Options;
var bin = MessagePackSerializer.Serialize(mc, options);
var mc2 = MessagePackSerializer.Deserialize<ClassWithOldSchoolNonSerializedAttribute>(bin, options);

mc2.PublicField.Is(1);
mc2.IgnoredPublicField.Is(0);

MessagePackSerializer.ConvertToJson(bin).Is(@"{""PublicField"":1}");
}

public class ClassWithOldSchoolNonSerializedAttribute
{
public int PublicField;

[NonSerialized]
public int IgnoredPublicField;
}

#if !UNITY_2018_3_OR_NEWER

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,14 @@ public void InterfaceDictionaryTest()
public void ConcurrentDictionaryTest()
{
var cd = new ConcurrentDictionary<int, int>();
ConcurrentDictionary<int, int> conv = this.Convert(cd);
conv.Count.Is(0);

cd.TryAdd(1, 100);
cd.TryAdd(2, 200);
cd.TryAdd(3, 300);

ConcurrentDictionary<int, int> conv = this.Convert(cd);
conv = this.Convert(cd);
conv[1].Is(100);
conv[2].Is(200);
conv[3].Is(300);
Expand Down
8 changes: 6 additions & 2 deletions src/MessagePack/MessagePack.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0;net8.0;net472</TargetFrameworks>
<NoWarn>$(NoWarn);CS0649</NoWarn>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<DefineConstants Condition=" '$(TargetFramework)' != 'netstandard2.0' ">$(DefineConstants);SPAN_BUILTIN</DefineConstants>
<DefineConstants Condition=" '$(TargetFramework)' == 'net6.0' or '$(TargetFramework)' == 'net8.0' ">$(DefineConstants);SPAN_BUILTIN</DefineConstants>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<LangVersion>9.0</LangVersion>

Expand Down Expand Up @@ -42,6 +42,10 @@
<PackageReference Include="System.Reflection.Emit.Lightweight" />
<PackageReference Include="System.Threading.Tasks.Extensions" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net472' ">
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" />
<PackageReference Include="System.Collections.Immutable" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\MessagePack.Annotations\MessagePack.Annotations.csproj" />
Expand Down

0 comments on commit caed65b

Please sign in to comment.