Skip to content

Commit

Permalink
Merge pull request #6 from martinsmith1968/feature/consolidation-befo…
Browse files Browse the repository at this point in the history
…re-netstandard

Feature/consolidation before netstandard
  • Loading branch information
martinsmith1968 authored Dec 27, 2019
2 parents b28141e + afe4348 commit 5000eb0
Show file tree
Hide file tree
Showing 15 changed files with 143 additions and 31 deletions.
20 changes: 14 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
# https://stackoverflow.com/questions/41509608/how-do-i-deploy-nuget-packages-in-travis-ci
# https://docs.travis-ci.com/user/languages/csharp/

env:
APPNAME=DNX.Helpers
CONFIGURATION=Release
NUGET_API_URL=https://www.nuget.org/api/v2/package
NUNIT_RUNNERS_VERSION=3.10.0

language: csharp

solution: $APPNAME.sln

install:
- nuget restore $APPNAME.sln
- nuget install NUnit.Runners -Version 3.8.0 -OutputDirectory testrunner
# - nuget install DNX.NuSpec.Updater -OutputDirectory nuspecupdater
- nuget install NUnit.Runners -Version $NUNIT_RUNNERS_VERSION -OutputDirectory testrunner

script:
- xbuild /p:Configuration=$CONFIGURATION $APPNAME.sln
- mono ./testrunner/NUnit.ConsoleRunner.3.8.0/tools/nunit3-console.exe ./Test.$APPNAME/bin/$CONFIGURATION/Test.$APPNAME.dll
# - xbuild /p:Configuration=$CONFIGURATION $APPNAME.sln
- msbuild /p:Configuration=$CONFIGURATION $APPNAME.sln
- mono ./testrunner/NUnit.ConsoleRunner.$NUNIT_RUNNERS_VERSION/tools/nunit3-console.exe ./Test.$APPNAME/bin/$CONFIGURATION/Test.$APPNAME.dll
- ls -laR ./$APPNAME
# - nuget pack $APPNAME/$APPNAME.csproj -Verbosity detailed -BasePath $APPNAME -Properties Configuration=$CONFIGURATION
- nuget pack ./$APPNAME/$APPNAME.nuspec -Verbosity detailed
# https://stackoverflow.com/questions/14797525/differences-between-nuget-packing-a-csproj-vs-nuspec
- nuget pack ./$APPNAME/$APPNAME.csproj -Verbosity detailed

deploy:
skip_cleanup: true
provider: script
Expand Down
6 changes: 6 additions & 0 deletions DNX.Helpers.sln
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".commands", ".commands", "{FB47A44B-A670-480D-8B11-6D02072596D4}"
ProjectSection(SolutionItems) = preProject
commands.json = commands.json
deploy.sh = deploy.sh
GenerateMarkdown.cmd = GenerateMarkdown.cmd
NuGet.Pack.cmd = NuGet.Pack.cmd
NuGet.Push.cmd = NuGet.Push.cmd
Expand Down Expand Up @@ -62,6 +63,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".build", ".build", "{BDB7BF
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Images", "Images", "{ED58C975-9E2F-4720-9634-62BE33EB58B3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".images", ".images", "{E2FA5B06-E65B-4D0E-86EC-6E9F2EC82A5A}"
ProjectSection(SolutionItems) = preProject
images\favicon-32x32.png = images\favicon-32x32.png
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
19 changes: 11 additions & 8 deletions DNX.Helpers/DNX.Helpers.nuspec
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
<?xml version="1.0"?>
<!--
https://stackoverflow.com/questions/14797525/differences-between-nuget-packing-a-csproj-vs-nuspec
-->
<package >
<metadata>
<id>DNX.Helpers</id>
<version>1.2.1.0</version>
<version>1.2.2</version>
<authors>Martin Smith</authors>
<owners>DNX Solutions Ltd</owners>
<!--
<licenseUrl>http://LICENSE_URL_HERE_OR_DELETE_THIS_LINE</licenseUrl>
-->
<licenseUrl>https://raw.githubusercontent.com/martinsmith1968/DNX.Helpers/master/licence.txt</licenseUrl>
<projectUrl>https://github.com/martinsmith1968/DNX.Helpers</projectUrl>
<iconUrl>http://www.dnx-solutions.co.uk/favicon-32x32.png</iconUrl>
<iconUrl>https://raw.githubusercontent.com/martinsmith1968/DNX.Helpers/master/images/favicon-32x32.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>.NET Extensions and helpers for Core and Common .NET types</description>
<releaseNotes>Initial release</releaseNotes>
<copyright>Copyright 2016 DNX Solutions Ltd</copyright>
<releaseNotes>
Interpolation to a working version and some preparation for moving to .NET Standard
</releaseNotes>
<copyright>Copyright 2016 $owners$</copyright>
<tags>DNX helpers extensions string array linq</tags>
</metadata>
<files>
<file src="**/bin/**/DNX.Helpers.dll" target="lib" />
<file src="**/bin/**/$id$.dll" target="lib" />
</files>
</package>
4 changes: 2 additions & 2 deletions DNX.Helpers/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.1.*")]
[assembly: AssemblyFileVersion("1.2.1.0")]
[assembly: AssemblyVersion("1.2.2.*")]
[assembly: AssemblyFileVersion("1.2.2.0")]
2 changes: 2 additions & 0 deletions NuGet.Pack.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ CALL SetNuGetServerAPIKey.cmd "%APPNAME%"

IF EXIST *.nupkg DEL *.nupkg

@ECHO ON
"%NUGETEXE%" pack "%SCRIPTPATH%\%APPNAME%\%APPNAME%.csproj"
@ECHO OFF
2 changes: 2 additions & 0 deletions NuGet.Push.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ CALL SetNuGetServerAPIKey.cmd "%APPNAME%"

FOR %%F IN (*.nupkg) DO (
ECHO.Pushing: %%~F
@ECHO ON
%NUGETEXE% push "%%~F" -Source "%NUGETSERVERAPIURL%" -ApiKey "%NUGETSERVERAPIKEY%"
@ECHO OFF
)
2 changes: 2 additions & 0 deletions Test.DNX.Helpers/Assemblies/AssemblyDetailsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public void AssemblyDetails_created_from_current_assembly()
assemblyDetails.Version.ShouldBe(targetAssembly.GetName().Version);
assemblyDetails.FileVersion.ShouldBe(targetAssembly.GetCustomAttributes<AssemblyFileVersionAttribute>().First().Version);
assemblyDetails.InformationalVersion.ShouldBe(targetAssembly.GetCustomAttributes<AssemblyInformationalVersionAttribute>().First().InformationalVersion);
assemblyDetails.SimplifiedVersion.ShouldBe(assemblyDetails.Version.Simplify());
}

[Test]
Expand Down Expand Up @@ -63,6 +64,7 @@ public void AssemblyDetails_created_from_specific_assembly()
assemblyDetails.Version.ShouldBe(targetAssembly.GetName().Version);
assemblyDetails.FileVersion.ShouldBe(targetAssembly.GetCustomAttributes<AssemblyFileVersionAttribute>().First().Version);
assemblyDetails.InformationalVersion.ShouldBeNull();
assemblyDetails.SimplifiedVersion.ShouldBe(assemblyDetails.Version.Simplify());
}
}
}
7 changes: 6 additions & 1 deletion Test.DNX.Helpers/Assemblies/AssemblyExtensionsTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Linq;
using System.Reflection;
using DNX.Helpers.Assemblies;
using NUnit.Framework;
using Shouldly;

