From b05a6a8f374ba70d1353fbcd7cb0fed6e9526cfc Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Mon, 28 Oct 2024 09:27:47 +0530 Subject: [PATCH] removed timer.cs, tuple.cs which was there for older .net versions --- src/Api/PubnubApi/Pubnub.cs | 4 +- src/Api/PubnubApi/Timer.cs | 115 ------------------- src/Api/PubnubApi/Tuple.cs | 53 --------- src/Api/PubnubApiPCL/PubnubApiPCL.csproj | 3 - src/Api/PubnubApiUWP/PubnubApiUWP.csproj | 3 - src/Api/PubnubApiUnity/PubnubApiUnity.csproj | 3 - 6 files changed, 3 insertions(+), 178 deletions(-) delete mode 100644 src/Api/PubnubApi/Timer.cs delete mode 100644 src/Api/PubnubApi/Tuple.cs diff --git a/src/Api/PubnubApi/Pubnub.cs b/src/Api/PubnubApi/Pubnub.cs index 2504995f1..0dc9a8953 100644 --- a/src/Api/PubnubApi/Pubnub.cs +++ b/src/Api/PubnubApi/Pubnub.cs @@ -42,7 +42,9 @@ static Pubnub() var assembly = typeof(Pubnub).GetTypeInfo().Assembly; var assemblyName = new AssemblyName(assembly.FullName); string assemblyVersion = assemblyName.Version.ToString(); - Version = string.Format(CultureInfo.InvariantCulture, "{0}CSharp{1}", PNPlatform.Get(), assemblyVersion); + var targetFramework = assembly.GetCustomAttribute()?.FrameworkDisplayName?.Replace(".",string.Empty).Replace(" ", string.Empty); + + Version = string.Format(CultureInfo.InvariantCulture, "{0}/CSharp/{1}", targetFramework??"UNKNOWN", assemblyVersion); } #if UNITY diff --git a/src/Api/PubnubApi/Timer.cs b/src/Api/PubnubApi/Timer.cs deleted file mode 100644 index 7ee86602e..000000000 --- a/src/Api/PubnubApi/Timer.cs +++ /dev/null @@ -1,115 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace System.Threading -{ -#if NETSTANDARD10 || NETSTANDARD11 - public delegate void TimerCallback(object state); - - public sealed class Timer : CancellationTokenSource, IDisposable - { - TimerCallback callback; - object state; - - public Timer(TimerCallback callback, object state, int dueTime, int period) - { - Init(callback, state, dueTime, period); - } - - public Timer(TimerCallback callback, object state, TimeSpan dueTime, TimeSpan period) - { - Init(callback, state, (long)dueTime.TotalMilliseconds, (long)period.TotalMilliseconds); - } - - public Timer(TimerCallback callback) - { - Init(callback, this, Timeout.Infinite, Timeout.Infinite); - } - - void Init(TimerCallback callback, object state, long dueTime, long period) - { - if (callback == null) - throw new ArgumentNullException("callback"); - - this.callback = callback; - this.state = state; - - Change(dueTime, period, true); - } - - - public new void Dispose() - { - base.Cancel(); - } - - public bool Change(int dueTime, int period) - { - return Change(dueTime, period, false); - } - - - public bool Change(TimeSpan dueTime, TimeSpan period) - { - return Change((long)dueTime.TotalMilliseconds, (long)period.TotalMilliseconds, false); - } - - - public bool Change(uint dueTime, uint period) - { - // convert all values to long - with a special case for -1 / 0xffffffff - long d = (dueTime == UInt32.MaxValue) ? Timeout.Infinite : (long)dueTime; - long p = (period == UInt32.MaxValue) ? Timeout.Infinite : (long)period; - return Change(d, p, false); - } - - public bool Change(long dueTime, long period) - { - return Change(dueTime, period, false); - } - - bool Change(long dueTime, long period, bool first) - { - bool status = false; - - if (dueTime < Timeout.Infinite) - throw new ArgumentOutOfRangeException("dueTime"); - - - if (period < Timeout.Infinite) - throw new ArgumentOutOfRangeException("period"); - - - Task.Delay((int)dueTime, Token).ContinueWith(async (t, s) => - { - var tuple = (Tuple)s; - - while (true) - { - if (IsCancellationRequested) - { - status = false; - break; - } - await Task.Run(() => tuple.Item1(tuple.Item2)).ConfigureAwait(false); - await Task.Delay((int)period).ConfigureAwait(false); - - status = true; - } - - }, Tuple.Create(callback, state), CancellationToken.None, - TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnRanToCompletion, - TaskScheduler.Default).ConfigureAwait(false); - - return status; - } - - - } - -#endif -} - diff --git a/src/Api/PubnubApi/Tuple.cs b/src/Api/PubnubApi/Tuple.cs deleted file mode 100644 index eed3fca84..000000000 --- a/src/Api/PubnubApi/Tuple.cs +++ /dev/null @@ -1,53 +0,0 @@ -#if NET35 || NET40 -namespace System -{ //THIS IS ADDED TO SUPPORT .NET 3.5 and .NET 4.0 BASED SDKs. IF THIS DOES NOT WORK, NEED TO REVIEW NetLegacySupport.Tuple NUGET PACKAGE, TO SEE IF IT CAN WORK - // CS0436,0436 warnings were disabled in project file - public class Tuple - { - public Tuple(T1 item1) - { - Item1 = item1; - } - - public T1 Item1 { get; set; } - } - - public class Tuple : Tuple - { - public Tuple(T1 item1, T2 item2) : base(item1) - { - Item2 = item2; - } - - public T2 Item2 { get; set; } - } - - public class Tuple : Tuple - { - public Tuple(T1 item1, T2 item2, T3 item3) : base(item1, item2) - { - Item3 = item3; - } - - public T3 Item3 { get; set; } - } - - public static class Tuple - { - public static Tuple Create(T1 item1) - { - return new Tuple(item1); - } - - public static Tuple Create(T1 item1, T2 item2) - { - return new Tuple(item1, item2); - } - - public static Tuple Create(T1 item1, T2 item2, T3 item3) - { - return new Tuple(item1, item2, item3); - } - } -} -#endif diff --git a/src/Api/PubnubApiPCL/PubnubApiPCL.csproj b/src/Api/PubnubApiPCL/PubnubApiPCL.csproj index 37b09002d..8a5b0d112 100644 --- a/src/Api/PubnubApiPCL/PubnubApiPCL.csproj +++ b/src/Api/PubnubApiPCL/PubnubApiPCL.csproj @@ -627,9 +627,6 @@ Security\SecureMessage.cs - - Timer.cs - diff --git a/src/Api/PubnubApiUWP/PubnubApiUWP.csproj b/src/Api/PubnubApiUWP/PubnubApiUWP.csproj index 4417c91fb..d10af0c14 100644 --- a/src/Api/PubnubApiUWP/PubnubApiUWP.csproj +++ b/src/Api/PubnubApiUWP/PubnubApiUWP.csproj @@ -760,9 +760,6 @@ Security\SecureMessage.cs - - Timer.cs - diff --git a/src/Api/PubnubApiUnity/PubnubApiUnity.csproj b/src/Api/PubnubApiUnity/PubnubApiUnity.csproj index f9cde8f5a..14f3c45c6 100644 --- a/src/Api/PubnubApiUnity/PubnubApiUnity.csproj +++ b/src/Api/PubnubApiUnity/PubnubApiUnity.csproj @@ -627,9 +627,6 @@ Security\SecureMessage.cs - - Timer.cs -