Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Added NetStandard compatibility projects #803

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ obj
*.crx
*.pem
*.csproj.user
*.xproj.user


# mstest test results
Expand All @@ -33,3 +34,5 @@ node_modules/
.vs/

settings.json

*project.lock.json
2 changes: 1 addition & 1 deletion PushSharp.Amazon/AdmConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public async Task Send (AdmNotification notification)
{
case HttpStatusCode.BadGateway: //400
case HttpStatusCode.BadRequest: //
if ("InvalidRegistrationId".Equals (reason, StringComparison.InvariantCultureIgnoreCase)) {
if ("InvalidRegistrationId".Equals (reason, StringComparison.OrdinalIgnoreCase)) {
throw new DeviceSubscriptionExpiredException (notification) {
OldSubscriptionId = regId,
ExpiredAt = DateTime.UtcNow
Expand Down
19 changes: 19 additions & 0 deletions PushSharp.Amazon/PushSharp.Amazon.NetStandard.xproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>fe547517-3380-4056-aa20-56b1868a88fd</ProjectGuid>
<RootNamespace>PushSharp.Amazon</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
10 changes: 10 additions & 0 deletions PushSharp.Amazon/PushSharp.Amazon.project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"dependencies": {
},
"runtimes": {
"win": {}
},
"frameworks": {
"net45": {}
}
}
19 changes: 19 additions & 0 deletions PushSharp.Amazon/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"version": "4.0.0-*",

"dependencies": {
"NETStandard.Library": "1.6.0",
"Newtonsoft.Json": "9.0.1",
"PushSharp.Core": "4.0.0-*"
},

"frameworks": {
"netstandard1.5": {
"imports": "dnxcore50"
}
},

"buildOptions": {
"define": [ "DEBUG", "NETSTANDARD" ]
}
}
12 changes: 9 additions & 3 deletions PushSharp.Apple/ApnsConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ public ApnsConnection (ApnsConfiguration configuration)

// Add local/machine certificate stores to our collection if requested
if (Configuration.AddLocalAndMachineCertificateStores) {
var store = new X509Store (StoreLocation.LocalMachine);
var store = new X509Store (StoreName.Root, StoreLocation.LocalMachine);
certificates.AddRange (store.Certificates);

store = new X509Store (StoreLocation.CurrentUser);
store = new X509Store (StoreName.Root, StoreLocation.CurrentUser);
certificates.AddRange (store.Certificates);
}

Expand Down Expand Up @@ -354,7 +354,7 @@ async Task connect ()
(sender, targetHost, localCerts, remoteCert, acceptableIssuers) => certificate);

try {
stream.AuthenticateAsClient (Configuration.Host, certificates, System.Security.Authentication.SslProtocols.Tls, false);
await stream.AuthenticateAsClientAsync(Configuration.Host, certificates, System.Security.Authentication.SslProtocols.Tls, false);
} catch (System.Security.Authentication.AuthenticationException ex) {
throw new ApnsConnectionException ("SSL Stream Failed to Authenticate as Client", ex);
}
Expand All @@ -378,16 +378,22 @@ void disconnect ()
//We now expect apple to close the connection on us anyway, so let's try and close things
// up here as well to get a head start
//Hopefully this way we have less messages written to the stream that we have to requeue
#if !NETSTANDARD
try { stream.Close (); } catch { }
#endif
try { stream.Dispose (); } catch { }

#if !NETSTANDARD
try { networkStream.Close (); } catch { }
#endif
try { networkStream.Dispose (); } catch { }

try { client.Client.Shutdown (SocketShutdown.Both); } catch { }
try { client.Client.Dispose (); } catch { }

#if !NETSTANDARD
try { client.Close (); } catch { }
#endif

client = null;
networkStream = null;
Expand Down
15 changes: 12 additions & 3 deletions PushSharp.Apple/ApnsFeedbackService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,17 @@ public void Check ()

var certificates = new X509CertificateCollection();
certificates.Add(certificate);

#if !NETSTANDARD
var client = new TcpClient (Configuration.FeedbackHost, Configuration.FeedbackPort);

#else
var client = new TcpClient();
client.ConnectAsync(Configuration.FeedbackHost, Configuration.FeedbackPort).Wait();
#endif
var stream = new SslStream (client.GetStream(), true,
(sender, cert, chain, sslErrs) => { return true; },
(sender, targetHost, localCerts, remoteCert, acceptableIssuers) => { return certificate; });

stream.AuthenticateAsClient(Configuration.FeedbackHost, certificates, System.Security.Authentication.SslProtocols.Tls, false);
stream.AuthenticateAsClientAsync(Configuration.FeedbackHost, certificates, System.Security.Authentication.SslProtocols.Tls, false).Wait();


//Set up
Expand Down Expand Up @@ -107,7 +110,9 @@ public void Check ()

try
{
#if !NETSTANDARD
stream.Close ();
#endif
stream.Dispose();
}
catch { }
Expand All @@ -119,7 +124,11 @@ public void Check ()
}
catch { }

