未验证 提交 5d702f87 编写于 作者: B Buyaa 提交者: GitHub

Fix new warnings (#43097)

* Fix CA1416 warnings in runtime repo
上级 75090807
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup Condition="'$(RunAnalyzers)' != 'false'"> <ItemGroup Condition="'$(RunAnalyzers)' != 'false'">
<PackageReference Include="Microsoft.DotNet.CodeAnalysis" Version="$(MicrosoftDotNetCodeAnalysisVersion)" PrivateAssets="all" IsImplicitlyDefined="true" /> <PackageReference Include="Microsoft.DotNet.CodeAnalysis" Version="$(MicrosoftDotNetCodeAnalysisVersion)" PrivateAssets="all" IsImplicitlyDefined="true" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="5.0.0-rtm.20502.2" PrivateAssets="all" /> <PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="$(MicrosoftCodeAnalysisNetAnalyzersVersion)" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="3.8.0-4.20503.2" PrivateAssets="all" /> <PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="$(MicrosoftCodeAnalysisCSharpCodeStyleVersion)" PrivateAssets="all" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.205" PrivateAssets="all" /> <PackageReference Include="StyleCop.Analyzers" Version="$(StyleCopAnalyzersVersion)" PrivateAssets="all" />
</ItemGroup> </ItemGroup>
</Project> </Project>
...@@ -51,6 +51,8 @@ ...@@ -51,6 +51,8 @@
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>
<!-- Arcade dependencies --> <!-- Arcade dependencies -->
<MicrosoftCodeAnalysisNetAnalyzersVersion>6.0.0-preview1.20513.4</MicrosoftCodeAnalysisNetAnalyzersVersion>
<MicrosoftCodeAnalysisCSharpCodeStyleVersion>3.8.0-4.20503.2</MicrosoftCodeAnalysisCSharpCodeStyleVersion>
<MicrosoftDotNetApiCompatVersion>5.0.0-beta.20506.7</MicrosoftDotNetApiCompatVersion> <MicrosoftDotNetApiCompatVersion>5.0.0-beta.20506.7</MicrosoftDotNetApiCompatVersion>
<MicrosoftDotNetBuildTasksFeedVersion>5.0.0-beta.20506.7</MicrosoftDotNetBuildTasksFeedVersion> <MicrosoftDotNetBuildTasksFeedVersion>5.0.0-beta.20506.7</MicrosoftDotNetBuildTasksFeedVersion>
<MicrosoftDotNetCodeAnalysisVersion>5.0.0-beta.20506.7</MicrosoftDotNetCodeAnalysisVersion> <MicrosoftDotNetCodeAnalysisVersion>5.0.0-beta.20506.7</MicrosoftDotNetCodeAnalysisVersion>
...@@ -69,6 +71,7 @@ ...@@ -69,6 +71,7 @@
<!-- CoreClr dependencies --> <!-- CoreClr dependencies -->
<MicrosoftNETCoreILAsmVersion>5.0.0-preview.8.20359.4</MicrosoftNETCoreILAsmVersion> <MicrosoftNETCoreILAsmVersion>5.0.0-preview.8.20359.4</MicrosoftNETCoreILAsmVersion>
<!-- Libraries dependencies --> <!-- Libraries dependencies -->
<StyleCopAnalyzersVersion>1.2.0-beta.205</StyleCopAnalyzersVersion>
<SystemBuffersVersion>4.5.1</SystemBuffersVersion> <SystemBuffersVersion>4.5.1</SystemBuffersVersion>
<SystemCollectionsVersion>4.3.0</SystemCollectionsVersion> <SystemCollectionsVersion>4.3.0</SystemCollectionsVersion>
<SystemCollectionsConcurrentVersion>4.3.0</SystemCollectionsConcurrentVersion> <SystemCollectionsConcurrentVersion>4.3.0</SystemCollectionsConcurrentVersion>
......
...@@ -22,8 +22,8 @@ ...@@ -22,8 +22,8 @@
</AssemblyMetadata> </AssemblyMetadata>
</ItemGroup> </ItemGroup>
<!-- Adds SupportedOSPlatform attribute for Windows Specific libraries --> <!-- Adds SupportedOSPlatform attribute for Windows Specific libraries and Windows targets -->
<ItemGroup Condition="'$(IsWindowsSpecific)' == 'true' and '$(IsTestProject)' != 'true'"> <ItemGroup Condition="('$(IsWindowsSpecific)' == 'true' or '$(TargetsWindows)' == 'true') and '$(IsTestProject)' != 'true'">
<AssemblyAttribute Include="System.Runtime.Versioning.SupportedOSPlatform"> <AssemblyAttribute Include="System.Runtime.Versioning.SupportedOSPlatform">
<_Parameter1>windows</_Parameter1> <_Parameter1>windows</_Parameter1>
</AssemblyAttribute> </AssemblyAttribute>
...@@ -33,9 +33,9 @@ ...@@ -33,9 +33,9 @@
<_unsupportedOSPlatforms Include="$(UnsupportedOSPlatforms)" /> <_unsupportedOSPlatforms Include="$(UnsupportedOSPlatforms)" />
</ItemGroup> </ItemGroup>
<Target Name="AddUnsupportedOSPlatformAttribute" BeforeTargets="GenerateAssemblyInfo" AfterTargets="PrepareForBuild"> <Target Name="AddUnsupportedOSPlatformAttribute" BeforeTargets="GenerateAssemblyInfo" AfterTargets="PrepareForBuild" Condition="'@(_unsupportedOSPlatforms)' != '' and '$(IsTestProject)' != 'true'">
<ItemGroup> <ItemGroup>
<AssemblyAttribute Include="System.Runtime.Versioning.UnsupportedOSPlatform" Condition="'@(_unsupportedOSPlatforms)' != ''"> <AssemblyAttribute Include="System.Runtime.Versioning.UnsupportedOSPlatform">
<_Parameter1>%(_unsupportedOSPlatforms.Identity)</_Parameter1> <_Parameter1>%(_unsupportedOSPlatforms.Identity)</_Parameter1>
</AssemblyAttribute> </AssemblyAttribute>
</ItemGroup> </ItemGroup>
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Runtime.Loader; using System.Runtime.Loader;
using System.Runtime.Versioning;
// //
// Types in this file marked as 'public' are done so only to aid in // Types in this file marked as 'public' are done so only to aid in
...@@ -108,6 +109,7 @@ public static unsafe ComActivationContext Create(ref ComActivationContextInterna ...@@ -108,6 +109,7 @@ public static unsafe ComActivationContext Create(ref ComActivationContextInterna
} }
} }
[SupportedOSPlatform("windows")]
public static class ComActivator public static class ComActivator
{ {
#if FEATURE_COMINTEROP_UNMANAGED_ACTIVATION #if FEATURE_COMINTEROP_UNMANAGED_ACTIVATION
......
// Licensed to the .NET Foundation under one or more agreements. // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license. // The .NET Foundation licenses this file to you under the MIT license.
using System.Runtime.Versioning;
namespace System.Runtime.InteropServices namespace System.Runtime.InteropServices
{ {
[SupportedOSPlatform("windows")]
internal class ComEventsInfo internal class ComEventsInfo
{ {
private ComEventsSink? _sinks; private ComEventsSink? _sinks;
......
// Licensed to the .NET Foundation under one or more agreements. // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license. // The .NET Foundation licenses this file to you under the MIT license.
using System.Runtime.Versioning;
namespace System.Runtime.InteropServices.CustomMarshalers namespace System.Runtime.InteropServices.CustomMarshalers
{ {
internal static class ComDataHelpers internal static class ComDataHelpers
{ {
[SupportedOSPlatform("windows")]
public static TView GetOrCreateManagedViewFromComData<T, TView>(object comObject, Func<T, TView> createCallback) public static TView GetOrCreateManagedViewFromComData<T, TView>(object comObject, Func<T, TView> createCallback)
{ {
object key = typeof(TView); object key = typeof(TView);
......
...@@ -2,9 +2,11 @@ ...@@ -2,9 +2,11 @@
// The .NET Foundation licenses this file to you under the MIT license. // The .NET Foundation licenses this file to you under the MIT license.
using System.Collections; using System.Collections;
using System.Runtime.Versioning;
namespace System.Runtime.InteropServices.CustomMarshalers namespace System.Runtime.InteropServices.CustomMarshalers
{ {
[SupportedOSPlatform("windows")]
internal class EnumerableToDispatchMarshaler : ICustomMarshaler internal class EnumerableToDispatchMarshaler : ICustomMarshaler
{ {
private static readonly EnumerableToDispatchMarshaler s_enumerableToDispatchMarshaler = new EnumerableToDispatchMarshaler(); private static readonly EnumerableToDispatchMarshaler s_enumerableToDispatchMarshaler = new EnumerableToDispatchMarshaler();
......
// Licensed to the .NET Foundation under one or more agreements. // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license. // The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics;
using System.Runtime.InteropServices.ComTypes; using System.Runtime.InteropServices.ComTypes;
namespace System.Runtime.InteropServices.CustomMarshalers namespace System.Runtime.InteropServices.CustomMarshalers
...@@ -38,6 +39,7 @@ public System.Collections.IEnumerator GetEnumerator() ...@@ -38,6 +39,7 @@ public System.Collections.IEnumerator GetEnumerator()
IntPtr.Zero); IntPtr.Zero);
} }
Debug.Assert(OperatingSystem.IsWindows());
IntPtr enumVariantPtr = IntPtr.Zero; IntPtr enumVariantPtr = IntPtr.Zero;
try try
{ {
......
...@@ -2,10 +2,12 @@ ...@@ -2,10 +2,12 @@
// The .NET Foundation licenses this file to you under the MIT license. // The .NET Foundation licenses this file to you under the MIT license.
using System.Collections; using System.Collections;
using System.Runtime.Versioning;
using ComTypes = System.Runtime.InteropServices.ComTypes; using ComTypes = System.Runtime.InteropServices.ComTypes;
namespace System.Runtime.InteropServices.CustomMarshalers namespace System.Runtime.InteropServices.CustomMarshalers
{ {
[SupportedOSPlatform("windows")]
internal class EnumeratorToEnumVariantMarshaler : ICustomMarshaler internal class EnumeratorToEnumVariantMarshaler : ICustomMarshaler
{ {
private static readonly EnumeratorToEnumVariantMarshaler s_enumeratorToEnumVariantMarshaler = new EnumeratorToEnumVariantMarshaler(); private static readonly EnumeratorToEnumVariantMarshaler s_enumeratorToEnumVariantMarshaler = new EnumeratorToEnumVariantMarshaler();
......
...@@ -4234,6 +4234,7 @@ private static void WrapArgsForInvokeCall(object[] aArgs, int[] aArgsWrapperType ...@@ -4234,6 +4234,7 @@ private static void WrapArgsForInvokeCall(object[] aArgs, int[] aArgsWrapperType
aArgs[i] = new UnknownWrapper(aArgs[i]); aArgs[i] = new UnknownWrapper(aArgs[i]);
break; break;
case DispatchWrapperType.Dispatch: case DispatchWrapperType.Dispatch:
Debug.Assert(OperatingSystem.IsWindows());
aArgs[i] = new DispatchWrapper(aArgs[i]); aArgs[i] = new DispatchWrapper(aArgs[i]);
break; break;
case DispatchWrapperType.Error: case DispatchWrapperType.Error:
......
...@@ -16,6 +16,7 @@ private static ThreadPoolBoundHandle BindHandleCore(SafeHandle handle) ...@@ -16,6 +16,7 @@ private static ThreadPoolBoundHandle BindHandleCore(SafeHandle handle)
try try
{ {
Debug.Assert(OperatingSystem.IsWindows());
// ThreadPool.BindHandle will always return true, otherwise, it throws. See the underlying FCall // ThreadPool.BindHandle will always return true, otherwise, it throws. See the underlying FCall
// implementation in ThreadPoolNative::CorBindIoCompletionCallback to see the implementation. // implementation in ThreadPoolNative::CorBindIoCompletionCallback to see the implementation.
bool succeeded = ThreadPool.BindHandle(handle); bool succeeded = ThreadPool.BindHandle(handle);
......
...@@ -279,6 +279,7 @@ public Variant(object? obj) ...@@ -279,6 +279,7 @@ public Variant(object? obj)
else if (obj is DispatchWrapper) else if (obj is DispatchWrapper)
{ {
vt = VarEnum.VT_DISPATCH; vt = VarEnum.VT_DISPATCH;
Debug.Assert(OperatingSystem.IsWindows());
obj = ((DispatchWrapper)obj).WrappedObject; obj = ((DispatchWrapper)obj).WrappedObject;
} }
else if (obj is ErrorWrapper) else if (obj is ErrorWrapper)
...@@ -401,6 +402,7 @@ internal static void MarshalHelperCastVariant(object pValue, int vt, ref Variant ...@@ -401,6 +402,7 @@ internal static void MarshalHelperCastVariant(object pValue, int vt, ref Variant
switch (vt) switch (vt)
{ {
case 9: /*VT_DISPATCH*/ case 9: /*VT_DISPATCH*/
Debug.Assert(OperatingSystem.IsWindows());
v = new Variant(new DispatchWrapper(pValue)); v = new Variant(new DispatchWrapper(pValue));
break; break;
...@@ -442,7 +444,9 @@ internal static void MarshalHelperCastVariant(object pValue, int vt, ref Variant ...@@ -442,7 +444,9 @@ internal static void MarshalHelperCastVariant(object pValue, int vt, ref Variant
6 => /*VT_CY*/ new Variant(new CurrencyWrapper(iv.ToDecimal(provider))), 6 => /*VT_CY*/ new Variant(new CurrencyWrapper(iv.ToDecimal(provider))),
7 => /*VT_DATE*/ new Variant(iv.ToDateTime(provider)), 7 => /*VT_DATE*/ new Variant(iv.ToDateTime(provider)),
8 => /*VT_BSTR*/ new Variant(iv.ToString(provider)), 8 => /*VT_BSTR*/ new Variant(iv.ToString(provider)),
#pragma warning disable CA1416 // Validate platform compatibility
9 => /*VT_DISPATCH*/ new Variant(new DispatchWrapper((object)iv)), 9 => /*VT_DISPATCH*/ new Variant(new DispatchWrapper((object)iv)),
#pragma warning restore CA1416
10 => /*VT_ERROR*/ new Variant(new ErrorWrapper(iv.ToInt32(provider))), 10 => /*VT_ERROR*/ new Variant(new ErrorWrapper(iv.ToInt32(provider))),
11 => /*VT_BOOL*/ new Variant(iv.ToBoolean(provider)), 11 => /*VT_BOOL*/ new Variant(iv.ToBoolean(provider)),
12 => /*VT_VARIANT*/ new Variant((object)iv), 12 => /*VT_VARIANT*/ new Variant((object)iv),
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
using System.Collections; using System.Collections;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Reflection; using System.Reflection;
using System.Runtime.Versioning;
namespace System namespace System
{ {
...@@ -11,6 +12,7 @@ namespace System ...@@ -11,6 +12,7 @@ namespace System
/// __ComObject is the root class for all COM wrappers. This class defines only /// __ComObject is the root class for all COM wrappers. This class defines only
/// the basics. This class is used for wrapping COM objects accessed from managed. /// the basics. This class is used for wrapping COM objects accessed from managed.
/// </summary> /// </summary>
[SupportedOSPlatform("windows")]
internal class __ComObject : MarshalByRefObject internal class __ComObject : MarshalByRefObject
{ {
private Hashtable? m_ObjectToDataMap; // Do not rename (runtime relies on this name). private Hashtable? m_ObjectToDataMap; // Do not rename (runtime relies on this name).
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#nullable enable #nullable enable
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.Versioning;
namespace System.Runtime.InteropServices namespace System.Runtime.InteropServices
{ {
...@@ -11,6 +12,7 @@ namespace System.Runtime.InteropServices ...@@ -11,6 +12,7 @@ namespace System.Runtime.InteropServices
/// Part of ComEventHelpers APIs which allow binding /// Part of ComEventHelpers APIs which allow binding
/// managed delegates to COM's connection point based events. /// managed delegates to COM's connection point based events.
/// </summary> /// </summary>
[SupportedOSPlatform("windows")]
internal partial class ComEventsSink : IDispatch, ICustomQueryInterface internal partial class ComEventsSink : IDispatch, ICustomQueryInterface
{ {
private Guid _iidSourceItf; private Guid _iidSourceItf;
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#nullable enable #nullable enable
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.Versioning;
namespace System.Runtime.InteropServices namespace System.Runtime.InteropServices
{ {
...@@ -13,6 +14,7 @@ namespace System.Runtime.InteropServices ...@@ -13,6 +14,7 @@ namespace System.Runtime.InteropServices
/// to and from COM calls. /// to and from COM calls.
/// </summary> /// </summary>
[StructLayout(LayoutKind.Explicit)] [StructLayout(LayoutKind.Explicit)]
[SupportedOSPlatform("windows")]
internal partial struct Variant internal partial struct Variant
{ {
#if DEBUG #if DEBUG
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
<TargetFrameworks>net461-Windows_NT</TargetFrameworks> <TargetFrameworks>net461-Windows_NT</TargetFrameworks>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<DocumentationFile>$(OutputPath)$(AssemblyName).xml</DocumentationFile> <DocumentationFile>$(OutputPath)$(AssemblyName).xml</DocumentationFile>
<IncludePlatformAttributes>true</IncludePlatformAttributes>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
......
...@@ -496,6 +496,7 @@ public sealed partial class Interaction ...@@ -496,6 +496,7 @@ public sealed partial class Interaction
public static object? CallByName(object? ObjectRef, string ProcName, Microsoft.VisualBasic.CallType UseCallType, params object?[] Args) { throw null; } public static object? CallByName(object? ObjectRef, string ProcName, Microsoft.VisualBasic.CallType UseCallType, params object?[] Args) { throw null; }
public static object? Choose(double Index, params object?[] Choice) { throw null; } public static object? Choose(double Index, params object?[] Choice) { throw null; }
public static string Command() { throw null; } public static string Command() { throw null; }
[System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
public static object CreateObject(string ProgId, string? ServerName = "") { throw null; } public static object CreateObject(string ProgId, string? ServerName = "") { throw null; }
[System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
public static void DeleteSetting(string AppName, string? Section = null, string? Key = null) { } public static void DeleteSetting(string AppName, string? Section = null, string? Key = null) { }
......
...@@ -266,6 +266,7 @@ Namespace Microsoft.VisualBasic.CompilerServices ...@@ -266,6 +266,7 @@ Namespace Microsoft.VisualBasic.CompilerServices
If UseCallType = CallType.Set Then If UseCallType = CallType.Set Then
flags = flags Or BindingFlags.PutRefDispProperty flags = flags Or BindingFlags.PutRefDispProperty
If args(args.GetUpperBound(0)) Is Nothing Then If args(args.GetUpperBound(0)) Is Nothing Then
Debug.Assert(OperatingSystem.IsWindows())
#Disable Warning BC40000 ' DispatchWrapper is marked obsolete. #Disable Warning BC40000 ' DispatchWrapper is marked obsolete.
args(args.GetUpperBound(0)) = New DispatchWrapper(Nothing) args(args.GetUpperBound(0)) = New DispatchWrapper(Nothing)
#Enable Warning BC40000 #Enable Warning BC40000
......
...@@ -494,6 +494,7 @@ Namespace Microsoft.VisualBasic ...@@ -494,6 +494,7 @@ Namespace Microsoft.VisualBasic
End If End If
End Sub End Sub
<SupportedOSPlatform("windows")>
Public Function CreateObject(ByVal ProgId As String, Optional ByVal ServerName As String = "") As Object Public Function CreateObject(ByVal ProgId As String, Optional ByVal ServerName As String = "") As Object
'Creates local or remote COM2 objects. Should not be used to create COM+ objects. 'Creates local or remote COM2 objects. Should not be used to create COM+ objects.
'Applications that need to be STA should set STA either on their Sub Main via STAThreadAttribute 'Applications that need to be STA should set STA either on their Sub Main via STAThreadAttribute
......
...@@ -466,9 +466,10 @@ public partial class PermissiveModifyControl : System.DirectoryServices.Protocol ...@@ -466,9 +466,10 @@ public partial class PermissiveModifyControl : System.DirectoryServices.Protocol
} }
public delegate System.Security.Cryptography.X509Certificates.X509Certificate QueryClientCertificateCallback(System.DirectoryServices.Protocols.LdapConnection connection, byte[][] trustedCAs); public delegate System.Security.Cryptography.X509Certificates.X509Certificate QueryClientCertificateCallback(System.DirectoryServices.Protocols.LdapConnection connection, byte[][] trustedCAs);
public delegate System.DirectoryServices.Protocols.LdapConnection QueryForConnectionCallback(System.DirectoryServices.Protocols.LdapConnection primaryConnection, System.DirectoryServices.Protocols.LdapConnection referralFromConnection, string newDistinguishedName, System.DirectoryServices.Protocols.LdapDirectoryIdentifier identifier, System.Net.NetworkCredential credential, long currentUserToken); public delegate System.DirectoryServices.Protocols.LdapConnection QueryForConnectionCallback(System.DirectoryServices.Protocols.LdapConnection primaryConnection, System.DirectoryServices.Protocols.LdapConnection referralFromConnection, string newDistinguishedName, System.DirectoryServices.Protocols.LdapDirectoryIdentifier identifier, System.Net.NetworkCredential credential, long currentUserToken);
[System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
public partial class QuotaControl : System.DirectoryServices.Protocols.DirectoryControl public partial class QuotaControl : System.DirectoryServices.Protocols.DirectoryControl
{ {
public QuotaControl() : base (default(string), default(byte[]), default(bool), default(bool)) { } public QuotaControl() : base (default(string), default(byte[]), default(bool), default(bool)) { }
public QuotaControl(System.Security.Principal.SecurityIdentifier querySid) : base (default(string), default(byte[]), default(bool), default(bool)) { } public QuotaControl(System.Security.Principal.SecurityIdentifier querySid) : base (default(string), default(byte[]), default(bool), default(bool)) { }
public System.Security.Principal.SecurityIdentifier QuerySid { get { throw null; } set { } } public System.Security.Principal.SecurityIdentifier QuerySid { get { throw null; } set { } }
public override byte[] GetValue() { throw null; } public override byte[] GetValue() { throw null; }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
using System.Text; using System.Text;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Security.Principal; using System.Security.Principal;
using System.Runtime.Versioning;
namespace System.DirectoryServices.Protocols namespace System.DirectoryServices.Protocols
{ {
...@@ -1020,6 +1021,7 @@ public byte[] ContextId ...@@ -1020,6 +1021,7 @@ public byte[] ContextId
public ResultCode Result { get; } public ResultCode Result { get; }
} }
[SupportedOSPlatform("windows")]
public class QuotaControl : DirectoryControl public class QuotaControl : DirectoryControl
{ {
private byte[] _sid; private byte[] _sid;
......
...@@ -21,6 +21,7 @@ protected StandardOleMarshalObject() ...@@ -21,6 +21,7 @@ protected StandardOleMarshalObject()
private IntPtr GetStdMarshaler(ref Guid riid, int dwDestContext, int mshlflags) private IntPtr GetStdMarshaler(ref Guid riid, int dwDestContext, int mshlflags)
{ {
Debug.Assert(OperatingSystem.IsWindows());
IntPtr pUnknown = Marshal.GetIUnknownForObject(this); IntPtr pUnknown = Marshal.GetIUnknownForObject(this);
if (pUnknown != IntPtr.Zero) if (pUnknown != IntPtr.Zero)
{ {
...@@ -69,6 +70,7 @@ unsafe int IMarshal.GetMarshalSizeMax(ref Guid riid, IntPtr pv, int dwDestContex ...@@ -69,6 +70,7 @@ unsafe int IMarshal.GetMarshalSizeMax(ref Guid riid, IntPtr pv, int dwDestContex
} }
finally finally
{ {
Debug.Assert(OperatingSystem.IsWindows());
Marshal.Release(pStandardMarshal); Marshal.Release(pStandardMarshal);
} }
} }
...@@ -91,6 +93,7 @@ unsafe int IMarshal.MarshalInterface(IntPtr pStm, ref Guid riid, IntPtr pv, int ...@@ -91,6 +93,7 @@ unsafe int IMarshal.MarshalInterface(IntPtr pStm, ref Guid riid, IntPtr pv, int
} }
finally finally
{ {
Debug.Assert(OperatingSystem.IsWindows());
Marshal.Release(pStandardMarshal); Marshal.Release(pStandardMarshal);
} }
} }
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<PropertyGroup> <PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFrameworks>netstandard2.0;netstandard2.0-Windows_NT</TargetFrameworks> <TargetFrameworks>netstandard2.0;netstandard2.0-Windows_NT</TargetFrameworks>
<IncludePlatformAttributes>true</IncludePlatformAttributes>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="System\Runtime\Caching\_shims.cs" /> <Compile Include="System\Runtime\Caching\_shims.cs" />
......
...@@ -76,6 +76,7 @@ public partial class UnmanagedMemoryAccessor : System.IDisposable ...@@ -76,6 +76,7 @@ public partial class UnmanagedMemoryAccessor : System.IDisposable
} }
namespace System.Runtime.CompilerServices namespace System.Runtime.CompilerServices
{ {
[System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
[System.AttributeUsageAttribute(System.AttributeTargets.Field | System.AttributeTargets.Parameter, Inherited=false)] [System.AttributeUsageAttribute(System.AttributeTargets.Field | System.AttributeTargets.Parameter, Inherited=false)]
public sealed partial class IDispatchConstantAttribute : System.Runtime.CompilerServices.CustomConstantAttribute public sealed partial class IDispatchConstantAttribute : System.Runtime.CompilerServices.CustomConstantAttribute
{ {
......
...@@ -2,9 +2,11 @@ ...@@ -2,9 +2,11 @@
// The .NET Foundation licenses this file to you under the MIT license. // The .NET Foundation licenses this file to you under the MIT license.
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Runtime.Versioning;
namespace System.Runtime.CompilerServices namespace System.Runtime.CompilerServices
{ {
[SupportedOSPlatform("windows")]
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)] [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
public sealed partial class IDispatchConstantAttribute : CustomConstantAttribute public sealed partial class IDispatchConstantAttribute : CustomConstantAttribute
{ {
......
...@@ -25,6 +25,7 @@ public partial class PasswordDeriveBytes : DeriveBytes ...@@ -25,6 +25,7 @@ public partial class PasswordDeriveBytes : DeriveBytes
private HashAlgorithm? _hash; private HashAlgorithm? _hash;
private readonly CspParameters? _cspParams; private readonly CspParameters? _cspParams;
#pragma warning disable CA1416 // Validate platform compatibility, CspParametersis is windows only type, we might want to annotate this constructors windows only, suppressing for now
public PasswordDeriveBytes(string strPassword, byte[]? rgbSalt) : this(strPassword, rgbSalt, new CspParameters()) { } public PasswordDeriveBytes(string strPassword, byte[]? rgbSalt) : this(strPassword, rgbSalt, new CspParameters()) { }
public PasswordDeriveBytes(byte[] password, byte[]? salt) : this(password, salt, new CspParameters()) { } public PasswordDeriveBytes(byte[] password, byte[]? salt) : this(password, salt, new CspParameters()) { }
...@@ -34,6 +35,7 @@ public partial class PasswordDeriveBytes : DeriveBytes ...@@ -34,6 +35,7 @@ public partial class PasswordDeriveBytes : DeriveBytes
public PasswordDeriveBytes(byte[] password, byte[]? salt, string hashName, int iterations) : public PasswordDeriveBytes(byte[] password, byte[]? salt, string hashName, int iterations) :
this(password, salt, hashName, iterations, new CspParameters()) { } this(password, salt, hashName, iterations, new CspParameters()) { }
#pragma warning restore CA1416
public PasswordDeriveBytes(string strPassword, byte[]? rgbSalt, CspParameters? cspParams) : public PasswordDeriveBytes(string strPassword, byte[]? rgbSalt, CspParameters? cspParams) :
this(strPassword, rgbSalt, "SHA1", 100, cspParams) { } this(strPassword, rgbSalt, "SHA1", 100, cspParams) { }
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>$(NetCoreAppCurrent);netstandard2.0;net461-Windows_NT</TargetFrameworks> <TargetFrameworks>$(NetCoreAppCurrent);netstandard2.0;net461-Windows_NT</TargetFrameworks>
<ExcludeCurrentNetCoreAppFromPackage>true</ExcludeCurrentNetCoreAppFromPackage> <ExcludeCurrentNetCoreAppFromPackage>true</ExcludeCurrentNetCoreAppFromPackage>
<IncludePlatformAttributes>true</IncludePlatformAttributes>
</PropertyGroup> </PropertyGroup>
<!-- DesignTimeBuild requires all the TargetFramework Derived Properties to not be present in the first property group. --> <!-- DesignTimeBuild requires all the TargetFramework Derived Properties to not be present in the first property group. -->
<PropertyGroup> <PropertyGroup>
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<TargetFrameworks>$(NetCoreAppCurrent);$(NetCoreAppCurrent)-Windows_NT;netstandard2.0;netcoreapp2.0-Windows_NT;netstandard2.0-Windows_NT;net461-Windows_NT</TargetFrameworks> <TargetFrameworks>$(NetCoreAppCurrent);$(NetCoreAppCurrent)-Windows_NT;netstandard2.0;netcoreapp2.0-Windows_NT;netstandard2.0-Windows_NT;net461-Windows_NT</TargetFrameworks>
<ExcludeCurrentNetCoreAppFromPackage>true</ExcludeCurrentNetCoreAppFromPackage> <ExcludeCurrentNetCoreAppFromPackage>true</ExcludeCurrentNetCoreAppFromPackage>
<IncludePlatformAttributes>true</IncludePlatformAttributes>
</PropertyGroup> </PropertyGroup>
<!-- Generator for code mapping table, target to invoke is GenerateEncodingSource --> <!-- Generator for code mapping table, target to invoke is GenerateEncodingSource -->
<PropertyGroup> <PropertyGroup>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册