Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

.Net Core support and Cake build support #91

Merged
merged 8 commits into from
Apr 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,9 @@ pip-log.txt
packages
*.private
.vs/config/applicationhost.config

#.Net core
*.lock.json

# Cake
tools/
11 changes: 11 additions & 0 deletions GlobalAssemblyVersion.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by Cake.
// </auto-generated>
//------------------------------------------------------------------------------
using System.Reflection;

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0.0")]

13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[![Build status](https://ci.appveyor.com/api/projects/status/5n9e7sruxpo0mw79/branch/master?svg=true)](https://ci.appveyor.com/project/Inumedia/slackapi/branch/master)
[![NuGet](https://img.shields.io/nuget/v/SlackAPI.svg)](https://www.nuget.org/packages/SlackAPI/)
[![MyGet Pre Release](https://img.shields.io/myget/slackapi/vpre/SlackAPI.svg)](https://www.myget.org/feed/slackapi/package/nuget/SlackAPI)

# SlackAPI

Expand Down Expand Up @@ -35,8 +37,9 @@ The project **SlackAPI.Tests** requires a valid `config.json` file for tests. Yo
- *directMessageUser* : A Slack member username
- *clientId*/*clientSecret*/*authCode* : Not used

# Creating NuGet package

Example:

```nuget pack SlackAPI.nuspec -version 1.2.3```
# NuGet package
SlackAPI NuGet package is build with following platforms support:
- .NET Framework 4.5 (support .NET Framework 4.5 and 4.5.1)
- .NET Standard 1.6 (support .NET Framework 4.6 and later)
- .NET Standard 1.3 (support UWP).
- The version cannot detect SlackSocketRouting attributes in loaded assemblies (used to extend SlackAPI to handle custom messages).
13 changes: 0 additions & 13 deletions SlackAPI.Console/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,3 @@

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("523b8aa3-1079-44e3-9dd3-70066a09684b")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// 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.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
3 changes: 3 additions & 0 deletions SlackAPI.Console/SlackAPI.Console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\GlobalAssemblyVersion.cs">
<Link>Properties\GlobalAssemblyVersion.cs</Link>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
Expand Down
28 changes: 28 additions & 0 deletions SlackAPI.NetCore.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26228.4
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SlackAPI.NetCore", "SlackAPI\SlackAPI.NetCore.csproj", "{7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SlackAPI.Tests.NetCore", "SlackAPI.Tests\SlackAPI.Tests.NetCore.csproj", "{DEFA9559-0F8F-4C38-9644-67A080EDC46D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}.Release|Any CPU.Build.0 = Release|Any CPU
{DEFA9559-0F8F-4C38-9644-67A080EDC46D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DEFA9559-0F8F-4C38-9644-67A080EDC46D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DEFA9559-0F8F-4C38-9644-67A080EDC46D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DEFA9559-0F8F-4C38-9644-67A080EDC46D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
5 changes: 4 additions & 1 deletion SlackAPI.Tests/Configuration/IntegrationFixture.cs
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Reflection;
using Newtonsoft.Json;
using SlackAPI.Tests.Helpers;
using Xunit;
Expand Down Expand Up @@ -29,7 +30,9 @@ public void Dispose()

private SlackConfig GetConfig()
{
string fileName = Path.Combine(Environment.CurrentDirectory, @"configuration\config.json");
var currentAssembly = this.GetType().GetTypeInfo().Assembly.Location;
var assemblyDirectory = Path.GetDirectoryName(currentAssembly);
string fileName = Path.Combine(assemblyDirectory, @"configuration\config.json");
string json = System.IO.File.ReadAllText(fileName);

var jsonObject = new {slack = (SlackConfig)null };
Expand Down
2 changes: 1 addition & 1 deletion SlackAPI.Tests/JoinDirectMessageChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void ShouldJoinDirectMessageChannel()
JoinDirectMessageChannelResponse actual = null;

string userName = this.fixture.Config.DirectMessageUser;
string user = client.Users.First(x => x.name.Equals(userName, StringComparison.InvariantCultureIgnoreCase)).id;
string user = client.Users.First(x => x.name.Equals(userName, StringComparison.OrdinalIgnoreCase)).id;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this changed to Ordinal instead of Invariant?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invariant is not supported in .NetCore. And according to this issue, InvariantCultureIgnoreCase usage is often to what we want


// when
using (var sync = new InSync(nameof(SlackClient.JoinDirectMessageChannel)))
Expand Down
13 changes: 0 additions & 13 deletions SlackAPI.Tests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,3 @@

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("c254f6ff-81d4-46df-aa21-3d1a6456253b")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// 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.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
36 changes: 36 additions & 0 deletions SlackAPI.Tests/SlackAPI.Tests.NetCore.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup>
<TargetFrameworks>net452;netcoreapp1.0</TargetFrameworks>
<AssemblyName>SlackAPI.Tests</AssemblyName>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
<PackageReference Include="Microsoft.NETCore.Platforms" Version="1.1.0" />
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SlackAPI\SlackAPI.NetCore.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="Configuration\config.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
</PropertyGroup>
</Project>
3 changes: 3 additions & 0 deletions SlackAPI.Tests/SlackAPI.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\GlobalAssemblyVersion.cs">
<Link>Properties\GlobalAssemblyVersion.cs</Link>
</Compile>
<Compile Include="Configuration\IntegrationCollection.cs" />
<Compile Include="Configuration\IntegrationFixture.cs" />
<Compile Include="Configuration\SlackConfig.cs" />
Expand Down
3 changes: 3 additions & 0 deletions SlackAPI.Tests/app.config
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@
</dependentAssembly>
</assemblyBinding>
</runtime>
<appSettings>
<add key="xunit.shadowCopy" value="false"/>
</appSettings>
</configuration>
25 changes: 0 additions & 25 deletions SlackAPI.nuspec

This file was deleted.

8 changes: 3 additions & 5 deletions SlackAPI/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;

namespace SlackAPI
Expand All @@ -27,18 +26,17 @@ public static string ToProperTimeStamp(this DateTime that, bool toUTC = true)
public static K Deserialize<K>(this string data)
where K : class
{
return JsonConvert.DeserializeObject<K>(data, CreateSettings(data));
return JsonConvert.DeserializeObject<K>(data, CreateSettings());
}

public static object Deserialize(this string data, Type type)
{
return JsonConvert.DeserializeObject(data, type, CreateSettings(data));
return JsonConvert.DeserializeObject(data, type, CreateSettings());
}

private static JsonSerializerSettings CreateSettings(object contextData)
private static JsonSerializerSettings CreateSettings()
{
JsonSerializerSettings settings = new JsonSerializerSettings();
settings.Context = new StreamingContext(StreamingContextStates.Other, contextData);
settings.Converters = Converters;

return settings;
Expand Down
15 changes: 1 addition & 14 deletions SlackAPI/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,4 @@
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("80fe3ab4-f0d5-4fee-a6ae-524b523cebcc")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// 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.0.4.1")]
[assembly: AssemblyFileVersion("1.0.4.1")]

[assembly: InternalsVisibleTo("SlackAPI.Tests")]
[assembly: InternalsVisibleTo("SlackAPI.Tests")]
49 changes: 49 additions & 0 deletions SlackAPI/SlackAPI.NetCore.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup>
<Description>A Slack wrapper for direct interaction with their APIs.</Description>
<Copyright>Inumedia - Copyright © 2014</Copyright>
<AssemblyTitle>SlackAPI</AssemblyTitle>
<NeutralLanguage>en-US</NeutralLanguage>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
<Authors>Inumedia</Authors>
<TargetFrameworks>net45;netstandard1.6;netstandard1.3</TargetFrameworks>
<AssemblyName>SlackAPI</AssemblyName>
<PackageProjectUrl>https://github.com/Inumedia/SlackAPI</PackageProjectUrl>
<PackageLicenseUrl>http://choosealicense.com/licenses/mit/</PackageLicenseUrl>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/Inumedia/SlackAPI</RepositoryUrl>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
<PackageReference Include="System.Net.Http" Version="4.3.1" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' ">
<PackageReference Include="System.Net.Requests" Version="4.3.0" />
<PackageReference Include="System.Net.WebSockets.Client" Version="4.3.0" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="1.1.1" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
<PackageReference Include="System.Net.Requests" Version="4.3.0" />
<PackageReference Include="System.Net.WebSockets.Client" Version="4.3.0" />
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.3.0" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="1.1.1" />
</ItemGroup>
<PropertyGroup Label="Configuration">
<RootNamespace>SlackAPI</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
</PropertyGroup>
</Project>
7 changes: 5 additions & 2 deletions SlackAPI/SlackAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DefineConstants>TRACE;DEBUG;NET45</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<DefineConstants>TRACE;NET45</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
Expand All @@ -44,6 +44,9 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\GlobalAssemblyVersion.cs">
<Link>Properties\GlobalAssemblyVersion.cs</Link>
</Compile>
<Compile Include="Attachment.cs" />
<Compile Include="Conversation.cs" />
<Compile Include="Reaction.cs" />
Expand Down
Loading