Skip to content

Mark APIs as unsupported on Browser WASM #41087

Closed

Description

@MaximLipnin

We can use UnsupportedOSPlatformAttribute("browser") attribute to mark unsupported APIs on Browser WASM so that the analyzer can provide warnings when developers accidentally call platform-specific APIs.
Spec: dotnet/designs#144

We use the scanner (https://github.com/dotnet/platform-compat) to gather the list of all the APIs throwing PNSE on Browser WASM at the moment. Below is the file containing ~4500 PNSE methods.
pnse-17082020.txt

There can be some special cases:

  • APIs can be Windows-specific
  • APIs might throw PNSE for all platforms
  • APIs might not be considered to be marked (e.g. APIs are not meant to be directly called by user code)
  • other cases?

Namespaces (L# in file above)

cc @steveisok @lewing

Activity

  1. added
    untriaged
    on Aug 20, 2020
  2. Dotnet-GitSync-Bot commented on Aug 20, 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. added
    arch-wasm
    and removed
    untriaged
    on Aug 20, 2020
  4. CoffeeFlux commented on Aug 21, 2020

    @CoffeeFlux
    Contributor

    area-VM-meta-mono seems like the wrong area for this since it's purely libraries, but I'm not sure what to use for something that applies to libraries as a whole. area-Meta also seems wrong...

  5. added this to the 6.0.0 milestone on Aug 21, 2020
  6. akoeplinger commented on Aug 24, 2020

    @akoeplinger
    Member

    @jeffhandley @adamsitnik while adding the [UnsupportedOSPlatform] attributes to the src a question came up what to do when the method we're annotating has multiple implementations (e.g. .Browser.cs, .Unix.cs and .Windows.cs).

    Should we add the attribute to all the implementations in those cases? If we don't do that then regenerating the ref would remove the attribute if you're on a different platform.

  7. jeffhandley commented on Aug 24, 2020

    @jeffhandley
    Member

    I've been encountering similar stuff with #41209, where we're trying to get the runtime repo ready to receive the analyzer. We don't yet have a solid strategy for this scenario.

  8. adamsitnik commented on Aug 25, 2020

    @adamsitnik
    Member

    Should we add the attribute to all the implementations in those cases?

    This is what we have been doing so far.

  9. jeffhandley commented on Aug 26, 2020

    @jeffhandley
    Member

    We have now filed #41354 against the runtime repo to resolve the issues there for RC2.

  10. MaximLipnin commented on Sep 16, 2020

    @MaximLipnin
    ContributorAuthor

    It looks like the exception scanner doesn't gather PNSEs thrown from runtime, e.g. something that uses mono_error_set_platform_not_supported method. At least, I don't see appropriate APIs in the result file attached to the PR's description. In case of Browser, an example of such API could be Thread.Start() which invokes StartInternal -> ves_icall_System_Threading_Thread_StartInternal -> mono_error_set_platform_not_supported .

  11. sigmarsson commented on May 5, 2021

    @sigmarsson

    Hi Seniors, Is there an alternative way to retrieve assembly version info on Wasm instead of FileVersionInfo ?
    That is not supported any more in the browser.

    unoplatform/uno#5916

  12. marek-safar commented on May 5, 2021

    @marek-safar
    Contributor

    @sigmarsson what about using RuntimeEnvironment.GetSystemVersion () ?

  13. sigmarsson commented on May 5, 2021

    @sigmarsson

    @marek-safar i wish to retrieve either the calling or the executing assembly version.

  14. sigmarsson commented on May 5, 2021

    @sigmarsson

    E.g.

    image

  15. marek-safar commented on May 5, 2021

    @marek-safar
    Contributor

    I see, in that case, the closest approximation would be to read System.Reflection.AssemblyFileVersionAttribute from the assembly.

  16. MaximLipnin commented on May 12, 2021

    @MaximLipnin
    ContributorAuthor

    All the namespaces mentioned in this issue are covered so I'm closing it as completed

  17. ghost locked as resolved and limited conversation to collaborators on Jun 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions