question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Request: Honor `SupportedOSPlatformAttribute` when emitting `.g.c` file.

See original GitHub issue

Would be nice if this would work…

    public static Exports
    {
        [SupportedOSPlatform("windows")]
        [UnmanagedCallersOnly(EntryPoint = "GetPluginFactory")]
        public static IntPtr GetPluginFactory_Win()
        {  ...  }

        [SupportedOSPlatform("linux")]
        [UnmanagedCallersOnly(EntryPoint = "GetPluginFactory")]
        public static IntPtr GetPluginFactory_Lnx()
        {  ...  }

Currently (v1.0.23) there is an (C/C++) compiler error that indicates both variations are being emitted in the generated .c file. Windows error C2084: function 'intptr_t GetPluginFactory(void)' already has a body Linux error G94CD4D9A: redefinition of 'GetPluginFactory'

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

0reactions
jkoritzinskycommented, Sep 20, 2021

The canonical implementation for the platform attributes is as follows:

The attributes (Supported/UnsupportedOSPlatformAttribute) can each be applied at one of the following levels (generalized for simplicity):

  • Assembly
  • Module
  • Type declaration
  • Member declaration

At the highest level that any of the attributes are applied, either SupportedOSPlatformAttribute or UnsupportedOSPlatformAttribute may be applied. This defines an include/exclude list. Any deeper nested level (lower in the list) can apply UnsupportedOSPlatformAttribute to slim down the cases where the most global SupportedOSPlatformAttribute applies, or vice versa. Nested scopes cannot expand the include-list or exclude-list, only slim it down.

Here’s a link to the design doc for the attributes: https://github.com/dotnet/designs/blob/main/accepted/2020/platform-exclusion/platform-exclusion.md#design

Read more comments on GitHub >

github_iconTop Results From Across the Web

SupportedOSPlatformAttribute Class (System.Runtime. ...
Indicates that an API is supported for a specified platform or operating system. If a version is specified, the API cannot be called...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found