未验证 提交 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 @@ ...@@ -45,7 +45,7 @@
<ProjectServicingConfiguration Include="Microsoft.NETCore.App.Ref" PatchVersion="0" /> <ProjectServicingConfiguration Include="Microsoft.NETCore.App.Ref" PatchVersion="0" />
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>
<MicrosoftCodeAnalysisNetAnalyzersVersion>6.0.0-preview3.21158.1</MicrosoftCodeAnalysisNetAnalyzersVersion> <MicrosoftCodeAnalysisNetAnalyzersVersion>6.0.0-preview3.21168.1</MicrosoftCodeAnalysisNetAnalyzersVersion>
<MicrosoftCodeAnalysisCSharpCodeStyleVersion>3.9.0-5.final</MicrosoftCodeAnalysisCSharpCodeStyleVersion> <MicrosoftCodeAnalysisCSharpCodeStyleVersion>3.9.0-5.final</MicrosoftCodeAnalysisCSharpCodeStyleVersion>
<MicrosoftCodeAnalysisCSharpVersion>3.9.0-5.final</MicrosoftCodeAnalysisCSharpVersion> <MicrosoftCodeAnalysisCSharpVersion>3.9.0-5.final</MicrosoftCodeAnalysisCSharpVersion>
<!-- Arcade dependencies --> <!-- Arcade dependencies -->
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
<TargetPlatformIdentifier>$(TargetFrameworkSuffix)</TargetPlatformIdentifier> <TargetPlatformIdentifier>$(TargetFrameworkSuffix)</TargetPlatformIdentifier>
<TargetPlatformVersion>1.0</TargetPlatformVersion> <TargetPlatformVersion>1.0</TargetPlatformVersion>
<TargetPlatformMoniker>$(TargetFrameworkSuffix),Version=$(TargetPlatformVersion)</TargetPlatformMoniker> <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> </PropertyGroup>
<Choose> <Choose>
......
...@@ -47,17 +47,27 @@ ...@@ -47,17 +47,27 @@
<ItemGroup Condition="('$(TargetsBrowser)' == 'true' or '$(CrossPlatformAndHasNoBrowserTarget)' == 'true') and '$(IsTestProject)' != 'true'"> <ItemGroup Condition="('$(TargetsBrowser)' == 'true' or '$(CrossPlatformAndHasNoBrowserTarget)' == 'true') and '$(IsTestProject)' != 'true'">
<SupportedPlatform Include="browser"/> <SupportedPlatform Include="browser"/>
</ItemGroup> </ItemGroup>
<!-- Enables warnings for tvOS targeted builds --> <!-- Add target platforms into MSBuild SupportedPlatform list -->
<ItemGroup Condition="'$(TargetstvOS)' == 'true' and '$(IsTestProject)' != 'true'"> <ItemGroup Condition="'$(TargetsAnyOS)' != 'true' and '$(IsTestProject)' != 'true'">
<SupportedPlatform Include="tvos"/> <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>
<ItemGroup> <ItemGroup>
<_unsupportedOSPlatforms Include="$(UnsupportedOSPlatforms)" /> <_unsupportedOSPlatforms Include="$(UnsupportedOSPlatforms)" />
</ItemGroup> </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> <ItemGroup>
<AssemblyAttribute Include="System.Runtime.Versioning.UnsupportedOSPlatform"> <AssemblyAttribute Include="System.Runtime.Versioning.UnsupportedOSPlatform">
<_Parameter1>%(_unsupportedOSPlatforms.Identity)</_Parameter1> <_Parameter1>%(_unsupportedOSPlatforms.Identity)</_Parameter1>
......
...@@ -15,7 +15,9 @@ namespace Microsoft.Diagnostics.Tracing ...@@ -15,7 +15,9 @@ namespace Microsoft.Diagnostics.Tracing
namespace System.Diagnostics.Tracing namespace System.Diagnostics.Tracing
#endif #endif
{ {
#if NETCOREAPP
[UnsupportedOSPlatform("browser")] [UnsupportedOSPlatform("browser")]
#endif
internal sealed class CounterGroup internal sealed class CounterGroup
{ {
private readonly EventSource _eventSource; private readonly EventSource _eventSource;
......
...@@ -20,7 +20,9 @@ namespace System.Diagnostics.Tracing ...@@ -20,7 +20,9 @@ namespace System.Diagnostics.Tracing
/// DiagnosticCounter is an abstract class that serves as the parent class for various Counter* classes, /// DiagnosticCounter is an abstract class that serves as the parent class for various Counter* classes,
/// namely EventCounter, PollingCounter, IncrementingEventCounter, and IncrementingPollingCounter. /// namely EventCounter, PollingCounter, IncrementingEventCounter, and IncrementingPollingCounter.
/// </summary> /// </summary>
#if NETCOREAPP
[UnsupportedOSPlatform("browser")] [UnsupportedOSPlatform("browser")]
#endif
public abstract class DiagnosticCounter : IDisposable public abstract class DiagnosticCounter : IDisposable
{ {
/// <summary> /// <summary>
......
...@@ -24,7 +24,9 @@ namespace System.Diagnostics.Tracing ...@@ -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 /// 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. /// which shows tests, which are also useful in seeing actual use.
/// </summary> /// </summary>
#if NETCOREAPP
[UnsupportedOSPlatform("browser")] [UnsupportedOSPlatform("browser")]
#endif
public partial class EventCounter : DiagnosticCounter public partial class EventCounter : DiagnosticCounter
{ {
/// <summary> /// <summary>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册