Repository navigation
Make some lib projects platform-agnostic - #132218
Conversation
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @karelz, @dotnet/ncl |
|
Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it. |
linux, freebsd, openbsd and haiku compiled the identical OpenSSL code path; build them as a single unix flavor.
linux and freebsd compiled the same sources; platform differences are already handled at runtime in msquic.cs. Remove the unused SOCKADDR_HAS_LENGTH define and the FreeBSD Interop.Libraries.cs which only duplicated the MsQuic library name.
linux, freebsd and openbsd shared the inotify implementation; build it as a single unix flavor and keep osx/maccatalyst on FSEvents. Throw PlatformNotSupportedException when inotify is unavailable instead of a generic IOException.
Build the OpenLDAP implementation for unix instead of linux only.
Replace the linux, freebsd, openbsd, illumos, solaris and haiku flavors with a single unix flavor that selects the Linux or BSD implementation via OperatingSystem checks, which are JIT/trim time constants. NetworkChange.IsSupported becomes a partial property so the unix flavor can compute it.
|
Azure Pipelines: Successfully started running 4 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
@jkotas, I've reworked it; published apps have no difference in size. There is a small 17.5 KB increase in shared framework size because in "library mode" we use ref assemblies and |
17.5 kB is not prohibitive on its own. The challenge is that this approach doesn't scale. So far, we've preferred build-time checks to exclude OS-specific types rather than relying on runtime checks. If we were to start favoring runtime checks more broadly, the cumulative size increase will be much more significant. This PR moves us away from having consistent preference. How are we going to decide between build-time and runtime checks for OS-specific types going forward? |
I don't think this framing is accurate because we are using mixed bag of #if TARGET_FOO and if (OperatingSystem.IsFoo()) in libraries (in my estimation, we are using OS.IsFoo more these days). Secondly, we have only five non-corelib projects left using per unix-flavor TPM. After this PR, there will be one. Also, trimming of OperatingSystem.IsXX in library mode is a illinker.targets fix, which levels the assembly size (I have it locally). |
Could you please submit this fix in a separate PR? This refactoring will be much easier to accept once there is no size regression. |
There was a problem hiding this comment.
🔵 Needs a closer look
The resolver registration can conflict with an existing application resolver, causing static initialization to fail and breaking LDAP and BER operations; a composable fallback and regression test are needed.
No open issues 🎉
What changed in this PR
This PR consolidates several library projects onto shared Unix targets, reducing OS-specific build variants while retaining runtime platform selection and unsupported-platform behavior.
Changes:
- Replace individual Unix targets with shared
-unixtargets in library and test projects. - Consolidate network-information dispatch and OpenLDAP implementation files.
- Update native-library loading, unsupported-platform handling, and test exclusions.
| File | Description |
|---|---|
| src/libraries/tests.proj | Clarifies the QUIC test-exclusion comment. |
| src/libraries/System.Net.Security/src/System.Net.Security.csproj | Consolidates Unix build targets. |
| src/libraries/System.Net.Quic/tests/FunctionalTests/System.Net.Quic.Functional.Tests.csproj | Uses the shared Unix test target. |
| src/libraries/System.Net.Quic/src/System.Net.Quic.csproj | Consolidates Unix sources and adds explicit unsupported Apple-mobile targets. |
| src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkInterfacePal.UnknownUnix.cs | Removes the separate unsupported-platform implementation. |
| src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkInterfacePal.Unix.cs | Selects Linux or BSD interfaces at runtime. |
| src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Windows.cs | Supplies Windows notification support status. |
| src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.UnknownUnix.cs | Removes the separate unsupported notification implementation. |
| src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Unix.cs | Adds runtime support checks for notifications. |
| src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.OSX.cs | Supplies Apple notification support status. |
| src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.cs | Makes support status platform-implemented. |
| src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Android.cs | Supplies Android notification support status. |
| src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPGlobalPropertiesPal.Unix.cs | Selects Linux or BSD global properties at runtime. |
| src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPGlobalPropertiesPal.Linux.cs | Removes the Linux-only factory. |
| src/libraries/System.Net.NetworkInformation/src/System.Net.NetworkInformation.csproj | Combines Linux and BSD implementations in the Unix target. |
| src/libraries/System.IO.FileSystem.Watcher/tests/System.IO.FileSystem.Watcher.Tests.csproj | Consolidates Unix test targets and source selection. |
| src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.Linux.cs | Maps unsupported inotify initialization to a platform exception. |
| src/libraries/System.IO.FileSystem.Watcher/src/System.IO.FileSystem.Watcher.csproj | Consolidates Unix targets and preserves unsupported Apple-mobile variants. |
| src/libraries/System.DirectoryServices.Protocols/tests/System.DirectoryServices.Protocols.Tests.csproj | Uses a Unix target and excludes Apple-mobile CI runs. |
| src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapSessionOptions.Unix.cs | Provides session options under the Unix implementation name. |
| src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapConnection.Unix.cs | Provides connection handling under the Unix implementation name. |
| src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/Interop/SafeHandles.Unix.cs | Provides Unix LDAP and BER handle management. |
| src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/Interop/LdapPal.Unix.cs | Provides the shared Unix LDAP abstraction. |
| src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/Interop/BerPal.Unix.cs | Provides the shared Unix BER abstraction. |
| src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/QuotaControl.Unix.cs | Provides Unix quota-control behavior. |
| src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/BerConverter.Unix.cs | Provides Unix bit-string decoding behavior. |
| src/libraries/System.DirectoryServices.Protocols/src/System.DirectoryServices.Protocols.csproj | Selects shared Unix sources and unsupported Apple-mobile variants. |
| src/libraries/Common/src/Interop/Unix/OpenLdap/Interop.Ldap.cs | Centralizes the OpenLDAP import name and changes library resolution. |
| src/libraries/Common/src/Interop/Unix/OpenLdap/Interop.Ber.cs | Places BER interop in the shared Unix location. |
| src/libraries/Common/src/Interop/OSX/Interop.Libraries.cs | Removes the platform-specific OpenLDAP constant. |
| src/libraries/Common/src/Interop/Linux/Interop.Libraries.cs | Removes the platform-specific OpenLDAP constant. |
| src/libraries/Common/src/Interop/FreeBSD/Interop.Libraries.cs | Removes the redundant FreeBSD MsQuic constant file. |
Review effort: Balanced
No description provided.