reactiveui / ReactiveUI.SourceGenerators

Use source generators to generate objects.
MIT License
31 stars 3 forks source link

Remove IsExternalInit #96

Closed glennawatson closed 3 weeks ago

glennawatson commented 4 weeks ago

As per the comment below we likely should remove the ExternalInit generation in our code, and opt for instead readme.md file changes to suggest the user use one of the different libraries that provide it like PolyFill or ExternalInit etc.

@ChrisPulman Hi, this PR seems incomplete/wrong, because it prevents usage of source packages like Polyfill due to duplicate definition of IsExternalInit.

There are some solutions:

  1. Never add IsExternalInit and let the developer choose the IsExternalInit implementation (and maybe add a FAQ and issue (closed) for the resulting error message
  2. Don't emit IsExternalInit and just use get; set; instead of get; init;
  3. Guard the implementation with a #if !REACTIVEUI_NO_ISEXTERNALINIT or something like that
  4. Allow setting a configuration in the csproj file to deactivate emitting IsExternalInit, similar to what PolySharp does

Originally posted by @fubar-coder in https://github.com/reactiveui/ReactiveUI.SourceGenerators/issues/83#issuecomment-2439771862

fubar-coder commented 4 weeks ago

Just an additional solution (not preferred):

It seems that using PolySharp works fine, but isn't as "complete" as Polyfill. My assumption is, that the source generator of PolySharp only emits the IsExternalInit class if it isn't already defined in the project. This may or may not cause problems, when you have a dependency (library) which defines IsExternalInit publicly (due to - for example - a set PolyPublic option for Polyfill).

glennawatson commented 3 weeks ago

Normally I use PrivateAssets="all" and then normally make use that IsExternalInit is internal only.

github-actions[bot] commented 1 week ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.