Skip to content

Commit

Permalink
Merge branch 'release/0.61.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jericho committed Sep 21, 2019
2 parents eefcea1 + d187a16 commit 67064f0
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 41 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ using StrongGrid;

## .NET framework suport

StrongGrid supports the `4.5.2` .NET framework as well as `.Net Core`.
StrongGrid supports the `4.6.1` .NET framework as well as `.NET Core`.


## Usage
Expand Down
3 changes: 1 addition & 2 deletions Source/StrongGrid.UnitTests/StrongGrid.UnitTests.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net461;net472;netcoreapp2.0</TargetFrameworks>
Expand All @@ -16,7 +16,6 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>

<ItemGroup>
Expand Down
26 changes: 4 additions & 22 deletions Source/StrongGrid/Models/Attachment.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using HeyRed.Mime;
using Newtonsoft.Json;
using System;
using System.Buffers;
using System.IO;
using System.Security.Cryptography;
using System.Text;

namespace StrongGrid.Models
Expand Down Expand Up @@ -100,29 +100,11 @@ public static Attachment FromStream(Stream contentStream, string fileName, strin
if (contentStream == null) throw new ArgumentNullException(nameof(contentStream));
if (!contentStream.CanRead) throw new ArgumentException("The content stream is not readable", nameof(contentStream));

var content = new StringBuilder();
byte[] buffer = ArrayPool<byte>.Shared.Rent(BUFFER_SIZE);
try
using (var base64ContentStream = new CryptoStream(contentStream, new ToBase64Transform(), CryptoStreamMode.Read))
using (var reader = new StreamReader(base64ContentStream))
{
var bytesRead = contentStream.Read(buffer, 0, BUFFER_SIZE);
while (bytesRead > 0)
{
content.Append(Convert.ToBase64String(buffer, 0, bytesRead));
if (content.Length > MAX_ATTACHMENT_SIZE) throw new Exception("Content exceeds the size limit");

bytesRead = contentStream.Read(buffer, 0, BUFFER_SIZE);
}
return FromBase64String(reader.ReadToEnd(), fileName, mimeType, contentId);
}
catch (Exception)
{
throw;
}
finally
{
ArrayPool<byte>.Shared.Return(buffer);
}

return FromBase64String(content.ToString(), fileName, mimeType, contentId);
}

/// <summary>
Expand Down
68 changes: 52 additions & 16 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
#addin nuget:?package=Cake.Coveralls&version=0.9.0

// Install tools.
#tool nuget:?package=GitVersion.CommandLine&version=4.0.0
#tool nuget:?package=GitVersion.CommandLine&version=5.0.1
#tool nuget:?package=GitReleaseManager&version=0.8.0
#tool nuget:?package=OpenCover&version=4.7.922
#tool nuget:?package=ReportGenerator&version=4.2.5
#tool nuget:?package=ReportGenerator&version=4.2.20
#tool nuget:?package=coveralls.io&version=1.4.2
#tool nuget:?package=xunit.runner.console&version=2.4.1

Expand Down Expand Up @@ -35,6 +35,7 @@ var nuGetApiKey = EnvironmentVariable("NUGET_API_KEY");
var myGetApiUrl = EnvironmentVariable("MYGET_API_URL");
var myGetApiKey = EnvironmentVariable("MYGET_API_KEY");

var gitHubToken = EnvironmentVariable("GITHUB_TOKEN");
var gitHubUserName = EnvironmentVariable("GITHUB_USERNAME");
var gitHubPassword = EnvironmentVariable("GITHUB_PASSWORD");

Expand Down Expand Up @@ -95,11 +96,22 @@ Setup(context =>
string.IsNullOrEmpty(nuGetApiKey) ? "[NULL]" : new string('*', nuGetApiKey.Length)
);

Information("GitHub Info:\r\n\tRepo: {0}\r\n\tUserName: {1}\r\n\tPassword: {2}",
gitHubRepo,
gitHubUserName,
string.IsNullOrEmpty(gitHubPassword) ? "[NULL]" : new string('*', gitHubPassword.Length)
);
if (!string.IsNullOrEmpty(gitHubToken))
{
Information("GitHub Info:\r\n\tRepo: {0}\r\n\tUserName: {1}\r\n\tToken: {2}",
gitHubRepo,
gitHubUserName,
new string('*', gitHubToken.Length)
);
}
else
{
Information("GitHub Info:\r\n\tRepo: {0}\r\n\tUserName: {1}\r\n\tPassword: {2}",
gitHubRepo,
gitHubUserName,
string.IsNullOrEmpty(gitHubPassword) ? "[NULL]" : new string('*', gitHubPassword.Length)
);
}
});

Teardown(context =>
Expand Down Expand Up @@ -149,7 +161,6 @@ Task("Restore-NuGet-Packages")
DotNetCoreRestore("./Source/", new DotNetCoreRestoreSettings
{
Sources = new [] {
"https://www.myget.org/F/xunit/api/v3/index.json",
"https://api.nuget.org/v3/index.json",
}
});
Expand Down Expand Up @@ -302,15 +313,25 @@ Task("Publish-MyGet")
Task("Create-Release-Notes")
.Does(() =>
{
if(string.IsNullOrEmpty(gitHubUserName)) throw new InvalidOperationException("Could not resolve GitHub user name.");
if(string.IsNullOrEmpty(gitHubPassword)) throw new InvalidOperationException("Could not resolve GitHub password.");

GitReleaseManagerCreate(gitHubUserName, gitHubPassword, gitHubUserName, gitHubRepo, new GitReleaseManagerCreateSettings {
var settings = new GitReleaseManagerCreateSettings
{
Name = milestone,
Milestone = milestone,
Prerelease = false,
TargetCommitish = "master"
});
};

if (!string.IsNullOrEmpty(gitHubToken))
{
GitReleaseManagerCreate(gitHubUserName, gitHubToken, gitHubRepo, settings);
}
else
{
if(string.IsNullOrEmpty(gitHubUserName)) throw new InvalidOperationException("Could not resolve GitHub user name.");
if(string.IsNullOrEmpty(gitHubPassword)) throw new InvalidOperationException("Could not resolve GitHub password.");

GitReleaseManagerCreate(gitHubUserName, gitHubPassword, gitHubUserName, gitHubRepo, settings);
}
});

Task("Publish-GitHub-Release")
Expand All @@ -321,10 +342,25 @@ Task("Publish-GitHub-Release")
.WithCriteria(() => isTagged)
.Does(() =>
{
if(string.IsNullOrEmpty(gitHubUserName)) throw new InvalidOperationException("Could not resolve GitHub user name.");
if(string.IsNullOrEmpty(gitHubPassword)) throw new InvalidOperationException("Could not resolve GitHub password.");
var settings = new GitReleaseManagerCreateSettings
{
Name = milestone,
Milestone = milestone,
Prerelease = false,
TargetCommitish = "master"
};

GitReleaseManagerClose(gitHubUserName, gitHubPassword, gitHubUserName, gitHubRepo, milestone);
if (!string.IsNullOrEmpty(gitHubToken))
{
GitReleaseManagerClose(gitHubToken, gitHubUserName, gitHubRepo, milestone);
}
else
{
if(string.IsNullOrEmpty(gitHubUserName)) throw new InvalidOperationException("Could not resolve GitHub user name.");
if(string.IsNullOrEmpty(gitHubPassword)) throw new InvalidOperationException("Could not resolve GitHub password.");

GitReleaseManagerClose(gitHubUserName, gitHubPassword, gitHubUserName, gitHubRepo, milestone);
}
});


Expand Down

0 comments on commit 67064f0

Please sign in to comment.