Skip to content

Commit

Permalink
Add .NET standard support
Browse files Browse the repository at this point in the history
- Upgrade to NUnit v3
- Rewrite http transport using HttpClient
- Add projects targeting .NET STandard
- Update the build scripts and .nuspec files
  • Loading branch information
jeremymeng committed Aug 20, 2016
1 parent 94be093 commit c3431f3
Show file tree
Hide file tree
Showing 32 changed files with 463 additions and 144 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ source/Loggly.Example/loggly.user.config
SolutionItems/Thumbs.db
*.nupkg
_output/
.vs/
*.lock.json
2 changes: 1 addition & 1 deletion SolutionItems/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#endif

[assembly: AllowPartiallyTrustedCallers]
[assembly: AssemblyVersion("4.5.1.0")]
[assembly: AssemblyVersion("4.6.1.0")]
[assembly: AssemblyProduct("loggly-csharp")]
[assembly: InternalsVisibleTo("Loggly.Tests")]

20 changes: 16 additions & 4 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ function nugetPack{
$env:PackageVersion = "1.0.0.0"
}

nuget pack $rootFolder\Source\Loggly\Loggly.csproj -o $outputFolder -IncludeReferencedProjects -p Configuration=$configuration -Version $env:PackageVersion
nuget pack $rootFolder\Source\Loggly.Config\Loggly.Config.csproj -IncludeReferencedProjects -o $outputFolder -p Configuration=$configuration -Version $env:PackageVersion
nuget pack $rootFolder\Source\Loggly\Loggly.nuspec -o $outputFolder -IncludeReferencedProjects -p Configuration=$configuration -Version $env:PackageVersion
nuget pack $rootFolder\Source\Loggly.Config\Loggly.Config.nuspec -IncludeReferencedProjects -o $outputFolder -p Configuration=$configuration -Version $env:PackageVersion
}

function nugetPublish{
Expand All @@ -67,8 +67,20 @@ function buildSolution{
function executeTests{

Write-Host "Execute Tests"
$nunitConsole = "$rootFolder\packages\NUnit.Runners.2.6.3\tools\nunit-console.exe"
& $nunitConsole .\Source\Loggly.Tests\bin\$configuration\Loggly.Tests.dll

$testResultformat = ""
$nunitConsole = "$rootFolder\packages\NUnit.ConsoleRunner.3.4.1\tools\nunit3-console.exe"

if(Test-Path Env:\APPVEYOR){
$testResultformat = ";format=AppVeyor"
$nunitConsole = "nunit3-console"
}

& $nunitConsole .\Source\Loggly.Tests\bin\$configuration\Loggly.Tests.dll --result=.\Source\Loggly.Tests\bin\$configuration\nunit-results.xml$testResultformat

checkExitCode

dotnet test .\Source\NetStandard\Loggly.Tests\project.json -c $configuration --result=.\Source\NetStandard\Loggly.Tests\bin\$configuration\nunit-netstandard-results.xml

checkExitCode
}
Expand Down
2 changes: 1 addition & 1 deletion common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ param(
function _DownloadNuget{
param([Parameter(Mandatory=$true,Position=0)]$rootPath)

$sourceNugetExe = "http://nuget.org/nuget.exe"
$sourceNugetExe = "https://dist.nuget.org/win-x86-commandline/v3.5.0-rc1/NuGet.exe"
$targetNugetExe = "$rootPath\nuget.exe"

if(!(Test-Path $targetNugetExe )){
Expand Down
28 changes: 27 additions & 1 deletion loggly.sln
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionItems", "{5B1BDA21-CAE4-4686-B45B-1087AA9A36F4}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
package.cmd = package.cmd
readme.md = readme.md
EndProjectSection
Expand All @@ -24,6 +25,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{C06638
.nuget\NuGet.targets = .nuget\NuGet.targets
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NetStandard", "NetStandard", "{FF964C86-C884-453C-ACE4-41A5ACBBF2C7}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Loggly.NetStandard", "source\NetStandard\Loggly\Loggly.NetStandard.xproj", "{9E9052E5-A217-477D-8A1A-010AA7A588AF}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Loggly.Config.NetStandard", "source\NetStandard\Loggly.Config\Loggly.Config.NetStandard.xproj", "{FC9EC8AD-F2C3-4FFD-916C-2A3639DB9AE4}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Loggly.Tests.NetStandard", "source\NetStandard\Loggly.Tests\Loggly.Tests.NetStandard.xproj", "{909515FA-7AFD-4E77-907F-8E776784DF1C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -45,8 +54,25 @@ Global
{F66349BA-29A6-4336-BA81-993170FC9963}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F66349BA-29A6-4336-BA81-993170FC9963}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F66349BA-29A6-4336-BA81-993170FC9963}.Release|Any CPU.Build.0 = Release|Any CPU
{9E9052E5-A217-477D-8A1A-010AA7A588AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9E9052E5-A217-477D-8A1A-010AA7A588AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9E9052E5-A217-477D-8A1A-010AA7A588AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9E9052E5-A217-477D-8A1A-010AA7A588AF}.Release|Any CPU.Build.0 = Release|Any CPU
{FC9EC8AD-F2C3-4FFD-916C-2A3639DB9AE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FC9EC8AD-F2C3-4FFD-916C-2A3639DB9AE4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FC9EC8AD-F2C3-4FFD-916C-2A3639DB9AE4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FC9EC8AD-F2C3-4FFD-916C-2A3639DB9AE4}.Release|Any CPU.Build.0 = Release|Any CPU
{909515FA-7AFD-4E77-907F-8E776784DF1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{909515FA-7AFD-4E77-907F-8E776784DF1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{909515FA-7AFD-4E77-907F-8E776784DF1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{909515FA-7AFD-4E77-907F-8E776784DF1C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{9E9052E5-A217-477D-8A1A-010AA7A588AF} = {FF964C86-C884-453C-ACE4-41A5ACBBF2C7}
{FC9EC8AD-F2C3-4FFD-916C-2A3639DB9AE4} = {FF964C86-C884-453C-ACE4-41A5ACBBF2C7}
{909515FA-7AFD-4E77-907F-8E776784DF1C} = {FF964C86-C884-453C-ACE4-41A5ACBBF2C7}
EndGlobalSection
EndGlobal
4 changes: 3 additions & 1 deletion source/Loggly.Config/AppConfigPartials/LogglyConfig.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if FEATURE_SYSTEM_CONFIGURATION
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand All @@ -23,3 +24,4 @@ public bool HasSearchConfig
}
}
}
#endif
4 changes: 3 additions & 1 deletion source/Loggly.Config/ApplicationNameProvider.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if FEATURE_SYSTEM_CONFIGURATION
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
Expand Down Expand Up @@ -36,3 +37,4 @@ public string GetName()
}
}
}
#endif
5 changes: 3 additions & 2 deletions source/Loggly.Config/Loggly.Config.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DefineConstants>TRACE;DEBUG;FEATURE_SYSTEM_CONFIGURATION FEATURE_SYSTEM_ENVIRONMENT_OSVERSION</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
Expand All @@ -28,7 +28,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<DefineConstants>TRACE;FEATURE_SYSTEM_CONFIGURATION FEATURE_SYSTEM_ENVIRONMENT_OSVERSION</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
Expand Down Expand Up @@ -77,6 +77,7 @@
<None Include="ConfigurationSection.csd">
<Generator>CsdFileGenerator</Generator>
<LastGenOutput>ConfigurationSection1.csd.cs</LastGenOutput>
<SubType>Designer</SubType>
</None>
<None Include="ConfigurationSection.csd.config">
<DependentUpon>ConfigurationSection.csd</DependentUpon>
Expand Down
22 changes: 18 additions & 4 deletions source/Loggly.Config/Loggly.Config.nuspec
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>loggly-csharp-config</id>
<id>loggly-csharp-config-netcore</id>
<title>loggly-csharp-config</title>
<version>$version$</version>
<authors>neutmute</authors>
<projectUrl>https://github.com/neutmute/loggly-csharp</projectUrl>
<iconUrl>https://raw.githubusercontent.com/neutmute/loggly-csharp/master/SolutionItems/loggly-config.png</iconUrl>
<description>$description$</description>
<description>Configuration classes for loggly clients. Settings are read from app.config or can be programmatically injected at runtime. See readme.md for documentation</description>
<language>en-US</language>
<tags>loggly</tags>
<dependencies>
<group targetFramework="net45" />
<group targetFramework=".NETStandard1.5">
<dependency id="System.Collections" version="4.0.11" />
<dependency id="System.Diagnostics.Tools" version="4.0.1" />
<dependency id="System.Linq" version="4.1.0" />
<dependency id="System.Runtime.Extensions" version="4.1.0" />
<dependency id="System.Text.RegularExpressions" version="4.1.0" />
<dependency id="System.Threading.Tasks" version="4.0.11" />
</group>
</dependencies>
</metadata>
<files>
<file src="bin\release\Loggly.Config.pdb" target="lib\net45\" />
</files>
<file src="bin\$configuration$\Loggly.Config.dll" target="lib\net45\" />
<file src="bin\$configuration$\Loggly.Config.pdb" target="lib\net45\" />
<file src="..\NetStandard\Loggly.Config\bin\$configuration$\netstandard1.5\Loggly.Config.dll" target="lib\netstandard1.5" />
<file src="..\NetStandard\Loggly.Config\bin\$configuration$\netstandard1.5\Loggly.Config.pdb" target="lib\netstandard1.5" />
</files>
</package>
16 changes: 8 additions & 8 deletions source/Loggly.Config/LogglyConfig.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;
#if FEATURE_SYSTEM_CONFIGURATION
using System.Configuration;
#endif
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Net;

namespace Loggly.Config
{
Expand Down Expand Up @@ -37,14 +35,14 @@ public static ILogglyConfig Instance
{
if (_instance == null)
{
#if FEATURE_SYSTEM_CONFIGURATION
if (LogglyAppConfig.HasAppCopnfig)
{
_instance = FromAppConfig();
return _instance;
}
else
{
_instance = GetNullConfig();
}
#endif
_instance = GetNullConfig();
}
return _instance;
}
Expand All @@ -56,6 +54,7 @@ private static ILogglyConfig GetNullConfig()
return new LogglyConfig();
}

#if FEATURE_SYSTEM_CONFIGURATION
private static ILogglyConfig FromAppConfig()
{
var config = new LogglyConfig();
Expand All @@ -77,5 +76,6 @@ private static ILogglyConfig FromAppConfig()

return config;
}
#endif
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if FEATURE_SYSTEM_ENVIRONMENT_OSVERSION
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand All @@ -13,3 +14,4 @@ public override string InputValue
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if FEATURE_SYSTEM_ENVIRONMENT_OSVERSION
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand All @@ -13,3 +14,4 @@ public override string InputValue
}
}
}
#endif
36 changes: 34 additions & 2 deletions source/Loggly.Tests/Loggly.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,40 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Mono.Cecil, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnit3TestAdapter.3.4.1\lib\Mono.Cecil.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Mono.Cecil.Mdb, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnit3TestAdapter.3.4.1\lib\Mono.Cecil.Mdb.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Mono.Cecil.Pdb, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnit3TestAdapter.3.4.1\lib\Mono.Cecil.Pdb.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Mono.Cecil.Rocks, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnit3TestAdapter.3.4.1\lib\Mono.Cecil.Rocks.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Moq">
<HintPath>..\..\packages\Moq.4.2.1409.1722\lib\net40\Moq.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
<Reference Include="nunit.engine, Version=3.4.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnit3TestAdapter.3.4.1\lib\nunit.engine.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="nunit.engine.api, Version=3.0.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnit3TestAdapter.3.4.1\lib\nunit.engine.api.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="nunit.framework, Version=3.4.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnit.3.4.1\lib\net45\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NUnit3.TestAdapter, Version=3.4.1.0, Culture=neutral, PublicKeyToken=4cb40d35494691ac, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnit3TestAdapter.3.4.1\lib\NUnit3.TestAdapter.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down Expand Up @@ -69,6 +98,9 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public void ToSyslog()
// Make this work outside of my timezone
var syslogForm = date.ToSyslog();
Assert.AreEqual(32, syslogForm.Length);
Assert.That(syslogForm.StartsWith("2013-10-11T22:14:15.003000+"));
Assert.That(syslogForm.EndsWith(":00"));
Assert.That(syslogForm.StartsWith("2013-10-11T22:14:15.003000"), "Expect syslogForm starting with \"2013-10-11T22:14:15.003000\", actual value \"{0}\"", syslogForm);
Assert.That(syslogForm.EndsWith(":00"), "Expect syslogForm ending with \":00\", actual value \"{0}\"", syslogForm);

Console.WriteLine(DateTime.UtcNow.ToSyslog());
}
Expand Down
11 changes: 9 additions & 2 deletions source/Loggly.Tests/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Moq" version="4.2.1409.1722" targetFramework="net451" />
<package id="NUnit" version="2.6.3" targetFramework="net451" />
<package id="NUnit.Runners" version="2.6.3" targetFramework="net451" />
<package id="NUnit" version="3.4.1" targetFramework="net451" />
<package id="NUnit.ConsoleRunner" version="3.4.1" targetFramework="net451" />
<package id="NUnit.Extension.NUnitProjectLoader" version="3.4.1" targetFramework="net451" />
<package id="NUnit.Extension.NUnitV2Driver" version="3.4.1" targetFramework="net451" />
<package id="NUnit.Extension.NUnitV2ResultWriter" version="3.4.1" targetFramework="net451" />
<package id="NUnit.Extension.TeamCityEventListener" version="1.0.1" targetFramework="net451" />
<package id="NUnit.Extension.VSProjectLoader" version="3.4.1" targetFramework="net451" />
<package id="NUnit.Runners" version="3.4.1" targetFramework="net451" />
<package id="NUnit3TestAdapter" version="3.4.1" targetFramework="net451" />
</packages>
17 changes: 16 additions & 1 deletion source/Loggly/Loggly.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
Expand All @@ -42,6 +42,16 @@
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http.Extensions, Version=2.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Net.Http.Primitives, Version=4.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Primitives.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="System.Web" />
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -104,6 +114,11 @@
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
<Error Condition="!Exists('..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
<Error Condition="Exists('..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
Loading

0 comments on commit c3431f3

Please sign in to comment.