From 4e1979a8f501c0cc3f727ab081fa4bc5033eacc1 Mon Sep 17 00:00:00 2001 From: Joe Schmitt Date: Mon, 1 Jul 2024 14:36:22 -0700 Subject: [PATCH 1/2] Enable nullable context for options --- .../ExperimentalSchemaProcessor.cs | 2 +- ...tics.Monitoring.ConfigurationSchema.csproj | 1 + .../Options/ConsoleFormatterOptions.cs | 2 +- .../Options/ConsoleLoggerOptions.cs | 4 +-- .../Options/JsonConsoleFormatterOptions.cs | 2 +- .../Options/LogLevelOptions.cs | 2 +- .../Options/LoggingOptions.cs | 10 +++---- .../Options/RootOptions.Logging.cs | 2 +- .../Options/SimpleConsoleFormatterOptions.cs | 2 +- .../SchemaGenerator.cs | 4 +-- .../Options/Actions/CollectDumpOptions.cs | 2 +- .../Actions/CollectExceptionsOptions.cs | 6 ++-- .../Options/Actions/CollectGCDumpOptions.cs | 2 +- .../Actions/CollectLiveMetricsOptions.cs | 8 ++++-- .../Options/Actions/CollectLogsOptions.cs | 6 ++-- .../Options/Actions/CollectStacksOptions.cs | 2 +- .../Options/Actions/CollectTraceOptions.cs | 8 ++++-- .../Options/Actions/ExecuteOptions.cs | 6 ++-- .../Actions/GetEnvironmentVariableOptions.cs | 2 +- .../Options/Actions/LoadProfilerOptions.cs | 2 +- .../Actions/SetEnvironmentVariableOptions.cs | 6 ++-- .../Options/Actions/TraceEventFilter.cs | 8 ++++-- .../CollectionRuleActionDefaultsOptions.cs | 4 ++- .../Options/CollectionRuleActionOptions.cs | 8 ++++-- .../Options/CollectionRuleDefaultsOptions.cs | 8 ++++-- .../Options/CollectionRuleOptions.cs | 10 ++++--- .../Options/CollectionRuleTriggerOptions.cs | 6 ++-- .../Options/RegularExpressionsAttribute.cs | 4 ++- .../Options/TemplateOptions.cs | 10 ++++--- .../Triggers/AspNetRequestCountOptions.cs | 6 ++-- .../Triggers/AspNetRequestDurationOptions.cs | 6 ++-- .../Triggers/AspNetResponseStatusOptions.cs | 8 ++++-- .../Options/Triggers/EventCounterOptions.cs | 4 +-- .../Options/Triggers/EventMeterOptions.cs | 4 +-- .../Triggers/IAspNetActionPathFilters.cs | 6 ++-- src/Tools/dotnet-monitor/RootOptions.cs | 28 ++++++++++--------- 36 files changed, 120 insertions(+), 81 deletions(-) diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/ExperimentalSchemaProcessor.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/ExperimentalSchemaProcessor.cs index e71abb219d6..f1fa97e620a 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/ExperimentalSchemaProcessor.cs +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/ExperimentalSchemaProcessor.cs @@ -17,7 +17,7 @@ public void Process(SchemaProcessorContext context) { if (null != property.GetCustomAttribute()) { - string description = context.Schema.Properties[property.Name].Description; + string? description = context.Schema.Properties[property.Name].Description; if (string.IsNullOrEmpty(description)) { description = ExperimentalPrefix; diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Microsoft.Diagnostics.Monitoring.ConfigurationSchema.csproj b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Microsoft.Diagnostics.Monitoring.ConfigurationSchema.csproj index a7af91ecb20..2ec74e69f6c 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Microsoft.Diagnostics.Monitoring.ConfigurationSchema.csproj +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Microsoft.Diagnostics.Monitoring.ConfigurationSchema.csproj @@ -2,6 +2,7 @@ Exe + enable $(SchemaTargetFramework) $(DefineConstants);SCHEMAGEN diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/ConsoleFormatterOptions.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/ConsoleFormatterOptions.cs index 6f7de9245b1..111d30c9897 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/ConsoleFormatterOptions.cs +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/ConsoleFormatterOptions.cs @@ -18,7 +18,7 @@ internal sealed class ConsoleFormatterOptions ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_ConsoleFormatterOptions_TimestampFormat))] [DefaultValue(null)] - public string TimestampFormat { get; set; } + public string? TimestampFormat { get; set; } [Display( ResourceType = typeof(OptionsDisplayStrings), diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/ConsoleLoggerOptions.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/ConsoleLoggerOptions.cs index 07a31e754e3..67a672fda0e 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/ConsoleLoggerOptions.cs +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/ConsoleLoggerOptions.cs @@ -25,11 +25,11 @@ internal sealed class ConsoleLoggerOptions [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_ConsoleLoggerOptions_FormatterOptions))] - public object FormatterOptions { get; set; } + public object? FormatterOptions { get; set; } [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_ConsoleLoggerOptions_LogLevel))] - public IDictionary LogLevel { get; set; } + public IDictionary? LogLevel { get; set; } } } diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/JsonConsoleFormatterOptions.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/JsonConsoleFormatterOptions.cs index b12b7a7cdf7..340249c50ba 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/JsonConsoleFormatterOptions.cs +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/JsonConsoleFormatterOptions.cs @@ -24,7 +24,7 @@ internal sealed class JsonConsoleFormatterOptions ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_ConsoleFormatterOptions_TimestampFormat))] [DefaultValue(null)] - public string TimestampFormat { get; set; } + public string? TimestampFormat { get; set; } [Display( ResourceType = typeof(OptionsDisplayStrings), diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/LogLevelOptions.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/LogLevelOptions.cs index f1595e11e02..e98f40cc06d 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/LogLevelOptions.cs +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/LogLevelOptions.cs @@ -13,6 +13,6 @@ internal sealed class LogLevelOptions [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_LogLevelOptions_LogLevel))] - public IDictionary LogLevel { get; set; } + public IDictionary? LogLevel { get; set; } } } diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/LoggingOptions.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/LoggingOptions.cs index 1fc38a4ea3b..87b2191428d 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/LoggingOptions.cs +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/LoggingOptions.cs @@ -14,27 +14,27 @@ internal sealed class LoggingOptions [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_LoggingOptions_LogLevel))] - public IDictionary LogLevel { get; set; } + public IDictionary? LogLevel { get; set; } [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_LoggingOptions_Console))] - public ConsoleLoggerOptions Console { get; set; } + public ConsoleLoggerOptions? Console { get; set; } [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_LoggingOptions_EventLog))] - public LogLevelOptions EventLog { get; set; } + public LogLevelOptions? EventLog { get; set; } [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_LoggingOptions_Debug))] - public LogLevelOptions Debug { get; set; } + public LogLevelOptions? Debug { get; set; } [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_LoggingOptions_EventSource))] - public LogLevelOptions EventSource { get; set; } + public LogLevelOptions? EventSource { get; set; } [Display( ResourceType = typeof(OptionsDisplayStrings), diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/RootOptions.Logging.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/RootOptions.Logging.cs index 23cfda4f420..94b426c85e8 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/RootOptions.Logging.cs +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/RootOptions.Logging.cs @@ -7,6 +7,6 @@ namespace Microsoft.Diagnostics.Tools.Monitor { internal partial class RootOptions { - public LoggingOptions Logging { get; set; } + public LoggingOptions? Logging { get; set; } } } diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/SimpleConsoleFormatterOptions.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/SimpleConsoleFormatterOptions.cs index c448362a34c..5e947480b99 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/SimpleConsoleFormatterOptions.cs +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/SimpleConsoleFormatterOptions.cs @@ -31,7 +31,7 @@ internal sealed class SimpleConsoleFormatterOptions ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_ConsoleFormatterOptions_TimestampFormat))] [DefaultValue(null)] - public string TimestampFormat { get; set; } + public string? TimestampFormat { get; set; } [Display( ResourceType = typeof(OptionsDisplayStrings), diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/SchemaGenerator.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/SchemaGenerator.cs index 3770ce11241..52f9739293d 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/SchemaGenerator.cs +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/SchemaGenerator.cs @@ -275,7 +275,7 @@ private static JsonSchemaProperty AddDiscriminatedSubSchema( string discriminatingPropertyName, string discriminatingPropertyValue, string discriminatedPropertyName, - JsonSchema subSchema = null) + JsonSchema? subSchema = null) { if (null == subSchema) { @@ -283,7 +283,7 @@ private static JsonSchemaProperty AddDiscriminatedSubSchema( } JsonSchemaProperty discriminatingProperty = new JsonSchemaProperty(); - discriminatingProperty.ExtensionData = new Dictionary(); + discriminatingProperty.ExtensionData = new Dictionary(); discriminatingProperty.ExtensionData.Add("const", discriminatingPropertyValue); subSchema.Properties.Add(discriminatingPropertyName, discriminatingProperty); diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectDumpOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectDumpOptions.cs index 666b0ada60c..ac0c66196af 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectDumpOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectDumpOptions.cs @@ -35,6 +35,6 @@ internal sealed partial record class CollectDumpOptions : BaseRecordOptions, IEg #if !UNITTEST && !SCHEMAGEN [ValidateEgressProvider] #endif - public string Egress { get; set; } + public string Egress { get; set; } = string.Empty; } } diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectExceptionsOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectExceptionsOptions.cs index b35bc2f22e7..babcf8286df 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectExceptionsOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectExceptionsOptions.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#nullable enable + using Microsoft.Diagnostics.Monitoring.Options; using Microsoft.Diagnostics.Monitoring.WebApi; using Microsoft.Diagnostics.Tools.Monitor.CollectionRules.Options.CollectionRuleDefaultsInterfaces; @@ -25,7 +27,7 @@ internal sealed partial record class CollectExceptionsOptions : BaseRecordOption #if !UNITTEST && !SCHEMAGEN [ValidateEgressProvider] #endif - public string Egress { get; set; } + public string Egress { get; set; } = string.Empty; [Display( ResourceType = typeof(OptionsDisplayStrings), @@ -36,6 +38,6 @@ internal sealed partial record class CollectExceptionsOptions : BaseRecordOption [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_CollectExceptionsOptions_Filters))] - public ExceptionsConfiguration Filters { get; set; } + public ExceptionsConfiguration? Filters { get; set; } } } diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectGCDumpOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectGCDumpOptions.cs index 00754715914..7f3c302f075 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectGCDumpOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectGCDumpOptions.cs @@ -26,6 +26,6 @@ internal sealed partial record class CollectGCDumpOptions : BaseRecordOptions, I #if !UNITTEST && !SCHEMAGEN [ValidateEgressProvider] #endif - public string Egress { get; set; } + public string Egress { get; set; } = string.Empty; } } diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectLiveMetricsOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectLiveMetricsOptions.cs index 5803078acc3..49af7fe1319 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectLiveMetricsOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectLiveMetricsOptions.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#nullable enable + using Microsoft.Diagnostics.Monitoring.WebApi; using Microsoft.Diagnostics.Monitoring.WebApi.Models; using Microsoft.Diagnostics.Tools.Monitor.CollectionRules.Options.CollectionRuleDefaultsInterfaces; @@ -29,12 +31,12 @@ internal sealed partial record class CollectLiveMetricsOptions : BaseRecordOptio [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_CollectLiveMetricsOptions_Providers))] - public EventMetricsProvider[] Providers { get; set; } + public EventMetricsProvider[]? Providers { get; set; } [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_CollectLiveMetricsOptions_Meters))] - public EventMetricsMeter[] Meters { get; set; } + public EventMetricsMeter[]? Meters { get; set; } [Display( ResourceType = typeof(OptionsDisplayStrings), @@ -52,6 +54,6 @@ internal sealed partial record class CollectLiveMetricsOptions : BaseRecordOptio #if !UNITTEST && !SCHEMAGEN [ValidateEgressProvider] #endif - public string Egress { get; set; } + public string Egress { get; set; } = string.Empty; } } diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectLogsOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectLogsOptions.cs index c10c5820eb8..5241c1a357f 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectLogsOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectLogsOptions.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#nullable enable + using Microsoft.Diagnostics.Monitoring.Options; using Microsoft.Diagnostics.Monitoring.WebApi; using Microsoft.Diagnostics.Tools.Monitor.CollectionRules.Options.CollectionRuleDefaultsInterfaces; @@ -32,7 +34,7 @@ internal sealed partial record class CollectLogsOptions : BaseRecordOptions, IEg [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_CollectLogsOptions_FilterSpecs))] - public Dictionary FilterSpecs { get; set; } + public Dictionary? FilterSpecs { get; set; } [Display( ResourceType = typeof(OptionsDisplayStrings), @@ -56,7 +58,7 @@ internal sealed partial record class CollectLogsOptions : BaseRecordOptions, IEg #if !UNITTEST && !SCHEMAGEN [ValidateEgressProvider] #endif - public string Egress { get; set; } + public string Egress { get; set; } = string.Empty; [Display( ResourceType = typeof(OptionsDisplayStrings), diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectStacksOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectStacksOptions.cs index dd1aeda5a35..1276386f0a4 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectStacksOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectStacksOptions.cs @@ -31,7 +31,7 @@ internal sealed partial record class CollectStacksOptions : BaseRecordOptions, I #if !UNITTEST && !SCHEMAGEN [ValidateEgressProvider] #endif - public string Egress { get; set; } + public string Egress { get; set; } = string.Empty; [Display( ResourceType = typeof(OptionsDisplayStrings), diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectTraceOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectTraceOptions.cs index dfe4c50a888..267ff9b76ca 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectTraceOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectTraceOptions.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#nullable enable + using Microsoft.Diagnostics.Monitoring.WebApi; using Microsoft.Diagnostics.Monitoring.WebApi.Models; using Microsoft.Diagnostics.Tools.Monitor.CollectionRules.Options.CollectionRuleDefaultsInterfaces; @@ -30,7 +32,7 @@ internal sealed partial record class CollectTraceOptions : BaseRecordOptions, IE [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_CollectTraceOptions_Providers))] - public List Providers { get; set; } + public List? Providers { get; set; } [Display( ResourceType = typeof(OptionsDisplayStrings), @@ -61,11 +63,11 @@ internal sealed partial record class CollectTraceOptions : BaseRecordOptions, IE #if !UNITTEST && !SCHEMAGEN [ValidateEgressProvider] #endif - public string Egress { get; set; } + public string Egress { get; set; } = string.Empty; [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_CollectTraceOptions_StoppingEvent))] - public TraceEventFilter StoppingEvent { get; set; } + public TraceEventFilter? StoppingEvent { get; set; } } } diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/ExecuteOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/ExecuteOptions.cs index f855a589882..f62f665430f 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/ExecuteOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/ExecuteOptions.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#nullable enable + using Microsoft.Diagnostics.Monitoring.WebApi; using System.ComponentModel; using System.ComponentModel.DataAnnotations; @@ -21,13 +23,13 @@ internal sealed record class ExecuteOptions : BaseRecordOptions ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_ExecuteOptions_Path))] [Required] - public string Path { get; set; } + public string Path { get; set; } = string.Empty; [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_ExecuteOptions_Arguments))] [ActionOptionsDependencyProperty] - public string Arguments { get; set; } + public string? Arguments { get; set; } [DefaultValue(ExecuteOptionsDefaults.IgnoreExitCode)] public bool? IgnoreExitCode { get; set; } diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/GetEnvironmentVariableOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/GetEnvironmentVariableOptions.cs index ff7ad9592f8..67da644add3 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/GetEnvironmentVariableOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/GetEnvironmentVariableOptions.cs @@ -20,6 +20,6 @@ internal sealed record class GetEnvironmentVariableOptions : BaseRecordOptions ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_GetEnvironmentVariableOptions_Name))] [Required] - public string Name { get; set; } + public string Name { get; set; } = string.Empty; } } diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/LoadProfilerOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/LoadProfilerOptions.cs index 6084293da0f..d3f2fadba13 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/LoadProfilerOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/LoadProfilerOptions.cs @@ -21,7 +21,7 @@ internal sealed record class LoadProfilerOptions : BaseRecordOptions ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_LoadProfilerOptions_Path))] [Required] - public string Path { get; set; } + public string Path { get; set; } = string.Empty; [Display( ResourceType = typeof(OptionsDisplayStrings), diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/SetEnvironmentVariableOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/SetEnvironmentVariableOptions.cs index 31c3412a745..d9323b29bcc 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/SetEnvironmentVariableOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/SetEnvironmentVariableOptions.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#nullable enable + using Microsoft.Diagnostics.Monitoring.WebApi; using System.ComponentModel.DataAnnotations; using System.Diagnostics; @@ -20,11 +22,11 @@ internal sealed record class SetEnvironmentVariableOptions : BaseRecordOptions ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_SetEnvironmentVariableOptions_Name))] [Required] - public string Name { get; set; } + public string Name { get; set; } = string.Empty; [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_SetEnvironmentVariableOptions_Value))] - public string Value { get; set; } + public string? Value { get; set; } } } diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/TraceEventFilter.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/TraceEventFilter.cs index 7f9e7e5d5c6..ab7e874fc9f 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/TraceEventFilter.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/TraceEventFilter.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#nullable enable + using Microsoft.Diagnostics.Monitoring.WebApi; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; @@ -21,17 +23,17 @@ internal sealed record class TraceEventFilter : BaseRecordOptions ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_TraceEventFilter_ProviderName))] [Required] - public string ProviderName { get; set; } + public string ProviderName { get; set; } = string.Empty; [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_TraceEventFilter_EventName))] [Required] - public string EventName { get; set; } + public string EventName { get; set; } = string.Empty; [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_TraceEventFilter_PayloadFilter))] - public IDictionary PayloadFilter { get; set; } + public IDictionary? PayloadFilter { get; set; } } } diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleActionDefaultsOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleActionDefaultsOptions.cs index 0eb8d329059..f9978705d0b 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleActionDefaultsOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleActionDefaultsOptions.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#nullable enable + using Microsoft.Diagnostics.Monitoring.WebApi; using System.ComponentModel.DataAnnotations; @@ -11,6 +13,6 @@ internal sealed class CollectionRuleActionDefaultsOptions [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_CollectionRuleActionDefaultsOptions_Egress))] - public string Egress { get; set; } + public string? Egress { get; set; } } } diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleActionOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleActionOptions.cs index 085708a7682..66e29494f0a 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleActionOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleActionOptions.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#nullable enable + using Microsoft.Diagnostics.Monitoring.WebApi; using System.ComponentModel; using System.ComponentModel.DataAnnotations; @@ -17,18 +19,18 @@ internal sealed partial class CollectionRuleActionOptions [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_CollectionRuleActionOptions_Name))] - public string Name { get; set; } + public string? Name { get; set; } [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_CollectionRuleActionOptions_Type))] [Required] - public string Type { get; set; } + public string Type { get; set; } = string.Empty; [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_CollectionRuleActionOptions_Settings))] - public object Settings { get; internal set; } + public object? Settings { get; internal set; } [Display( ResourceType = typeof(OptionsDisplayStrings), diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleDefaultsOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleDefaultsOptions.cs index 57d6a637cc4..064d4ab8f9b 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleDefaultsOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleDefaultsOptions.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#nullable enable + using Microsoft.Diagnostics.Monitoring.WebApi; using System.ComponentModel.DataAnnotations; @@ -11,16 +13,16 @@ internal sealed class CollectionRuleDefaultsOptions [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_CollectionRuleDefaultsOptions_Triggers))] - public CollectionRuleTriggerDefaultsOptions Triggers { get; set; } + public CollectionRuleTriggerDefaultsOptions? Triggers { get; set; } [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_CollectionRuleDefaultsOptions_Actions))] - public CollectionRuleActionDefaultsOptions Actions { get; set; } + public CollectionRuleActionDefaultsOptions? Actions { get; set; } [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_CollectionRuleDefaultsOptions_Limits))] - public CollectionRuleLimitsDefaultsOptions Limits { get; set; } + public CollectionRuleLimitsDefaultsOptions? Limits { get; set; } } } diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleOptions.cs index 95b8f9562a6..791c81f801d 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleOptions.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#nullable enable + using Microsoft.Diagnostics.Monitoring.WebApi; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; @@ -15,23 +17,23 @@ internal sealed partial class CollectionRuleOptions [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_CollectionRuleOptions_Filters))] - public List Filters { get; } = new List(0); + public List? Filters { get; } = new List(0); [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_CollectionRuleOptions_Trigger))] [Required] - public CollectionRuleTriggerOptions Trigger { get; set; } + public CollectionRuleTriggerOptions Trigger { get; set; } = new(); [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_CollectionRuleOptions_Actions))] - public List Actions { get; } = new List(0); + public List? Actions { get; } = new List(0); [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_CollectionRuleOptions_Limits))] - public CollectionRuleLimitsOptions Limits { get; set; } + public CollectionRuleLimitsOptions? Limits { get; set; } internal List ErrorList { get; } = new List(); } diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleTriggerOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleTriggerOptions.cs index 1ea171a3219..6abf18ab2d0 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleTriggerOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleTriggerOptions.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#nullable enable + using Microsoft.Diagnostics.Monitoring.WebApi; using System.ComponentModel.DataAnnotations; using System.Diagnostics; @@ -17,11 +19,11 @@ internal sealed partial class CollectionRuleTriggerOptions ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_CollectionRuleTriggerOptions_Type))] [Required] - public string Type { get; set; } + public string Type { get; set; } = string.Empty; [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_CollectionRuleTriggerOptions_Settings))] - public object Settings { get; internal set; } + public object? Settings { get; internal set; } } } diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/RegularExpressionsAttribute.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/RegularExpressionsAttribute.cs index adbb53c620b..1188ed42326 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/RegularExpressionsAttribute.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/RegularExpressionsAttribute.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#nullable enable + using System; using System.ComponentModel.DataAnnotations; @@ -13,7 +15,7 @@ public RegularExpressionsAttribute(string pattern) : base(pattern) { } - public override bool IsValid(object value) + public override bool IsValid(object? value) { if (value is string[] values) { diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/TemplateOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/TemplateOptions.cs index bb28aebd736..40b91ff4282 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/TemplateOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/TemplateOptions.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#nullable enable + using Microsoft.Diagnostics.Monitoring.WebApi; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; @@ -15,21 +17,21 @@ internal sealed partial class TemplateOptions [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_CollectionRuleOptions_Filters))] - public IDictionary CollectionRuleFilters { get; set; } = new Dictionary(); + public IDictionary? CollectionRuleFilters { get; set; } = new Dictionary(); [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_CollectionRuleOptions_Trigger))] - public IDictionary CollectionRuleTriggers { get; set; } = new Dictionary(); + public IDictionary? CollectionRuleTriggers { get; set; } = new Dictionary(); [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_CollectionRuleOptions_Actions))] - public IDictionary CollectionRuleActions { get; set; } = new Dictionary(); + public IDictionary? CollectionRuleActions { get; set; } = new Dictionary(); [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_CollectionRuleOptions_Limits))] - public IDictionary CollectionRuleLimits { get; set; } = new Dictionary(); + public IDictionary? CollectionRuleLimits { get; set; } = new Dictionary(); } } diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/AspNetRequestCountOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/AspNetRequestCountOptions.cs index cfe312de124..adb6868e8fa 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/AspNetRequestCountOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/AspNetRequestCountOptions.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#nullable enable + using Microsoft.Diagnostics.Monitoring.WebApi; using Microsoft.Diagnostics.Tools.Monitor.CollectionRules.Options.CollectionRuleDefaultsInterfaces; using System; @@ -35,13 +37,13 @@ internal sealed class AspNetRequestCountOptions : [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_AspNetRequestCountOptions_IncludePaths))] - public string[] IncludePaths { get; set; } + public string[]? IncludePaths { get; set; } // CONSIDER: Currently described that paths have to exactly match one item in the list. // Consider allowing for wildcard/globbing to simplify list of matchable paths. [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_AspNetRequestCountOptions_ExcludePaths))] - public string[] ExcludePaths { get; set; } + public string[]? ExcludePaths { get; set; } } } diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/AspNetRequestDurationOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/AspNetRequestDurationOptions.cs index b9c4f28388f..1967a34f1f8 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/AspNetRequestDurationOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/AspNetRequestDurationOptions.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#nullable enable + using Microsoft.Diagnostics.Monitoring.WebApi; using Microsoft.Diagnostics.Tools.Monitor.CollectionRules.Options.CollectionRuleDefaultsInterfaces; using System; @@ -46,13 +48,13 @@ internal sealed class AspNetRequestDurationOptions : [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_AspNetRequestDurationOptions_IncludePaths))] - public string[] IncludePaths { get; set; } + public string[]? IncludePaths { get; set; } // CONSIDER: Currently described that paths have to exactly match one item in the list. // Consider allowing for wildcard/globbing to simplify list of matchable paths. [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_AspNetRequestDurationOptions_ExcludePaths))] - public string[] ExcludePaths { get; set; } + public string[]? ExcludePaths { get; set; } } } diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/AspNetResponseStatusOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/AspNetResponseStatusOptions.cs index d124033b2b8..01f85593abf 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/AspNetResponseStatusOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/AspNetResponseStatusOptions.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#nullable enable + using Microsoft.Diagnostics.Monitoring.WebApi; using Microsoft.Diagnostics.Tools.Monitor.CollectionRules.Options.CollectionRuleDefaultsInterfaces; using System; @@ -25,7 +27,7 @@ internal sealed class AspNetResponseStatusOptions : [RegularExpressions(StatusCodesRegex, ErrorMessageResourceType = typeof(OptionsDisplayStrings), ErrorMessageResourceName = nameof(OptionsDisplayStrings.ErrorMessage_StatusCodesRegularExpressionDoesNotMatch))] - public string[] StatusCodes { get; set; } + public string[] StatusCodes { get; set; } = []; [Display( ResourceType = typeof(OptionsDisplayStrings), @@ -48,13 +50,13 @@ internal sealed class AspNetResponseStatusOptions : [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_AspNetResponseStatusOptions_IncludePaths))] - public string[] IncludePaths { get; set; } + public string[]? IncludePaths { get; set; } // CONSIDER: Currently described that paths have to exactly match one item in the list. // Consider allowing for wildcard/globbing to simplify list of matchable paths. [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_AspNetResponseStatusOptions_ExcludePaths))] - public string[] ExcludePaths { get; set; } + public string[]? ExcludePaths { get; set; } } } diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/EventCounterOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/EventCounterOptions.cs index 3546b3ff123..3c02bcd03cf 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/EventCounterOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/EventCounterOptions.cs @@ -17,13 +17,13 @@ internal sealed partial class EventCounterOptions : ISlidingWindowDurationProper ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_EventCounterOptions_ProviderName))] [Required] - public string ProviderName { get; set; } + public string ProviderName { get; set; } = string.Empty; [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_EventCounterOptions_CounterName))] [Required] - public string CounterName { get; set; } + public string CounterName { get; set; } = string.Empty; [Display( ResourceType = typeof(OptionsDisplayStrings), diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/EventMeterOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/EventMeterOptions.cs index c5288203f6b..cc22561940f 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/EventMeterOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/EventMeterOptions.cs @@ -17,13 +17,13 @@ internal sealed partial class EventMeterOptions : ISlidingWindowDurationProperti ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_EventMeterOptions_MeterName))] [Required] - public string MeterName { get; set; } + public string MeterName { get; set; } = string.Empty; [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_EventMeterOptions_InstrumentName))] [Required] - public string InstrumentName { get; set; } + public string InstrumentName { get; set; } = string.Empty; [Display( ResourceType = typeof(OptionsDisplayStrings), diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/IAspNetActionPathFilters.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/IAspNetActionPathFilters.cs index 723073aaeff..28657b2c5d6 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/IAspNetActionPathFilters.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/IAspNetActionPathFilters.cs @@ -1,12 +1,14 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#nullable enable + namespace Microsoft.Diagnostics.Tools.Monitor.CollectionRules.Options.Triggers { internal interface IAspNetActionPathFilters { - public string[] IncludePaths { get; } + public string[]? IncludePaths { get; } - public string[] ExcludePaths { get; } + public string[]? ExcludePaths { get; } } } diff --git a/src/Tools/dotnet-monitor/RootOptions.cs b/src/Tools/dotnet-monitor/RootOptions.cs index 526ee2d8acf..f3a42b42575 100644 --- a/src/Tools/dotnet-monitor/RootOptions.cs +++ b/src/Tools/dotnet-monitor/RootOptions.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#nullable enable + using Microsoft.Diagnostics.Monitoring.Options; using Microsoft.Diagnostics.Monitoring.WebApi; using Microsoft.Diagnostics.Tools.Monitor.CollectionRules.Options; @@ -10,32 +12,32 @@ namespace Microsoft.Diagnostics.Tools.Monitor { internal sealed partial class RootOptions { - public AuthenticationOptions Authentication { get; set; } + public AuthenticationOptions? Authentication { get; set; } - public IDictionary CollectionRules { get; set; } + public IDictionary? CollectionRules { get; set; } = new Dictionary(0); - public GlobalCounterOptions GlobalCounter { get; set; } + public GlobalCounterOptions? GlobalCounter { get; set; } - public InProcessFeaturesOptions InProcessFeatures { get; set; } + public InProcessFeaturesOptions? InProcessFeatures { get; set; } - public CorsConfigurationOptions CorsConfiguration { get; set; } + public CorsConfigurationOptions? CorsConfiguration { get; set; } - public DiagnosticPortOptions DiagnosticPort { get; set; } + public DiagnosticPortOptions? DiagnosticPort { get; set; } - public EgressOptions Egress { get; set; } + public EgressOptions? Egress { get; set; } - public MetricsOptions Metrics { get; set; } + public MetricsOptions? Metrics { get; set; } - public StorageOptions Storage { get; set; } + public StorageOptions? Storage { get; set; } - public ProcessFilterOptions DefaultProcess { get; set; } + public ProcessFilterOptions? DefaultProcess { get; set; } - public CollectionRuleDefaultsOptions CollectionRuleDefaults { get; set; } + public CollectionRuleDefaultsOptions? CollectionRuleDefaults { get; set; } - public TemplateOptions Templates { get; set; } + public TemplateOptions? Templates { get; set; } - public DotnetMonitorDebugOptions DotnetMonitorDebug { get; set; } + public DotnetMonitorDebugOptions? DotnetMonitorDebug { get; set; } } } From f08aefb15d62e3e22fc6a698a530de6cf4c58313 Mon Sep 17 00:00:00 2001 From: Joe Schmitt Date: Mon, 1 Jul 2024 15:57:32 -0700 Subject: [PATCH 2/2] Fix build --- .../CollectionRules/Options/CollectionRuleOptions.cs | 4 +++- .../Options/Triggers/AspNetResponseStatusOptions.cs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleOptions.cs index 791c81f801d..607f9e735a5 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleOptions.cs @@ -19,11 +19,13 @@ internal sealed partial class CollectionRuleOptions Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_CollectionRuleOptions_Filters))] public List? Filters { get; } = new List(0); +#nullable disable [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_CollectionRuleOptions_Trigger))] [Required] - public CollectionRuleTriggerOptions Trigger { get; set; } = new(); + public CollectionRuleTriggerOptions Trigger { get; set; } +#nullable enable [Display( ResourceType = typeof(OptionsDisplayStrings), diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/AspNetResponseStatusOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/AspNetResponseStatusOptions.cs index 01f85593abf..9f998a007cf 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/AspNetResponseStatusOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/AspNetResponseStatusOptions.cs @@ -19,6 +19,7 @@ internal sealed class AspNetResponseStatusOptions : private const string StatusCodeRegex = "[1-5][0-9]{2}"; private const string StatusCodesRegex = StatusCodeRegex + "(-" + StatusCodeRegex + ")?"; +#nullable disable [Display( ResourceType = typeof(OptionsDisplayStrings), Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_AspNetResponseStatusOptions_StatusCodes))] @@ -27,7 +28,8 @@ internal sealed class AspNetResponseStatusOptions : [RegularExpressions(StatusCodesRegex, ErrorMessageResourceType = typeof(OptionsDisplayStrings), ErrorMessageResourceName = nameof(OptionsDisplayStrings.ErrorMessage_StatusCodesRegularExpressionDoesNotMatch))] - public string[] StatusCodes { get; set; } = []; + public string[] StatusCodes { get; set; } +#nullable enable [Display( ResourceType = typeof(OptionsDisplayStrings),