#if !NETSTANDARD
try { client.Close (); } catch { }
#else
try { client.Dispose (); } catch { }
#endif

}
}
Expand Down
25 changes: 25 additions & 0 deletions PushSharp.Apple/PushSharp.Apple.NetStandard.xproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>266b2380-f497-4bcc-81c0-fd313e73f6e7</ProjectGuid>
<RootNamespace>PushSharp.Apple</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<ItemGroup>
<DnxInvisibleCompile Include="ApnsHttp2Configuration.cs" />
<DnxInvisibleCompile Include="ApnsHttp2Connection.cs" />
<DnxInvisibleCompile Include="ApnsHttp2Notification.cs" />
<DnxInvisibleCompile Include="ApnsHttp2ServiceConnection.cs" />
</ItemGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
10 changes: 10 additions & 0 deletions PushSharp.Apple/PushSharp.Apple.project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"dependencies": {
},
"runtimes": {
"win": {}
},
"frameworks": {
"net45": {}
}
}
23 changes: 23 additions & 0 deletions PushSharp.Apple/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"version": "4.0.0-*",

"dependencies": {
"NETStandard.Library": "1.6.0",
"Newtonsoft.Json": "9.0.1",
"PushSharp.Core": "4.0.0-*",
"System.Net.Sockets": "4.3.0"
},

"frameworks": {
"netstandard1.5": {
"imports": "dnxcore50"
}
},

"buildOptions": {
"define": [ "DEBUG", "NETSTANDARD" ],
"compile": {
"exclude": [ "ApnsHttp2*" ]
}
}
}
4 changes: 2 additions & 2 deletions PushSharp.Blackberry/BlackberryConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public void OverrideSendUrl(string url)
{
if (!string.IsNullOrWhiteSpace(url))
{
if (url.EndsWith("pushapi.na.blackberry.com", StringComparison.InvariantCultureIgnoreCase) ||
url.EndsWith("pushapi.eval.blackberry.com", StringComparison.InvariantCultureIgnoreCase))
if (url.EndsWith("pushapi.na.blackberry.com", StringComparison.OrdinalIgnoreCase) ||
url.EndsWith("pushapi.eval.blackberry.com", StringComparison.OrdinalIgnoreCase))
url = url + @"/mss/PD_pushRequest";
}
SendUrl = url;
Expand Down
2 changes: 1 addition & 1 deletion PushSharp.Blackberry/BlackberryHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public BlackberryHttpClient (BlackberryConfiguration configuration) : base()
Configuration = configuration;

var authInfo = Configuration.ApplicationId + ":" + Configuration.Password;
authInfo = Convert.ToBase64String (Encoding.Default.GetBytes(authInfo));
authInfo = Convert.ToBase64String (Encoding.GetEncoding(0).GetBytes(authInfo));

this.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue ("Basic", authInfo);
this.DefaultRequestHeaders.ConnectionClose = true;
Expand Down
7 changes: 2 additions & 5 deletions PushSharp.Blackberry/BlackberryNotification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public string ToPapXml()

if (!string.IsNullOrEmpty(r.RecipientType))
{
addrValue = string.Format("WAPPUSH={0}%3A{1}/TYPE={2}", System.Web.HttpUtility.UrlEncode(r.Recipient),
addrValue = string.Format("WAPPUSH={0}%3A{1}/TYPE={2}", System.Net.WebUtility.UrlEncode(r.Recipient),
r.Port, r.RecipientType);
}

Expand All @@ -109,10 +109,7 @@ public string ToPapXml()
}


protected string XmlEncode(string text)
{
return System.Security.SecurityElement.Escape(text);
}


}

Expand Down
19 changes: 19 additions & 0 deletions PushSharp.Blackberry/PushSharp.Blackberry.NetStandard.xproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>c10bad6c-5a09-42b9-afc6-86ab5d789a5a</ProjectGuid>
<RootNamespace>PushSharp.Blackberry</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
10 changes: 10 additions & 0 deletions PushSharp.Blackberry/PushSharp.Blackberry.project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"dependencies": {
},
"runtimes": {
"win": {}
},
"frameworks": {
"net45": {}
}
}
19 changes: 19 additions & 0 deletions PushSharp.Blackberry/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"version": "4.0.0-*",

"dependencies": {
"NETStandard.Library": "1.6.0",
"Newtonsoft.Json": "9.0.1",
"PushSharp.Core": "4.0.0-*"
},

"frameworks": {
"netstandard1.5": {
"imports": "dnxcore50"
}
},

"buildOptions": {
"define": [ "DEBUG", "NETSTANDARD" ]
}
}
Loading