Skip to content

Use Sdks assembly Level Attributes for supported and unsupported platforms. #44257

Open

Description

@Anipik

We are no longer removing the platform from the targetFrameworkString for net5.0 and above, this results in sdk adding
SupportedOSPlatformAttribute & TargetPlatformAttribute to the assemblyInfo file. This conflicts with the attributes that we are adding on the api level.

We should define a repo wide policy going forward.

There is currently no flag in the sdk to disable writing this attribute while writing this assembly level attriibute. asking sdk team to provide a flag will also be helpful here.

cc @ViktorHofer @ericstj @buyaa-n @safern

Activity

  1. added
    untriaged
    on Nov 4, 2020
  2. Dotnet-GitSync-Bot commented on Nov 4, 2020

    @Dotnet-GitSync-Bot
    Collaborator

    I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

  3. ViktorHofer commented on Nov 4, 2020

    @ViktorHofer
    Member

    We should define a repo wide policy going forward.

    Does this even matter outside of libraries?

  4. removed
    untriaged
    on Nov 4, 2020
  5. added this to the 6.0.0 milestone on Nov 4, 2020
  6. ViktorHofer commented on Nov 11, 2020

    @ViktorHofer
    Member

    @buyaa-n @jeffhandley what are your thoughts on this? The SDK by default adds the in the top post mentioned attributes. Is there a reason to not have them? Presumably the TargetPlatformAttribute is less of a concern?

  7. ViktorHofer commented on Nov 11, 2020

    @ViktorHofer
    Member

    Another thought, are we concerned about the assembly metadata difference: SupportedOSPlatform (dotnet/runtime specific and already shipped with 5.0) vs SupportedOSPlatformAttribute (sdk style)?

  8. buyaa-n commented on Nov 19, 2020

    @buyaa-n
    Contributor

    The SDK by default adds the in the top post mentioned attributes. Is there a reason to not have them?

    The reason for not having them is false positives mentioned in this issue, I have no good way (non-hack like) of handling those, the question if it could happen outside of runtime, if not i thinke its just better to keep disabling the sdk logic cc @terrajobst

    Presumably the TargetPlatformAttribute is less of a concern?

    I don't think there is a concern, the analyzer not using that attribute at all

  9. buyaa-n commented on Nov 30, 2020

    @buyaa-n
    Contributor

    I think we should reenable SupportedOSPlatformAttribute attributes added by sdk, most of the warning are found in Browser build which i think is the only target we should disable/remove adding the attribute. The details how to handle the warnings introduced are commented here. By enabling the sdk attribute back

    • We will have the attribute for windows build from sdk, which we added to suppress warnings on windows build
      <ItemGroup Condition="('$(IsWindowsSpecific)' == 'true' or '$(TargetsWindows)' == 'true') and '$(IsTestProject)' != 'true'">
      <AssemblyAttribute Include="System.Runtime.Versioning.SupportedOSPlatform">
      <_Parameter1>windows</_Parameter1>
      </AssemblyAttribute>
    • We will have the attribute for other build targets like linux, ios etc. For now we have no any APIs attributed with those platforms but they are coming soon, so having corresponding attributes added by MSBuild would help with seeing warning for existing platform inconsistency and suppress warnings for proper usage of platform specific APIs in runtime repo
  10. buyaa-n commented on Jan 7, 2021

    @buyaa-n
    Contributor

    @ViktorHofer @Anipik I see the TFM targets platforms other than windows is not really working, for non-runtime env, for example with simple console app i cannot use Browser or ios or Linux, Android platforms as a target. The error message: C:\Program Files\dotnet\sdk\5.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(109,5): error NETSDK1139: The target platform identifier iOS was not recognized. How/why it is able to work in runtime?

  11. buyaa-n commented on Jan 7, 2021

    @buyaa-n
    Contributor

    Never mind i see the new identifiers added here

    <PropertyGroup Condition="'$(TargetFrameworkSuffix)' != '' and '$(TargetFrameworkSuffix)' != 'windows'">
    <TargetPlatformIdentifier>$(TargetFrameworkSuffix)</TargetPlatformIdentifier>
    <TargetPlatformVersion>0.0</TargetPlatformVersion>
    <TargetPlatformMoniker>$(TargetFrameworkSuffix),Version=$(TargetPlatformVersion)</TargetPlatformMoniker>
    </PropertyGroup>

  12. Anipik commented on Aug 4, 2021

    @Anipik
    ContributorAuthor

    @buyaa-n is this still an issue ?

  13. buyaa-n commented on Aug 4, 2021

    @buyaa-n
    Contributor

    There is nothing more left until dotnet/sdk#14836 implemented and using that feature for disabling TFM attribute in test projects

  14. modified the milestones: 6.0.0, 7.0.0 on Aug 4, 2021
  15. modified the milestones: 7.0.0, Future on Jul 20, 2022
  16. removed their assignment
    on Jul 22, 2024
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

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions