Conversation
…with PolyShim Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/62ed1b9c-62a5-4b9f-a9e6-42f951a40b50 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
|
@copilot please fix conflicts |
…ync methods Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Conflicts resolved in 8c581eb. The |
…add net10.0 target; simplify ElementAtOrNull Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/065ab2f6-f4f0-4bb0-923d-620848f5d8b1 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/092152bb-90bb-4660-a69c-d821170f96a0 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
…ption> (PolyShim polyfills AggregateException) Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/56d471b2-e851-414e-987b-f3210dd64367 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
No new commits on |
…s, IEnumerable<Exception> on net35 Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/4ef6a122-f948-4abf-98cb-2834ce1022ee Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@copilot please update PolyShim to v2.9.0, I've added polyfills that should fix some of the issues you've outlined. |
…APIs now polyfilled Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/d1aaa064-db73-483d-b2e7-07ac3af20f6c Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Done in e49666f. PolyShim 2.9.0 polyfills |
| @@ -1,3 +1,4 @@ | |||
| #if NET40_OR_GREATER || NETSTANDARD || NET | |||
There was a problem hiding this comment.
Wrap the methods, nto the whole file. We might add sync extensions later. @copilot
There was a problem hiding this comment.
Done in 74a003f — the #if NET40_OR_GREATER || NETSTANDARD || NET guard is now inside the extension(Stream source) block wrapping the methods, with using directives unconditional at the top of the file.
| @@ -1,3 +1,4 @@ | |||
| #if NET40_OR_GREATER || NETSTANDARD || NET | |||
There was a problem hiding this comment.
Wrap the methods, nto the whole file. We might add sync extensions later. @copilot
There was a problem hiding this comment.
Done in 74a003f — same approach as StreamExtensions.cs: #if NET40_OR_GREATER || NETSTANDARD || NET wraps the ReadLinesAsync method inside the extension(TextReader reader) block, with using directives unconditional at the top.
…Shim provides NamespaceDummies) Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/4a03314a-3fbb-4070-9f15-85c35c9af036 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
…ot/add-compiler-guards-for-powerkit Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
…derExtensions.cs; merge prime Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/e33ccf50-1803-4a60-8997-81a3cf566bb5 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Conflicts resolved in 74a003f — merged latest
Already done in e49666f — PolyShim is at 2.9.0. The whole-file guards were removed from |
PowerKit needs to compile on .NET Framework 3.5 with PolyShim. PolyShim 2.9.0 is now required and provides polyfills for several APIs that previously required compiler guards.
Project targets
PowerKit.csproj:TargetFramework→TargetFrameworks, addingnet35,netstandard2.0, andnet10.0(order:netstandard2.0;net35;net10.0)PolyShim version
Updated to PolyShim 2.9.0, which adds net35 polyfills for:
Guid.TryParseTimeSpan.TryParse(string, IFormatProvider, out TimeSpan)Assembly.GetCustomAttribute<T>()Stream.CopyTo()PolyShim also provides
NamespaceDummies.cs, which declares dummy types inSystem.Threading.Tasks(and other namespaces) so thatusingdirectives for those namespaces always compile on all targets without any#ifguard.Method-level
#if NET40_OR_GREATER || NETSTANDARD || NETguardsThe guard is placed around individual methods inside the
extension(...)block rather than wrapping the whole file, so sync extensions can be added later without restructuring:AsyncEnumerableExtensions.csStreamExtensions.csCopyToAsyncoverloads insideextension(Stream source)TextReaderExtensions.csReadLinesAsyncinsideextension(TextReader reader)FileExtensions.csReadAllBytesAsyncoverloads insideextension(string path)Partial guards in
AssemblyExtensions.csNo whole-file guard needed. Sync methods (
TryGetVersionString,GetManifestResourceString,ExtractManifestResource) are unguarded thanks to PolyShim 2.9.0 polyfills. Only the async method bodies (GetManifestResourceStringAsync,ExtractManifestResourceAsync) remain under a#if NET40_OR_GREATER || NETSTANDARD || NETguard sinceTask/asyncrequires .NET 4.6+. Theusing System.Threading;andusing System.Threading.Tasks;directives are unconditional — PolyShim'sNamespaceDummies.csensures they compile on net35.ExceptionExtensions.cs— no whole-file guard neededPolyShim polyfills
AggregateException, so the file compiles on net35 without a guard.GetSelfAndDescendantsuses a guarded return type:IReadOnlyList<Exception>on modern targets (NET40_OR_GREATER || NETSTANDARD || NET) andIList<Exception>on net35 (available since .NET 2.0, no polyfill needed). The method body is shared and returns a concreteList<Exception>in both cases.Partial guards in
EnumerableExtensions.csThe
IReadOnlyList<T>fast-path inLastOrNullis guarded. InElementAtOrNull, the modern branch usesvar(inferred asIReadOnlyList<T>), while the net35 branch uses an explicitIList<T>so that.Countresolves to the interface property rather than the LINQ extension-method group onT[]: