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

Add nullable annotations to the datadog logging files #4994

Merged
merged 4 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions tracer/missing-nullability-files.csv
Original file line number Diff line number Diff line change
Expand Up @@ -433,12 +433,6 @@ src/Datadog.Trace/IAST/Analyzers/UserStringInterop.cs
src/Datadog.Trace/IAST/Aspects/DebugAspects.cs
src/Datadog.Trace/IAST/Dataflow/AspectFilter.cs
src/Datadog.Trace/IAST/Dataflow/AspectType.cs
src/Datadog.Trace/Logging/Internal/DatadogLogging.cs
src/Datadog.Trace/Logging/Internal/DatadogSerilogLogger.cs
src/Datadog.Trace/Logging/Internal/IDatadogLogger.cs
src/Datadog.Trace/Logging/Internal/ILogRateLimiter.cs
src/Datadog.Trace/Logging/Internal/LogRateLimiter.cs
src/Datadog.Trace/Logging/Internal/NullLogRateLimiter.cs
src/Datadog.Trace/PDBs/dnlibAdditions/DssSymbolReaderImpl.Additions.cs
src/Datadog.Trace/PDBs/dnlibAdditions/PdbReader.Additions.cs
src/Datadog.Trace/PDBs/dnlibAdditions/PortablePdbReader.Additions.cs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<!-- Using the root namespace so generators are all in the root + we can control how they're written to disk -->
<RootNamespace></RootNamespace>
<EnforceExtendedAnalyzerRules>false</EnforceExtendedAnalyzerRules>
<NoWarn>RS2008</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Reflection.Emit" Version="4.3.0" />
Expand Down Expand Up @@ -257,8 +259,8 @@
</Compile>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.4.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
<Content Include="..\Datadog.Trace\Vendors\MessagePack\Formatters\ForceSizePrimitiveFormatter.tt">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<IsPackable>false</IsPackable>
<EnforceExtendedAnalyzerRules>false</EnforceExtendedAnalyzerRules>
<NoWarn>RS2008</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.4.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.4.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.8.0" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class Diagnostics
"CodeQuality",
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true,
description: "Exceptions should be passed in the Exception Parameter");
description: "Exceptions should be passed in the Exception Parameter.");

internal static readonly DiagnosticDescriptor TemplateRule = new(
TemplateDiagnosticId,
Expand All @@ -74,7 +74,7 @@ public class Diagnostics
category: "CodeQuality",
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true,
description: "Checks for errors in the MessageTemplate");
description: "Checks for errors in the MessageTemplate.");

internal static readonly DiagnosticDescriptor PropertyBindingRule = new(
PropertyBindingDiagnosticId,
Expand All @@ -83,7 +83,7 @@ public class Diagnostics
category: "CodeQuality",
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true,
description: "Checks whether properties and arguments match up");
description: "Checks whether properties and arguments match up.");

internal static readonly DiagnosticDescriptor ConstantMessageTemplateRule = new(
ConstantMessageTemplateDiagnosticId,
Expand All @@ -92,7 +92,7 @@ public class Diagnostics
category: "CodeQuality",
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true,
description: "MessageTemplate must be a constant value to ensure caching and avoid interpolation issues");
description: "MessageTemplate must be a constant value to ensure caching and avoid interpolation issues.");

internal static readonly DiagnosticDescriptor UniquePropertyNameRule = new(
UniquePropertyNameDiagnosticId,
Expand All @@ -101,7 +101,7 @@ public class Diagnostics
category: "CodeQuality",
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true,
description: "All property names in a MessageTemplate must be unique");
description: "All property names in a MessageTemplate must be unique.");

internal static readonly DiagnosticDescriptor PascalPropertyNameRule = new(
PascalPropertyNameDiagnosticId,
Expand All @@ -110,7 +110,7 @@ public class Diagnostics
category: "CodeQuality",
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true,
description: "Property names in a MessageTemplates should be Pascal Case for consistency");
description: "Property names in a MessageTemplates should be Pascal Case for consistency.");

internal static readonly DiagnosticDescriptor DestructureAnonymousObjectsRule = new(
DestructureAnonymousObjectsDiagnosticId,
Expand All @@ -119,7 +119,7 @@ public class Diagnostics
category: "CodeQuality",
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true,
description: "Anonymous objects should use the '@' hint to ensure they are destructed");
description: "Anonymous objects should use the '@' hint to ensure they are destructed.");

internal static readonly DiagnosticDescriptor UseCorrectContextualLoggerRule = new(
UseCorrectContextualLoggerDiagnosticId,
Expand All @@ -128,14 +128,14 @@ public class Diagnostics
category: "CodeQuality",
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true,
description: "Logger instances should use the current class for context");
description: "Logger instances should use the current class for context.");

internal static readonly DiagnosticDescriptor UseDatadogLoggerRule = new(
UseDatadogLoggerDiagnosticId,
title: "Incorrect logger type",
messageFormat: "Incorrect use of Serilog ILogger. Use IDatadogLogger instead",
messageFormat: "Incorrect use of Serilog ILogger. Use IDatadogLogger instead.",
category: "CodeQuality",
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true,
description: "You should use the IDatadogLogger wrapper for logging");
description: "You should use the IDatadogLogger wrapper for logging.");
}
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ private static void AnalyzeSymbol(SyntaxNodeAnalysisContext context)
var nextParameterIndex = messageTemplateArgumentIndex + 1;
if ((invocationArguments.Count == nextParameterIndex + 1)
&& method.Parameters.Length > nextParameterIndex
&& method.Parameters[nextParameterIndex].Type.ToString() == "object[]")
&& (method.Parameters[nextParameterIndex].Type.ToString() == "object[]"
|| method.Parameters[nextParameterIndex].Type.ToString() == "object?[]"))
{
// we're in the object[] version of the log message,
if (invocationArguments[nextParameterIndex].Expression is ArrayCreationExpressionSyntax { Initializer: { } initializer })
Expand Down
2 changes: 2 additions & 0 deletions tracer/src/Datadog.Trace/Logging/Internal/DatadogLogging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc.
// </copyright>

#nullable enable

using System;
using System.IO;
using System.Threading.Tasks;
Expand Down
Loading
Loading