diff --git a/src/Backup/MonoMod.Common.csproj b/src/Backup/MonoMod.Common.csproj new file mode 100644 index 00000000..cb55ab75 --- /dev/null +++ b/src/Backup/MonoMod.Common.csproj @@ -0,0 +1,124 @@ + + + + + $(BUILD_BUILDNUMBER) + + Library + $(AssemblyName) + + Debug;Release;DebugLegacy;ReleaseLegacy + Debug + AnyCPU + bin\$(Configuration) + + 7.3 + true + + prompt + 4 + true + + true + false + false + + true + false + + false + + false + false + false + + + + + 0x0ade + Copyright 2018 Maik Macho + MonoMod;assembly;assemblies;module;modules;il;cil;msil;bytecode;reflection;injection;cecil;mono;$(PackageTags) + https://github.com/0x0ade/MonoMod/blob/master/LICENSE + https://github.com/0x0ade/MonoMod + https://user-images.githubusercontent.com/1200380/47308180-28242880-d631-11e8-89d2-14d86f3db113.png + + $(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\Client + + + + + true + full + false + DEBUG;TRACE;$(DefineConstants) + + + + + pdbonly + true + TRACE;$(DefineConstants) + + + + + true + + + + + + + + true + true + NETSTANDARD;$(DefineConstants) + NETSTANDARD1_X;$(DefineConstants) + CECIL0_10;$(DefineConstants) + 0.10.3 + + + + + + + + + + + + + + + true + NETFRAMEWORK;$(DefineConstants) + CECIL0_9;$(DefineConstants) + 0.9.6 + + + + + + + + + + + 0.10.3 + + + + $(CecilVersion) + + + + + + + AssemblyInfo.Common.cs + + + NETStandardShims.cs + + + \ No newline at end of file diff --git a/src/Newtonsoft.Json/JsonConvert.cs b/src/Newtonsoft.Json/JsonConvert.cs index 356e06ec..b0e480d6 100644 --- a/src/Newtonsoft.Json/JsonConvert.cs +++ b/src/Newtonsoft.Json/JsonConvert.cs @@ -58,7 +58,7 @@ namespace Newtonsoft.Json /// To serialize without using any default settings create a with /// . /// - public static Serialization.Func DefaultSettings { get; set; } + public static Func DefaultSettings { get; set; } /// /// Represents JavaScript's boolean value true as a string. This field is read-only. diff --git a/src/Newtonsoft.Json/JsonSerializerSettings.cs b/src/Newtonsoft.Json/JsonSerializerSettings.cs index 6067c6ed..ea68dc94 100644 --- a/src/Newtonsoft.Json/JsonSerializerSettings.cs +++ b/src/Newtonsoft.Json/JsonSerializerSettings.cs @@ -245,7 +245,7 @@ namespace Newtonsoft.Json { ReferenceResolverProvider = (value != null) ? () => value - : (Serialization.Func)null; + : (Func)null; } } @@ -253,7 +253,7 @@ namespace Newtonsoft.Json /// Gets or sets a function that creates the used by the serializer when resolving references. /// /// A function that creates the used by the serializer when resolving references. - public Serialization.Func ReferenceResolverProvider { get; set; } + public Func ReferenceResolverProvider { get; set; } /// /// Gets or sets the used by the serializer when writing trace messages. diff --git a/src/Newtonsoft.Json/Serialization/DefaultContractResolver.cs b/src/Newtonsoft.Json/Serialization/DefaultContractResolver.cs index 78664d50..adb29472 100644 --- a/src/Newtonsoft.Json/Serialization/DefaultContractResolver.cs +++ b/src/Newtonsoft.Json/Serialization/DefaultContractResolver.cs @@ -349,7 +349,7 @@ namespace Newtonsoft.Json.Serialization contract.MemberSerialization = JsonTypeReflector.GetObjectMemberSerialization(contract.NonNullableUnderlyingType, ignoreSerializableAttribute); contract.Properties.AddRange(CreateProperties(contract.NonNullableUnderlyingType, contract.MemberSerialization)); - Serialization.Func extensionDataNameResolver = null; + Func extensionDataNameResolver = null; JsonObjectAttribute attribute = JsonTypeReflector.GetCachedAttribute(contract.NonNullableUnderlyingType); if (attribute != null) @@ -511,14 +511,14 @@ namespace Newtonsoft.Json.Serialization createdType = t; } - Serialization.Func getExtensionDataDictionary = JsonTypeReflector.ReflectionDelegateFactory.CreateGet(member); + Func getExtensionDataDictionary = JsonTypeReflector.ReflectionDelegateFactory.CreateGet(member); if (extensionDataAttribute.ReadData) { - Serialization.Action setExtensionDataDictionary = (ReflectionUtils.CanSetMemberValue(member, true, false)) + Action setExtensionDataDictionary = (ReflectionUtils.CanSetMemberValue(member, true, false)) ? JsonTypeReflector.ReflectionDelegateFactory.CreateSet(member) : null; - Serialization.Func createExtensionDataDictionary = JsonTypeReflector.ReflectionDelegateFactory.CreateDefaultConstructor(createdType); + Func createExtensionDataDictionary = JsonTypeReflector.ReflectionDelegateFactory.CreateDefaultConstructor(createdType); MethodInfo setMethod = t.GetProperty("Item", BindingFlags.Public | BindingFlags.Instance, null, valueType, new[] { keyType }, null)?.GetSetMethod(); if (setMethod == null) { @@ -775,7 +775,7 @@ namespace Newtonsoft.Json.Serialization return JsonTypeReflector.GetJsonConverter(objectType); } - private Serialization.Func GetDefaultCreator(Type createdType) + private Func GetDefaultCreator(Type createdType) { return JsonTypeReflector.ReflectionDelegateFactory.CreateDefaultConstructor(createdType); } @@ -1397,14 +1397,14 @@ namespace Newtonsoft.Json.Serialization IValueProvider valueProvider; #if !(PORTABLE40 || PORTABLE || DOTNET || NETSTANDARD2_0) - //if (DynamicCodeGeneration) - //{ - // valueProvider = new DynamicValueProvider(member); - //} - //else - //{ + if (DynamicCodeGeneration) + { + valueProvider = new DynamicValueProvider(member); + } + else + { valueProvider = new ReflectionValueProvider(member); - //} + } #elif !(PORTABLE40) valueProvider = new ExpressionValueProvider(member); #else @@ -1652,7 +1652,7 @@ namespace Newtonsoft.Json.Serialization return; } - Serialization.Func specifiedPropertyGet = JsonTypeReflector.ReflectionDelegateFactory.CreateGet(specifiedMember); + Func specifiedPropertyGet = JsonTypeReflector.ReflectionDelegateFactory.CreateGet(specifiedMember); property.GetIsSpecified = o => (bool)specifiedPropertyGet(o); diff --git a/src/Newtonsoft.Json/Serialization/DynamicValueProvider.cs b/src/Newtonsoft.Json/Serialization/DynamicValueProvider.cs index 8d8d9e02..ec9231c7 100644 --- a/src/Newtonsoft.Json/Serialization/DynamicValueProvider.cs +++ b/src/Newtonsoft.Json/Serialization/DynamicValueProvider.cs @@ -42,8 +42,8 @@ namespace Newtonsoft.Json.Serialization public class DynamicValueProvider : IValueProvider { private readonly MemberInfo _memberInfo; - private Serialization.Func _getter; - private Serialization.Action _setter; + private Func _getter; + private Action _setter; /// /// Initializes a new instance of the class. diff --git a/src/Newtonsoft.Json/Serialization/ExpressionValueProvider.cs b/src/Newtonsoft.Json/Serialization/ExpressionValueProvider.cs index 8c4788e6..ae2a3086 100644 --- a/src/Newtonsoft.Json/Serialization/ExpressionValueProvider.cs +++ b/src/Newtonsoft.Json/Serialization/ExpressionValueProvider.cs @@ -43,8 +43,8 @@ namespace Newtonsoft.Json.Serialization public class ExpressionValueProvider : IValueProvider { private readonly MemberInfo _memberInfo; - private Serialization.Func _getter; - private Serialization.Action _setter; + private Func _getter; + private Action _setter; /// /// Initializes a new instance of the class. diff --git a/src/Newtonsoft.Json/Serialization/JsonArrayContract.cs b/src/Newtonsoft.Json/Serialization/JsonArrayContract.cs index e712267f..d7f4106f 100644 --- a/src/Newtonsoft.Json/Serialization/JsonArrayContract.cs +++ b/src/Newtonsoft.Json/Serialization/JsonArrayContract.cs @@ -61,7 +61,7 @@ namespace Newtonsoft.Json.Serialization private Type _genericWrapperType; private ObjectConstructor _genericWrapperCreator; - private Serialization.Func _genericTemporaryCollectionCreator; + private Func _genericTemporaryCollectionCreator; internal bool IsArray { get; } internal bool ShouldCreateWrapper { get; } diff --git a/src/Newtonsoft.Json/Serialization/JsonContract.cs b/src/Newtonsoft.Json/Serialization/JsonContract.cs index 358fb44a..37365bb6 100644 --- a/src/Newtonsoft.Json/Serialization/JsonContract.cs +++ b/src/Newtonsoft.Json/Serialization/JsonContract.cs @@ -227,7 +227,7 @@ namespace Newtonsoft.Json.Serialization /// Gets or sets the default creator method used to create the object. /// /// The default creator method used to create the object. - public Serialization.Func DefaultCreator { get; set; } + public Func DefaultCreator { get; set; } /// /// Gets or sets a value indicating whether the default creator is non-public. diff --git a/src/Newtonsoft.Json/Serialization/JsonDictionaryContract.cs b/src/Newtonsoft.Json/Serialization/JsonDictionaryContract.cs index 4a4268fd..c486be2b 100644 --- a/src/Newtonsoft.Json/Serialization/JsonDictionaryContract.cs +++ b/src/Newtonsoft.Json/Serialization/JsonDictionaryContract.cs @@ -45,7 +45,7 @@ namespace Newtonsoft.Json.Serialization /// Gets or sets the dictionary key resolver. /// /// The dictionary key resolver. - public Serialization.Func DictionaryKeyResolver { get; set; } + public Func DictionaryKeyResolver { get; set; } /// /// Gets the of the dictionary keys. @@ -66,7 +66,7 @@ namespace Newtonsoft.Json.Serialization private Type _genericWrapperType; private ObjectConstructor _genericWrapperCreator; - private Serialization.Func _genericTemporaryDictionaryCreator; + private Func _genericTemporaryDictionaryCreator; internal bool ShouldCreateWrapper { get; } diff --git a/src/Newtonsoft.Json/Serialization/JsonDynamicContract.cs b/src/Newtonsoft.Json/Serialization/JsonDynamicContract.cs index 5233d91a..f8a6ad39 100644 --- a/src/Newtonsoft.Json/Serialization/JsonDynamicContract.cs +++ b/src/Newtonsoft.Json/Serialization/JsonDynamicContract.cs @@ -46,26 +46,26 @@ namespace Newtonsoft.Json.Serialization /// Gets or sets the property name resolver. /// /// The property name resolver. - public Serialization.Func PropertyNameResolver { get; set; } + public Func PropertyNameResolver { get; set; } - private readonly ThreadSafeStore>> _callSiteGetters = - new ThreadSafeStore>>(CreateCallSiteGetter); + private readonly ThreadSafeStore>> _callSiteGetters = + new ThreadSafeStore>>(CreateCallSiteGetter); - private readonly ThreadSafeStore>> _callSiteSetters = - new ThreadSafeStore>>(CreateCallSiteSetter); + private readonly ThreadSafeStore>> _callSiteSetters = + new ThreadSafeStore>>(CreateCallSiteSetter); - private static CallSite> CreateCallSiteGetter(string name) + private static CallSite> CreateCallSiteGetter(string name) { GetMemberBinder getMemberBinder = (GetMemberBinder)DynamicUtils.BinderWrapper.GetMember(name, typeof(DynamicUtils)); - return CallSite>.Create(new NoThrowGetBinderMember(getMemberBinder)); + return CallSite>.Create(new NoThrowGetBinderMember(getMemberBinder)); } - private static CallSite> CreateCallSiteSetter(string name) + private static CallSite> CreateCallSiteSetter(string name) { SetMemberBinder binder = (SetMemberBinder)DynamicUtils.BinderWrapper.SetMember(name, typeof(DynamicUtils)); - return CallSite>.Create(new NoThrowSetBinderMember(binder)); + return CallSite>.Create(new NoThrowSetBinderMember(binder)); } /// @@ -84,7 +84,7 @@ namespace Newtonsoft.Json.Serialization { ValidationUtils.ArgumentNotNull(dynamicProvider, nameof(dynamicProvider)); - CallSite> callSite = _callSiteGetters.Get(name); + CallSite> callSite = _callSiteGetters.Get(name); object result = callSite.Target(callSite, dynamicProvider); @@ -104,7 +104,7 @@ namespace Newtonsoft.Json.Serialization { ValidationUtils.ArgumentNotNull(dynamicProvider, nameof(dynamicProvider)); - CallSite> callSite = _callSiteSetters.Get(name); + CallSite> callSite = _callSiteSetters.Get(name); object result = callSite.Target(callSite, dynamicProvider, value); diff --git a/src/Newtonsoft.Json/Serialization/JsonObjectContract.cs b/src/Newtonsoft.Json/Serialization/JsonObjectContract.cs index 7f9e26c2..aeb5410e 100644 --- a/src/Newtonsoft.Json/Serialization/JsonObjectContract.cs +++ b/src/Newtonsoft.Json/Serialization/JsonObjectContract.cs @@ -124,7 +124,7 @@ namespace Newtonsoft.Json.Serialization /// Gets or sets the extension data name resolver. /// /// The extension data name resolver. - public Serialization.Func ExtensionDataNameResolver { get; set; } + public Func ExtensionDataNameResolver { get; set; } internal bool ExtensionDataIsJToken; private bool? _hasRequiredOrDefaultValueProperties; diff --git a/src/Newtonsoft.Json/Serialization/JsonProperty.cs b/src/Newtonsoft.Json/Serialization/JsonProperty.cs index 281a0270..38fe8516 100644 --- a/src/Newtonsoft.Json/Serialization/JsonProperty.cs +++ b/src/Newtonsoft.Json/Serialization/JsonProperty.cs @@ -266,7 +266,7 @@ namespace Newtonsoft.Json.Serialization /// Gets or sets an action used to set whether the property has been deserialized. /// /// An action used to set whether the property has been deserialized. - public Serialization.Action SetIsSpecified { get; set; } + public Action SetIsSpecified { get; set; } /// /// Returns a that represents this instance. diff --git a/src/Newtonsoft.Json/Serialization/JsonTypeReflector.cs b/src/Newtonsoft.Json/Serialization/JsonTypeReflector.cs index bee03617..25100201 100644 --- a/src/Newtonsoft.Json/Serialization/JsonTypeReflector.cs +++ b/src/Newtonsoft.Json/Serialization/JsonTypeReflector.cs @@ -58,8 +58,8 @@ namespace Newtonsoft.Json.Serialization public const string ConcurrentDictionaryTypeName = "System.Collections.Concurrent.ConcurrentDictionary`2"; - private static readonly ThreadSafeStore> CreatorCache = - new ThreadSafeStore>(GetCreator); + private static readonly ThreadSafeStore> CreatorCache = + new ThreadSafeStore>(GetCreator); #if !(NET20 || DOTNET) private static readonly ThreadSafeStore AssociatedMetadataTypesCache = new ThreadSafeStore(GetAssociateMetadataTypeFromAttribute); @@ -184,7 +184,7 @@ namespace Newtonsoft.Json.Serialization if (converterAttribute != null) { - Serialization.Func creator = CreatorCache.Get(converterAttribute.ConverterType); + Func creator = CreatorCache.Get(converterAttribute.ConverterType); if (creator != null) { return (JsonConverter)creator(converterAttribute.ConverterParameters); @@ -202,13 +202,13 @@ namespace Newtonsoft.Json.Serialization /// If null, the default constructor is used. public static JsonConverter CreateJsonConverterInstance(Type converterType, object[] args) { - Serialization.Func converterCreator = CreatorCache.Get(converterType); + Func converterCreator = CreatorCache.Get(converterType); return (JsonConverter)converterCreator(args); } public static NamingStrategy CreateNamingStrategyInstance(Type namingStrategyType, object[] args) { - Serialization.Func converterCreator = CreatorCache.Get(namingStrategyType); + Func converterCreator = CreatorCache.Get(namingStrategyType); return (NamingStrategy)converterCreator(args); } @@ -227,9 +227,9 @@ namespace Newtonsoft.Json.Serialization return containerAttribute.NamingStrategyInstance; } - private static Serialization.Func GetCreator(Type type) + private static Func GetCreator(Type type) { - Serialization.Func defaultConstructor = (ReflectionUtils.HasDefaultConstructor(type, false)) + Func defaultConstructor = (ReflectionUtils.HasDefaultConstructor(type, false)) ? ReflectionDelegateFactory.CreateDefaultConstructor(type) : null; @@ -516,10 +516,10 @@ namespace Newtonsoft.Json.Serialization get { #if !(PORTABLE40 || PORTABLE || DOTNET || NETSTANDARD2_0) - //if (DynamicCodeGeneration) - //{ - // return DynamicReflectionDelegateFactory.Instance; - //} + if (DynamicCodeGeneration) + { + return DynamicReflectionDelegateFactory.Instance; + } return LateBoundReflectionDelegateFactory.Instance; #else diff --git a/src/Newtonsoft.Json/Utilities/CollectionUtils.cs b/src/Newtonsoft.Json/Utilities/CollectionUtils.cs index f61870d0..c42ec8ef 100644 --- a/src/Newtonsoft.Json/Utilities/CollectionUtils.cs +++ b/src/Newtonsoft.Json/Utilities/CollectionUtils.cs @@ -211,7 +211,7 @@ namespace Newtonsoft.Json.Utilities return allAdded; } - public static int IndexOf(this IEnumerable collection, Serialization.Func predicate) + public static int IndexOf(this IEnumerable collection, Func predicate) { int index = 0; foreach (T value in collection) diff --git a/src/Newtonsoft.Json/Utilities/ConvertUtils.cs b/src/Newtonsoft.Json/Utilities/ConvertUtils.cs index ef82aa8a..f00d8947 100644 --- a/src/Newtonsoft.Json/Utilities/ConvertUtils.cs +++ b/src/Newtonsoft.Json/Utilities/ConvertUtils.cs @@ -248,10 +248,10 @@ namespace Newtonsoft.Json.Utilities #endif } - private static readonly ThreadSafeStore, Serialization.Func> CastConverters = - new ThreadSafeStore, Serialization.Func>(CreateCastConverter); + private static readonly ThreadSafeStore, Func> CastConverters = + new ThreadSafeStore, Func>(CreateCastConverter); - private static Serialization.Func CreateCastConverter(StructMultiKey t) + private static Func CreateCastConverter(StructMultiKey t) { Type initialType = t.Value1; Type targetType = t.Value2; @@ -599,7 +599,7 @@ namespace Newtonsoft.Json.Utilities return value; } - Serialization.Func castConverter = CastConverters.Get(new StructMultiKey(valueType, targetType)); + Func castConverter = CastConverters.Get(new StructMultiKey(valueType, targetType)); if (castConverter != null) { return castConverter(value); diff --git a/src/Newtonsoft.Json/Utilities/DynamicReflectionDelegateFactory.cs b/src/Newtonsoft.Json/Utilities/DynamicReflectionDelegateFactory.cs index 78a78924..10b3e10b 100644 --- a/src/Newtonsoft.Json/Utilities/DynamicReflectionDelegateFactory.cs +++ b/src/Newtonsoft.Json/Utilities/DynamicReflectionDelegateFactory.cs @@ -239,7 +239,7 @@ namespace Newtonsoft.Json.Utilities generator.Return(); } - public override Serialization.Func CreateDefaultConstructor(Type type) + public override Func CreateDefaultConstructor(Type type) { DynamicMethod dynamicMethod = CreateDynamicMethod("Create" + type.FullName, typeof(T), ReflectionUtils.EmptyTypes, type); dynamicMethod.InitLocals = true; @@ -247,7 +247,7 @@ namespace Newtonsoft.Json.Utilities GenerateCreateDefaultConstructorIL(type, generator, typeof(T)); - return (Serialization.Func)dynamicMethod.CreateDelegate(typeof(Serialization.Func)); + return (Func)dynamicMethod.CreateDelegate(typeof(Func)); } private void GenerateCreateDefaultConstructorIL(Type type, ILGenerator generator, Type delegateType) @@ -279,14 +279,14 @@ namespace Newtonsoft.Json.Utilities generator.Return(); } - public override Serialization.Func CreateGet(PropertyInfo propertyInfo) + public override Func CreateGet(PropertyInfo propertyInfo) { DynamicMethod dynamicMethod = CreateDynamicMethod("Get" + propertyInfo.Name, typeof(object), new[] { typeof(T) }, propertyInfo.DeclaringType); ILGenerator generator = dynamicMethod.GetILGenerator(); GenerateCreateGetPropertyIL(propertyInfo, generator); - return (Serialization.Func)dynamicMethod.CreateDelegate(typeof(Serialization.Func)); + return (Func)dynamicMethod.CreateDelegate(typeof(Func)); } private void GenerateCreateGetPropertyIL(PropertyInfo propertyInfo, ILGenerator generator) @@ -307,12 +307,12 @@ namespace Newtonsoft.Json.Utilities generator.Return(); } - public override Serialization.Func CreateGet(FieldInfo fieldInfo) + public override Func CreateGet(FieldInfo fieldInfo) { if (fieldInfo.IsLiteral) { object constantValue = fieldInfo.GetValue(null); - Serialization.Func getter = o => constantValue; + Func getter = o => constantValue; return getter; } @@ -321,7 +321,7 @@ namespace Newtonsoft.Json.Utilities GenerateCreateGetFieldIL(fieldInfo, generator); - return (Serialization.Func)dynamicMethod.CreateDelegate(typeof(Serialization.Func)); + return (Func)dynamicMethod.CreateDelegate(typeof(Func)); } private void GenerateCreateGetFieldIL(FieldInfo fieldInfo, ILGenerator generator) @@ -340,14 +340,14 @@ namespace Newtonsoft.Json.Utilities generator.Return(); } - public override Serialization.Action CreateSet(FieldInfo fieldInfo) + public override Action CreateSet(FieldInfo fieldInfo) { DynamicMethod dynamicMethod = CreateDynamicMethod("Set" + fieldInfo.Name, null, new[] { typeof(T), typeof(object) }, fieldInfo.DeclaringType); ILGenerator generator = dynamicMethod.GetILGenerator(); GenerateCreateSetFieldIL(fieldInfo, generator); - return (Serialization.Action)dynamicMethod.CreateDelegate(typeof(Serialization.Action)); + return (Action)dynamicMethod.CreateDelegate(typeof(Action)); } internal static void GenerateCreateSetFieldIL(FieldInfo fieldInfo, ILGenerator generator) @@ -372,14 +372,14 @@ namespace Newtonsoft.Json.Utilities generator.Return(); } - public override Serialization.Action CreateSet(PropertyInfo propertyInfo) + public override Action CreateSet(PropertyInfo propertyInfo) { DynamicMethod dynamicMethod = CreateDynamicMethod("Set" + propertyInfo.Name, null, new[] { typeof(T), typeof(object) }, propertyInfo.DeclaringType); ILGenerator generator = dynamicMethod.GetILGenerator(); GenerateCreateSetPropertyIL(propertyInfo, generator); - return (Serialization.Action)dynamicMethod.CreateDelegate(typeof(Serialization.Action)); + return (Action)dynamicMethod.CreateDelegate(typeof(Action)); } internal static void GenerateCreateSetPropertyIL(PropertyInfo propertyInfo, ILGenerator generator) diff --git a/src/Newtonsoft.Json/Utilities/ExpressionReflectionDelegateFactory.cs b/src/Newtonsoft.Json/Utilities/ExpressionReflectionDelegateFactory.cs index 22723fe4..6d6f8d7b 100644 --- a/src/Newtonsoft.Json/Utilities/ExpressionReflectionDelegateFactory.cs +++ b/src/Newtonsoft.Json/Utilities/ExpressionReflectionDelegateFactory.cs @@ -180,7 +180,7 @@ namespace Newtonsoft.Json.Utilities return callExpression; } - public override Serialization.Func CreateDefaultConstructor(Type type) + public override Func CreateDefaultConstructor(Type type) { ValidationUtils.ArgumentNotNull(type, "type"); @@ -198,9 +198,9 @@ namespace Newtonsoft.Json.Utilities expression = EnsureCastExpression(expression, resultType); - LambdaExpression lambdaExpression = Expression.Lambda(typeof(Serialization.Func), expression); + LambdaExpression lambdaExpression = Expression.Lambda(typeof(Func), expression); - Serialization.Func compiled = (Serialization.Func)lambdaExpression.Compile(); + Func compiled = (Func)lambdaExpression.Compile(); return compiled; } catch @@ -211,7 +211,7 @@ namespace Newtonsoft.Json.Utilities } } - public override Serialization.Func CreateGet(PropertyInfo propertyInfo) + public override Func CreateGet(PropertyInfo propertyInfo) { ValidationUtils.ArgumentNotNull(propertyInfo, nameof(propertyInfo)); @@ -236,13 +236,13 @@ namespace Newtonsoft.Json.Utilities resultExpression = EnsureCastExpression(resultExpression, resultType); - LambdaExpression lambdaExpression = Expression.Lambda(typeof(Serialization.Func), resultExpression, parameterExpression); + LambdaExpression lambdaExpression = Expression.Lambda(typeof(Func), resultExpression, parameterExpression); - Serialization.Func compiled = (Serialization.Func)lambdaExpression.Compile(); + Func compiled = (Func)lambdaExpression.Compile(); return compiled; } - public override Serialization.Func CreateGet(FieldInfo fieldInfo) + public override Func CreateGet(FieldInfo fieldInfo) { ValidationUtils.ArgumentNotNull(fieldInfo, nameof(fieldInfo)); @@ -262,11 +262,11 @@ namespace Newtonsoft.Json.Utilities fieldExpression = EnsureCastExpression(fieldExpression, typeof(object)); - Serialization.Func compiled = Expression.Lambda>(fieldExpression, sourceParameter).Compile(); + Func compiled = Expression.Lambda>(fieldExpression, sourceParameter).Compile(); return compiled; } - public override Serialization.Action CreateSet(FieldInfo fieldInfo) + public override Action CreateSet(FieldInfo fieldInfo) { ValidationUtils.ArgumentNotNull(fieldInfo, nameof(fieldInfo)); @@ -296,13 +296,13 @@ namespace Newtonsoft.Json.Utilities BinaryExpression assignExpression = Expression.Assign(fieldExpression, valueExpression); - LambdaExpression lambdaExpression = Expression.Lambda(typeof(Serialization.Action), assignExpression, sourceParameterExpression, valueParameterExpression); + LambdaExpression lambdaExpression = Expression.Lambda(typeof(Action), assignExpression, sourceParameterExpression, valueParameterExpression); - Serialization.Action compiled = (Serialization.Action)lambdaExpression.Compile(); + Action compiled = (Action)lambdaExpression.Compile(); return compiled; } - public override Serialization.Action CreateSet(PropertyInfo propertyInfo) + public override Action CreateSet(PropertyInfo propertyInfo) { ValidationUtils.ArgumentNotNull(propertyInfo, nameof(propertyInfo)); @@ -335,9 +335,9 @@ namespace Newtonsoft.Json.Utilities setExpression = Expression.Call(readInstanceParameter, setMethod, readValueParameter); } - LambdaExpression lambdaExpression = Expression.Lambda(typeof(Serialization.Action), setExpression, instanceParameter, valueParameter); + LambdaExpression lambdaExpression = Expression.Lambda(typeof(Action), setExpression, instanceParameter, valueParameter); - Serialization.Action compiled = (Serialization.Action)lambdaExpression.Compile(); + Action compiled = (Action)lambdaExpression.Compile(); return compiled; } diff --git a/src/Newtonsoft.Json/Utilities/FSharpUtils.cs b/src/Newtonsoft.Json/Utilities/FSharpUtils.cs index 5ff9ead9..55e15d81 100644 --- a/src/Newtonsoft.Json/Utilities/FSharpUtils.cs +++ b/src/Newtonsoft.Json/Utilities/FSharpUtils.cs @@ -67,9 +67,9 @@ namespace Newtonsoft.Json.Utilities public static MethodCall PreComputeUnionTagReader { get; private set; } public static MethodCall PreComputeUnionReader { get; private set; } public static MethodCall PreComputeUnionConstructor { get; private set; } - public static Serialization.Func GetUnionCaseInfoDeclaringType { get; private set; } - public static Serialization.Func GetUnionCaseInfoName { get; private set; } - public static Serialization.Func GetUnionCaseInfoTag { get; private set; } + public static Func GetUnionCaseInfoDeclaringType { get; private set; } + public static Func GetUnionCaseInfoName { get; private set; } + public static Func GetUnionCaseInfoTag { get; private set; } public static MethodCall GetUnionCaseInfoFields { get; private set; } public const string FSharpSetTypeName = "FSharpSet`1"; diff --git a/src/Newtonsoft.Json/Utilities/LateBoundReflectionDelegateFactory.cs b/src/Newtonsoft.Json/Utilities/LateBoundReflectionDelegateFactory.cs index 817004b1..2150e4a3 100644 --- a/src/Newtonsoft.Json/Utilities/LateBoundReflectionDelegateFactory.cs +++ b/src/Newtonsoft.Json/Utilities/LateBoundReflectionDelegateFactory.cs @@ -65,7 +65,7 @@ namespace Newtonsoft.Json.Utilities return (o, a) => method.Invoke(o, a); } - public override Serialization.Func CreateDefaultConstructor(Type type) + public override Func CreateDefaultConstructor(Type type) { ValidationUtils.ArgumentNotNull(type, nameof(type)); @@ -79,28 +79,28 @@ namespace Newtonsoft.Json.Utilities return () => (T)constructorInfo.Invoke(null); } - public override Serialization.Func CreateGet(PropertyInfo propertyInfo) + public override Func CreateGet(PropertyInfo propertyInfo) { ValidationUtils.ArgumentNotNull(propertyInfo, nameof(propertyInfo)); return o => propertyInfo.GetValue(o, null); } - public override Serialization.Func CreateGet(FieldInfo fieldInfo) + public override Func CreateGet(FieldInfo fieldInfo) { ValidationUtils.ArgumentNotNull(fieldInfo, nameof(fieldInfo)); return o => fieldInfo.GetValue(o); } - public override Serialization.Action CreateSet(FieldInfo fieldInfo) + public override Action CreateSet(FieldInfo fieldInfo) { ValidationUtils.ArgumentNotNull(fieldInfo, nameof(fieldInfo)); return (o, v) => fieldInfo.SetValue(o, v); } - public override Serialization.Action CreateSet(PropertyInfo propertyInfo) + public override Action CreateSet(PropertyInfo propertyInfo) { ValidationUtils.ArgumentNotNull(propertyInfo, nameof(propertyInfo)); diff --git a/src/Newtonsoft.Json/Utilities/LinqBridge.cs b/src/Newtonsoft.Json/Utilities/LinqBridge.cs index c00efaad..dc812583 100644 --- a/src/Newtonsoft.Json/Utilities/LinqBridge.cs +++ b/src/Newtonsoft.Json/Utilities/LinqBridge.cs @@ -156,7 +156,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static IEnumerable Where( this IEnumerable source, - Serialization.Func predicate) + Func predicate) { CheckNotNull(source, "source"); CheckNotNull(predicate, "predicate"); @@ -166,7 +166,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge private static IEnumerable WhereYield( IEnumerable source, - Serialization.Func predicate) + Func predicate) { foreach (var item in source) if (predicate(item)) @@ -179,7 +179,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static IEnumerable Where( this IEnumerable source, - Serialization.Func predicate) + Func predicate) { CheckNotNull(source, "source"); CheckNotNull(predicate, "predicate"); @@ -189,7 +189,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge private static IEnumerable WhereYield( IEnumerable source, - Serialization.Func predicate) + Func predicate) { var i = 0; foreach (var item in source) @@ -203,7 +203,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static IEnumerable Select( this IEnumerable source, - Serialization.Func selector) + Func selector) { CheckNotNull(source, "source"); CheckNotNull(selector, "selector"); @@ -213,7 +213,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge private static IEnumerable SelectYield( IEnumerable source, - Serialization.Func selector) + Func selector) { foreach (var item in source) yield return selector(item); @@ -226,7 +226,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static IEnumerable Select( this IEnumerable source, - Serialization.Func selector) + Func selector) { CheckNotNull(source, "source"); CheckNotNull(selector, "selector"); @@ -236,7 +236,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge private static IEnumerable SelectYield( IEnumerable source, - Serialization.Func selector) + Func selector) { var i = 0; foreach (var item in source) @@ -250,7 +250,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static IEnumerable SelectMany( this IEnumerable source, - Serialization.Func> selector) + Func> selector) { CheckNotNull(selector, "selector"); @@ -266,7 +266,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static IEnumerable SelectMany( this IEnumerable source, - Serialization.Func> selector) + Func> selector) { CheckNotNull(selector, "selector"); @@ -281,8 +281,8 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static IEnumerable SelectMany( this IEnumerable source, - Serialization.Func> collectionSelector, - Serialization.Func resultSelector) + Func> collectionSelector, + Func resultSelector) { CheckNotNull(collectionSelector, "collectionSelector"); @@ -299,8 +299,8 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static IEnumerable SelectMany( this IEnumerable source, - Serialization.Func> collectionSelector, - Serialization.Func resultSelector) + Func> collectionSelector, + Func resultSelector) { CheckNotNull(source, "source"); CheckNotNull(collectionSelector, "collectionSelector"); @@ -311,8 +311,8 @@ namespace Newtonsoft.Json.Utilities.LinqBridge private static IEnumerable SelectManyYield( this IEnumerable source, - Serialization.Func> collectionSelector, - Serialization.Func resultSelector) + Func> collectionSelector, + Func resultSelector) { var i = 0; foreach (var item in source) @@ -326,7 +326,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static IEnumerable TakeWhile( this IEnumerable source, - Serialization.Func predicate) + Func predicate) { CheckNotNull(predicate, "predicate"); @@ -340,7 +340,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static IEnumerable TakeWhile( this IEnumerable source, - Serialization.Func predicate) + Func predicate) { CheckNotNull(source, "source"); CheckNotNull(predicate, "predicate"); @@ -350,7 +350,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge private static IEnumerable TakeWhileYield( this IEnumerable source, - Serialization.Func predicate) + Func predicate) { var i = 0; foreach (var item in source) @@ -362,8 +362,8 @@ namespace Newtonsoft.Json.Utilities.LinqBridge private static class Futures { - public static readonly Serialization.Func Default = () => default(T); - public static readonly Serialization.Func Undefined = () => { throw new InvalidOperationException(); }; + public static readonly Func Default = () => default(T); + public static readonly Func Undefined = () => { throw new InvalidOperationException(); }; } /// @@ -372,7 +372,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge private static TSource FirstImpl( this IEnumerable source, - Serialization.Func empty) + Func empty) { CheckNotNull(source, "source"); Debug.Assert(empty != null); @@ -401,7 +401,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static TSource First( this IEnumerable source, - Serialization.Func predicate) + Func predicate) { return First(source.Where(predicate)); } @@ -424,7 +424,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static TSource FirstOrDefault( this IEnumerable source, - Serialization.Func predicate) + Func predicate) { return FirstOrDefault(source.Where(predicate)); } @@ -435,7 +435,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge private static TSource LastImpl( this IEnumerable source, - Serialization.Func empty) + Func empty) { CheckNotNull(source, "source"); @@ -472,7 +472,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static TSource Last( this IEnumerable source, - Serialization.Func predicate) + Func predicate) { return Last(source.Where(predicate)); } @@ -495,7 +495,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static TSource LastOrDefault( this IEnumerable source, - Serialization.Func predicate) + Func predicate) { return LastOrDefault(source.Where(predicate)); } @@ -506,7 +506,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge private static TSource SingleImpl( this IEnumerable source, - Serialization.Func empty) + Func empty) { CheckNotNull(source, "source"); @@ -544,7 +544,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static TSource Single( this IEnumerable source, - Serialization.Func predicate) + Func predicate) { return Single(source.Where(predicate)); } @@ -570,7 +570,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static TSource SingleOrDefault( this IEnumerable source, - Serialization.Func predicate) + Func predicate) { return SingleOrDefault(source.Where(predicate)); } @@ -674,7 +674,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static IEnumerable SkipWhile( this IEnumerable source, - Serialization.Func predicate) + Func predicate) { CheckNotNull(predicate, "predicate"); @@ -689,7 +689,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static IEnumerable SkipWhile( this IEnumerable source, - Serialization.Func predicate) + Func predicate) { CheckNotNull(source, "source"); CheckNotNull(predicate, "predicate"); @@ -699,7 +699,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge private static IEnumerable SkipWhileYield( IEnumerable source, - Serialization.Func predicate) + Func predicate) { using (var e = source.GetEnumerator()) { @@ -753,7 +753,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static int Count( this IEnumerable source, - Serialization.Func predicate) + Func predicate) { return Count(source.Where(predicate)); } @@ -781,7 +781,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static long LongCount( this IEnumerable source, - Serialization.Func predicate) + Func predicate) { return LongCount(source.Where(predicate)); } @@ -900,7 +900,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static ILookup ToLookup( this IEnumerable source, - Serialization.Func keySelector) + Func keySelector) { return ToLookup(source, keySelector, e => e, /* comparer */ null); } @@ -913,7 +913,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static ILookup ToLookup( this IEnumerable source, - Serialization.Func keySelector, + Func keySelector, IEqualityComparer comparer) { return ToLookup(source, keySelector, e => e, comparer); @@ -927,8 +927,8 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static ILookup ToLookup( this IEnumerable source, - Serialization.Func keySelector, - Serialization.Func elementSelector) + Func keySelector, + Func elementSelector) { return ToLookup(source, keySelector, elementSelector, /* comparer */ null); } @@ -941,8 +941,8 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static ILookup ToLookup( this IEnumerable source, - Serialization.Func keySelector, - Serialization.Func elementSelector, + Func keySelector, + Func elementSelector, IEqualityComparer comparer) { CheckNotNull(source, "source"); @@ -975,7 +975,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static IEnumerable> GroupBy( this IEnumerable source, - Serialization.Func keySelector) + Func keySelector) { return GroupBy(source, keySelector, /* comparer */ null); } @@ -988,7 +988,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static IEnumerable> GroupBy( this IEnumerable source, - Serialization.Func keySelector, + Func keySelector, IEqualityComparer comparer) { return GroupBy(source, keySelector, e => e, comparer); @@ -1002,8 +1002,8 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static IEnumerable> GroupBy( this IEnumerable source, - Serialization.Func keySelector, - Serialization.Func elementSelector) + Func keySelector, + Func elementSelector) { return GroupBy(source, keySelector, elementSelector, /* comparer */ null); } @@ -1016,8 +1016,8 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static IEnumerable> GroupBy( this IEnumerable source, - Serialization.Func keySelector, - Serialization.Func elementSelector, + Func keySelector, + Func elementSelector, IEqualityComparer comparer) { CheckNotNull(source, "source"); @@ -1035,8 +1035,8 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static IEnumerable GroupBy( this IEnumerable source, - Serialization.Func keySelector, - Serialization.Func, TResult> resultSelector) + Func keySelector, + Func, TResult> resultSelector) { return GroupBy(source, keySelector, resultSelector, /* comparer */ null); } @@ -1050,8 +1050,8 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static IEnumerable GroupBy( this IEnumerable source, - Serialization.Func keySelector, - Serialization.Func, TResult> resultSelector, + Func keySelector, + Func, TResult> resultSelector, IEqualityComparer comparer) { CheckNotNull(source, "source"); @@ -1069,9 +1069,9 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static IEnumerable GroupBy( this IEnumerable source, - Serialization.Func keySelector, - Serialization.Func elementSelector, - Serialization.Func, TResult> resultSelector) + Func keySelector, + Func elementSelector, + Func, TResult> resultSelector) { return GroupBy(source, keySelector, elementSelector, resultSelector, /* comparer */ null); } @@ -1086,9 +1086,9 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static IEnumerable GroupBy( this IEnumerable source, - Serialization.Func keySelector, - Serialization.Func elementSelector, - Serialization.Func, TResult> resultSelector, + Func keySelector, + Func elementSelector, + Func, TResult> resultSelector, IEqualityComparer comparer) { CheckNotNull(source, "source"); @@ -1106,7 +1106,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static TSource Aggregate( this IEnumerable source, - Serialization.Func func) + Func func) { CheckNotNull(source, "source"); CheckNotNull(func, "func"); @@ -1128,7 +1128,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static TAccumulate Aggregate( this IEnumerable source, TAccumulate seed, - Serialization.Func func) + Func func) { return Aggregate(source, seed, func, r => r); } @@ -1142,8 +1142,8 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static TResult Aggregate( this IEnumerable source, TAccumulate seed, - Serialization.Func func, - Serialization.Func resultSelector) + Func func, + Func resultSelector) { CheckNotNull(source, "source"); CheckNotNull(func, "func"); @@ -1230,7 +1230,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static bool All( this IEnumerable source, - Serialization.Func predicate) + Func predicate) { CheckNotNull(source, "source"); CheckNotNull(predicate, "predicate"); @@ -1262,7 +1262,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static bool Any( this IEnumerable source, - Serialization.Func predicate) + Func predicate) { foreach (TSource item in source) { @@ -1359,7 +1359,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge private static TSource MinMaxImpl( this IEnumerable source, - Serialization.Func lesser) + Func lesser) { CheckNotNull(source, "source"); Debug.Assert(lesser != null); @@ -1373,7 +1373,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge private static TSource? MinMaxImpl( this IEnumerable source, - TSource? seed, Serialization.Func lesser) where TSource : struct + TSource? seed, Func lesser) where TSource : struct { CheckNotNull(source, "source"); Debug.Assert(lesser != null); @@ -1400,7 +1400,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static TResult Min( this IEnumerable source, - Serialization.Func selector) + Func selector) { return source.Select(selector).Min(); } @@ -1423,7 +1423,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static TResult Max( this IEnumerable source, - Serialization.Func selector) + Func selector) { return source.Select(selector).Max(); } @@ -1454,7 +1454,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static IOrderedEnumerable OrderBy( this IEnumerable source, - Serialization.Func keySelector) + Func keySelector) { return source.OrderBy(keySelector, /* comparer */ null); } @@ -1466,7 +1466,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static IOrderedEnumerable OrderBy( this IEnumerable source, - Serialization.Func keySelector, + Func keySelector, IComparer comparer) { CheckNotNull(source, "source"); @@ -1481,7 +1481,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static IOrderedEnumerable OrderByDescending( this IEnumerable source, - Serialization.Func keySelector) + Func keySelector) { return source.OrderByDescending(keySelector, /* comparer */ null); } @@ -1493,7 +1493,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static IOrderedEnumerable OrderByDescending( this IEnumerable source, - Serialization.Func keySelector, + Func keySelector, IComparer comparer) { CheckNotNull(source, "source"); @@ -1509,7 +1509,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static IOrderedEnumerable ThenBy( this IOrderedEnumerable source, - Serialization.Func keySelector) + Func keySelector) { return source.ThenBy(keySelector, /* comparer */ null); } @@ -1521,7 +1521,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static IOrderedEnumerable ThenBy( this IOrderedEnumerable source, - Serialization.Func keySelector, + Func keySelector, IComparer comparer) { CheckNotNull(source, "source"); @@ -1536,7 +1536,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static IOrderedEnumerable ThenByDescending( this IOrderedEnumerable source, - Serialization.Func keySelector) + Func keySelector) { return source.ThenByDescending(keySelector, /* comparer */ null); } @@ -1548,7 +1548,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static IOrderedEnumerable ThenByDescending( this IOrderedEnumerable source, - Serialization.Func keySelector, + Func keySelector, IComparer comparer) { CheckNotNull(source, "source"); @@ -1647,7 +1647,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static Dictionary ToDictionary( this IEnumerable source, - Serialization.Func keySelector) + Func keySelector) { return source.ToDictionary(keySelector, /* comparer */ null); } @@ -1660,7 +1660,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static Dictionary ToDictionary( this IEnumerable source, - Serialization.Func keySelector, + Func keySelector, IEqualityComparer comparer) { return source.ToDictionary(keySelector, e => e); @@ -1674,8 +1674,8 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static Dictionary ToDictionary( this IEnumerable source, - Serialization.Func keySelector, - Serialization.Func elementSelector) + Func keySelector, + Func elementSelector) { return source.ToDictionary(keySelector, elementSelector, /* comparer */ null); } @@ -1688,8 +1688,8 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static Dictionary ToDictionary( this IEnumerable source, - Serialization.Func keySelector, - Serialization.Func elementSelector, + Func keySelector, + Func elementSelector, IEqualityComparer comparer) { CheckNotNull(source, "source"); @@ -1726,9 +1726,9 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static IEnumerable Join( this IEnumerable outer, IEnumerable inner, - Serialization.Func outerKeySelector, - Serialization.Func innerKeySelector, - Serialization.Func resultSelector) + Func outerKeySelector, + Func innerKeySelector, + Func resultSelector) { return outer.Join(inner, outerKeySelector, innerKeySelector, resultSelector, /* comparer */ null); } @@ -1742,9 +1742,9 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static IEnumerable Join( this IEnumerable outer, IEnumerable inner, - Serialization.Func outerKeySelector, - Serialization.Func innerKeySelector, - Serialization.Func resultSelector, + Func outerKeySelector, + Func innerKeySelector, + Func resultSelector, IEqualityComparer comparer) { CheckNotNull(outer, "outer"); @@ -1770,9 +1770,9 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static IEnumerable GroupJoin( this IEnumerable outer, IEnumerable inner, - Serialization.Func outerKeySelector, - Serialization.Func innerKeySelector, - Serialization.Func, TResult> resultSelector) + Func outerKeySelector, + Func innerKeySelector, + Func, TResult> resultSelector) { return outer.GroupJoin(inner, outerKeySelector, innerKeySelector, resultSelector, /* comparer */ null); } @@ -1787,9 +1787,9 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static IEnumerable GroupJoin( this IEnumerable outer, IEnumerable inner, - Serialization.Func outerKeySelector, - Serialization.Func innerKeySelector, - Serialization.Func, TResult> resultSelector, + Func outerKeySelector, + Func innerKeySelector, + Func, TResult> resultSelector, IEqualityComparer comparer) { CheckNotNull(outer, "outer"); @@ -1851,7 +1851,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static int Sum( this IEnumerable source, - Serialization.Func selector) + Func selector) { return source.Select(selector).Sum(); } @@ -1889,7 +1889,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static double Average( this IEnumerable source, - Serialization.Func selector) + Func selector) { return source.Select(selector).Average(); } @@ -1919,7 +1919,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static int? Sum( this IEnumerable source, - Serialization.Func selector) + Func selector) { return source.Select(selector).Sum(); } @@ -1957,7 +1957,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static double? Average( this IEnumerable source, - Serialization.Func selector) + Func selector) { return source.Select(selector).Average(); } @@ -1982,7 +1982,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static int? Min( this IEnumerable source, - Serialization.Func selector) + Func selector) { return source.Select(selector).Min(); } @@ -2008,7 +2008,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static int? Max( this IEnumerable source, - Serialization.Func selector) + Func selector) { return source.Select(selector).Max(); } @@ -2037,7 +2037,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static long Sum( this IEnumerable source, - Serialization.Func selector) + Func selector) { return source.Select(selector).Sum(); } @@ -2075,7 +2075,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static double Average( this IEnumerable source, - Serialization.Func selector) + Func selector) { return source.Select(selector).Average(); } @@ -2105,7 +2105,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static long? Sum( this IEnumerable source, - Serialization.Func selector) + Func selector) { return source.Select(selector).Sum(); } @@ -2143,7 +2143,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static double? Average( this IEnumerable source, - Serialization.Func selector) + Func selector) { return source.Select(selector).Average(); } @@ -2168,7 +2168,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static long? Min( this IEnumerable source, - Serialization.Func selector) + Func selector) { return source.Select(selector).Min(); } @@ -2194,7 +2194,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static long? Max( this IEnumerable source, - Serialization.Func selector) + Func selector) { return source.Select(selector).Max(); } @@ -2223,7 +2223,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static float Sum( this IEnumerable source, - Serialization.Func selector) + Func selector) { return source.Select(selector).Sum(); } @@ -2261,7 +2261,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static float Average( this IEnumerable source, - Serialization.Func selector) + Func selector) { return source.Select(selector).Average(); } @@ -2291,7 +2291,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static float? Sum( this IEnumerable source, - Serialization.Func selector) + Func selector) { return source.Select(selector).Sum(); } @@ -2329,7 +2329,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static float? Average( this IEnumerable source, - Serialization.Func selector) + Func selector) { return source.Select(selector).Average(); } @@ -2354,7 +2354,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static float? Min( this IEnumerable source, - Serialization.Func selector) + Func selector) { return source.Select(selector).Min(); } @@ -2380,7 +2380,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static float? Max( this IEnumerable source, - Serialization.Func selector) + Func selector) { return source.Select(selector).Max(); } @@ -2409,7 +2409,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static double Sum( this IEnumerable source, - Serialization.Func selector) + Func selector) { return source.Select(selector).Sum(); } @@ -2447,7 +2447,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static double Average( this IEnumerable source, - Serialization.Func selector) + Func selector) { return source.Select(selector).Average(); } @@ -2477,7 +2477,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static double? Sum( this IEnumerable source, - Serialization.Func selector) + Func selector) { return source.Select(selector).Sum(); } @@ -2515,7 +2515,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static double? Average( this IEnumerable source, - Serialization.Func selector) + Func selector) { return source.Select(selector).Average(); } @@ -2540,7 +2540,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static double? Min( this IEnumerable source, - Serialization.Func selector) + Func selector) { return source.Select(selector).Min(); } @@ -2566,7 +2566,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static double? Max( this IEnumerable source, - Serialization.Func selector) + Func selector) { return source.Select(selector).Max(); } @@ -2595,7 +2595,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static decimal Sum( this IEnumerable source, - Serialization.Func selector) + Func selector) { CheckNotNull(source, "source"); CheckNotNull(selector, "selector"); @@ -2642,7 +2642,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static decimal Average( this IEnumerable source, - Serialization.Func selector) + Func selector) { return source.Select(selector).Average(); } @@ -2672,7 +2672,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static decimal? Sum( this IEnumerable source, - Serialization.Func selector) + Func selector) { return source.Select(selector).Sum(); } @@ -2710,7 +2710,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static decimal? Average( this IEnumerable source, - Serialization.Func selector) + Func selector) { return source.Select(selector).Average(); } @@ -2735,7 +2735,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static decimal? Min( this IEnumerable source, - Serialization.Func selector) + Func selector) { return source.Select(selector).Min(); } @@ -2761,7 +2761,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge public static decimal? Max( this IEnumerable source, - Serialization.Func selector) + Func selector) { return source.Select(selector).Max(); } @@ -2802,7 +2802,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge /// IOrderedEnumerable CreateOrderedEnumerable( - Serialization.Func keySelector, IComparer comparer, bool descending); + Func keySelector, IComparer comparer, bool descending); } /// @@ -2862,7 +2862,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge /// public IEnumerable ApplyResultSelector( - Serialization.Func, TResult> resultSelector) + Func, TResult> resultSelector) { if (resultSelector == null) throw new ArgumentNullException("resultSelector"); @@ -2892,13 +2892,13 @@ namespace Newtonsoft.Json.Utilities.LinqBridge private readonly List> _comparisons; public OrderedEnumerable(IEnumerable source, - Serialization.Func keySelector, IComparer comparer, bool descending) : + Func keySelector, IComparer comparer, bool descending) : this(source, null, keySelector, comparer, descending) { } private OrderedEnumerable(IEnumerable source, List> comparisons, - Serialization.Func keySelector, IComparer comparer, bool descending) + Func keySelector, IComparer comparer, bool descending) { if (source == null) throw new ArgumentNullException("source"); if (keySelector == null) throw new ArgumentNullException("keySelector"); @@ -2917,7 +2917,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge } public IOrderedEnumerable CreateOrderedEnumerable( - Serialization.Func keySelector, IComparer comparer, bool descending) + Func keySelector, IComparer comparer, bool descending) { return new OrderedEnumerable(_source, _comparisons, keySelector, comparer, descending); } @@ -2934,7 +2934,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge // thus making the sort stable. // - var list = _source.Select(new Serialization.Func>(TagPosition)).ToList(); + var list = _source.Select(new Func>(TagPosition)).ToList(); list.Sort((x, y) => { @@ -2958,7 +2958,7 @@ namespace Newtonsoft.Json.Utilities.LinqBridge return x.Second.CompareTo(y.Second); }); - return list.Select(new Serialization.Func, T>(GetFirst)).GetEnumerator(); + return list.Select(new Func, T>(GetFirst)).GetEnumerator(); } diff --git a/src/Newtonsoft.Json/Utilities/ReflectionDelegateFactory.cs b/src/Newtonsoft.Json/Utilities/ReflectionDelegateFactory.cs index eeedc03b..13d38f63 100644 --- a/src/Newtonsoft.Json/Utilities/ReflectionDelegateFactory.cs +++ b/src/Newtonsoft.Json/Utilities/ReflectionDelegateFactory.cs @@ -36,7 +36,7 @@ namespace Newtonsoft.Json.Utilities { internal abstract class ReflectionDelegateFactory { - public Serialization.Func CreateGet(MemberInfo memberInfo) + public Func CreateGet(MemberInfo memberInfo) { if (memberInfo is PropertyInfo propertyInfo) { @@ -57,7 +57,7 @@ namespace Newtonsoft.Json.Utilities throw new Exception("Could not create getter for {0}.".FormatWith(CultureInfo.InvariantCulture, memberInfo)); } - public Serialization.Action CreateSet(MemberInfo memberInfo) + public Action CreateSet(MemberInfo memberInfo) { if (memberInfo is PropertyInfo propertyInfo) { @@ -74,10 +74,10 @@ namespace Newtonsoft.Json.Utilities public abstract MethodCall CreateMethodCall(MethodBase method); public abstract ObjectConstructor CreateParameterizedConstructor(MethodBase method); - public abstract Serialization.Func CreateDefaultConstructor(Type type); - public abstract Serialization.Func CreateGet(PropertyInfo propertyInfo); - public abstract Serialization.Func CreateGet(FieldInfo fieldInfo); - public abstract Serialization.Action CreateSet(FieldInfo fieldInfo); - public abstract Serialization.Action CreateSet(PropertyInfo propertyInfo); + public abstract Func CreateDefaultConstructor(Type type); + public abstract Func CreateGet(PropertyInfo propertyInfo); + public abstract Func CreateGet(FieldInfo fieldInfo); + public abstract Action CreateSet(FieldInfo fieldInfo); + public abstract Action CreateSet(PropertyInfo propertyInfo); } } \ No newline at end of file diff --git a/src/Newtonsoft.Json/Utilities/ReflectionObject.cs b/src/Newtonsoft.Json/Utilities/ReflectionObject.cs index a3009d6f..5eda2da0 100644 --- a/src/Newtonsoft.Json/Utilities/ReflectionObject.cs +++ b/src/Newtonsoft.Json/Utilities/ReflectionObject.cs @@ -40,8 +40,8 @@ namespace Newtonsoft.Json.Utilities internal class ReflectionMember { public Type MemberType { get; set; } - public Serialization.Func Getter { get; set; } - public Serialization.Action Setter { get; set; } + public Func Getter { get; set; } + public Action Setter { get; set; } } internal class ReflectionObject @@ -57,13 +57,13 @@ namespace Newtonsoft.Json.Utilities public object GetValue(object target, string member) { - Serialization.Func getter = Members[member].Getter; + Func getter = Members[member].Getter; return getter(target); } public void SetValue(object target, string member, object value) { - Serialization.Action setter = Members[member].Setter; + Action setter = Members[member].Setter; setter(target, value); } @@ -90,7 +90,7 @@ namespace Newtonsoft.Json.Utilities { if (ReflectionUtils.HasDefaultConstructor(t, false)) { - Serialization.Func ctor = delegateFactory.CreateDefaultConstructor(t); + Func ctor = delegateFactory.CreateDefaultConstructor(t); creatorConstructor = args => ctor(); } diff --git a/src/Newtonsoft.Json/Utilities/ReflectionUtils.cs b/src/Newtonsoft.Json/Utilities/ReflectionUtils.cs index c4ed506e..15e04769 100644 --- a/src/Newtonsoft.Json/Utilities/ReflectionUtils.cs +++ b/src/Newtonsoft.Json/Utilities/ReflectionUtils.cs @@ -41,7 +41,7 @@ using Newtonsoft.Json.Serialization; namespace Newtonsoft.Json.Utilities { -#if (DOTNET || PORTABLE || PORTABLE40) && !NETSTANDARD2_0 +#if (DOTNET || PORTABLE) && !NETSTANDARD2_0 [Flags] internal enum MemberTypes { diff --git a/src/Newtonsoft.Json/Utilities/StringUtils.cs b/src/Newtonsoft.Json/Utilities/StringUtils.cs index 4ed03c93..049c70a7 100644 --- a/src/Newtonsoft.Json/Utilities/StringUtils.cs +++ b/src/Newtonsoft.Json/Utilities/StringUtils.cs @@ -122,7 +122,7 @@ namespace Newtonsoft.Json.Utilities buffer[5] = MathUtils.IntToHex(c & '\x000f'); } - public static TSource ForgivingCaseSensitiveFind(this IEnumerable source, Serialization.Func valueSelector, string testValue) + public static TSource ForgivingCaseSensitiveFind(this IEnumerable source, Func valueSelector, string testValue) { if (source == null) { diff --git a/src/Newtonsoft.Json/Utilities/ThreadSafeStore.cs b/src/Newtonsoft.Json/Utilities/ThreadSafeStore.cs index 6b618efe..2e135f0a 100644 --- a/src/Newtonsoft.Json/Utilities/ThreadSafeStore.cs +++ b/src/Newtonsoft.Json/Utilities/ThreadSafeStore.cs @@ -44,9 +44,9 @@ namespace Newtonsoft.Json.Utilities private readonly object _lock = new object(); private Dictionary _store; #endif - private readonly Serialization.Func _creator; + private readonly Func _creator; - public ThreadSafeStore(Serialization.Func creator) + public ThreadSafeStore(Func creator) { ValidationUtils.ArgumentNotNull(creator, nameof(creator)); diff --git a/src/Properties/AssemblyInfo.cs b/src/Properties/AssemblyInfo.cs index 4cb475e1..5639b9a1 100644 --- a/src/Properties/AssemblyInfo.cs +++ b/src/Properties/AssemblyInfo.cs @@ -1,6 +1,8 @@ -using System.Reflection; +using System; +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using System.Security; // 有关程序集的一般信息由以下 // 控制。更改这些特性值可修改 @@ -34,3 +36,5 @@ using System.Runtime.InteropServices; // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] + +[assembly: AllowPartiallyTrustedCallers] diff --git a/src/UpgradeLog.htm b/src/UpgradeLog.htm new file mode 100644 index 00000000..22d7d333 Binary files /dev/null and b/src/UpgradeLog.htm differ