// ReSharper disable InconsistentNaming
Expand All @@ -24,14 +25,16 @@ public class InstanceResolutionExtensionsTests
{
public class GetTypesThatImplementInterface_ITypeA
{
[Test]
public void FindTypesThatImplementType_should_find_all_that_implement_interface()
{
// Act
var result = Assembly.GetExecutingAssembly().FindTypesThatImplementType<ITypeA>();

// Assert
result.ShouldNotBeNull();
result.Count.ShouldBe(6);
result.Count.ShouldBe(7);
result.Count(x => x == typeof(ITypeA)).ShouldBe(1);
result.Count(x => x == typeof(ITypeD)).ShouldBe(1);
result.Count(x => x == typeof(CTypeA)).ShouldBe(1);
result.Count(x => x == typeof(CTypeD)).ShouldBe(1);
Expand All @@ -40,6 +43,7 @@ public void FindTypesThatImplementType_should_find_all_that_implement_interface(
result.Count(x => x == typeof(CTypeCA)).ShouldBe(1);
}

[Test]
public void FindConcreteTypesThatImplementType_should_find_all_that_implement_interface()
{
// Act
Expand All @@ -55,6 +59,7 @@ public void FindConcreteTypesThatImplementType_should_find_all_that_implement_in
result.Count(x => x == typeof(CTypeCA)).ShouldBe(1);
}

[Test]
public void CreateInstancesOfClassesThatImplementInterface_should_create_instances_for_all_that_implement_interface()
{
// Act
Expand Down
14 changes: 14 additions & 0 deletions Test.DNX.Helpers/Assemblies/VersionExtensionsTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using DNX.Helpers.Assemblies;
using NUnit.Framework;
using Shouldly;

namespace Test.DNX.Helpers.Assemblies
{
Expand Down Expand Up @@ -41,5 +42,18 @@ public bool Simplify_GuardException_Tests(int major, int minor, int build, int r
return false;
}
}

[Test]
public void Simplify_for_null_returns_expected()
{
// Arrange
Version version = null;

// Act
var result = version.Simplify();

// Assert
result.ShouldBeNull();
}
}
}
9 changes: 3 additions & 6 deletions Test.DNX.Helpers/Dates/DateTimeExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,16 @@ public object GetFormat(Type formatType)

public string Format(string format, object arg, IFormatProvider formatProvider)
{
if (arg is DateTime)
if (arg is DateTime dt)
{
var dt = (DateTime) arg;

// if user supplied own format use it
return string.IsNullOrEmpty(format)
? dt.ToString(FormatString)
: ((DateTime)arg).ToString(format);
: dt.ToString(format);
}

// format everything else normally
var formattable = arg as IFormattable;
return formattable != null
return arg is IFormattable formattable
? formattable.ToString(format, formatProvider)
: arg.ToString();
}
Expand Down
6 changes: 3 additions & 3 deletions Test.DNX.Helpers/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.1")]
[assembly: AssemblyFileVersion("1.2.1.0")]
[assembly: AssemblyInformationalVersion("1.2.1.0")]
[assembly: AssemblyVersion("1.2.2")]
[assembly: AssemblyFileVersion("1.2.2.0")]
[assembly: AssemblyInformationalVersion("1.2.2.0")]
60 changes: 60 additions & 0 deletions Test.DNX.Helpers/Strings/Interpolation/StringInterpolatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,32 @@ public void InterpolateWithAll_Environment_SpecialFolders()
result.ShouldBe(string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.System), "\\Shell32.dll"));
}

[Test]
public void InterpolateWithAll_Environment_Folders()
{
// Arrange
var folderLocations = new Dictionary<string, string>()
{
{ nameof(Environment.SystemDirectory), Environment.SystemDirectory },
{ nameof(Environment.CurrentDirectory), Environment.CurrentDirectory },
{ $"{nameof(Environment.SpecialFolder)}.{nameof(Environment.SpecialFolder.Windows)}", Environment.GetFolderPath(Environment.SpecialFolder.Windows) },
{ $"{nameof(Environment.SpecialFolder)}.{nameof(Environment.SpecialFolder.Personal)}", Environment.GetFolderPath(Environment.SpecialFolder.Personal) }
};

var interpolationInstances = new[]
{
new NamedInstance(folderLocations, nameof(Environment)),
};

var text = "{Environment.SystemDirectory}\\Shell32.dll";

// Act
var result = text.InterpolateWithAll(interpolationInstances);

// Assert
result.ShouldBe(string.Concat(Environment.SystemDirectory, "\\Shell32.dll"));
}

[TestCase("{One}{Two}{Three}{Four}{Five}", "12345")]
public void InterpolateWithAll_Dictionary(string text, string expectedValue)
{
Expand Down Expand Up @@ -157,5 +183,39 @@ public void InterpolateWithAll_FileName_Test()
result.ShouldNotBeNull();
result.ShouldBe(string.Concat(Environment.GetFolderPath(specialFolder), "\\", myFileName));
}

[Test]
public void InterpolateWithAll_null_dictionary()
{
// Arrange
const string myFileName = "myFileName.txt";
var specialFolder = Environment.SpecialFolder.CommonProgramFiles;
var fileName = $"{{Environment.{specialFolder}}}\\{myFileName}";

IDictionary<string, object> dict = null;

// Act
var result = fileName.InterpolateWithAll(dict);

// Assert
result.ShouldBe(fileName);
}

