diff --git a/appveyor.yml b/appveyor.yml
index 81ad853de..cc128af4a 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -35,16 +35,10 @@ before_build:
- ps: $NTP = Start-Process node ntp.js -PassThru
- dotnet restore -v Minimal
- cmd: mkdir tools
-- cmd: nuget install coveralls.net -Version 0.7.0 -OutputDirectory tools
build_script:
- msbuild /p:Configuration=Release /verbosity:quiet
test_script:
-- dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude=[NUnit3.TestAdapter]* test/Swan.Test/Swan.Test.csproj -c Release
-- ps: |
- if(-Not $env:APPVEYOR_PULL_REQUEST_TITLE -And $isWindows)
- {
- tools\coveralls.net.0.7.0\tools\csmacnz.Coveralls.exe --opencover -i test\Swan.Test\coverage.opencover.xml --serviceName appveyor --jobId $Env:APPVEYOR_BUILD_NUMBER
- }
+- dotnet test test/Swan.Test/Swan.Test.csproj -c Release
after_build:
- ps: |
if(-Not $env:APPVEYOR_PULL_REQUEST_TITLE -And $isWindows -And $env:APPVEYOR_REPO_BRANCH -eq "master")
diff --git a/src/Swan.Lite/Collections/IComponentCollection`1.cs b/src/Swan.Lite/Collections/IComponentCollection`1.cs
index a18c7340f..7edfdc2bd 100644
--- a/src/Swan.Lite/Collections/IComponentCollection`1.cs
+++ b/src/Swan.Lite/Collections/IComponentCollection`1.cs
@@ -8,6 +8,7 @@ namespace Swan.Collections
/// Each component in the collection may be given a unique name for later retrieval.
///
/// The type of components in the collection.
+ [Obsolete("This interface will be removed in the next major version")]
public interface IComponentCollection : IReadOnlyList
{
///
diff --git a/src/Swan.Lite/Extensions.ByteArrays.cs b/src/Swan.Lite/Extensions.ByteArrays.cs
index 3888912c4..bd025ce38 100644
--- a/src/Swan.Lite/Extensions.ByteArrays.cs
+++ b/src/Swan.Lite/Extensions.ByteArrays.cs
@@ -125,7 +125,7 @@ public static byte SetBitValueAt(this byte @this, byte offset, byte length, byte
///
/// A byte array containing the results the specified sequence of bytes.
///
- ///
+ ///
/// buffer
/// or
/// sequence.
@@ -172,7 +172,7 @@ public static List Split(this byte[] @this, int offset, params byte[] se
///
/// A byte array containing the results of encoding the specified set of characters.
///
- /// this
+ /// this
public static byte[] DeepClone(this byte[] @this)
{
if (@this == null)
@@ -398,14 +398,17 @@ public static MemoryStream Append(this MemoryStream stream, IEnumerable
///
/// The buffer.
/// The encoding.
- /// A that contains the results of decoding the specified sequence of bytes.
- public static string ToText(this IEnumerable buffer, Encoding encoding) => encoding.GetString(buffer.ToArray());
+ /// A that contains the results of decoding the specified sequence of bytes.
+ public static string ToText(this IEnumerable buffer, Encoding encoding) =>
+ encoding == null
+ ? throw new ArgumentNullException(nameof(encoding))
+ : encoding.GetString(buffer.ToArray());
///
/// Converts an array of bytes into text with UTF8 encoding.
///
/// The buffer.
- /// A that contains the results of decoding the specified sequence of bytes.
+ /// A that contains the results of decoding the specified sequence of bytes.
public static string ToText(this IEnumerable buffer) => buffer.ToText(Encoding.UTF8);
///
@@ -424,31 +427,32 @@ public static async Task ReadBytesAsync(this Stream stream, long length,
if (stream == null)
throw new ArgumentNullException(nameof(stream));
- using (var dest = new MemoryStream())
+ using var dest = new MemoryStream();
+
+ try
{
- try
- {
- var buff = new byte[bufferLength];
- while (length > 0)
- {
- if (length < bufferLength)
- bufferLength = (int)length;
-
- var nread = await stream.ReadAsync(buff, 0, bufferLength, cancellationToken).ConfigureAwait(false);
- if (nread == 0)
- break;
-
- dest.Write(buff, 0, nread);
- length -= nread;
- }
- }
- catch
+ var buff = new byte[bufferLength];
+ while (length > 0)
{
- // ignored
- }
+ if (length < bufferLength)
+ bufferLength = (int)length;
+
+ var read = await stream.ReadAsync(buff, 0, bufferLength, cancellationToken).ConfigureAwait(false);
+ if (read == 0)
+ break;
- return dest.ToArray();
+ dest.Write(buff, 0, read);
+ length -= read;
+ }
+ }
+#pragma warning disable CA1031 // Do not catch general exception types
+ catch
+#pragma warning restore CA1031 // Do not catch general exception types
+ {
+ // ignored
}
+
+ return dest.ToArray();
}
///
@@ -468,19 +472,22 @@ public static async Task ReadBytesAsync(this Stream stream, int length,
var buff = new byte[length];
var offset = 0;
+
try
{
while (length > 0)
{
- var nread = await stream.ReadAsync(buff, offset, length, cancellationToken).ConfigureAwait(false);
- if (nread == 0)
+ var read = await stream.ReadAsync(buff, offset, length, cancellationToken).ConfigureAwait(false);
+ if (read == 0)
break;
- offset += nread;
- length -= nread;
+ offset += read;
+ length -= read;
}
}
+#pragma warning disable CA1031 // Do not catch general exception types
catch
+#pragma warning restore CA1031 // Do not catch general exception types
{
// ignored
}
diff --git a/src/Swan/DependencyInjection/DependencyContainerRegistrationException.cs b/src/Swan/DependencyInjection/DependencyContainerRegistrationException.cs
index 389074493..bed99f2da 100644
--- a/src/Swan/DependencyInjection/DependencyContainerRegistrationException.cs
+++ b/src/Swan/DependencyInjection/DependencyContainerRegistrationException.cs
@@ -8,6 +8,7 @@
/// Generic Constraint Registration Exception.
///
///
+ [Serializable]
public class DependencyContainerRegistrationException : Exception
{
private const string ConvertErrorText = "Cannot convert current registration of {0} to {1}";
@@ -38,9 +39,6 @@ public DependencyContainerRegistrationException(Type type, string method, bool i
{
}
- private static string GetTypesString(IEnumerable types)
- {
- return string.Join(",", types.Select(type => type.FullName));
- }
+ private static string GetTypesString(IEnumerable types) => string.Join(",", types.Select(type => type.FullName));
}
}
\ No newline at end of file
diff --git a/test/Swan.Test/CsvWriterTest.cs b/test/Swan.Test/CsvWriterTest.cs
index 178b528ca..61bf9f768 100644
--- a/test/Swan.Test/CsvWriterTest.cs
+++ b/test/Swan.Test/CsvWriterTest.cs
@@ -79,11 +79,9 @@ public void TempFileFilled_SetStreamLengthToZero()
using (var stream = File.OpenWrite(tempFile))
{
- using (var writer = new CsvWriter(stream))
- {
- writer.WriteHeadings(data);
- writer.WriteObjects(new List