未验证 提交 09f075ff 编写于 作者: B Buyaa Namnan 提交者: GitHub

Resolve unknown platform name warnings (#50193)

* Add targets as supported platforms

* Update analyzer version

* Update comment, remove '' != 'false' condition
上级 da23d5a6
......@@ -45,7 +45,7 @@
<ProjectServicingConfiguration Include="Microsoft.NETCore.App.Ref" PatchVersion="0" />
</ItemGroup>
<PropertyGroup>
<MicrosoftCodeAnalysisNetAnalyzersVersion>6.0.0-preview3.21158.1</MicrosoftCodeAnalysisNetAnalyzersVersion>
<MicrosoftCodeAnalysisNetAnalyzersVersion>6.0.0-preview3.21168.1</MicrosoftCodeAnalysisNetAnalyzersVersion>
<MicrosoftCodeAnalysisCSharpCodeStyleVersion>3.9.0-5.final</MicrosoftCodeAnalysisCSharpCodeStyleVersion>
<MicrosoftCodeAnalysisCSharpVersion>3.9.0-5.final</MicrosoftCodeAnalysisCSharpVersion>
<!-- Arcade dependencies -->
......
......@@ -9,6 +9,8 @@
<TargetPlatformIdentifier>$(TargetFrameworkSuffix)</TargetPlatformIdentifier>
<TargetPlatformVersion>1.0</TargetPlatformVersion>
<TargetPlatformMoniker>$(TargetFrameworkSuffix),Version=$(TargetPlatformVersion)</TargetPlatformMoniker>
<!-- Value of 0.0 produces versionless SupportedOSPlatform attribute, which is important for platforms not expected to have a version -->
<SupportedOSPlatformVersion>0.0</SupportedOSPlatformVersion>
</PropertyGroup>
<Choose>
......
......@@ -47,17 +47,27 @@
<ItemGroup Condition="('$(TargetsBrowser)' == 'true' or '$(CrossPlatformAndHasNoBrowserTarget)' == 'true') and '$(IsTestProject)' != 'true'">
<SupportedPlatform Include="browser"/>
</ItemGroup>
<!-- Enables warnings for tvOS targeted builds -->
<ItemGroup Condition="'$(TargetstvOS)' == 'true' and '$(IsTestProject)' != 'true'">
<SupportedPlatform Include="tvos"/>
<!-- Add target platforms into MSBuild SupportedPlatform list -->
<ItemGroup Condition="'$(TargetsAnyOS)' != 'true' and '$(IsTestProject)' != 'true'">
<SupportedPlatform Condition="'$(Targetsillumos)' == 'true'" Include="illumos"/>
<SupportedPlatform Condition="'$(TargetsSolaris)' == 'true'" Include="Solaris"/>
<SupportedPlatform Condition="'$(TargetstvOS)' == 'true'" Include="tvOS"/>
<SupportedPlatform Condition="'$(TargetsUnix)' == 'true'" Include="Unix"/>
</ItemGroup>
<ItemGroup>
<_unsupportedOSPlatforms Include="$(UnsupportedOSPlatforms)" />
</ItemGroup>
<Target Name="AddUnsupportedOSPlatformAttribute" BeforeTargets="GenerateAssemblyInfo" AfterTargets="PrepareForBuild" Condition="'@(_unsupportedOSPlatforms)' != '' and '$(IsTestProject)' != 'true' and '$(IncludePlatformAttributes)' != 'false'">
<!-- Adds UnsupportedOSPlatform attribute to the assembly when:
* At least one <UnsupportedOSPlatforms /> has been specified
* This isn't a test project
* This is a cross-platform target
* The build isn't targeting .NET Framework
-->
<Target Name="AddUnsupportedOSPlatformAttribute" BeforeTargets="GenerateAssemblyInfo" AfterTargets="PrepareForBuild"
Condition="'@(_unsupportedOSPlatforms)' != '' and '$(TargetsAnyOS)' == 'true' and '$(IsTestProject)' != 'true' and '$(TargetFrameworkIdentifier)' != '.NETFramework'">
<ItemGroup>
<AssemblyAttribute Include="System.Runtime.Versioning.UnsupportedOSPlatform">
<_Parameter1>%(_unsupportedOSPlatforms.Identity)</_Parameter1>
......
......@@ -15,7 +15,9 @@ namespace Microsoft.Diagnostics.Tracing
namespace System.Diagnostics.Tracing
#endif
{
#if NETCOREAPP
[UnsupportedOSPlatform("browser")]
#endif
internal sealed class CounterGroup
{
private readonly EventSource _eventSource;
......
......@@ -20,7 +20,9 @@ namespace System.Diagnostics.Tracing
/// DiagnosticCounter is an abstract class that serves as the parent class for various Counter* classes,
/// namely EventCounter, PollingCounter, IncrementingEventCounter, and IncrementingPollingCounter.
/// </summary>
#if NETCOREAPP
[UnsupportedOSPlatform("browser")]
#endif
public abstract class DiagnosticCounter : IDisposable
{
/// <summary>
......
......@@ -24,7 +24,9 @@ namespace System.Diagnostics.Tracing
/// See https://github.com/dotnet/runtime/blob/main/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestEventCounter.cs
/// which shows tests, which are also useful in seeing actual use.
/// </summary>
#if NETCOREAPP
[UnsupportedOSPlatform("browser")]
#endif
public partial class EventCounter : DiagnosticCounter
{
/// <summary>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册