.Net Standard 2.0中的43个API是什么,但.Net Framework 4.6.1中没有?

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (2)
  • 关注 (0)
  • 查看 (215)

标题为“ .NET标准API参考 ”的SO问题引用了https://github.com/dotnet/standard/issues/133中的讨论,提到43个API将包含在.Net标准2.0中,但不支持.Net框架4.6.1。但是,我一直无法在互联网上的任何地方找到这43个API的列表。我在搜索中最接近的是https://github.com/dotnet/standard/blob/master/docs/versions/netstandard1.5_diff.mdhttps://github.com/dotnet/standard/blob/ master / docs / versions / netstandard1.6_diff.md,其中列出了.Net Standard 1.5和1.6中引入的API。起初我认为我的搜索结束了,但后来我意识到:

  1. 这两个列表中有超过43个API,而且
  2. 它们中的很多已经被.Net Framework 4.6.1支持。

互联网上的任何地方是否有.Net Standard 2.0中包含但未包含在.Net Framework 4.6.1 中的43个特定 API 的列表?

提问于
用户回答回答于

我在.Net标准项目中发布了一个类似的问题

所有信用转到 @benaadams

可以在以下位置找到缺少的apis:ApiCompatBaseline.net461.txt

我检查了这个文件并找到了52条(超过43条!)。

52个缺失的API是:

     Member 'System.AppContext.GetData(System.String)' 
     Member 'System.AppContext.TargetFrameworkName.get()' 
     Type 'System.StringNormalizationExtensions' 
     Type 'System.Data.Common.DbColumn' 
     Type 'System.Data.Common.DbDataReaderExtensions' 
     Type 'System.Data.Common.IDbColumnSchemaGenerator' 
     Type 'System.Diagnostics.StackFrameExtensions' 
     Type 'System.Diagnostics.Tracing.EventCounter' 
     Member 'System.Diagnostics.Tracing.EventSource.add_EventCommandExecuted(System.EventHandler<System.Diagnostics.Tracing.EventCommandEventArgs>)' 
     Member 'System.Diagnostics.Tracing.EventSource.remove_EventCommandExecuted(System.EventHandler<System.Diagnostics.Tracing.EventCommandEventArgs>)' 
     Type 'System.Globalization.GlobalizationExtensions' 
     Member 'System.Linq.Enumerable.Append<TSource>(System.Collections.Generic.IEnumerable<TSource>, TSource)' 
     Member 'System.Linq.Enumerable.Prepend<TSource>(System.Collections.Generic.IEnumerable<TSource>, TSource)' 
     Member 'System.Linq.Expressions.Expression<TDelegate>.Compile(System.Boolean)' 
     Member 'System.Linq.Expressions.LambdaExpression.Compile(System.Boolean)' 
     Member 'System.Net.Http.HttpClientHandler.CheckCertificateRevocationList.get()' 
     Member 'System.Net.Http.HttpClientHandler.CheckCertificateRevocationList.set(System.Boolean)' 
     Member 'System.Net.Http.HttpClientHandler.ClientCertificates.get()' 
     Member 'System.Net.Http.HttpClientHandler.DefaultProxyCredentials.get()' 
     Member 'System.Net.Http.HttpClientHandler.DefaultProxyCredentials.set(System.Net.ICredentials)' 
     Member 'System.Net.Http.HttpClientHandler.MaxConnectionsPerServer.get()' 
     Member 'System.Net.Http.HttpClientHandler.MaxConnectionsPerServer.set(System.Int32)' 
     Member 'System.Net.Http.HttpClientHandler.MaxResponseHeadersLength.get()' 
     Member 'System.Net.Http.HttpClientHandler.MaxResponseHeadersLength.set(System.Int32)' 
     Member 'System.Net.Http.HttpClientHandler.Properties.get()' 
     Member 'System.Net.Http.HttpClientHandler.ServerCertificateCustomValidationCallback.get()' 
     Member 'System.Net.Http.HttpClientHandler.ServerCertificateCustomValidationCallback.set(System.Func<System.Net.Http.HttpRequestMessage, System.Security.Cryptography.X509Certificates.X509Certificate2, System.Security.Cryptography.X509Certificates.X509Chain, System.Net.Security.SslPolicyErrors, System.Boolean>)' 
     Member 'System.Net.Http.HttpClientHandler.SslProtocols.get()' 
     Member 'System.Net.Http.HttpClientHandler.SslProtocols.set(System.Security.Authentication.SslProtocols)' 
     Type 'System.Net.Sockets.SocketReceiveFromResult' 
     Type 'System.Net.Sockets.SocketReceiveMessageFromResult' 
     Type 'System.Net.Sockets.SocketTaskExtensions' 
     Type 'System.Runtime.Serialization.DataContractSerializerExtensions' 
     Type 'System.Runtime.Serialization.ISerializationSurrogateProvider' 
     Type 'System.Security.SecureStringMarshal' 
     Type 'System.Security.Cryptography.ECCurve' 
     Member 'System.Security.Cryptography.ECDsa.Create(System.Security.Cryptography.ECCurve)' 
     Member 'System.Security.Cryptography.ECDsa.Create(System.Security.Cryptography.ECParameters)' 
     Member 'System.Security.Cryptography.ECDsa.ExportExplicitParameters(System.Boolean)' 
     Member 'System.Security.Cryptography.ECDsa.ExportParameters(System.Boolean)' 
     Member 'System.Security.Cryptography.ECDsa.GenerateKey(System.Security.Cryptography.ECCurve)' 
     Member 'System.Security.Cryptography.ECDsa.ImportParameters(System.Security.Cryptography.ECParameters)' 
     Type 'System.Security.Cryptography.ECParameters' 
     Type 'System.Security.Cryptography.ECPoint' 
     Type 'System.Security.Cryptography.IncrementalHash' 
     Member 'System.Text.RegularExpressions.Regex.CapNames.get()' 
     Member 'System.Text.RegularExpressions.Regex.CapNames.set(System.Collections.IDictionary)' 
     Member 'System.Text.RegularExpressions.Regex.Caps.get()' 
     Member 'System.Text.RegularExpressions.Regex.Caps.set(System.Collections.IDictionary)' 
     Type 'System.Threading.PreAllocatedOverlapped' 
     Type 'System.Threading.ThreadPoolBoundHandle' 
     Type 'System.Xml.XPath.XDocumentExtensions' 

我检查了大部分这些API,发现它们在net461中不可用,但在netstandard2中可用

预计缺少的API将在.NET Framework 7.1中实现.NET Framework 4.7.1提供了对.NET Standard 2.0的内置支持

.NET Framework 4.7.1早期访问

随着.NET Framework 4.7.1的最终版本,4.6.1中所有缺少的API都被实现。

已实施的API列表

现在.Net Standard 2.0内置于.NET Framework 4.7.1中,无需安装.Net Standard 2.0支持的二进制文件。

用户回答回答于

通过使用https://apisof.net并根据https://github.com/dotnet/standard/blob/master/docs/versions/netstandard1.5_diff.mdhttps://github.com中列出的所有API进行检查/dotnet/standard/blob/master/docs/versions/netstandard1.6_diff.md,我设法将.Net Standard 1.6中的API列表放在一起,但在.Net Framework 4.6.1中缺少:

  • System.Diagnostics.Tracing.EventCounter:
    • public EventCounter(string name, EventSource eventSource) (不在.Net框架中)
    • public void WriteMetric(float value) (不在.Net框架中)

  • System.Diagnostics.Tracing.EventSource:
    • public event EventHandler<EventCommandEventArgs> EventCommandExecuted (在.Net Framework 4.6.2中,但不是4.6.1)

  • System.IO.BufferedStream:
    • public int BufferSize { get; } (不在.Net框架中)
    • public Stream UnderlyingStream { get; } (不在.Net框架中)

  • System.Reflection.TypeInfo:所有以下API,其中没有一个在.Net Framework中 public virtual bool IsCOMObject { get; } public override MemberTypes MemberType { get; } public virtual StructLayoutAttribute StructLayoutAttribute { get; } public ConstructorInfo TypeInitializer { get; } public virtual Type UnderlyingSystemType { get; } public virtual Type[] FindInterfaces(TypeFilter filter, object filterCriteria); public virtual MemberInfo[] FindMembers(MemberTypes memberType, BindingFlags bindingAttr, MemberFilter filter, object filterCriteria); public ConstructorInfo GetConstructor(Type[] types); public ConstructorInfo[] GetConstructors(); public virtual ConstructorInfo[] GetConstructors(BindingFlags bindingAttr); public virtual MemberInfo[] GetDefaultMembers(); public virtual string GetEnumName(object value); public virtual string[] GetEnumNames(); public virtual Type GetEnumUnderlyingType(); public virtual Array GetEnumValues(); public EventInfo GetEvent(string name); public virtual EventInfo GetEvent(string name, BindingFlags bindingAttr); public virtual EventInfo[] GetEvents(); public virtual EventInfo[] GetEvents(BindingFlags bindingAttr); public FieldInfo GetField(string name); public virtual FieldInfo GetField(string name, BindingFlags bindingAttr); public FieldInfo[] GetFields(); public virtual FieldInfo[] GetFields(BindingFlags bindingAttr); public virtual Type[] GetGenericArguments(); public Type GetInterface(string name); public virtual Type GetInterface(string name, bool ignoreCase); public virtual Type[] GetInterfaces(); public MemberInfo[] GetMember(string name); public virtual MemberInfo[] GetMember(string name, BindingFlags bindingAttr); public virtual MemberInfo[] GetMember(string name, MemberTypes type, BindingFlags bindingAttr); public MemberInfo[] GetMembers(); public virtual MemberInfo[] GetMembers(BindingFlags bindingAttr); public MethodInfo GetMethod(string name); public MethodInfo GetMethod(string name, BindingFlags bindingAttr); public MethodInfo GetMethod(string name, Type[] types); public MethodInfo GetMethod(string name, Type[] types, ParameterModifier[] modifiers); public MethodInfo[] GetMethods(); public virtual MethodInfo[] GetMethods(BindingFlags bindingAttr); public Type GetNestedType(string name); public virtual Type GetNestedType(string name, BindingFlags bindingAttr); public Type[] GetNestedTypes(); public virtual Type[] GetNestedTypes(BindingFlags bindingAttr); public PropertyInfo[] GetProperties(); public virtual PropertyInfo[] GetProperties(BindingFlags bindingAttr); public PropertyInfo GetProperty(string name); public PropertyInfo GetProperty(string name, BindingFlags bindingAttr); public PropertyInfo GetProperty(string name, Type returnType); public PropertyInfo GetProperty(string name, Type returnType, Type[] types); public PropertyInfo GetProperty(string name, Type returnType, Type[] types, ParameterModifier[] modifiers); public PropertyInfo GetProperty(string name, Type[] types); public virtual bool IsAssignableFrom(Type c); public virtual bool IsEnumDefined(object value); public virtual bool IsEquivalentTo(Type other); public virtual bool IsInstanceOfType(object o);
  • System.AppContext:
    • public static string TargetFrameworkName { get; } (不在.Net框架中)
    • public static object GetData(string name) (不在.Net框架中)

  • System.Linq.Enumerable:
    • public static IEnumerable<TSource> Append<TSource>(this IEnumerable<TSource> source, TSource element) (不在.Net框架中)
    • public static IEnumerable<TSource> Prepend<TSource>(this IEnumerable<TSource> source, TSource element) (不在.Net框架中)

  • System.Security.Cryptography.ECCurve:整个ECCurve结构体和其中的所有内容(包括System.Security.Cryptography.ECCurve.NamedCurves静态类)都不在.Net Framework中。换句话说,以下列表中的所有API都是.Net Core中的新增功能,无法在.Net Framework 4.6.1(或4.6.2)中找到: public struct ECCurve { public enum ECCurveType { Characteristic2 = 4, Implicit = 0, Named = 5, PrimeMontgomery = 3, PrimeShortWeierstrass = 1, PrimeTwistedEdwards = 2, } public static class NamedCurves { public static ECCurve brainpoolP160r1 { get; } public static ECCurve brainpoolP160t1 { get; } public static ECCurve brainpoolP192r1 { get; } public static ECCurve brainpoolP192t1 { get; } public static ECCurve brainpoolP224r1 { get; } public static ECCurve brainpoolP224t1 { get; } public static ECCurve brainpoolP256r1 { get; } public static ECCurve brainpoolP256t1 { get; } public static ECCurve brainpoolP320r1 { get; } public static ECCurve brainpoolP320t1 { get; } public static ECCurve brainpoolP384r1 { get; } public static ECCurve brainpoolP384t1 { get; } public static ECCurve brainpoolP512r1 { get; } public static ECCurve brainpoolP512t1 { get; } public static ECCurve nistP256 { get; } public static ECCurve nistP384 { get; } public static ECCurve nistP521 { get; } } public byte[] A; public byte[] B; public byte[] Cofactor; public ECCurve.ECCurveType CurveType; public ECPoint G; public Nullable<HashAlgorithmName> Hash; public byte[] Order; public byte[] Polynomial; public byte[] Prime; public byte[] Seed; public bool IsCharacteristic2 { get; } public bool IsExplicit { get; } public bool IsNamed { get; } public bool IsPrime { get; } public Oid Oid { get; } public static ECCurve CreateFromFriendlyName(string oidFriendlyName); public static ECCurve CreateFromOid(Oid curveOid); public static ECCurve CreateFromValue(string oidValue); public void Validate(); }
  • System.Security.Cryptography.ECParameters 结构:不在.Net框架中
  • System.Security.Cryptography.ECPoint 结构:不在.Net框架中
  • System.Security.Cryptography.ECDsa:
    • public static ECDsa Create(ECCurve curve) (不在.Net框架中)
    • public static ECDsa Create(ECParameters parameters) (不在.Net框架中)
    • public virtual ECParameters ExportExplicitParameters(bool includePrivateParameters) (不在.Net框架中)
    • public virtual ECParameters ExportParameters(bool includePrivateParameters) (不在.Net框架中)
    • public virtual void GenerateKey(ECCurve curve) (不在.Net框架中)
    • public virtual void ImportParameters(ECParameters parameters) (不在.Net框架中)

  • System.Text.RegularExpressions.Regex:
    • protected IDictionary CapNames { get; set; } (不在.Net框架中)
    • protected IDictionary Caps { get; set; } (不在.Net框架中)

这比43个API多得多。我还没有通过.Net Standard 2.0 API列表(这是巨大的)。

扫码关注云+社区