diff --git a/src/Microsoft.Diagnostics.EventFlow.ServiceFabric/Microsoft.Diagnostics.EventFlow.ServiceFabric.csproj b/src/Microsoft.Diagnostics.EventFlow.ServiceFabric/Microsoft.Diagnostics.EventFlow.ServiceFabric.csproj index 13a1de05..b03617e2 100644 --- a/src/Microsoft.Diagnostics.EventFlow.ServiceFabric/Microsoft.Diagnostics.EventFlow.ServiceFabric.csproj +++ b/src/Microsoft.Diagnostics.EventFlow.ServiceFabric/Microsoft.Diagnostics.EventFlow.ServiceFabric.csproj @@ -3,7 +3,7 @@ Provides types that simplify the use of EventFlow library by Microsoft Service Fabric services. © Microsoft Corporation. All rights reserved. - 1.1.3 + 1.1.4 Microsoft net451 x64 diff --git a/src/Microsoft.Diagnostics.EventFlow.ServiceFabric/ServiceFabricDiagnosticPipelineFactory.cs b/src/Microsoft.Diagnostics.EventFlow.ServiceFabric/ServiceFabricDiagnosticPipelineFactory.cs index e900c38b..55321bba 100644 --- a/src/Microsoft.Diagnostics.EventFlow.ServiceFabric/ServiceFabricDiagnosticPipelineFactory.cs +++ b/src/Microsoft.Diagnostics.EventFlow.ServiceFabric/ServiceFabricDiagnosticPipelineFactory.cs @@ -91,7 +91,7 @@ internal static IConfigurationRoot ApplyFabricConfigurationOverrides( { string valueReferencePath = ConfigurationPath.Combine(valueReferenceMatch.Groups["section"].Value, valueReferenceMatch.Groups["name"].Value); string newValue = configurationRoot[valueReferencePath]; - if (string.IsNullOrEmpty(newValue)) + if (newValue == null) { healthReporter.ReportWarning( $"Configuration value reference '{kvp.Value}' was encountered but no corresponding configuration value was found using path '{valueReferencePath}'", diff --git a/test/Microsoft.Diagnostics.EventFlow.ServiceFabric.Tests/ServiceFabricTests.cs b/test/Microsoft.Diagnostics.EventFlow.ServiceFabric.Tests/ServiceFabricTests.cs index 4f6858bc..60433227 100644 --- a/test/Microsoft.Diagnostics.EventFlow.ServiceFabric.Tests/ServiceFabricTests.cs +++ b/test/Microsoft.Diagnostics.EventFlow.ServiceFabric.Tests/ServiceFabricTests.cs @@ -78,6 +78,31 @@ public void ConfigurationUpdatedWithValueReferences() Assert.True(isOK, verificationError); } + [Fact] + public void ReferencedValueCanBeEmpty() + { + var healthReporterMock = new Mock(); + var configurationSource = new Dictionary() + { + ["alpha"] = "Alpha", + ["bravo:charlie"] = "", + ["delta"] = "servicefabric:/bravo/charlie" + }; + + IConfigurationRoot configuration = (new ConfigurationBuilder()).AddInMemoryCollection(configurationSource).Build(); + ServiceFabricDiagnosticPipelineFactory.ApplyFabricConfigurationOverrides(configuration, "unused-configuration-package-path", healthReporterMock.Object); + healthReporterMock.Verify(o => o.ReportProblem(It.IsAny(), It.IsAny()), Times.Never()); + healthReporterMock.Verify(o => o.ReportWarning(It.IsAny(), It.IsAny()), Times.Never()); + + string verificationError; + bool isOK = VerifyConfguration(configuration.AsEnumerable(), configurationSource, out verificationError); + Assert.False(isOK, verificationError); + + configurationSource["delta"] = ""; + isOK = VerifyConfguration(configuration.AsEnumerable(), configurationSource, out verificationError); + Assert.True(isOK, verificationError); + } + [Fact] public void ConfigurationIsNotChangedIfFileReferenceIsEmpty() { @@ -152,7 +177,7 @@ private bool VerifyConfguration( if (!valueComparer.Equals(kvp.Value, correspondingPair.Value.Value)) { - verificationError = $"The value for key '{kvp.Key}' was expected to be '{kvp.Value}' but instead it is '{correspondingPair.Value.Value}')"; + verificationError = $"The value for key '{kvp.Key}' was expected to be '{kvp.Value}' but instead it is '{correspondingPair.Value.Value}'"; return false; } }