diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 51b9ad6..8fa840a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -58,12 +58,14 @@ jobs: run: dotnet build --no-restore -c Debug - name: Test solution [Debug] working-directory: src - run: dotnet test --no-restore -p:CollectCoverage=true + run: dotnet test --no-restore -p:CollectCoverage=true -p:CoverletOutputFormat=opencover -p:CoverletOutput=../.coverage/ - name: Upload coverage to codecov if: ${{ startsWith(matrix.os, 'ubuntu') }} uses: codecov/codecov-action@v3 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} with: - files: .coverage/Destructurama.ByIgnoring.Tests/coverage.net8.opencover.xml + files: src/.coverage/*.opencover.xml buildcheck: needs: diff --git a/README.md b/README.md index 2193a4f..9860548 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![License](https://img.shields.io/github/license/destructurama/attributed) -[![codecov](https://codecov.io/gh/destructurama/attributed/branch/master/graph/badge.svg?token=0ZRHIUEQM4)](https://codecov.io/gh/destructurama/attributed) +[![codecov](https://codecov.io/gh/destructurama/attributed/graph/badge.svg?token=Ma2sUoqqb1)](https://codecov.io/gh/destructurama/attributed) [![Nuget](https://img.shields.io/nuget/dt/Destructurama.Attributed)](https://www.nuget.org/packages/Destructurama.Attributed) [![Nuget](https://img.shields.io/nuget/v/Destructurama.Attributed)](https://www.nuget.org/packages/Destructurama.Attributed) diff --git a/src/Destructurama.Attributed.Tests/Destructurama.Attributed.Tests.csproj b/src/Destructurama.Attributed.Tests/Destructurama.Attributed.Tests.csproj index e88c937..4b05d66 100644 --- a/src/Destructurama.Attributed.Tests/Destructurama.Attributed.Tests.csproj +++ b/src/Destructurama.Attributed.Tests/Destructurama.Attributed.Tests.csproj @@ -13,6 +13,10 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/Destructurama.Attributed/Attributed/AttributedDestructuringPolicy.cs b/src/Destructurama.Attributed/Attributed/AttributedDestructuringPolicy.cs index 8bee32a..cd5beb3 100644 --- a/src/Destructurama.Attributed/Attributed/AttributedDestructuringPolicy.cs +++ b/src/Destructurama.Attributed/Attributed/AttributedDestructuringPolicy.cs @@ -50,7 +50,7 @@ private CacheEntry CreateCacheEntry(Type type) { var classDestructurer = type.GetCustomAttribute(); if (classDestructurer != null) - return new((o, f) => classDestructurer.CreateLogEventPropertyValue(o, f)); + return new(classDestructurer.CreateLogEventPropertyValue); var properties = type.GetPropertiesRecursive().ToList(); if (!_options.IgnoreNullProperties diff --git a/src/Destructurama.Attributed/Attributed/AttributedDestructuringPolicyOptions.cs b/src/Destructurama.Attributed/Attributed/AttributedDestructuringPolicyOptions.cs index 9d0dcc9..3f2c4b6 100644 --- a/src/Destructurama.Attributed/Attributed/AttributedDestructuringPolicyOptions.cs +++ b/src/Destructurama.Attributed/Attributed/AttributedDestructuringPolicyOptions.cs @@ -1,3 +1,5 @@ +using Serilog.Events; + namespace Destructurama.Attributed; /// @@ -6,9 +8,9 @@ namespace Destructurama.Attributed; public class AttributedDestructuringPolicyOptions { /// - /// By setting IgnoreNullProperties to true no need to set [NotLoggedIfNull] for every logged property. - /// Custom types implementing IEnumerable, will be destructed as StructureValue and affected by IgnoreNullProperties - /// only in case at least one property (or the type itself) has Destructurama attribute applied. + /// By setting this property to no need to set + /// for every logged property. Custom types implementing IEnumerable, will be destructed as + /// and affected by this property only in case at least one property (or the type itself) has Destructurama attribute applied. /// public bool IgnoreNullProperties { get; set; } } diff --git a/src/Destructurama.Attributed/Attributed/IPropertyDestructuringAttribute.cs b/src/Destructurama.Attributed/Attributed/IPropertyDestructuringAttribute.cs index 292848e..4f7a8e0 100644 --- a/src/Destructurama.Attributed/Attributed/IPropertyDestructuringAttribute.cs +++ b/src/Destructurama.Attributed/Attributed/IPropertyDestructuringAttribute.cs @@ -19,7 +19,7 @@ namespace Destructurama.Attributed; /// -/// Base interfaces for all s that override how a property is destructured. +/// Base interface for all Destructurama attributes that override how a property is destructured. /// public interface IPropertyDestructuringAttribute { @@ -27,7 +27,7 @@ public interface IPropertyDestructuringAttribute /// Attempt to create a replacement for a property. /// /// The current property name. - /// The current property value + /// The current property value. /// The current . /// The to use as a replacement. /// trueIf a replacement has been derived. diff --git a/src/Destructurama.Attributed/Attributed/IPropertyOptionalIgnoreAttribute.cs b/src/Destructurama.Attributed/Attributed/IPropertyOptionalIgnoreAttribute.cs index c2e4bbe..bb913c8 100644 --- a/src/Destructurama.Attributed/Attributed/IPropertyOptionalIgnoreAttribute.cs +++ b/src/Destructurama.Attributed/Attributed/IPropertyOptionalIgnoreAttribute.cs @@ -1,11 +1,11 @@ // Copyright 2020 Destructurama Contributors, Serilog Contributors -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,16 +15,16 @@ namespace Destructurama.Attributed; /// -/// Base interfaces for all s that determine should a property be ignored. +/// Base interface for all Destructurama attributes that determine should a property be ignored. /// public interface IPropertyOptionalIgnoreAttribute { /// /// Determine should a property be ignored /// - /// The current property name - /// The current property value - /// The current property type + /// The current property name. + /// The current property value. + /// The current property type. /// bool ShouldPropertyBeIgnored(string name, object? value, Type type); } diff --git a/src/Destructurama.Attributed/Attributed/ITypeDestructuringAttribute.cs b/src/Destructurama.Attributed/Attributed/ITypeDestructuringAttribute.cs index b3d86f9..3f840d9 100644 --- a/src/Destructurama.Attributed/Attributed/ITypeDestructuringAttribute.cs +++ b/src/Destructurama.Attributed/Attributed/ITypeDestructuringAttribute.cs @@ -18,7 +18,7 @@ namespace Destructurama.Attributed; /// -/// Base interfaces for all s that override how a property type type is destructured. +/// Base interface for all Destructurama attributes that override how a property type is destructured. /// public interface ITypeDestructuringAttribute { diff --git a/src/Destructurama.Attributed/Attributed/LogAsScalarAttribute.cs b/src/Destructurama.Attributed/Attributed/LogAsScalarAttribute.cs index 5cfc010..0a6f848 100644 --- a/src/Destructurama.Attributed/Attributed/LogAsScalarAttribute.cs +++ b/src/Destructurama.Attributed/Attributed/LogAsScalarAttribute.cs @@ -29,9 +29,11 @@ public class LogAsScalarAttribute : Attribute, ITypeDestructuringAttribute, IPro /// /// Construct a . /// - /// Whether the scalar value should be converted into a string before - /// being passed down the (asynchronous) logging pipeline. For mutable types, specify - /// true, otherwise leave as false. + /// + /// Whether the scalar value should be converted into a string before + /// being passed down the (asynchronous) logging pipeline. For mutable + /// types, specify true, otherwise leave as false. + /// public LogAsScalarAttribute(bool isMutable = false) { _isMutable = isMutable; diff --git a/src/Destructurama.Attributed/Attributed/LogMaskedAttribute.cs b/src/Destructurama.Attributed/Attributed/LogMaskedAttribute.cs index 8676874..6caaafc 100644 --- a/src/Destructurama.Attributed/Attributed/LogMaskedAttribute.cs +++ b/src/Destructurama.Attributed/Attributed/LogMaskedAttribute.cs @@ -29,14 +29,17 @@ public class LogMaskedAttribute : Attribute, IPropertyDestructuringAttribute /// If set, the property value will be set to this text. /// public string Text { get; set; } = DEFAULT_MASK; + /// /// Shows the first x characters in the property value. /// public int ShowFirst { get; set; } + /// /// Shows the last x characters in the property value. /// public int ShowLast { get; set; } + /// /// If set, it will swap out each character with the default value. Note that this /// property will be ignored if has been set to custom value. diff --git a/src/Destructurama.Attributed/Attributed/LogReplacedAttribute.cs b/src/Destructurama.Attributed/Attributed/LogReplacedAttribute.cs index 3753754..f1b91be 100644 --- a/src/Destructurama.Attributed/Attributed/LogReplacedAttribute.cs +++ b/src/Destructurama.Attributed/Attributed/LogReplacedAttribute.cs @@ -20,7 +20,7 @@ namespace Destructurama.Attributed; /// -/// Apply to a property to use a replace the current value. +/// Apply to a property to replace the current value. /// [AttributeUsage(AttributeTargets.Property)] public class LogReplacedAttribute : Attribute, IPropertyDestructuringAttribute @@ -29,7 +29,7 @@ public class LogReplacedAttribute : Attribute, IPropertyDestructuringAttribute private readonly string _replacement; /// - /// The RegexOptions that will be applied. Defaults to + /// The options that will be applied. Defaults to /// public RegexOptions Options { get; set; } diff --git a/src/Destructurama.Attributed/Attributed/NotLoggedIfNullAttribute.cs b/src/Destructurama.Attributed/Attributed/NotLoggedIfNullAttribute.cs index 7cccd54..7c80cc0 100644 --- a/src/Destructurama.Attributed/Attributed/NotLoggedIfNullAttribute.cs +++ b/src/Destructurama.Attributed/Attributed/NotLoggedIfNullAttribute.cs @@ -1,11 +1,11 @@ // Copyright 2020 Destructurama Contributors, Serilog Contributors -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,7 +15,7 @@ namespace Destructurama.Attributed; /// -/// Specified that a property with null value should not be included when destructuring an object for logging. +/// Specified that a property with value should not be included when destructuring an object for logging. /// [AttributeUsage(AttributeTargets.Property)] public class NotLoggedIfNullAttribute : Attribute, IPropertyOptionalIgnoreAttribute diff --git a/src/Destructurama.Attributed/LoggerConfigurationAttributedExtensions.cs b/src/Destructurama.Attributed/LoggerConfigurationAttributedExtensions.cs index c460ebc..b3f9a4b 100644 --- a/src/Destructurama.Attributed/LoggerConfigurationAttributedExtensions.cs +++ b/src/Destructurama.Attributed/LoggerConfigurationAttributedExtensions.cs @@ -33,14 +33,14 @@ public static class LoggerConfigurationAppSettingsExtensions public static LoggerConfiguration UsingAttributes(this LoggerDestructuringConfiguration configuration) => configuration.With(); - /// + /// Adds a custom to enable manipulation of how objects + /// are logged to Serilog using attributes. /// /// The logger configuration to apply configuration to. - /// Configure Destructurama options + /// Delegate to configure Destructurama options. /// An object allowing configuration to continue. - public static LoggerConfiguration UsingAttributes(this LoggerDestructuringConfiguration configuration, - Action configure) + public static LoggerConfiguration UsingAttributes(this LoggerDestructuringConfiguration configuration, Action configure) { var policy = new AttributedDestructuringPolicy(configure); return configuration.With(policy); diff --git a/src/Destructurama.Attributed/Util/CacheEntry.cs b/src/Destructurama.Attributed/Util/CacheEntry.cs index e187b4d..b1033b1 100644 --- a/src/Destructurama.Attributed/Util/CacheEntry.cs +++ b/src/Destructurama.Attributed/Util/CacheEntry.cs @@ -22,13 +22,13 @@ internal struct CacheEntry public CacheEntry(Func destructureFunc) { CanDestructure = true; - DestructureFunc = destructureFunc ?? throw new ArgumentNullException(nameof(destructureFunc)); + DestructureFunc = destructureFunc; } private CacheEntry(bool canDestructure, Func destructureFunc) { CanDestructure = canDestructure; - DestructureFunc = destructureFunc ?? throw new ArgumentNullException(nameof(destructureFunc)); + DestructureFunc = destructureFunc; } public bool CanDestructure { get; }