Skip to content

Commit

Permalink
Review and remove coveralls for now
Browse files Browse the repository at this point in the history
  • Loading branch information
geoperez committed Feb 6, 2020
1 parent 586d3cd commit 3524977
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 52 deletions.
8 changes: 1 addition & 7 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions src/Swan.Lite/Collections/IComponentCollection`1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace Swan.Collections
/// <para>Each component in the collection may be given a unique name for later retrieval.</para>
/// </summary>
/// <typeparam name="T">The type of components in the collection.</typeparam>
[Obsolete("This interface will be removed in the next major version")]
public interface IComponentCollection<T> : IReadOnlyList<T>
{
/// <summary>
Expand Down
67 changes: 37 additions & 30 deletions src/Swan.Lite/Extensions.ByteArrays.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public static byte SetBitValueAt(this byte @this, byte offset, byte length, byte
/// <returns>
/// A byte array containing the results the specified sequence of bytes.
/// </returns>
/// <exception cref="System.ArgumentNullException">
/// <exception cref="ArgumentNullException">
/// buffer
/// or
/// sequence.
Expand Down Expand Up @@ -172,7 +172,7 @@ public static List<byte[]> Split(this byte[] @this, int offset, params byte[] se
/// <returns>
/// A byte array containing the results of encoding the specified set of characters.
/// </returns>
/// <exception cref="System.ArgumentNullException">this</exception>
/// <exception cref="ArgumentNullException">this</exception>
public static byte[] DeepClone(this byte[] @this)
{
if (@this == null)
Expand Down Expand Up @@ -398,14 +398,17 @@ public static MemoryStream Append(this MemoryStream stream, IEnumerable<byte[]>
/// </summary>
/// <param name="buffer">The buffer.</param>
/// <param name="encoding">The encoding.</param>
/// <returns>A <see cref="System.String" /> that contains the results of decoding the specified sequence of bytes.</returns>
public static string ToText(this IEnumerable<byte> buffer, Encoding encoding) => encoding.GetString(buffer.ToArray());
/// <returns>A <see cref="string" /> that contains the results of decoding the specified sequence of bytes.</returns>
public static string ToText(this IEnumerable<byte> buffer, Encoding encoding) =>
encoding == null
? throw new ArgumentNullException(nameof(encoding))
: encoding.GetString(buffer.ToArray());

/// <summary>
/// Converts an array of bytes into text with UTF8 encoding.
/// </summary>
/// <param name="buffer">The buffer.</param>
/// <returns>A <see cref="System.String" /> that contains the results of decoding the specified sequence of bytes.</returns>
/// <returns>A <see cref="string" /> that contains the results of decoding the specified sequence of bytes.</returns>
public static string ToText(this IEnumerable<byte> buffer) => buffer.ToText(Encoding.UTF8);

/// <summary>
Expand All @@ -424,31 +427,32 @@ public static async Task<byte[]> 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();
}

/// <summary>
Expand All @@ -468,19 +472,22 @@ public static async Task<byte[]> 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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
/// Generic Constraint Registration Exception.
/// </summary>
/// <seealso cref="Exception" />
[Serializable]
public class DependencyContainerRegistrationException : Exception
{
private const string ConvertErrorText = "Cannot convert current registration of {0} to {1}";
Expand Down Expand Up @@ -38,9 +39,6 @@ public DependencyContainerRegistrationException(Type type, string method, bool i
{
}

private static string GetTypesString(IEnumerable<Type> types)
{
return string.Join(",", types.Select(type => type.FullName));
}
private static string GetTypesString(IEnumerable<Type> types) => string.Join(",", types.Select(type => type.FullName));
}
}
19 changes: 8 additions & 11 deletions test/Swan.Test/CsvWriterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<object> { data.Select(k => k.Key) });
}
using var writer = new CsvWriter(stream);
writer.WriteHeadings(data);
writer.WriteObjects(new List<object> { data.Select(k => k.Key) });
}

var valuesInFile = CsvReader.LoadRecords<object>(tempFile);
Expand Down Expand Up @@ -145,7 +143,7 @@ public void Strings_ReturnsAreEqual()
using var writer = new CsvWriter(stream);
writer.WriteObjects(strings);

Assert.AreEqual((int) writer.Count, strings.Count);
Assert.AreEqual((int)writer.Count, strings.Count);
}

[Test]
Expand All @@ -159,7 +157,7 @@ public void DynamicObject_ReturnsAreEqual()
writer.WriteObject(dynObject);

Assert.IsNotNull(writer);
Assert.AreEqual(1, (int) writer.Count);
Assert.AreEqual(1, (int)writer.Count);
}
}

Expand All @@ -181,7 +179,7 @@ public void NullDictionary_ThrowsArgumentNullException()
using var stream = new MemoryStream();
using var writer = new CsvWriter(stream);

Assert.Throws<ArgumentNullException>(() =>
Assert.Throws<ArgumentNullException>(() =>
writer.WriteHeadings(null as Dictionary<string, string>));
}

Expand Down Expand Up @@ -245,7 +243,7 @@ public void WritingHeadersFromSampleClass_WritesHeaders()
}

[Test]
public void WriteHeadingNull ()
public void WriteHeadingNull()
{
using var stream = new MemoryStream();
using var writer = new CsvWriter(stream);
Expand Down Expand Up @@ -295,9 +293,8 @@ public void ChangeSeparator()
var objHeaders = new SampleCsvRecord();

using var stream = new MemoryStream();
using var writer = new CsvWriter(stream);
using var writer = new CsvWriter(stream) {SeparatorCharacter = '#'};

writer.SeparatorCharacter = '#';
writer.WriteHeadings(objHeaders);

stream.Position = 0;
Expand Down

0 comments on commit 3524977

Please sign in to comment.