Skip to content

Commit

Permalink
noise reduction (#1129)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgravell committed Feb 17, 2024
1 parent 9cce21c commit 99eb2c3
Show file tree
Hide file tree
Showing 64 changed files with 207 additions and 207 deletions.
3 changes: 2 additions & 1 deletion protobuf-net.sln
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{0A6E81
src\Directory.Packages.props = src\Directory.Packages.props
global.json = global.json
NuGet.Config = NuGet.Config
protobuf-net.png = protobuf-net.png
protobuf-net.svg = protobuf-net.svg
src\Tools\protogen.proto = src\Tools\protogen.proto
README.md = README.md
Expand Down Expand Up @@ -95,7 +96,7 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "protobuf-net.FSharp.Test",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "protobuf-net.FSharp", "src\protobuf-net.FSharp\protobuf-net.FSharp.csproj", "{763193DB-D730-4898-AB6B-986880AB18BF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuildToolsSmokeTests", "src\BuildToolsSmokeTests\BuildToolsSmokeTests.csproj", "{5BF248A8-1B2A-474C-9B62-A5173AD1BD55}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BuildToolsSmokeTests", "src\BuildToolsSmokeTests\BuildToolsSmokeTests.csproj", "{5BF248A8-1B2A-474C-9B62-A5173AD1BD55}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
2 changes: 1 addition & 1 deletion src/Benchmark/DeserializeBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private protogen.Database MemoryStream_Legacy(TypeModel model)
private MemoryStream _exposable;
private Stream ExposableData()
{
if (_exposable == null) _exposable = new MemoryStream(_data, 0, _data.Length, false, true);
_exposable ??= new MemoryStream(_data, 0, _data.Length, false, true);
_exposable.Position = 0;
return _exposable;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Benchmark/DeserializeBenchmarks_NewApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private static void Merge(ref ProtoReader.State state, ref protogen.Database obj
{
SubItemToken tok;
int field;
if (obj == null) obj = new protogen.Database();
obj ??= new protogen.Database();
while ((field = state.ReadFieldHeader()) != 0)
{
switch (field)
Expand All @@ -152,7 +152,7 @@ private static void Merge(ref ProtoReader.State state, ref protogen.Order obj)
{
SubItemToken tok;
int field;
if (obj == null) obj = new protogen.Order();
obj ??= new protogen.Order();
while ((field = state.ReadFieldHeader()) != 0)
{
switch (field)
Expand Down Expand Up @@ -219,7 +219,7 @@ private static void Merge(ref ProtoReader.State state, ref protogen.Order obj)
private static void Merge(ref ProtoReader.State state, ref protogen.OrderLine obj)
{
int field;
if (obj == null) obj = new protogen.OrderLine();
obj ??= new protogen.OrderLine();
while ((field = state.ReadFieldHeader()) != 0)
{
switch (field)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static TargetFrameworkAttribute CurrentRunningAssemblyTargetFramework
params DiagnosticResult[] standardExpectedDiagnostics)
where TDiagnosticAnalyzer : DiagnosticAnalyzer, new()
{
var codeFixTest = BuildCSharpCodeFixTest<TDiagnosticAnalyzer>(sourceCode, expectedCode, targetFramework);
var codeFixTest = CodeFixProviderTestsBase<TCodeFixProvider>.BuildCSharpCodeFixTest<TDiagnosticAnalyzer>(sourceCode, expectedCode, targetFramework);

if (diagnosticResult is not null)
{
Expand All @@ -42,7 +42,7 @@ static TargetFrameworkAttribute CurrentRunningAssemblyTargetFramework
await codeFixTest.RunAsync();
}

CSharpCodeFixTest<TDiagnosticAnalyzer, TCodeFixProvider, XUnitVerifier> BuildCSharpCodeFixTest<TDiagnosticAnalyzer>(
static CSharpCodeFixTest<TDiagnosticAnalyzer, TCodeFixProvider, XUnitVerifier> BuildCSharpCodeFixTest<TDiagnosticAnalyzer>(
string sourceCode, string expectedCode, string? targetFramework = null)
where TDiagnosticAnalyzer : DiagnosticAnalyzer, new()
{
Expand All @@ -55,11 +55,10 @@ static TargetFrameworkAttribute CurrentRunningAssemblyTargetFramework
{
ReferenceAssemblies = new ReferenceAssemblies(targetFramework),
TestState = { Sources = { sourceCode }, OutputKind = OutputKind.DynamicallyLinkedLibrary },
FixedState = { Sources = { expectedCode }, OutputKind = OutputKind.DynamicallyLinkedLibrary }
FixedState = { Sources = { expectedCode }, OutputKind = OutputKind.DynamicallyLinkedLibrary },
CodeActionValidationMode = CodeActionValidationMode.SemanticStructure
};

codeFixTest.CodeActionValidationMode = CodeActionValidationMode.SemanticStructure;

AddAdditionalReferences(codeFixTest.TestState);
AddAdditionalReferences(codeFixTest.FixedState);

Expand Down
2 changes: 1 addition & 1 deletion src/BuildToolsUnitTests/GeneratorTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected virtual TGenerator Generator

var parseOptions = new CSharpParseOptions(kind: SourceCodeKind.Regular, documentationMode: DocumentationMode.Parse);

if (globalOptions is null) globalOptions = ImmutableDictionary<string, string>.Empty;
globalOptions ??= ImmutableDictionary<string, string>.Empty;
if (debugLog) globalOptions = globalOptions.SetItem("pbn_debug_log", "true");

var optionsProvider = TestAnalyzeConfigOptionsProvider.Empty.WithGlobalOptions(new TestAnalyzerConfigOptions(globalOptions));
Expand Down
7 changes: 3 additions & 4 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>

<LibSysValueTuple>4.5.0</LibSysValueTuple>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release' or '$(Configuration)'=='VS'">
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down Expand Up @@ -57,9 +58,7 @@
</ItemGroup>

<ItemGroup>
<None Include="../../protobuf-net.png">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
<None Include="../../protobuf-net.png" Pack="true" PackagePath="/" Visible="false" />
<None Include="../../readme.md" Link="readme.md" Pack="true" PackagePath="/" Visible="false" />
</ItemGroup>
</Project>
54 changes: 27 additions & 27 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@
<Project>
<ItemGroup>
<PackageVersion Include="BenchmarkDotNet" Version="0.13.5" />
<!-- actual package output dependencies -->
<PackageVersion Include="System.Collections.Immutable" Version="7.0.0" />
<PackageVersion Include="System.Memory" Version="4.5.5" />
<PackageVersion Include="System.Reflection.Emit" Version="4.7.0" />
<PackageVersion Include="System.Reflection.Emit.Lightweight" Version="4.7.0" />
<PackageVersion Include="System.IO.Pipelines" Version="7.0.0" />
<PackageVersion Include="System.ServiceModel.Primitives" Version="4.10.3" />
</ItemGroup>
<ItemGroup>
<PackageVersion Include="BenchmarkDotNet" Version="0.13.12" />
<PackageVersion Include="BlazorInputFile" Version="0.2.0" />

<PackageVersion Include="coverlet.collector" Version="3.2.0" />

<!-- exclude due to F# build problems -->
<!--<PackageVersion Include="FSharp.Core" Version="7.0.0" />-->
<PackageVersion Include="coverlet.collector" Version="6.0.0" />

<PackageVersion Include="Google.Protobuf" Version="3.22.0" />
<PackageVersion Include="Grpc.Net.Client" Version="2.51.0" />
<PackageVersion Include="Google.Protobuf" Version="3.25.3" />
<PackageVersion Include="Grpc.Net.Client" Version="2.60.0" />

<PackageVersion Include="Iesi.Collections" Version="4.0.5" />

<PackageVersion Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.21.0" />
<PackageVersion Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.22.0" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.1" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.1" PrivateAssets="all" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="3.2.1" />
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="7.0.0" />
<PackageVersion Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All"/>

<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.3.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.XUnit" Version="1.1.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.XUnit" Version="1.1.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeRefactoring.Testing.XUnit" Version="1.1.1" />

<PackageVersion Include="Nerdbank.GitVersioning" Version="3.5.119" PrivateAssets="All" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.2" />
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.6.133" PrivateAssets="All" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="NHibernate" Version="[4.1.1.4000]" />
<PackageVersion Include="NodaTime" Version="3.1.6" />
<PackageVersion Include="NodaTime.Serialization.Protobuf" Version="2.0.0" />
<PackageVersion Include="NodaTime" Version="3.1.11" />
<PackageVersion Include="NodaTime.Serialization.Protobuf" Version="2.0.1" />

<PackageVersion Include="Pipelines.Sockets.Unofficial" Version="2.2.2" />
<PackageVersion Include="protobuf-net.BuildTools" Version="3.2.8" />
<PackageVersion Include="Pipelines.Sockets.Unofficial" Version="2.2.8" />
<PackageVersion Include="protobuf-net.BuildTools" Version="3.2.33" />
<PackageVersion Include="protobuf-net.Grpc" Version="1.0.21" />
<PackageVersion Include="protobuf-net.Grpc.Reflection" Version="1.1.1" />

<PackageVersion Include="System.Buffers" Version="4.5.1" />
<PackageVersion Include="System.CodeDom" Version="7.0.0" />
<PackageVersion Include="System.Collections.Immutable" Version="7.0.0" />
<PackageVersion Include="System.CodeDom" Version="8.0.0" />
<PackageVersion Include="System.Collections.NonGeneric" Version="4.3.0" />
<PackageVersion Include="System.Configuration.ConfigurationManager" Version="7.0.0" />
<PackageVersion Include="System.Data.SqlClient" Version="4.8.5" />
<PackageVersion Include="System.IO.Pipelines" Version="7.0.0" />
<PackageVersion Include="System.Memory" Version="4.5.5" />
<PackageVersion Include="System.Reflection.Emit" Version="4.7.0" />
<PackageVersion Include="System.Reflection.Emit.Lightweight" Version="4.7.0" />
<PackageVersion Include="System.Data.SqlClient" Version="4.8.6" />
<PackageVersion Include="System.Reflection.TypeExtensions" Version="4.7.0" />
<PackageVersion Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.3.0" />
<PackageVersion Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
<PackageVersion Include="System.Runtime.Serialization.Formatters" Version="4.3.0" />
<PackageVersion Include="System.Runtime.Serialization.Primitives" Version="4.3.0" />
<PackageVersion Include="System.Runtime.Serialization.Xml" Version="4.3.0" />
<PackageVersion Include="System.ServiceModel.Primitives" Version="4.10.0" />
<PackageVersion Include="System.Text.Json" Version="7.0.2"/>
<PackageVersion Include="System.Text.Json" Version="8.0.2"/>
<PackageVersion Include="System.Threading" Version="4.3.0" />
<PackageVersion Include="System.Threading.Channels" Version="7.0.0" />
<PackageVersion Include="System.Threading.Thread" Version="4.3.0" />
Expand All @@ -64,8 +64,8 @@
<!-- exclude due to F# build problems; look in Directory.build.props -->
<!--<PackageVersion Include="System.ValueTuple" Version="4.5.0" />-->

<PackageVersion Include="xunit" Version="2.4.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.5" />
<PackageVersion Include="xunit" Version="2.7.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.7" />
<PackageVersion Include="Xunit.SkippableFact" Version="1.4.13" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions src/Examples/AutoTuple.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ public BasicTuple(int foo, string bar)
this.foo = foo;
this.bar = bar;
}
public int Foo { get { return foo; } }
public string Bar { get { return bar; } }
public readonly int Foo { get { return foo; } }
public readonly string Bar { get { return bar; } }
}

public class BasicTupleReversedOrder
Expand Down
4 changes: 2 additions & 2 deletions src/Examples/Callbacks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -476,12 +476,12 @@ public static int AfterSerializeCount
[OnDeserializing]
public void OnDeserializing() { History += ";OnDeserializing"; }
[OnSerialized]
public void OnSerialized()
public readonly void OnSerialized()
{
Interlocked.Increment(ref afterSer);
}
[OnSerializing]
public void OnSerializing()
public readonly void OnSerializing()
{
Interlocked.Increment(ref beforeSer);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Examples/DictionaryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public void EmptyDictionaryShouldDeserializeAsNonNullViaInterface()
var clone = Serializer.Deserialize<IDictionary<string, int>>(ms);

Assert.NotNull(clone);
Assert.Equal(0, clone.Count);
Assert.Empty(clone);

}
[Fact]
Expand All @@ -276,7 +276,7 @@ public void NonEmptyDictionaryShouldDeserializeViaInterface()
var clone = Serializer.Deserialize<IDictionary<string, int>>(ms);

Assert.NotNull(clone);
Assert.Equal(1, clone.Count);
Assert.Single(clone);
Assert.Equal(123, clone["abc"]);
}
}
Expand Down Expand Up @@ -375,7 +375,7 @@ static void CheckNested<TInner>(IDictionary<string, TInner> data, string message
Assert.Equal("abc, jkl", allKeys);

var inner = data["abc"];
Assert.Equal(1, inner.Keys.Count); //, message);
Assert.Single(inner.Keys); //, message);
Assert.Equal("ghi", inner["def"]); //, message);
inner = data["jkl"];
Assert.Equal(2, inner.Keys.Count); //, message);
Expand Down
2 changes: 1 addition & 1 deletion src/Examples/InheritanceExtensible.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public void DetectValueTypeInstance()
[ProtoContract]
struct Foo : ITypedExtensible
{
IExtension ITypedExtensible.GetExtensionObject(Type type, bool createIfMissing)
readonly IExtension ITypedExtensible.GetExtensionObject(Type type, bool createIfMissing)
=> throw new NotImplementedException("shouldn't be called");
}

Expand Down
2 changes: 1 addition & 1 deletion src/Examples/Issues/Issue27.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public KeyPair(TKey1 k1, TKey2 k2)
[DataMember(Order = 2)]
public TKey2 Key2 { get; internal set; }

public override string ToString() {
public override readonly string ToString() {
return Key1.ToString() + ", " + Key2.ToString();
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/Examples/Issues/SO7120856.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ public MyValueTypeViaFields(SerializationInfo info, StreamingContext text)
}
#endif

public int X
public readonly int X
{
get { return _x; }
}

public int Z
public readonly int Z
{
get { return _z; }
}
Expand Down Expand Up @@ -145,13 +145,13 @@ public MyValueTypeAsTuple(SerializationInfo info, StreamingContext text)
}
#endif
[DataMember(Order = 1)]
public int X
public readonly int X
{
get { return _x; }
}

[DataMember(Order = 2)]
public int Z
public readonly int Z
{
get { return _z; }
}
Expand Down
2 changes: 1 addition & 1 deletion src/Examples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static bool CheckBytes<T>(ITestOutputHelper output, T item, TypeModel mod

public static bool CheckBytes<T>(ITestOutputHelper output, T item, TypeModel model, string hex, params byte[] expected)
{
if (model == null) model = RuntimeTypeModel.Default;
model ??= RuntimeTypeModel.Default;
using (MemoryStream ms = new MemoryStream())
{
model.Serialize(ms, item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static IMvcCoreBuilder AddProtoBufNet(this IMvcCoreBuilder builder, Actio
}

builder.Services.TryAddEnumerable(ServiceDescriptor.Transient<IConfigureOptions<MvcOptions>, MvcProtoBufNetOptionsSetup>());
if (setupAction is object) builder.Services.Configure(setupAction);
if (setupAction is not null) builder.Services.Configure(setupAction);
return builder;
}

Expand All @@ -38,7 +38,7 @@ public static IMvcBuilder AddProtoBufNet(this IMvcBuilder builder, Action<MvcPro
}

builder.Services.TryAddEnumerable(ServiceDescriptor.Transient<IConfigureOptions<MvcOptions>, MvcProtoBufNetOptionsSetup>());
if (setupAction is object) builder.Services.Configure(setupAction);
if (setupAction is not null) builder.Services.Configure(setupAction);
return builder;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected internal struct DiagnosticArguments
/// <summary>
/// Returns default value string representation with a cast to type included
/// </summary>
internal string GetCastedRepresentation()
internal readonly string GetCastedRepresentation()
{
if (MemberSpecialType == SpecialType.System_Enum)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
var protoMemberAttributeSyntax = root?.FindNode(diagnosticTextSpan) as AttributeSyntax;
if (protoMemberAttributeSyntax is null) return;

if (!TryBuildDiagnosticArguments(diagnostic, out var diagnosticArguments)) return;
if (!TryBuildDiagnosticArguments(diagnostic, out var diagnosticArguments)) return;

context.RegisterCodeFix(
CodeAction.Create(
Expand Down
2 changes: 1 addition & 1 deletion src/protobuf-net.BuildTools/Internal/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal static class Utils
return Convert.ChangeType(value, type, CultureInfo.InvariantCulture);

// Looking for ad hoc created TypeDescriptor.ConvertFromInvariantString(Type, string)
bool TryConvertFromInvariantString(
static bool TryConvertFromInvariantString(
Type typeToConvert,
string? stringValue,
out object? conversionResult)
Expand Down
2 changes: 1 addition & 1 deletion src/protobuf-net.Core/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal static MethodInfo GetStaticMethod(Type declaringType, string name)

internal static MethodInfo GetInstanceMethod(Type declaringType, string name, Type[] types)
{
if (types is null) types = Type.EmptyTypes;
types ??= Type.EmptyTypes;
return declaringType.GetMethod(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic,
null, types, null);
}
Expand Down

0 comments on commit 99eb2c3

Please sign in to comment.