dotnet / dotnet/winforms

Layering related functionality is awkward

Open
#10,603 0 comments 0 reactions 1 assignee Claimed by @JeremyKuhne View on GitHub
tracking-external-issue
Dominant language
C#
Stars
4.9k
Forks
1.1k
Avg merge
20h 23m
Merged PRs (30d)
103

Description

We have a number of assemblies that we produce where we share common static functionality that logically belongs together. Static classes contain this functionality but require naming changes and/or namespace isolation to implement. This is becoming even more awkward with the introduction of a shared interop assembly with System.Drawing.

For example, CsWin32 generates a static class for imports (defaulting to `PInvoke`). We have to have it generate different names now that we are using CsWin32 on multiple levels of the assembly dependency hierarchy. Currently we use `PInvokeCore` for the shared assembly and `PInvoke` for the upper layers.

A similar thing occurs for helper classes such as `ScaleHelper`. We'll follow the same pattern (`ScaleHelperCore`) and (`ScaleHelper`) for non-shared functionality, but that only scales to two layers. For `System.Windows.Forms.Design` we have 4 layers of assemblies now.

Ideally, we'd be able to "append" functionality to a common static base type, much like extension methods do. C# is considering something that might make this possible:

https://github.com/dotnet/csharplang/issues/5497
https://github.com/dotnet/csharplang/blob/1f55d3c05d549edc817589502bfee90db887d56e/proposals/extensions.md

If and when this is implemented, we should clean up our static helpers to allow using single, common names. A follow up should be made with CsWin32 to find a way to specify that we want the `PInvoke` class as an extension class.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.