Skip to content

Commit

Permalink
Update to .NET Core App 2.2 and fix unsafe Connection methods (#162)
Browse files Browse the repository at this point in the history
* Remove UWP

* Update Connection

* Update ExclusiveTimer.cs
  • Loading branch information
geoperez authored Feb 7, 2019
1 parent 51c22d2 commit 4a34aa4
Show file tree
Hide file tree
Showing 55 changed files with 127 additions and 231 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ language: csharp
notifications:
slack: unolabs:cbusXPH6pBwZ35rVDzi4k4ve
mono: none
dotnet: 2.1.300
dotnet: 2.2.101
matrix:
include:
- os: linux
dist: trusty
dist: xenial
sudo: false
- os: osx
osx_image: xcode9.1
Expand All @@ -20,6 +20,6 @@ script:
- node ./tcp.js &
- node ./ntp.js &
- cd ./test/Unosquare.Swan.Test/
- dotnet test Unosquare.Swan.Test.csproj -s .runsettings -f netcoreapp2.1
- dotnet test Unosquare.Swan.Test.csproj -s .runsettings -f netcoreapp2.2
after_script:
- killall -9 node
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Repeating code and reinventing the wheel is generally considered bad practice. A

Table of contents
=================

* [📚 Libraries](#-libraries)
* [💾Installation](#-installation)
* [What's in the library](#whats-in-the-library)
Expand All @@ -40,7 +41,7 @@ Table of contents
* [The DelayProvider component](#the-delayprovider-component)
* [The WaitEventFactory component](#the-waiteventfactory-component)
* [Atomic Types](#atomic-types)

## 📚 Libraries
We offer the Swan library in two flavors since version 0.24. Swan Lite provides basic classes and extension methods and Swan Standard (we call it Fat Swan) provides everything in Swan Lite plus Network, WinServices, DI and more. See the following table to understand the components available to these flavors of Swan.

Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ build_script:
cd ..
cd ..
test_script:
- dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude=[NUnit3.TestAdapter]* test/Unosquare.Swan.Test/Unosquare.Swan.Test.csproj -c Release -f netcoreapp2.1
- dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude=[NUnit3.TestAdapter]* test/Unosquare.Swan.Test/Unosquare.Swan.Test.csproj -c Release -f netcoreapp2.2
- ps: |
if(-Not $env:APPVEYOR_PULL_REQUEST_TITLE -And $isWindows)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Unosquare.Swan.Lite/Abstractions/ExclusiveTimer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ private void InternalCallback(object state)
}
finally
{
_cycleDoneEvent.Set();
_backingTimer.Change(_period, Timeout.Infinite);
_cycleDoneEvent?.Set();
_backingTimer?.Change(_period, Timeout.Infinite);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Unosquare.Swan.Lite/Abstractions/RunnerBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !NETSTANDARD1_3 && !UWP
#if !NETSTANDARD1_3
namespace Unosquare.Swan.Abstractions
{
using System;
Expand Down
2 changes: 1 addition & 1 deletion src/Unosquare.Swan.Lite/Abstractions/SettingsProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public sealed class SettingsProvider<T>
/// The configuration file path.
/// </value>
public string ConfigurationFilePath { get; set; } =
#if NETSTANDARD1_3 || UWP
#if NETSTANDARD1_3
Path.Combine(Runtime.LocalStoragePath, "appsettings.json");
#else
Path.Combine(Runtime.EntryAssemblyDirectory, "appsettings.json");
Expand Down
2 changes: 1 addition & 1 deletion src/Unosquare.Swan.Lite/Components/ArgumentParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ private static void ReportUnknownVerb<T>()

private void ReportIssues(Validator validator)
{
#if !NETSTANDARD1_3 && !UWP
#if !NETSTANDARD1_3
if (Settings.WriteBanner)
Runtime.WriteWelcomeBanner();
#endif
Expand Down
6 changes: 3 additions & 3 deletions src/Unosquare.Swan.Lite/Components/SyncLockerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private interface ISyncReleasable

#region Factory Methods

#if !NETSTANDARD1_3 && !UWP
#if !NETSTANDARD1_3
/// <summary>
/// Creates a reader-writer lock backed by a standard ReaderWriterLock.
/// </summary>
Expand All @@ -50,7 +50,7 @@ private interface ISyncReleasable
#else
/// <summary>
/// Creates a reader-writer lock backed by a standard ReaderWriterLockSlim when
/// running at NETSTANDARD 1.3 or UWP.
/// running at NETSTANDARD 1.3.
/// </summary>
/// <returns>The synchronized locker</returns>
public static ISyncLocker Create() => new SyncLockerSlim();
Expand Down Expand Up @@ -108,7 +108,7 @@ public void Dispose()
}
}

#if !NETSTANDARD1_3 && !UWP
#if !NETSTANDARD1_3
/// <summary>
/// The Sync Locker backed by a ReaderWriterLock.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Unosquare.Swan.Lite/Components/TimerControl.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !NETSTANDARD1_3 && !UWP
#if !NETSTANDARD1_3
namespace Unosquare.Swan.Components
{
using System;
Expand Down
2 changes: 1 addition & 1 deletion src/Unosquare.Swan.Lite/Components/WaitEventFactory.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !NETSTANDARD1_3 && !UWP
#if !NETSTANDARD1_3
namespace Unosquare.Swan.Components
{
using System;
Expand Down
2 changes: 1 addition & 1 deletion src/Unosquare.Swan.Lite/Extensions.ValueTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private static byte[] GetStructBytes<T>(byte[] data)
if (data == null)
throw new ArgumentNullException(nameof(data));

#if !NETSTANDARD1_3 && !UWP
#if !NETSTANDARD1_3
var fields = typeof(T).GetTypeInfo()
.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
#else
Expand Down
14 changes: 7 additions & 7 deletions src/Unosquare.Swan.Lite/Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
using System.IO;
using System.Threading;
using Reflection;
#if !NETSTANDARD1_3 && !UWP
#if !NETSTANDARD1_3
using System.Reflection;
#endif

/// <summary>
/// Provides utility methods to retrieve information about the current application.
/// </summary>
#if !NETSTANDARD1_3 && !UWP
#if !NETSTANDARD1_3
public class Runtime : MarshalByRefObject
#else
public static class Runtime
Expand Down Expand Up @@ -40,7 +40,7 @@ public static class Runtime
private static readonly Lazy<System.Diagnostics.Process> ProcessLazy = new Lazy<System.Diagnostics.Process>(System.Diagnostics.Process.GetCurrentProcess);
#endif

#if !NETSTANDARD1_3 && !UWP
#if !NETSTANDARD1_3
private static readonly Lazy<string> CompanyNameLazy = new Lazy<string>(() =>
{
var attribute =
Expand Down Expand Up @@ -68,7 +68,7 @@ public static class Runtime

private static readonly Lazy<ObjectMapper> _objectMapper = new Lazy<ObjectMapper>(() => new ObjectMapper());

#if !NETSTANDARD1_3 && !UWP
#if !NETSTANDARD1_3
private static readonly string ApplicationMutexName = "Global\\{{" + EntryAssembly.FullName + "}}";
#else
private const string ApplicationMutexName = "Global\\{{SWANINSTANCE}}";
Expand Down Expand Up @@ -208,7 +208,7 @@ public static bool IsTheOnlyInstance
/// </value>
public static MethodInfoCache MethodInfoCache => _methodInfoCache.Value;

#if !NETSTANDARD1_3 && !UWP
#if !NETSTANDARD1_3
/// <summary>
/// Gets the assembly that started the application.
/// </summary>
Expand Down Expand Up @@ -281,7 +281,7 @@ public static string LocalStoragePath
{
get
{
#if !NETSTANDARD1_3 && !UWP
#if !NETSTANDARD1_3
var localAppDataPath =
#if NET452
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
Expand Down Expand Up @@ -324,7 +324,7 @@ public static string LocalStoragePath

#region Methods

#if !NETSTANDARD1_3 && !UWP
#if !NETSTANDARD1_3
/// <summary>
/// Writes a standard banner to the standard output
/// containing the company name, product name, assembly version and trademark.
Expand Down
23 changes: 2 additions & 21 deletions src/Unosquare.Swan.Lite/Unosquare.Swan.Lite.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

<PropertyGroup>
<Description>Repeating code and reinventing the wheel is generally considered bad practice. At Unosquare we are committed to beautiful code and great software. Swan is a collection of classes and extension methods that we and other good developers have developed and evolved over the years. We found ourselves copying and pasting the same code for every project every time we started it. We decide to kill that cycle once and for all. This is the result of that idea. Our philosophy is that SWAN should have no external dependencies, it should be cross-platform, and it should be useful.</Description>
<Copyright>Copyright (c) 2016-2018 - Unosquare</Copyright>
<Copyright>Copyright (c) 2016-2019 - Unosquare</Copyright>
<AssemblyTitle>Unosquare SWAN</AssemblyTitle>
<TargetFrameworks>netstandard2.0;netstandard1.3;net452;uap10.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard1.3;net452</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>Unosquare.Swan.Lite</AssemblyName>
<CodeAnalysisRuleSet>..\..\StyleCop.Analyzers.ruleset</CodeAnalysisRuleSet>
Expand All @@ -24,14 +24,6 @@
</PackageReference>
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'uap10.0' ">
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="5.4.4" />
<PackageReference Include="System.ComponentModel.TypeConverter" Version="4.3.0" />
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.5.1" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.0" />
<PackageReference Include="System.Threading.Thread" Version="4.3.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="System.ComponentModel.TypeConverter" Version="4.3.0" />
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.5.1" />
Expand All @@ -46,17 +38,6 @@
<PackageReference Include="System.Threading.Thread" Version="4.3.0" />
</ItemGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'uap10.0' ">
<CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies>
<NugetTargetMoniker>UAP,Version=v10.0</NugetTargetMoniker>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion>10.0.14393.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.10240.0</TargetPlatformMinVersion>
<TargetFrameworkIdentifier>.NETCore</TargetFrameworkIdentifier>
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
<DefineConstants>$(DefineConstants);UWP</DefineConstants>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Unosquare.Swan.Samples/Unosquare.Swan.Samples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

<PropertyGroup>
<Description>Some usage samples of the Swan library</Description>
<Copyright>Copyright (c) 2016-2018 - Unosquare</Copyright>
<Copyright>Copyright (c) 2016-2019 - Unosquare</Copyright>
<AssemblyTitle>Unosquare SWAN Samples</AssemblyTitle>
<TargetFrameworks>net46;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp2.2</TargetFrameworks>
<AssemblyName>Unosquare.Swan.Samples</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>Unosquare.Swan.Samples</PackageId>
Expand Down
4 changes: 1 addition & 3 deletions src/Unosquare.Swan/Components/CircularBuffer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#if !UWP
namespace Unosquare.Swan.Components
{
using System;
Expand Down Expand Up @@ -202,5 +201,4 @@ public void Dispose()

#endregion
}
}
#endif
}
6 changes: 2 additions & 4 deletions src/Unosquare.Swan/Components/DelayProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,10 @@ public enum DelayStrategy
/// </summary>
TaskDelay,

#if !UWP
/// <summary>
/// Using a wait event that completes in a background ThreadPool thread.
/// </summary>
ThreadPool,
#endif
}

/// <summary>
Expand Down Expand Up @@ -93,7 +91,7 @@ public TimeSpan WaitOne()
case DelayStrategy.TaskDelay:
DelayTask();
break;
#if !NETSTANDARD1_3 && !UWP
#if !NETSTANDARD1_3
case DelayStrategy.ThreadPool:
DelayThreadPool();
break;
Expand Down Expand Up @@ -125,7 +123,7 @@ public void Dispose()

private static void DelayTask() => Task.Delay(1).Wait();

#if !NETSTANDARD1_3 && !UWP
#if !NETSTANDARD1_3
private void DelayThreadPool()
{
if (_delayEvent == null)
Expand Down
4 changes: 2 additions & 2 deletions src/Unosquare.Swan/Components/DependencyContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void Dispose()

#region Registration

#if !NETSTANDARD1_3 && !UWP
#if !NETSTANDARD1_3
/// <summary>
/// Attempt to automatically register all non-generic classes and interfaces in the current app domain.
/// Types will only be registered if they pass the supplied registration predicate.
Expand Down Expand Up @@ -704,7 +704,7 @@ internal static bool IsValidAssignment(Type registerType, Type registerImplement
return true;
}

#if !NETSTANDARD1_3 && !UWP
#if !NETSTANDARD1_3
private static bool IsIgnoredAssembly(Assembly assembly)
{
// TODO - find a better way to remove "system" assemblies from the auto registration
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Unosquare.Swan.Components
{
using System;
#if NETSTANDARD1_3 || UWP
#if NETSTANDARD1_3
using System.Reflection;
#endif

Expand Down
6 changes: 2 additions & 4 deletions src/Unosquare.Swan/Components/ProcessResult.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if !UWP
namespace Unosquare.Swan.Components
namespace Unosquare.Swan.Components
{
/// <summary>
/// Represents the text of the standard output and standard error
Expand Down Expand Up @@ -44,5 +43,4 @@ public ProcessResult(int exitCode, string standardOutput, string standardError)
/// </value>
public string StandardError { get; }
}
}
#endif
}
6 changes: 2 additions & 4 deletions src/Unosquare.Swan/Components/ProcessRunner.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if !UWP
namespace Unosquare.Swan.Components
namespace Unosquare.Swan.Components
{
using System;
using System.Diagnostics;
Expand Down Expand Up @@ -472,5 +471,4 @@ private static Task<ulong> CopyStreamAsync(
}, ct).Unwrap();
}
}
}
#endif
}
2 changes: 1 addition & 1 deletion src/Unosquare.Swan/Exceptions/JsonRequestException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/// Represents errors that occurs requesting a JSON file through HTTP.
/// </summary>
/// <seealso cref="System.Exception" />
#if !NETSTANDARD1_3 && !UWP
#if !NETSTANDARD1_3
[Serializable]
#endif
public class JsonRequestException
Expand Down
6 changes: 2 additions & 4 deletions src/Unosquare.Swan/Exceptions/LdapException.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if !UWP
namespace Unosquare.Swan.Exceptions
namespace Unosquare.Swan.Exceptions
{
using System;
using Networking.Ldap;
Expand Down Expand Up @@ -132,5 +131,4 @@ public override string ToString()
return msg;
}
}
}
#endif
}
2 changes: 1 addition & 1 deletion src/Unosquare.Swan/Exceptions/SmtpException.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NETSTANDARD1_3 || UWP
#if NETSTANDARD1_3
namespace Unosquare.Swan.Exceptions
{
using Networking;
Expand Down
2 changes: 1 addition & 1 deletion src/Unosquare.Swan/Extensions.WindowsServices.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !NETSTANDARD1_3 && !UWP
#if !NETSTANDARD1_3
namespace Unosquare.Swan
{
using System;
Expand Down
Loading

0 comments on commit 4a34aa4

Please sign in to comment.