[Test]
public void InterpolateWithAll_empty_dictionary()
{
// Arrange
const string myFileName = "myFileName.txt";
var specialFolder = Environment.SpecialFolder.CommonProgramFiles;
var fileName = $"{{Environment.{specialFolder}}}\\{myFileName}";

var dict = new Dictionary<string, object>();

// Act
var result = fileName.InterpolateWithAll(dict);

// Assert
result.ShouldBe(fileName);
}
}
}
4 changes: 0 additions & 4 deletions Test.DNX.Helpers/Strings/StringExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,6 @@ public bool Test_IsValidNumber_default_culture(string text, string cultureInfoNa

return result;
}
catch (Exception e)
{
throw;
}
finally
{
CultureInfo.DefaultThreadCurrentCulture = previousCulture;
Expand Down
1 change: 0 additions & 1 deletion deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ NUGET_API_KEY=$3

echo nuget push $APPNAME.*.nupkg -Source $NUGET_API_URL -ApiKey secret
nuget push $APPNAME.*.nupkg -Source $NUGET_API_URL -ApiKey $NUGET_API_KEY

18 changes: 18 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# DNX.Helpers

Built by [Travis CI](https://travis-ci.org/) ![Build Status](https://travis-ci.org/martinsmith1968/DNX.Helpers.svg?branch=master)

![DNX Solutions Logo](images/favicon-32x32.png)
[DNX.Helpers](http://github.com/martinsmith1968/DNX.Helpers) is a .NET package that contains the bits that I've found lacking or missing from the .NET standard library. It has minimal dependencies on other packages and so is designed to be included to your projects with little or no disruption.

Expand Down Expand Up @@ -78,3 +80,19 @@ By Martin Smith, 2001 onwards
| [DNX.Helpers.Console](http://github.com/martinsmith1968/DNX.Helpers.Console) | For working with console applications |
| [DNX.Helpers.CommandLine](http://github.com/martinsmith1968/DNX.Helpers.CommandLine) | For working with Command Line parsing |
| [DNX.Helpers.Log4Net](http://github.com/martinsmith1968/DNX.Helpers.Log4Net) | For working with Log4Net |

### Acknowledgements

With grateful thanks to all the people and organisations below, who've contributed something to either
make the development of this easier, or generally contributed to making [Visual Studio](https://visualstudio.microsoft.com/) an awesome environment:

| Title | Description |
|---|----|
| [Resharper Ultimate](https://www.jetbrains.com/resharper) | The guys at [JetBrains](https://www.jetbrains.com) make awesome tools for whatever your development language of preference. Visual Studio would not be complete without Resharper Ultimate |
| [Travis CI](https://travis-ci.org) | A cloud Continuous Integration environment that's easy to integrate with and is still as feature rich as you could need. Your builds have caught my lack of cross-platform awareness more than once |
| [GhostDoc Pro](https://submain.com/download/ghostdoc/pro/) | Good intellisense is key to almost any library and GhostDoc generates sensible documentation at the touch of a button. A community edition is also available for free |
| [BuildVision](https://github.com/StefanKert/BuildVision) | For multi-project solutions, this is the __best__ build visualizer. Can't wait for a VS 2019 version |
| [VSColorOutput](https://github.com/mike-ward/VSColorOutput) | Bring colour to your output window. Don't forget to donate... |
| [Automatic Versions](https://www.precisioninfinity.com/software-development-productivity-improvement/business-software-tools/automatic-versions-extension-for-visual-studio/) | A recent addition to my toolset, this is awesome at controlling my versioning for releases |
| [Mads Kristensen](https://marketplace.visualstudio.com/publishers/MadsKristensen) | Last but by no means least, a huge thank you to Mads at Microsoft for some brilliant time saving tools that make Visual Studio just that little bit more brilliant (E.g. [Markdown Editor](https://marketplace.visualstudio.com/items?itemName=MadsKristensen.MarkdownEditor), [Add New File](https://marketplace.visualstudio.com/items?itemName=MadsKristensen.AddNewFile), [Task Runner Explorer](https://marketplace.visualstudio.com/items?itemName=MadsKristensen.TaskRunnerExplorer) |
| [Microsoft DevLabs](https://marketplace.visualstudio.com/publishers/Microsoft%20DevLabs) | Not sure why some of these aren't part of Visual Studio from the start but kudos to Microsoft for releasing them. Some excellent productivity enhancers here (E.g. [Fix Mixed Tabs](https://marketplace.visualstudio.com/items?itemName=VisualStudioPlatformTeam.FixMixedTabs), [Align Assignments](https://marketplace.visualstudio.com/items?itemName=VisualStudioPlatformTeam.AlignAssignments) |

0 comments on commit 5000eb0

Please sign in to comment.