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.

Provide a standard item group for OS platforms

See original GitHub issue

We’ve built an analyzer that allows an API to be marked as unsupported for a given set of platforms. We’re going to use this to mark APIs that we can’t make work in Blazor WebAssembly.

In the Blazor case, there are many cuts and they cut deep (threading or file I/O). We don’t want an experience where developers of normal cross-platform class libraries or console apps are confronted with a myriad of diagnostics these APIs don’t work in WebAssembly – most developers don’t need their code to run in those environment.

We intend to address this experience by allowing the developer to include and exclude platforms that the analyzer will consider. Since we want developers to add an remove from the default set, it sees an item group is much more natural fit than a property:

Desired experience:

  1. The base SDK includes a standard set, such as:
    <ItemGroup>
        <SupportedPlatform Include="android" />
        <SupportedPlatform Include="ios" />
        <SupportedPlatform Include="linux" />
        <SupportedPlatform Include="macos" />
        <SupportedPlatform Include="windows" />
    </ItemGroup>
    
  2. The Blazor SDK changes that set:
    <ItemGroup>
        <SupportedPlatform Include="browser" />
    </ItemGroup>
    
  3. Developers can do this manually in the project file, if, for example, they are building a class library for Blazor:
    <ItemGroup>
        <SupportedPlatform Include="browser" />
    </ItemGroup>
    
  4. Developers can also manually remove platforms from the project file that they don’t care about:
    <ItemGroup>
        <SupportedPlatform Remove="macos" />
    </ItemGroup>
    

Questions

  • The name seems to conflict with the existing item groups in the SDK has: SupportedTargetFramework and SupportedTargetPlatform. So maybe we should call this one AnalyzedPlatform?

  • The assumption is that there is a way to pass this to the Roslyn analyzer. @mavasani is looking into that.

/cc @dsplaisted @mavasani @buyaa-n @jeffhandley @eerhardt

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
mavasanicommented, Aug 4, 2020

Analyzer support is now checked into roslyn-analyzers repo. It uses the item name SupportedPlatform - if that is changed, @buyaa-n please rename the field declared at https://github.com/dotnet/roslyn-analyzers/blob/31fe7d4b7dbf85609426f49861ca58f0d2d04b3b/src/Utilities/Compiler/Options/MSBuildItemOptionNames.cs#L21 accordingly.

1reaction
mavasanicommented, Aug 4, 2020

I have a PR out to add this support to NuGet packages built out of analyzers repo: https://github.com/dotnet/roslyn-analyzers/pull/3950

@chsienki just as an FYI, ; separated list does not work as that is the comment character for editorconfig, so only the first entry gets retained in the analyzer options. I instead used the , char as separator. @terrajobst to confirm that we don’t expect a , char in any supported platform name.

<Project>
  <!-- MSBuild item metadata to thread to the analyzers as options -->
  <PropertyGroup>
    <_SupportedPlatformList>@(SupportedPlatform, ',')</_SupportedPlatformList>
  </PropertyGroup>

  <!-- MSBuild properties to thread to the analyzers as options --> 
  <ItemGroup>
    <CompilerVisibleProperty Include="_SupportedPlatformList" />
  </ItemGroup>
</Project>
Read more comments on GitHub >

github_iconTop Results From Across the Web

MSBuild reference for .NET SDK projects
Reference for the MSBuild properties and items that are understood by the .NET SDK.
Read more >
Configure projects to target platforms - Visual Studio
Learn how Visual Studio enables you to set up your applications to target different platforms, including the Arm64 platform.
Read more >
Products to Platforms: Making the Leap
Make it tough for rivals to copy your product-to-platform strategy: Consider creating proprietary standards, using exclusivity contracts, and erecting other ...
Read more >
What is an Operating System (OS)? Definition, Types ...
The OS identifies and configures physical and logical devices for service and typically records them in a standardized structure, such as Windows Registry. ......
Read more >
os — Miscellaneous operating system interfaces
os.uname() gives system-dependent version information. The platform module provides detailed checks for the system's identity. File Names, Command Line ...
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