Sergio0694 / PolySharp

PolySharp provides generated, source-only polyfills for C# language features, to easily use all runtime-agnostic features downlevel. Add a reference, set your C# version to latest and have fun! 🚀
MIT License
1.77k stars 46 forks source link

`UnreachableException` polyfill #60

Open alexrp opened 1 year ago

alexrp commented 1 year ago

This exception is not really intended to be caught as it being thrown indicates that something has gone horribly wrong, like a Debug.Assert() failing or Environment.FailFast() being called.

I have several code paths in some of my analyzer and source generator projects where throwing UnreachableException is the obvious thing to do, but the type is net7.0 only.

dnperfors commented 1 year ago

I have a separate package for this, but I am willing to include it in pollysharp.. (https://github.com/dnperfors/unreachableexception/)