diff --git a/AMWD.Common.AspNetCore/BasicAuthentication/BasicAuthenticationAttribute.cs b/AMWD.Common.AspNetCore/BasicAuthentication/BasicAuthenticationAttribute.cs
index b2b2cb6..61e3825 100644
--- a/AMWD.Common.AspNetCore/BasicAuthentication/BasicAuthenticationAttribute.cs
+++ b/AMWD.Common.AspNetCore/BasicAuthentication/BasicAuthenticationAttribute.cs
@@ -95,6 +95,7 @@ namespace AMWD.Common.AspNetCore.BasicAuthentication
if (!string.IsNullOrWhiteSpace(Realm))
context.HttpContext.Response.Headers["WWW-Authenticate"] += $" realm=\"{Realm.Replace("\"", "")}\"";
+ context.HttpContext.Response.StatusCode = 401;
context.Result = new UnauthorizedResult();
}
}
diff --git a/AMWD.Common.Tests/Extensions/StreamExtensionsTests.cs b/AMWD.Common.Tests/Extensions/StreamExtensionsTests.cs
index 731420c..8fd902f 100644
--- a/AMWD.Common.Tests/Extensions/StreamExtensionsTests.cs
+++ b/AMWD.Common.Tests/Extensions/StreamExtensionsTests.cs
@@ -7,6 +7,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace AMWD.Common.Tests.Extensions
{
[TestClass]
+ [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public class StreamExtensionsTests
{
[TestMethod]
diff --git a/AMWD.Common.Tests/Extensions/StringExtensionsTests.cs b/AMWD.Common.Tests/Extensions/StringExtensionsTests.cs
index 162290c..3fcabc3 100644
--- a/AMWD.Common.Tests/Extensions/StringExtensionsTests.cs
+++ b/AMWD.Common.Tests/Extensions/StringExtensionsTests.cs
@@ -333,5 +333,21 @@ namespace AMWD.Common.Tests.Extensions
Assert.IsNull(hexDecodeNull);
Assert.AreEqual("", hexDecodeEmpty);
}
+
+ [TestMethod]
+ public void ShouldAddCustomLineTermination()
+ {
+ // arrange
+ string value = "abc";
+ var sb = new StringBuilder();
+
+ // act
+ sb.AppendLine(value, "\r");
+ sb.AppendLine(value, "\r");
+
+ // assert
+ Assert.AreEqual($"{value}\r{value}\r", sb.ToString());
+ Assert.IsFalse(sb.ToString().Contains('\n'));
+ }
}
}
diff --git a/AMWD.Common/Extensions/StringExtensions.cs b/AMWD.Common/Extensions/StringExtensions.cs
index 2b4f971..cec9ef6 100644
--- a/AMWD.Common/Extensions/StringExtensions.cs
+++ b/AMWD.Common/Extensions/StringExtensions.cs
@@ -203,5 +203,16 @@ namespace System
return false;
}
}
+
+ ///
+ /// Appends a copy of the specified string followed by the specified line terminator
+ /// to the end of the current object.
+ ///
+ /// The object.
+ /// The string to append.
+ /// The line terminator.
+ ///
+ public static StringBuilder AppendLine(this StringBuilder sb, string value, string newLine)
+ => sb.Append(value).Append(newLine);
}
}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 44f1816..60a9ab3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
_nothing changed yet_
+## [v1.4.2](https://git.am-wd.de/AM.WD/common/compare/v1.4.1...v1.4.2) - 2022-05-06
+### Added
+- New extension for `StringBuilder` `AppendLine(value: string, newLine: string)` to add a line with a explicit defined new line character.
+
+
## [v1.4.1](https://git.am-wd.de/AM.WD/common/compare/v1.4.0...v1.4.1) - 2022-03-23
### Added
- `IntegrityHashTagHelper` can be used with `asp-integrity="true|false"` and `asp-integrity-strength="256|384|512"`
diff --git a/LICENSE.txt b/LICENSE.txt
index c6a64eb..3ada2ea 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,6 +1,6 @@
The MIT License
-Copyright (c) 2020-2021 Andreas Müller
+Copyright (c) 2020-2022 Andreas Müller
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
\ No newline at end of file
+THE SOFTWARE.