-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
132 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/JSSoft.Communication/Compatibility/CancellationTokenSourceExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// <copyright file="CancellationTokenSourceExtensions.cs" company="JSSoft"> | ||
// Copyright (c) 2024 Jeesu Choi. All Rights Reserved. | ||
// Licensed under the MIT License. See LICENSE.md in the project root for license information. | ||
// </copyright> | ||
|
||
#if !NET8_0_OR_GREATER | ||
#pragma warning disable | ||
|
||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace JSSoft.Communication; | ||
|
||
internal static class CancellationTokenSourceExtensions | ||
{ | ||
public static Task CancelAsync(this CancellationTokenSource @this) | ||
{ | ||
return Task.Run(() => @this.Cancel()); | ||
} | ||
|
||
} | ||
|
||
#endif // !NET8_0_OR_GREATER |
27 changes: 27 additions & 0 deletions
27
src/JSSoft.Communication/Compatibility/CompilerFeatureRequiredAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// <copyright file="CompilerFeatureRequiredAttribute.cs" company="JSSoft"> | ||
// Copyright (c) 2024 Jeesu Choi. All Rights Reserved. | ||
// Licensed under the MIT License. See LICENSE.md in the project root for license information. | ||
// </copyright> | ||
|
||
#if !NET7_0_OR_GREATER | ||
#pragma warning disable | ||
// https://stackoverflow.com/questions/74447497/is-it-possible-to-use-the-c11-required-modifier-with-net-framework-4-8-and | ||
|
||
namespace System.Runtime.CompilerServices; | ||
|
||
[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)] | ||
internal sealed class CompilerFeatureRequiredAttribute : Attribute | ||
{ | ||
public CompilerFeatureRequiredAttribute(string featureName) | ||
{ | ||
FeatureName = featureName; | ||
} | ||
|
||
public string FeatureName { get; } | ||
public bool IsOptional { get; init; } | ||
|
||
public const string RefStructs = nameof(RefStructs); | ||
public const string RequiredMembers = nameof(RequiredMembers); | ||
} | ||
|
||
#endif // !NET7_0_OR_GREATER |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// <copyright file="IsExternalInit.cs" company="JSSoft"> | ||
// Copyright (c) 2024 Jeesu Choi. All Rights Reserved. | ||
// Licensed under the MIT License. See LICENSE.md in the project root for license information. | ||
// </copyright> | ||
|
||
#if !NET5_0_OR_GREATER | ||
#pragma warning disable | ||
using System.ComponentModel; | ||
|
||
namespace System.Runtime.CompilerServices; | ||
|
||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
internal static class IsExternalInit { } | ||
|
||
#endif // !NET5_0_OR_GREATER |
22 changes: 22 additions & 0 deletions
22
src/JSSoft.Communication/Compatibility/ObjectDisposedException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// <copyright file="ObjectDisposedException.cs" company="JSSoft"> | ||
// Copyright (c) 2024 Jeesu Choi. All Rights Reserved. | ||
// Licensed under the MIT License. See LICENSE.md in the project root for license information. | ||
// </copyright> | ||
|
||
#if !NET7_0_OR_GREATER | ||
#pragma warning disable | ||
namespace JSSoft.Communication; | ||
|
||
internal class ObjectDisposedException(string objectName) | ||
: System.ObjectDisposedException(objectName) | ||
{ | ||
public static void ThrowIf(bool condition, object instance) | ||
{ | ||
if (condition == true) | ||
{ | ||
throw new System.ObjectDisposedException(instance.GetType().Name); | ||
} | ||
} | ||
} | ||
|
||
#endif // !NET7_0_OR_GREATER |
17 changes: 17 additions & 0 deletions
17
src/JSSoft.Communication/Compatibility/RequiredMemberAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// <copyright file="RequiredMemberAttribute.cs" company="JSSoft"> | ||
// Copyright (c) 2024 Jeesu Choi. All Rights Reserved. | ||
// Licensed under the MIT License. See LICENSE.md in the project root for license information. | ||
// </copyright> | ||
|
||
#if !NET7_0_OR_GREATER | ||
#pragma warning disable | ||
#pragma warning disable MEN002 // Line is too long | ||
namespace System.Runtime.CompilerServices; | ||
|
||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Field | ||
| AttributeTargets.Property, AllowMultiple = false, Inherited = false)] | ||
internal sealed class RequiredMemberAttribute : Attribute { } | ||
|
||
|
||
#pragma warning restore MEN002 // Line is too long | ||
#endif // !NET7_0_OR_GREATER |
13 changes: 13 additions & 0 deletions
13
src/JSSoft.Communication/Compatibility/SetsRequiredMembersAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// <copyright file="SetsRequiredMembersAttribute.cs" company="JSSoft"> | ||
// Copyright (c) 2024 Jeesu Choi. All Rights Reserved. | ||
// Licensed under the MIT License. See LICENSE.md in the project root for license information. | ||
// </copyright> | ||
|
||
#if !NET7_0_OR_GREATER | ||
#pragma warning disable | ||
namespace System.Diagnostics.CodeAnalysis; | ||
|
||
[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)] | ||
internal sealed class SetsRequiredMembersAttribute : Attribute { } | ||
|
||
#endif // !NET7_0_OR_GREATER |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters