Skip to content

Declare a MetalamaPlatformRequirement for the packages whose supported platforms are stricter than the framework's #1887

Description

@sharpcrafters-agent

Summary

#1884 introduces the MetalamaPlatformRequirement item and seeds it for Metalama.Framework alone. The comment
on that issue lists four packages of this repository whose requirement is stricter than the framework's, and
records that adding their contributions in a follow-up issue is the acceptable order:

If the plain check has to ship sooner, the fallback is to implement the target so that it reads
@(MetalamaPlatformRequirement) from the start, seed the item from Metalama.Framework alone, and add the
contributions of the four packages listed above in a follow-up issue. The documentation of the item as a public
contract can then follow in that second issue.

This is that follow-up issue. The mechanism shipped in #1886 and is documented in
metalama/Metalama.Documentation#290.

The packages that should declare a requirement

Package Why its requirement is stricter
Metalama.Patterns.Wpf It declares net472;net8.0-windows, which #1876 turns into net472;net10.0-windows. It has no netstandard2.0 asset and it requires the Windows platform, so it is narrower than the framework on two dimensions at once. This is the motivating case, and #1876 records it as a breaking change.
Metalama.LinqPad It targets net8.0-windows, which becomes net10.0-windows. Its requirement follows the LINQPad host rather than the framework.
Metalama.Extensions.DiffEngine It already selects assets per target framework through MetalamaExtensionAssembly, so it has a requirement to state and already has the build folder to state it in.
Metalama.Extensions.HtmlWriter The same.

The Metalama.Patterns.* packages that declare netstandard2.0 beside the .NET target framework have the same
requirement as the framework and should declare nothing. None of them has a build folder today, and none should
gain one for this.

What has to be done

For each of the four packages, add a MetalamaPlatformRequirement item to its build/<PackageId>.props and to
the same file under buildTransitive. Metalama.Patterns.Wpf and Metalama.LinqPad have no build folder yet,
so this issue creates one for them, which is a packaging change and needs its own verification that the props file
reaches the consumer.

The item must be declared in a .props file rather than a .targets file. NuGet imports the build props of
every package before it reads any targets file, so the check sees every contribution whatever the order in which
NuGet imports the packages.

Order with respect to #1876

The values to declare are the target frameworks that #1876 leaves each package with. Doing this issue before
#1876 would declare values that #1876 immediately changes, so this issue should follow #1876.

Acceptance criteria

  • A project that targets net10.0 without the Windows platform and references Metalama.Patterns.Wpf reports
    LAMA0600 naming Metalama.Patterns.Wpf.
  • A project that targets net10.0-windows and references Metalama.Patterns.Wpf reports nothing.
  • MetalamaSupportedPlatformExclusion with Metalama.Patterns.Wpf suppresses that warning and leaves the
    warning of Metalama.Framework, if any, in place.
  • Building this repository reports none of these warnings.
  • The MetalamaPlatformRequirement item is documented as a public contract that a third-party package may use,
    with the compatibility obligations that Warn when the target framework, the .NET SDK or the Visual Studio version is outside the tested support matrix #1884 records: unknown metadata is ignored, and absent metadata means no
    constraint.

— Claude for Gaël Fraiteur (@gfraiteur)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects