summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System
diff options
context:
space:
mode:
authorJiyoung Yun <jy910.yun@samsung.com>2016-12-27 07:46:08 (GMT)
committerJiyoung Yun <jy910.yun@samsung.com>2016-12-27 07:46:08 (GMT)
commitdb20f3f1bb8595633a7e16c8900fd401a453a6b5 (patch)
treee5435159cd1bf0519276363a6fe1663d1721bed3 /src/mscorlib/src/System
parent4b4aad7217d3292650e77eec2cf4c198ea9c3b4b (diff)
downloadcoreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.zip
coreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.tar.gz
coreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.tar.bz2
Imported Upstream version 1.0.0.9127upstream/1.0.0.9127
Diffstat (limited to 'src/mscorlib/src/System')
-rw-r--r--src/mscorlib/src/System/Action.cs43
-rw-r--r--src/mscorlib/src/System/Activator.cs136
-rw-r--r--src/mscorlib/src/System/AggregateException.cs17
-rw-r--r--src/mscorlib/src/System/AppContext/AppContext.cs56
-rw-r--r--src/mscorlib/src/System/AppContext/AppContextDefaultValues.Defaults.cs12
-rw-r--r--src/mscorlib/src/System/AppContext/AppContextDefaultValues.cs6
-rw-r--r--src/mscorlib/src/System/AppContext/AppContextSwitches.cs30
-rw-r--r--src/mscorlib/src/System/AppDomain.cs2188
-rw-r--r--src/mscorlib/src/System/AppDomainManager.cs171
-rw-r--r--src/mscorlib/src/System/AppDomainSetup.cs469
-rw-r--r--src/mscorlib/src/System/ApplicationId.cs6
-rw-r--r--src/mscorlib/src/System/ArgIterator.cs11
-rw-r--r--src/mscorlib/src/System/ArgumentException.cs3
-rw-r--r--src/mscorlib/src/System/ArgumentNullException.cs1
-rw-r--r--src/mscorlib/src/System/ArgumentOutOfRangeException.cs3
-rw-r--r--src/mscorlib/src/System/Array.cs433
-rw-r--r--src/mscorlib/src/System/ArraySegment.cs96
-rw-r--r--src/mscorlib/src/System/Attribute.cs137
-rw-r--r--src/mscorlib/src/System/BCLDebug.cs32
-rw-r--r--src/mscorlib/src/System/BadImageFormatException.cs3
-rw-r--r--src/mscorlib/src/System/BitConverter.cs61
-rw-r--r--src/mscorlib/src/System/Boolean.cs2
-rw-r--r--src/mscorlib/src/System/Buffer.cs50
-rw-r--r--src/mscorlib/src/System/ByReference.cs31
-rw-r--r--src/mscorlib/src/System/Byte.cs4
-rw-r--r--src/mscorlib/src/System/CLRConfig.cs2
-rw-r--r--src/mscorlib/src/System/CfgParser.cs14
-rw-r--r--src/mscorlib/src/System/Char.cs94
-rw-r--r--src/mscorlib/src/System/Collections/ArrayList.cs179
-rw-r--r--src/mscorlib/src/System/Collections/BitArray.cs524
-rw-r--r--src/mscorlib/src/System/Collections/CollectionBase.cs10
-rw-r--r--src/mscorlib/src/System/Collections/Comparer.cs5
-rw-r--r--src/mscorlib/src/System/Collections/CompatibleComparer.cs2
-rw-r--r--src/mscorlib/src/System/Collections/Concurrent/ConcurrentDictionary.cs216
-rw-r--r--src/mscorlib/src/System/Collections/Concurrent/ConcurrentQueue.cs21
-rw-r--r--src/mscorlib/src/System/Collections/Concurrent/ConcurrentStack.cs91
-rw-r--r--src/mscorlib/src/System/Collections/Concurrent/IProducerConsumerCollection.cs2
-rw-r--r--src/mscorlib/src/System/Collections/Concurrent/OrderablePartitioner.cs1
-rw-r--r--src/mscorlib/src/System/Collections/Concurrent/Partitioner.cs1
-rw-r--r--src/mscorlib/src/System/Collections/Concurrent/PartitionerStatic.cs104
-rw-r--r--src/mscorlib/src/System/Collections/DictionaryEntry.cs7
-rw-r--r--src/mscorlib/src/System/Collections/EmptyReadOnlyDictionaryInternal.cs20
-rw-r--r--src/mscorlib/src/System/Collections/Generic/ArraySortHelper.cs452
-rw-r--r--src/mscorlib/src/System/Collections/Generic/Comparer.cs18
-rw-r--r--src/mscorlib/src/System/Collections/Generic/DebugView.cs2
-rw-r--r--src/mscorlib/src/System/Collections/Generic/Dictionary.cs101
-rw-r--r--src/mscorlib/src/System/Collections/Generic/EqualityComparer.cs171
-rw-r--r--src/mscorlib/src/System/Collections/Generic/KeyValuePair.cs17
-rw-r--r--src/mscorlib/src/System/Collections/Generic/List.cs116
-rw-r--r--src/mscorlib/src/System/Collections/Hashtable.cs187
-rw-r--r--src/mscorlib/src/System/Collections/ListDictionaryInternal.cs30
-rw-r--r--src/mscorlib/src/System/Collections/ObjectModel/Collection.cs8
-rw-r--r--src/mscorlib/src/System/Collections/ObjectModel/KeyedCollection.cs4
-rw-r--r--src/mscorlib/src/System/Collections/ObjectModel/ReadOnlyCollection.cs8
-rw-r--r--src/mscorlib/src/System/Collections/ObjectModel/ReadOnlyDictionary.cs14
-rw-r--r--src/mscorlib/src/System/Collections/SortedList.cs39
-rw-r--r--src/mscorlib/src/System/Collections/Stack.cs13
-rw-r--r--src/mscorlib/src/System/CompatibilitySwitches.cs72
-rw-r--r--src/mscorlib/src/System/ContextBoundObject.cs24
-rw-r--r--src/mscorlib/src/System/ContextStaticAttribute.cs32
-rw-r--r--src/mscorlib/src/System/Convert.cs80
-rw-r--r--src/mscorlib/src/System/Currency.cs2
-rw-r--r--src/mscorlib/src/System/CurrentTimeZone.cs276
-rw-r--r--src/mscorlib/src/System/DBNull.cs1
-rw-r--r--src/mscorlib/src/System/DateTime.cs86
-rw-r--r--src/mscorlib/src/System/DateTimeOffset.cs34
-rw-r--r--src/mscorlib/src/System/Decimal.cs60
-rw-r--r--src/mscorlib/src/System/DefaultBinder.cs26
-rw-r--r--src/mscorlib/src/System/Delegate.cs107
-rw-r--r--src/mscorlib/src/System/DelegateSerializationHolder.cs29
-rw-r--r--src/mscorlib/src/System/Diagnostics/Assert.cs18
-rw-r--r--src/mscorlib/src/System/Diagnostics/AssertFilter.cs1
-rw-r--r--src/mscorlib/src/System/Diagnostics/Contracts/Contracts.cs19
-rw-r--r--src/mscorlib/src/System/Diagnostics/Contracts/ContractsBCL.cs62
-rw-r--r--src/mscorlib/src/System/Diagnostics/Debugger.cs9
-rw-r--r--src/mscorlib/src/System/Diagnostics/DebuggerAttributes.cs20
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/ActivityTracker.cs13
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/EventProvider.cs66
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/EventSource.cs465
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/EventSource_CoreCLR.cs4
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/DataCollector.cs1
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/EventPayload.cs9
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/EventSourceActivity.cs2
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/FieldMetadata.cs2
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/PropertyValue.cs7
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/SimpleTypeInfos.cs3
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/Statics.cs2
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingDataCollector.cs1
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingEventSource.cs18
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingEventTypes.cs10
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingMetadataCollector.cs6
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingTypeInfo.cs4
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/XplatEventLogger.cs28
-rw-r--r--src/mscorlib/src/System/Diagnostics/LogSwitch.cs7
-rw-r--r--src/mscorlib/src/System/Diagnostics/Stackframe.cs23
-rw-r--r--src/mscorlib/src/System/Diagnostics/Stacktrace.cs79
-rw-r--r--src/mscorlib/src/System/Diagnostics/SymbolStore/ISymWriter.cs30
-rw-r--r--src/mscorlib/src/System/Diagnostics/log.cs5
-rw-r--r--src/mscorlib/src/System/Double.cs8
-rw-r--r--src/mscorlib/src/System/Empty.cs3
-rw-r--r--src/mscorlib/src/System/Enum.cs174
-rw-r--r--src/mscorlib/src/System/Environment.cs1154
-rw-r--r--src/mscorlib/src/System/Exception.cs88
-rw-r--r--src/mscorlib/src/System/FormattableString.cs2
-rw-r--r--src/mscorlib/src/System/GC.cs172
-rw-r--r--src/mscorlib/src/System/Globalization/Calendar.cs18
-rw-r--r--src/mscorlib/src/System/Globalization/CalendarData.cs6
-rw-r--r--src/mscorlib/src/System/Globalization/CalendricalCalculationsHelper.cs17
-rw-r--r--src/mscorlib/src/System/Globalization/CharUnicodeInfo.cs66
-rw-r--r--src/mscorlib/src/System/Globalization/ChineseLunisolarCalendar.cs4
-rw-r--r--src/mscorlib/src/System/Globalization/CompareInfo.cs171
-rw-r--r--src/mscorlib/src/System/Globalization/CultureData.cs445
-rw-r--r--src/mscorlib/src/System/Globalization/CultureInfo.cs167
-rw-r--r--src/mscorlib/src/System/Globalization/CultureNotFoundException.cs3
-rw-r--r--src/mscorlib/src/System/Globalization/DateTimeFormat.cs134
-rw-r--r--src/mscorlib/src/System/Globalization/DateTimeFormatInfo.cs248
-rw-r--r--src/mscorlib/src/System/Globalization/DateTimeFormatInfoScanner.cs3
-rw-r--r--src/mscorlib/src/System/Globalization/DateTimeParse.cs90
-rw-r--r--src/mscorlib/src/System/Globalization/DaylightTime.cs23
-rw-r--r--src/mscorlib/src/System/Globalization/EastAsianLunisolarCalendar.cs26
-rw-r--r--src/mscorlib/src/System/Globalization/EncodingDataItem.cs7
-rw-r--r--src/mscorlib/src/System/Globalization/EncodingTable.Unix.cs9
-rw-r--r--src/mscorlib/src/System/Globalization/EncodingTable.cs16
-rw-r--r--src/mscorlib/src/System/Globalization/GlobalizationAssembly.cs8
-rw-r--r--src/mscorlib/src/System/Globalization/GregorianCalendar.cs50
-rw-r--r--src/mscorlib/src/System/Globalization/GregorianCalendarHelper.cs24
-rw-r--r--src/mscorlib/src/System/Globalization/HebrewCalendar.cs31
-rw-r--r--src/mscorlib/src/System/Globalization/HebrewNumber.cs3
-rw-r--r--src/mscorlib/src/System/Globalization/HijriCalendar.cs24
-rw-r--r--src/mscorlib/src/System/Globalization/IdnMapping.cs156
-rw-r--r--src/mscorlib/src/System/Globalization/JapaneseCalendar.cs5
-rw-r--r--src/mscorlib/src/System/Globalization/JulianCalendar.cs18
-rw-r--r--src/mscorlib/src/System/Globalization/KoreanCalendar.cs2
-rw-r--r--src/mscorlib/src/System/Globalization/KoreanLunisolarCalendar.cs4
-rw-r--r--src/mscorlib/src/System/Globalization/NumberFormatInfo.cs66
-rw-r--r--src/mscorlib/src/System/Globalization/PersianCalendar.cs37
-rw-r--r--src/mscorlib/src/System/Globalization/RegionInfo.cs200
-rw-r--r--src/mscorlib/src/System/Globalization/SortKey.cs7
-rw-r--r--src/mscorlib/src/System/Globalization/StringInfo.cs29
-rw-r--r--src/mscorlib/src/System/Globalization/TaiwanCalendar.cs4
-rw-r--r--src/mscorlib/src/System/Globalization/TextElementEnumerator.cs7
-rw-r--r--src/mscorlib/src/System/Globalization/TextInfo.cs77
-rw-r--r--src/mscorlib/src/System/Globalization/ThaiBuddhistCalendar.cs2
-rw-r--r--src/mscorlib/src/System/Globalization/TimeSpanFormat.cs30
-rw-r--r--src/mscorlib/src/System/Globalization/TimeSpanParse.cs33
-rw-r--r--src/mscorlib/src/System/Globalization/UmAlQuraCalendar.cs31
-rw-r--r--src/mscorlib/src/System/Guid.cs37
-rw-r--r--src/mscorlib/src/System/IAppDomain.cs246
-rw-r--r--src/mscorlib/src/System/IAppDomainPauseManager.cs15
-rw-r--r--src/mscorlib/src/System/IO/BinaryReader.cs46
-rw-r--r--src/mscorlib/src/System/IO/BinaryWriter.cs37
-rw-r--r--src/mscorlib/src/System/IO/BufferedStream.cs1320
-rw-r--r--src/mscorlib/src/System/IO/Directory.cs642
-rw-r--r--src/mscorlib/src/System/IO/DirectoryInfo.cs265
-rw-r--r--src/mscorlib/src/System/IO/DriveInfo.cs281
-rw-r--r--src/mscorlib/src/System/IO/EncodingCache.cs (renamed from src/mscorlib/src/System/Runtime/CompilerServices/IsPinned.cs)8
-rw-r--r--src/mscorlib/src/System/IO/File.cs658
-rw-r--r--src/mscorlib/src/System/IO/FileAttributes.cs20
-rw-r--r--src/mscorlib/src/System/IO/FileInfo.cs207
-rw-r--r--src/mscorlib/src/System/IO/FileLoadException.cs14
-rw-r--r--src/mscorlib/src/System/IO/FileNotFoundException.cs11
-rw-r--r--src/mscorlib/src/System/IO/FileSecurityState.cs133
-rw-r--r--src/mscorlib/src/System/IO/FileSecurityStateAccess.cs32
-rw-r--r--src/mscorlib/src/System/IO/FileStream.cs2695
-rw-r--r--src/mscorlib/src/System/IO/FileSystemEnumerable.cs185
-rw-r--r--src/mscorlib/src/System/IO/FileSystemInfo.cs137
-rw-r--r--src/mscorlib/src/System/IO/LongPathHelper.cs521
-rw-r--r--src/mscorlib/src/System/IO/MemoryStream.cs112
-rw-r--r--src/mscorlib/src/System/IO/Path.cs1435
-rw-r--r--src/mscorlib/src/System/IO/PathHelper.cs448
-rw-r--r--src/mscorlib/src/System/IO/PathInternal.cs806
-rw-r--r--src/mscorlib/src/System/IO/PinnedBufferMemoryStream.cs6
-rw-r--r--src/mscorlib/src/System/IO/Stream.cs144
-rw-r--r--src/mscorlib/src/System/IO/StreamHelpers.CopyValidation.cs46
-rw-r--r--src/mscorlib/src/System/IO/StreamReader.cs100
-rw-r--r--src/mscorlib/src/System/IO/StreamWriter.cs175
-rw-r--r--src/mscorlib/src/System/IO/StringReader.cs187
-rw-r--r--src/mscorlib/src/System/IO/StringWriter.cs196
-rw-r--r--src/mscorlib/src/System/IO/TextReader.cs36
-rw-r--r--src/mscorlib/src/System/IO/TextWriter.cs37
-rw-r--r--src/mscorlib/src/System/IO/UnmanagedMemoryAccessor.cs215
-rw-r--r--src/mscorlib/src/System/IO/UnmanagedMemoryStream.cs187
-rw-r--r--src/mscorlib/src/System/IO/UnmanagedMemoryStreamWrapper.cs9
-rw-r--r--src/mscorlib/src/System/IO/__DebugOutputTextWriter.cs76
-rw-r--r--src/mscorlib/src/System/IO/__Error.cs12
-rw-r--r--src/mscorlib/src/System/Int16.cs3
-rw-r--r--src/mscorlib/src/System/Int32.cs4
-rw-r--r--src/mscorlib/src/System/Int64.cs4
-rw-r--r--src/mscorlib/src/System/IntPtr.cs27
-rw-r--r--src/mscorlib/src/System/Internal.cs19
-rw-r--r--src/mscorlib/src/System/InvalidTimeZoneException.cs12
-rw-r--r--src/mscorlib/src/System/Lazy.cs23
-rw-r--r--src/mscorlib/src/System/LowLevelConsole.cs3
-rw-r--r--src/mscorlib/src/System/MarshalByRefObject.cs245
-rw-r--r--src/mscorlib/src/System/Math.cs191
-rw-r--r--src/mscorlib/src/System/MathF.cs253
-rw-r--r--src/mscorlib/src/System/MissingFieldException.cs1
-rw-r--r--src/mscorlib/src/System/MissingMemberException.cs5
-rw-r--r--src/mscorlib/src/System/MissingMethodException.cs1
-rw-r--r--src/mscorlib/src/System/MulticastDelegate.cs40
-rw-r--r--src/mscorlib/src/System/NotFiniteNumberException.cs3
-rw-r--r--src/mscorlib/src/System/Nullable.cs2
-rw-r--r--src/mscorlib/src/System/Number.cs191
-rw-r--r--src/mscorlib/src/System/Numerics/Hashing/HashHelpers.cs19
-rw-r--r--src/mscorlib/src/System/Object.cs48
-rw-r--r--src/mscorlib/src/System/ObjectDisposedException.cs1
-rw-r--r--src/mscorlib/src/System/OleAutBinder.cs21
-rw-r--r--src/mscorlib/src/System/OperatingSystem.cs7
-rw-r--r--src/mscorlib/src/System/ParseNumbers.cs8
-rw-r--r--src/mscorlib/src/System/Progress.cs4
-rw-r--r--src/mscorlib/src/System/Random.cs74
-rw-r--r--src/mscorlib/src/System/ReadOnlySpan.cs397
-rw-r--r--src/mscorlib/src/System/Reflection/Assembly.cs1048
-rw-r--r--src/mscorlib/src/System/Reflection/AssemblyAttributes.cs2
-rw-r--r--src/mscorlib/src/System/Reflection/AssemblyName.cs274
-rw-r--r--src/mscorlib/src/System/Reflection/Associates.cs9
-rw-r--r--src/mscorlib/src/System/Reflection/ComInterfaces.cs572
-rw-r--r--src/mscorlib/src/System/Reflection/ConstructorInfo.cs145
-rw-r--r--src/mscorlib/src/System/Reflection/CustomAttribute.cs168
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/AQNBuilder.cs30
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs1145
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderAccess.cs6
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderData.cs40
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/ComInterfaces.cs173
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/ConstructorBuilder.cs61
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/CustomAttributeBuilder.cs143
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs69
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs224
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/EnumBuilder.cs30
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/EventBuilder.cs47
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs54
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/FlowControl.cs3
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs3
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/ILGenerator.cs111
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/ISymWrapperCore.cs136
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/LocalBuilder.cs22
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/MethodBuilder.cs165
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/ModuleBuilder.cs489
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/ModuleBuilderData.cs6
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/Opcode.cs118
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/OpcodeType.cs3
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/OperandType.cs3
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/ParameterBuilder.cs35
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/PropertyBuilder.cs49
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs69
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/SymbolMethod.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/SymbolType.cs2
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs324
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs4
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/UnmanagedMarshal.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/XXXOnTypeBuilderInstantiation.cs13
-rw-r--r--src/mscorlib/src/System/Reflection/EventInfo.cs55
-rw-r--r--src/mscorlib/src/System/Reflection/FieldInfo.cs98
-rw-r--r--src/mscorlib/src/System/Reflection/IntrospectionExtensions.cs23
-rw-r--r--src/mscorlib/src/System/Reflection/InvalidFilterCriteriaException.cs4
-rw-r--r--src/mscorlib/src/System/Reflection/LoaderAllocator.cs2
-rw-r--r--src/mscorlib/src/System/Reflection/MdConstant.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/MdImport.cs55
-rw-r--r--src/mscorlib/src/System/Reflection/MemberInfo.cs31
-rw-r--r--src/mscorlib/src/System/Reflection/MemberInfoSerializationHolder.cs6
-rw-r--r--src/mscorlib/src/System/Reflection/Metadata/AssemblyExtensions.cs4
-rw-r--r--src/mscorlib/src/System/Reflection/MethodBase.cs50
-rw-r--r--src/mscorlib/src/System/Reflection/MethodBody.cs3
-rw-r--r--src/mscorlib/src/System/Reflection/MethodInfo.cs164
-rw-r--r--src/mscorlib/src/System/Reflection/Missing.cs3
-rw-r--r--src/mscorlib/src/System/Reflection/Module.cs158
-rw-r--r--src/mscorlib/src/System/Reflection/ParameterInfo.cs90
-rw-r--r--src/mscorlib/src/System/Reflection/Pointer.cs14
-rw-r--r--src/mscorlib/src/System/Reflection/PropertyInfo.cs51
-rw-r--r--src/mscorlib/src/System/Reflection/ReflectionContext.cs2
-rw-r--r--src/mscorlib/src/System/Reflection/ReflectionTypeLoadException.cs3
-rw-r--r--src/mscorlib/src/System/Reflection/RuntimeReflectionExtensions.cs4
-rw-r--r--src/mscorlib/src/System/Reflection/StrongNameKeyPair.cs115
-rw-r--r--src/mscorlib/src/System/Reflection/TargetException.cs4
-rw-r--r--src/mscorlib/src/System/Reflection/TargetInvocationException.cs4
-rw-r--r--src/mscorlib/src/System/Reflection/TargetParameterCountException.cs4
-rw-r--r--src/mscorlib/src/System/Reflection/TypeDelegator.cs5
-rw-r--r--src/mscorlib/src/System/Resources/FileBasedResourceGroveler.cs31
-rw-r--r--src/mscorlib/src/System/Resources/IResourceGroveler.cs5
-rw-r--r--src/mscorlib/src/System/Resources/LooselyLinkedResourceReference.cs10
-rw-r--r--src/mscorlib/src/System/Resources/ManifestBasedResourceGroveler.cs153
-rw-r--r--src/mscorlib/src/System/Resources/NeutralResourcesLanguageAttribute.cs4
-rw-r--r--src/mscorlib/src/System/Resources/ResourceFallbackManager.cs14
-rw-r--r--src/mscorlib/src/System/Resources/ResourceManager.cs306
-rw-r--r--src/mscorlib/src/System/Resources/ResourceReader.cs71
-rw-r--r--src/mscorlib/src/System/Resources/ResourceSet.cs21
-rw-r--r--src/mscorlib/src/System/Resources/RuntimeResourceSet.cs9
-rw-r--r--src/mscorlib/src/System/Resources/SatelliteContractVersionAttribute.cs2
-rw-r--r--src/mscorlib/src/System/Resources/__FastResourceComparer.cs14
-rw-r--r--src/mscorlib/src/System/RtType.cs861
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs58
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/CallingConvention.cs30
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs905
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/DecimalConstantAttribute.cs7
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/FormattableStringFactory.cs4
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/HasCopySemanticsAttribute.cs14
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/IDispatchConstantAttribute.cs26
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/INotifyCompletion.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/IUnknownConstantAttribute.cs27
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/IsBoxed.cs11
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/IsByValue.cs11
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/IsConst.cs11
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/IsCopyConstructed.cs11
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/IsExplicitlyDereferenced.cs22
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/IsImplicitlyDereferenced.cs22
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/IsJitIntrinsic.cs12
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/IsLong.cs18
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/IsSignUnspecifiedByte.cs16
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/IsUdtReturn.cs11
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/NativeCppClassAttribute.cs16
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/RequiredAttributeAttribute.cs26
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs92
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/RuntimeWrappedException.cs3
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/ScopelessEnumAttribute.cs14
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/TaskAwaiter.cs23
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/TypeDependencyAttribute.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/TypeForwardedFromAttribute.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/TypeForwardedToAttribute.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/Unsafe.cs80
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/YieldAwaitable.cs6
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/jithelpers.cs52
-rw-r--r--src/mscorlib/src/System/Runtime/ExceptionServices/ExceptionNotification.cs41
-rw-r--r--src/mscorlib/src/System/Runtime/ExceptionServices/ExceptionServicesCommon.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/GcSettings.cs7
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ArrayWithOffset.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/Attributes.cs12
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/BStrWrapper.cs8
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/COMException.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ComEventsHelper.cs16
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ComEventsInfo.cs5
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ComEventsSink.cs9
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/CriticalHandle.cs11
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/CurrencyWrapper.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/DispatchWrapper.cs4
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ErrorWrapper.cs6
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ExtensibleClassFactory.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ExternalException.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/GcHandle.cs21
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/ICustomQueryInterface.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/IException.cs48
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/IRegistrationServices.cs6
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/Marshal.cs622
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/NativeBuffer.cs175
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/NativeMethods.cs4
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/NonPortable.cs34
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/RegistrationServices.cs52
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/RuntimeEnvironment.cs57
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/SafeBuffer.cs28
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/SafeHandle.cs13
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/SafeHeapHandle.cs115
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/StringBuffer.cs402
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/TCEAdapterGen/EventProviderWriter.cs67
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/TCEAdapterGen/EventSinkHelperWriter.cs9
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/TypeLibConverter.cs595
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/Variant.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/BindableVectorToCollectionAdapter.cs11
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/BindableVectorToListAdapter.cs30
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIPropertyValueImpl.cs8
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIReferenceImpl.cs11
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ConstantSplittableMap.cs4
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CustomPropertyImpl.cs6
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryKeyCollection.cs8
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryToMapAdapter.cs12
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryValueCollection.cs8
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/EnumeratorToIteratorAdapter.cs7
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IClosable.cs8
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ICustomPropertyProvider.cs7
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IMapViewToIReadOnlyDictionaryAdapter.cs29
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IReadOnlyDictionaryToIMapViewAdapter.cs6
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IReadOnlyListToIVectorViewAdapter.cs8
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IRestrictedErrorInfo.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IVectorViewToIReadOnlyListAdapter.cs8
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IteratorToEnumeratorAdapter.cs19
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ListToBindableVectorAdapter.cs15
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ListToBindableVectorViewAdapter.cs4
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ListToVectorAdapter.cs19
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ManagedActivationFactory.cs5
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/MapToCollectionAdapter.cs14
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/MapToDictionaryAdapter.cs23
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/MapViewToReadOnlyCollectionAdapter.cs4
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/NativeMethods.cs7
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/RuntimeClass.cs9
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/VectorToCollectionAdapter.cs14
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/VectorToListAdapter.cs24
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/VectorViewToReadOnlyCollectionAdapter.cs4
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeBufferHelper.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs52
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMetadata.cs5
-rw-r--r--src/mscorlib/src/System/Runtime/Loader/AssemblyLoadContext.cs92
-rw-r--r--src/mscorlib/src/System/Runtime/MemoryFailPoint.cs16
-rw-r--r--src/mscorlib/src/System/Runtime/ProfileOptimization.cs4
-rw-r--r--src/mscorlib/src/System/Runtime/Reliability/CriticalFinalizerObject.cs6
-rw-r--r--src/mscorlib/src/System/Runtime/Remoting/ObjectHandle.cs42
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/FormatterConverter.cs34
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/FormatterServices.cs76
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/IObjectReference.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/ISerializable.cs1
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/ISerializationSurrogate.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/ISurrogateSelector.cs3
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/SafeSerializationManager.cs446
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/SerializationFieldInfo.cs36
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/SerializationInfo.cs98
-rw-r--r--src/mscorlib/src/System/Runtime/Serialization/SerializationInfoEnumerator.cs15
-rw-r--r--src/mscorlib/src/System/Runtime/Versioning/BinaryCompatibility.cs485
-rw-r--r--src/mscorlib/src/System/Runtime/Versioning/CompatibilitySwitch.cs5
-rw-r--r--src/mscorlib/src/System/Runtime/Versioning/ComponentGuaranteesAttribute.cs44
-rw-r--r--src/mscorlib/src/System/Runtime/Versioning/ResourceAttributes.cs237
-rw-r--r--src/mscorlib/src/System/Runtime/Versioning/TargetFrameworkAttribute.cs2
-rw-r--r--src/mscorlib/src/System/RuntimeHandles.cs273
-rw-r--r--src/mscorlib/src/System/SByte.cs3
-rw-r--r--src/mscorlib/src/System/Security/AccessControl/Enums.cs6
-rw-r--r--src/mscorlib/src/System/Security/Attributes.cs11
-rw-r--r--src/mscorlib/src/System/Security/BuiltInPermissionSets.cs103
-rw-r--r--src/mscorlib/src/System/Security/CodeAccessPermission.cs69
-rw-r--r--src/mscorlib/src/System/Security/CodeAccessSecurityEngine.cs468
-rw-r--r--src/mscorlib/src/System/Security/FrameSecurityDescriptor.cs31
-rw-r--r--src/mscorlib/src/System/Security/HostProtectionException.cs5
-rw-r--r--src/mscorlib/src/System/Security/HostSecurityManager.cs131
-rw-r--r--src/mscorlib/src/System/Security/IEvidenceFactory.cs15
-rw-r--r--src/mscorlib/src/System/Security/ISecurityEncodable.cs18
-rw-r--r--src/mscorlib/src/System/Security/ISecurityPolicyEncodable.cs17
-rw-r--r--src/mscorlib/src/System/Security/NamedPermissionSet.cs202
-rw-r--r--src/mscorlib/src/System/Security/PermissionListSet.cs29
-rw-r--r--src/mscorlib/src/System/Security/PermissionSet.cs1100
-rw-r--r--src/mscorlib/src/System/Security/PermissionSetEnumerator.cs14
-rw-r--r--src/mscorlib/src/System/Security/PermissionSetTriple.cs20
-rw-r--r--src/mscorlib/src/System/Security/PermissionToken.cs202
-rw-r--r--src/mscorlib/src/System/Security/Permissions/EnvironmentPermission.cs60
-rw-r--r--src/mscorlib/src/System/Security/Permissions/FileDialogPermission.cs33
-rw-r--r--src/mscorlib/src/System/Security/Permissions/FileIOPermission.cs304
-rw-r--r--src/mscorlib/src/System/Security/Permissions/GACIdentityPermission.cs16
-rw-r--r--src/mscorlib/src/System/Security/Permissions/HostProtectionPermission.cs34
-rw-r--r--src/mscorlib/src/System/Security/Permissions/IsolatedStorageFilePermission.cs13
-rw-r--r--src/mscorlib/src/System/Security/Permissions/IsolatedStoragePermission.cs91
-rw-r--r--src/mscorlib/src/System/Security/Permissions/PermissionAttributes.cs314
-rw-r--r--src/mscorlib/src/System/Security/Permissions/ReflectionPermission.cs39
-rw-r--r--src/mscorlib/src/System/Security/Permissions/RegistryPermission.cs131
-rw-r--r--src/mscorlib/src/System/Security/Permissions/SecurityPermission.cs96
-rw-r--r--src/mscorlib/src/System/Security/Permissions/SiteIdentityPermission.cs108
-rw-r--r--src/mscorlib/src/System/Security/Permissions/StrongNameIdentityPermission.cs90
-rw-r--r--src/mscorlib/src/System/Security/Permissions/StrongNamePublicKeyBlob.cs2
-rw-r--r--src/mscorlib/src/System/Security/Permissions/UIPermission.cs44
-rw-r--r--src/mscorlib/src/System/Security/Permissions/URLIdentityPermission.cs111
-rw-r--r--src/mscorlib/src/System/Security/Permissions/ZoneIdentityPermission.cs101
-rw-r--r--src/mscorlib/src/System/Security/Permissions/keycontainerpermission.cs72
-rw-r--r--src/mscorlib/src/System/Security/Policy/ApplicationTrust.cs573
-rw-r--r--src/mscorlib/src/System/Security/Policy/Evidence.cs1865
-rw-r--r--src/mscorlib/src/System/Security/Policy/EvidenceBase.cs31
-rw-r--r--src/mscorlib/src/System/Security/Policy/EvidenceTypeDescriptor.cs20
-rw-r--r--src/mscorlib/src/System/Security/Policy/IDelayEvaluatedEvidence.cs1
-rw-r--r--src/mscorlib/src/System/Security/Policy/PolicyStatement.cs302
-rw-r--r--src/mscorlib/src/System/Security/Policy/Site.cs29
-rw-r--r--src/mscorlib/src/System/Security/Policy/StrongName.cs59
-rw-r--r--src/mscorlib/src/System/Security/Policy/URL.cs29
-rw-r--r--src/mscorlib/src/System/Security/Policy/Zone.cs66
-rw-r--r--src/mscorlib/src/System/Security/Principal/TokenImpersonationLevel.cs9
-rw-r--r--src/mscorlib/src/System/Security/SafeSecurityHandles.cs16
-rw-r--r--src/mscorlib/src/System/Security/SecurityContext.cs238
-rw-r--r--src/mscorlib/src/System/Security/SecurityElement.cs100
-rw-r--r--src/mscorlib/src/System/Security/SecurityException.cs608
-rw-r--r--src/mscorlib/src/System/Security/SecurityManager.cs524
-rw-r--r--src/mscorlib/src/System/Security/SecurityRuntime.cs156
-rw-r--r--src/mscorlib/src/System/Security/SecurityState.cs10
-rw-r--r--src/mscorlib/src/System/Security/Util/Config.cs48
-rw-r--r--src/mscorlib/src/System/Security/Util/Hex.cs2
-rw-r--r--src/mscorlib/src/System/Security/Util/StringExpressionSet.cs41
-rw-r--r--src/mscorlib/src/System/Security/Util/TokenBasedSet.cs32
-rw-r--r--src/mscorlib/src/System/Security/Util/URLString.cs17
-rw-r--r--src/mscorlib/src/System/Security/Util/XMLUtil.cs272
-rw-r--r--src/mscorlib/src/System/Security/securestring.cs31
-rw-r--r--src/mscorlib/src/System/SharedStatics.cs64
-rw-r--r--src/mscorlib/src/System/Single.cs16
-rw-r--r--src/mscorlib/src/System/Span.cs477
-rw-r--r--src/mscorlib/src/System/String.Comparison.cs82
-rw-r--r--src/mscorlib/src/System/String.Manipulation.cs475
-rw-r--r--src/mscorlib/src/System/String.Searching.cs36
-rw-r--r--src/mscorlib/src/System/String.cs126
-rw-r--r--src/mscorlib/src/System/StringComparer.cs35
-rw-r--r--src/mscorlib/src/System/StubHelpers.cs161
-rw-r--r--src/mscorlib/src/System/Text/ASCIIEncoding.cs77
-rw-r--r--src/mscorlib/src/System/Text/BaseCodePageEncoding.cs30
-rw-r--r--src/mscorlib/src/System/Text/CodePageEncoding.cs13
-rw-r--r--src/mscorlib/src/System/Text/DBCSCodePageEncoding.cs102
-rw-r--r--src/mscorlib/src/System/Text/Decoder.cs32
-rw-r--r--src/mscorlib/src/System/Text/DecoderBestFitFallback.cs9
-rw-r--r--src/mscorlib/src/System/Text/DecoderFallback.cs13
-rw-r--r--src/mscorlib/src/System/Text/DecoderNLS.cs43
-rw-r--r--src/mscorlib/src/System/Text/DecoderReplacementFallback.cs9
-rw-r--r--src/mscorlib/src/System/Text/EUCJPEncoding.cs3
-rw-r--r--src/mscorlib/src/System/Text/Encoder.cs32
-rw-r--r--src/mscorlib/src/System/Text/EncoderBestFitFallback.cs12
-rw-r--r--src/mscorlib/src/System/Text/EncoderExceptionFallback.cs6
-rw-r--r--src/mscorlib/src/System/Text/EncoderFallback.cs8
-rw-r--r--src/mscorlib/src/System/Text/EncoderNLS.cs43
-rw-r--r--src/mscorlib/src/System/Text/EncoderReplacementFallback.cs10
-rw-r--r--src/mscorlib/src/System/Text/Encoding.cs222
-rw-r--r--src/mscorlib/src/System/Text/EncodingForwarder.cs98
-rw-r--r--src/mscorlib/src/System/Text/EncodingNLS.cs4
-rw-r--r--src/mscorlib/src/System/Text/EncodingProvider.cs2
-rw-r--r--src/mscorlib/src/System/Text/GB18030Encoding.cs60
-rw-r--r--src/mscorlib/src/System/Text/ISCIIEncoding.cs88
-rw-r--r--src/mscorlib/src/System/Text/ISO2022Encoding.cs74
-rw-r--r--src/mscorlib/src/System/Text/Latin1Encoding.cs66
-rw-r--r--src/mscorlib/src/System/Text/MLangCodePageEncoding.cs19
-rw-r--r--src/mscorlib/src/System/Text/Normalization.Unix.cs123
-rw-r--r--src/mscorlib/src/System/Text/Normalization.Windows.cs286
-rw-r--r--src/mscorlib/src/System/Text/Normalization.cs314
-rw-r--r--src/mscorlib/src/System/Text/SBCSCodePageEncoding.cs93
-rw-r--r--src/mscorlib/src/System/Text/StringBuilder.cs309
-rw-r--r--src/mscorlib/src/System/Text/SurrogateEncoder.cs7
-rw-r--r--src/mscorlib/src/System/Text/UTF32Encoding.cs71
-rw-r--r--src/mscorlib/src/System/Text/UTF7Encoding.cs55
-rw-r--r--src/mscorlib/src/System/Text/UTF8Encoding.cs96
-rw-r--r--src/mscorlib/src/System/Text/UnicodeEncoding.cs92
-rw-r--r--src/mscorlib/src/System/Threading/AsyncLocal.cs387
-rw-r--r--src/mscorlib/src/System/Threading/AutoResetEvent.cs1
-rw-r--r--src/mscorlib/src/System/Threading/CancellationToken.cs14
-rw-r--r--src/mscorlib/src/System/Threading/CancellationTokenRegistration.cs1
-rw-r--r--src/mscorlib/src/System/Threading/CancellationTokenSource.cs37
-rw-r--r--src/mscorlib/src/System/Threading/CountdownEvent.cs23
-rw-r--r--src/mscorlib/src/System/Threading/EventWaitHandle.cs69
-rw-r--r--src/mscorlib/src/System/Threading/ExecutionContext.cs1222
-rw-r--r--src/mscorlib/src/System/Threading/Interlocked.cs17
-rw-r--r--src/mscorlib/src/System/Threading/LazyInitializer.cs4
-rw-r--r--src/mscorlib/src/System/Threading/LockRecursionException.cs3
-rw-r--r--src/mscorlib/src/System/Threading/ManualResetEvent.cs1
-rw-r--r--src/mscorlib/src/System/Threading/ManualResetEventSlim.cs33
-rw-r--r--src/mscorlib/src/System/Threading/Monitor.cs26
-rw-r--r--src/mscorlib/src/System/Threading/Mutex.cs208
-rw-r--r--src/mscorlib/src/System/Threading/Overlapped.cs42
-rw-r--r--src/mscorlib/src/System/Threading/ReaderWriterLock.cs36
-rw-r--r--src/mscorlib/src/System/Threading/Semaphore.cs35
-rw-r--r--src/mscorlib/src/System/Threading/SemaphoreFullException.cs3
-rw-r--r--src/mscorlib/src/System/Threading/SemaphoreSlim.cs50
-rw-r--r--src/mscorlib/src/System/Threading/SpinLock.cs110
-rw-r--r--src/mscorlib/src/System/Threading/SpinWait.cs18
-rw-r--r--src/mscorlib/src/System/Threading/SynchronizationContext.cs90
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/AsyncCausalityTracer.cs4
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/BeginEndAwaitableAdapter.cs16
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/ConcurrentExclusiveSchedulerPair.cs42
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/FutureFactory.cs148
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/Parallel.cs229
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/ParallelLoopState.cs7
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/ParallelRangeManager.cs9
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/ProducerConsumerQueues.cs12
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/TPLETWProvider.cs12
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/Task.cs229
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/TaskCompletionSource.cs6
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/TaskContinuation.cs64
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/TaskExceptionHolder.cs36
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/TaskFactory.cs100
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/TaskScheduler.cs21
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/TaskToApm.cs5
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/ThreadPoolTaskScheduler.cs7
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/future.cs27
-rw-r--r--src/mscorlib/src/System/Threading/Thread.cs633
-rw-r--r--src/mscorlib/src/System/Threading/ThreadAbortException.cs1
-rw-r--r--src/mscorlib/src/System/Threading/ThreadLocal.cs17
-rw-r--r--src/mscorlib/src/System/Threading/ThreadPool.cs230
-rw-r--r--src/mscorlib/src/System/Threading/Timer.cs79
-rw-r--r--src/mscorlib/src/System/Threading/Volatile.cs6
-rw-r--r--src/mscorlib/src/System/Threading/WaitHandle.cs83
-rw-r--r--src/mscorlib/src/System/Threading/WaitHandleCannotBeOpenedException.cs4
-rw-r--r--src/mscorlib/src/System/Threading/WaitHandleExtensions.cs46
-rw-r--r--src/mscorlib/src/System/ThrowHelper.cs211
-rw-r--r--src/mscorlib/src/System/TimeSpan.cs28
-rw-r--r--src/mscorlib/src/System/TimeZone.cs4
-rw-r--r--src/mscorlib/src/System/TimeZoneInfo.cs641
-rw-r--r--src/mscorlib/src/System/TimeZoneNotFoundException.cs3
-rw-r--r--src/mscorlib/src/System/Tuple.cs23
-rw-r--r--src/mscorlib/src/System/Type.cs144
-rw-r--r--src/mscorlib/src/System/TypeInitializationException.cs1
-rw-r--r--src/mscorlib/src/System/TypeLoadException.cs9
-rw-r--r--src/mscorlib/src/System/TypeNameParser.cs30
-rw-r--r--src/mscorlib/src/System/TypedReference.cs10
-rw-r--r--src/mscorlib/src/System/UInt16.cs4
-rw-r--r--src/mscorlib/src/System/UInt32.cs4
-rw-r--r--src/mscorlib/src/System/UInt64.cs4
-rw-r--r--src/mscorlib/src/System/UIntPtr.cs25
-rw-r--r--src/mscorlib/src/System/UnSafeCharBuffer.cs57
-rw-r--r--src/mscorlib/src/System/UnhandledExceptionEventHandler.cs3
-rw-r--r--src/mscorlib/src/System/UnitySerializationHolder.cs4
-rw-r--r--src/mscorlib/src/System/ValueType.cs4
-rw-r--r--src/mscorlib/src/System/Variant.cs27
-rw-r--r--src/mscorlib/src/System/Version.cs164
-rw-r--r--src/mscorlib/src/System/WeakReference.cs23
-rw-r--r--src/mscorlib/src/System/WeakReferenceOfT.cs10
-rw-r--r--src/mscorlib/src/System/_LocalDataStore.cs6
-rw-r--r--src/mscorlib/src/System/_LocalDataStoreMgr.cs13
-rw-r--r--src/mscorlib/src/System/__ComObject.cs13
-rw-r--r--src/mscorlib/src/System/cominterfaces.cs34
-rw-r--r--src/mscorlib/src/System/mda.cs11
592 files changed, 12002 insertions, 47123 deletions
diff --git a/src/mscorlib/src/System/Action.cs b/src/mscorlib/src/System/Action.cs
index d6653c7..27f7faf 100644
--- a/src/mscorlib/src/System/Action.cs
+++ b/src/mscorlib/src/System/Action.cs
@@ -2,62 +2,23 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-//
-
-namespace System {
- using System.Runtime.CompilerServices;
-
+namespace System
+{
public delegate void Action<in T>(T obj);
// Action/Func delegates first shipped with .NET Framework 3.5 in System.Core.dll as part of LINQ
// These were type forwarded to mscorlib.dll in .NET Framework 4.0 and in Silverlight 5.0
-
-#if !FEATURE_CORECLR
- [TypeForwardedFrom("System.Core, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=b77a5c561934e089")]
-#endif
public delegate void Action();
-
-#if !FEATURE_CORECLR
- [TypeForwardedFrom("System.Core, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=b77a5c561934e089")]
-#endif
public delegate void Action<in T1,in T2>(T1 arg1, T2 arg2);
-
-#if !FEATURE_CORECLR
- [TypeForwardedFrom("System.Core, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=b77a5c561934e089")]
-#endif
public delegate void Action<in T1,in T2,in T3>(T1 arg1, T2 arg2, T3 arg3);
-
-#if !FEATURE_CORECLR
- [TypeForwardedFrom("System.Core, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=b77a5c561934e089")]
-#endif
public delegate void Action<in T1,in T2,in T3,in T4>(T1 arg1, T2 arg2, T3 arg3, T4 arg4);
-#if !FEATURE_CORECLR
- [TypeForwardedFrom("System.Core, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=b77a5c561934e089")]
-#endif
public delegate TResult Func<out TResult>();
-
-#if !FEATURE_CORECLR
- [TypeForwardedFrom("System.Core, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=b77a5c561934e089")]
-#endif
public delegate TResult Func<in T, out TResult>(T arg);
-
-#if !FEATURE_CORECLR
- [TypeForwardedFrom("System.Core, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=b77a5c561934e089")]
-#endif
public delegate TResult Func<in T1, in T2, out TResult>(T1 arg1, T2 arg2);
-
-#if !FEATURE_CORECLR
- [TypeForwardedFrom("System.Core, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=b77a5c561934e089")]
-#endif
public delegate TResult Func<in T1, in T2, in T3, out TResult>(T1 arg1, T2 arg2, T3 arg3);
-
-#if !FEATURE_CORECLR
- [TypeForwardedFrom("System.Core, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=b77a5c561934e089")]
-#endif
public delegate TResult Func<in T1, in T2, in T3, in T4, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4);
-
public delegate void Action<in T1,in T2,in T3,in T4,in T5>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5);
public delegate void Action<in T1,in T2,in T3,in T4,in T5,in T6>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6);
public delegate void Action<in T1,in T2,in T3,in T4,in T5,in T6,in T7>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7);
diff --git a/src/mscorlib/src/System/Activator.cs b/src/mscorlib/src/System/Activator.cs
index 274b0e7..6fad8f3 100644
--- a/src/mscorlib/src/System/Activator.cs
+++ b/src/mscorlib/src/System/Activator.cs
@@ -16,10 +16,6 @@ namespace System {
using System;
using System.Reflection;
using System.Runtime.Remoting;
-#if FEATURE_REMOTING
- using System.Runtime.Remoting.Activation;
- using Message = System.Runtime.Remoting.Messaging.Message;
-#endif
using System.Security;
using CultureInfo = System.Globalization.CultureInfo;
using Evidence = System.Security.Policy.Evidence;
@@ -34,7 +30,7 @@ namespace System {
// Only statics, does not need to be marked with the serializable attribute
[ClassInterface(ClassInterfaceType.None)]
[ComDefaultInterface(typeof(_Activator))]
-[System.Runtime.InteropServices.ComVisible(true)]
+ [System.Runtime.InteropServices.ComVisible(true)]
public sealed class Activator : _Activator
{
internal const int LookupMask = 0x000000FF;
@@ -60,7 +56,6 @@ namespace System {
return CreateInstance(type, bindingAttr, binder, args, culture, null);
}
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
static public Object CreateInstance(Type type,
BindingFlags bindingAttr,
@@ -70,7 +65,7 @@ namespace System {
Object[] activationAttributes)
{
if ((object)type == null)
- throw new ArgumentNullException("type");
+ throw new ArgumentNullException(nameof(type));
Contract.EndContractBlock();
if (type is System.Reflection.Emit.TypeBuilder)
@@ -81,26 +76,13 @@ namespace System {
bindingAttr |= Activator.ConstructorDefault;
if (activationAttributes != null && activationAttributes.Length > 0){
- // If type does not derive from MBR
- // throw notsupportedexception
-#if FEATURE_REMOTING
- if(type.IsMarshalByRef){
- // The fix below is preventative.
- //
- if(!(type.IsContextful)){
- if(activationAttributes.Length > 1 || !(activationAttributes[0] is UrlAttribute))
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonUrlAttrOnMBR"));
- }
- }
- else
-#endif
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_ActivAttrOnNonMBR" ));
+ throw new PlatformNotSupportedException(Environment.GetResourceString("NotSupported_ActivAttr" ));
}
RuntimeType rt = type.UnderlyingSystemType as RuntimeType;
if (rt == null)
- throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"),"type");
+ throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), nameof(type));
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
return rt.CreateInstanceImpl(bindingAttr,binder,args,culture,activationAttributes, ref stackMark);
@@ -138,7 +120,6 @@ namespace System {
* types to be created remotely without having to load the type locally.
*/
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
static public ObjectHandle CreateInstance(String assemblyName,
String typeName)
@@ -156,7 +137,6 @@ namespace System {
ref stackMark);
}
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
static public ObjectHandle CreateInstance(String assemblyName,
String typeName,
@@ -180,13 +160,13 @@ namespace System {
static public Object CreateInstance(Type type, bool nonPublic)
{
if ((object)type == null)
- throw new ArgumentNullException("type");
+ throw new ArgumentNullException(nameof(type));
Contract.EndContractBlock();
RuntimeType rt = type.UnderlyingSystemType as RuntimeType;
if (rt == null)
- throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), "type");
+ throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), nameof(type));
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
return rt.CreateInstanceDefaultCtor(!nonPublic, false, true, ref stackMark);
@@ -230,7 +210,6 @@ namespace System {
activationAttributes);
}
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
[Obsolete("Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of CreateInstance which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
static public ObjectHandle CreateInstance(String assemblyName,
@@ -256,7 +235,6 @@ namespace System {
ref stackMark);
}
- [SecuritySafeCritical]
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
public static ObjectHandle CreateInstance(string assemblyName,
string typeName,
@@ -280,7 +258,6 @@ namespace System {
ref stackMark);
}
- [System.Security.SecurityCritical] // auto-generated
static internal ObjectHandle CreateInstance(String assemblyString,
String typeName,
bool ignoreCase,
@@ -292,13 +269,6 @@ namespace System {
Evidence securityInfo,
ref StackCrawlMark stackMark)
{
-#if FEATURE_CAS_POLICY
- if (securityInfo != null && !AppDomain.CurrentDomain.IsLegacyCasPolicyEnabled)
- {
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_RequiresCasPolicyImplicit"));
- }
-#endif // FEATURE_CAS_POLICY
-
Type type = null;
Assembly assembly = null;
if (assemblyString == null) {
@@ -356,13 +326,6 @@ namespace System {
Evidence securityInfo)
{
-#if FEATURE_CAS_POLICY
- if (securityInfo != null && !AppDomain.CurrentDomain.IsLegacyCasPolicyEnabled)
- {
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_RequiresCasPolicyImplicit"));
- }
-#endif // FEATURE_CAS_POLICY
-
return CreateInstanceFromInternal(assemblyFile,
typeName,
ignoreCase,
@@ -404,10 +367,6 @@ namespace System {
Object[] activationAttributes,
Evidence securityInfo)
{
-#if FEATURE_CAS_POLICY
- Contract.Assert(AppDomain.CurrentDomain.IsLegacyCasPolicyEnabled || securityInfo == null);
-#endif // FEATURE_CAS_POLICY
-
#pragma warning disable 618
Assembly assembly = Assembly.LoadFrom(assemblyFile, securityInfo);
#pragma warning restore 618
@@ -436,15 +395,13 @@ namespace System {
// to pass the security checks when activating the type.
//
- [System.Security.SecurityCritical] // auto-generated_required
public static ObjectHandle CreateInstance (AppDomain domain, string assemblyName, string typeName) {
if (domain == null)
- throw new ArgumentNullException("domain");
+ throw new ArgumentNullException(nameof(domain));
Contract.EndContractBlock();
return domain.InternalCreateInstanceWithNoSecurity(assemblyName, typeName);
}
- [System.Security.SecurityCritical] // auto-generated_required
[Obsolete("Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of CreateInstance which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
public static ObjectHandle CreateInstance (AppDomain domain,
string assemblyName,
@@ -457,20 +414,12 @@ namespace System {
Object[] activationAttributes,
Evidence securityAttributes) {
if (domain == null)
- throw new ArgumentNullException("domain");
+ throw new ArgumentNullException(nameof(domain));
Contract.EndContractBlock();
-#if FEATURE_CAS_POLICY
- if (securityAttributes != null && !AppDomain.CurrentDomain.IsLegacyCasPolicyEnabled)
- {
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_RequiresCasPolicyImplicit"));
- }
-#endif // FEATURE_CAS_POLICY
-
return domain.InternalCreateInstanceWithNoSecurity(assemblyName, typeName, ignoreCase, bindingAttr, binder, args, culture, activationAttributes, securityAttributes);
}
- [SecurityCritical]
public static ObjectHandle CreateInstance(AppDomain domain,
string assemblyName,
string typeName,
@@ -482,7 +431,7 @@ namespace System {
object[] activationAttributes)
{
if (domain == null)
- throw new ArgumentNullException("domain");
+ throw new ArgumentNullException(nameof(domain));
Contract.EndContractBlock();
return domain.InternalCreateInstanceWithNoSecurity(assemblyName,
@@ -503,15 +452,13 @@ namespace System {
// to pass the security checks when activating the type.
//
- [System.Security.SecurityCritical] // auto-generated_required
public static ObjectHandle CreateInstanceFrom (AppDomain domain, string assemblyFile, string typeName) {
if (domain == null)
- throw new ArgumentNullException("domain");
+ throw new ArgumentNullException(nameof(domain));
Contract.EndContractBlock();
return domain.InternalCreateInstanceFromWithNoSecurity(assemblyFile, typeName);
}
- [System.Security.SecurityCritical] // auto-generated_required
[Obsolete("Methods which use Evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of CreateInstanceFrom which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
public static ObjectHandle CreateInstanceFrom (AppDomain domain,
string assemblyFile,
@@ -524,20 +471,12 @@ namespace System {
Object[] activationAttributes,
Evidence securityAttributes) {
if (domain == null)
- throw new ArgumentNullException("domain");
+ throw new ArgumentNullException(nameof(domain));
Contract.EndContractBlock();
-#if FEATURE_CAS_POLICY
- if (securityAttributes != null && !AppDomain.CurrentDomain.IsLegacyCasPolicyEnabled)
- {
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_RequiresCasPolicyImplicit"));
- }
-#endif // FEATURE_CAS_POLICY
-
return domain.InternalCreateInstanceFromWithNoSecurity(assemblyFile, typeName, ignoreCase, bindingAttr, binder, args, culture, activationAttributes, securityAttributes);
}
- [SecurityCritical]
public static ObjectHandle CreateInstanceFrom(AppDomain domain,
string assemblyFile,
string typeName,
@@ -549,7 +488,7 @@ namespace System {
object[] activationAttributes)
{
if (domain == null)
- throw new ArgumentNullException("domain");
+ throw new ArgumentNullException(nameof(domain));
Contract.EndContractBlock();
return domain.InternalCreateInstanceFromWithNoSecurity(assemblyFile,
@@ -563,28 +502,8 @@ namespace System {
null);
}
-#if FEATURE_CLICKONCE
- [System.Security.SecuritySafeCritical] // auto-generated
- public static ObjectHandle CreateInstance (ActivationContext activationContext) {
- AppDomainManager domainManager = AppDomain.CurrentDomain.DomainManager;
- if (domainManager == null)
- domainManager = new AppDomainManager();
-
- return domainManager.ApplicationActivator.CreateInstance(activationContext);
- }
-
- [System.Security.SecuritySafeCritical] // auto-generated
- public static ObjectHandle CreateInstance (ActivationContext activationContext, string[] activationCustomData) {
- AppDomainManager domainManager = AppDomain.CurrentDomain.DomainManager;
- if (domainManager == null)
- domainManager = new AppDomainManager();
-
- return domainManager.ApplicationActivator.CreateInstance(activationContext, activationCustomData);
- }
-#endif // FEATURE_CLICKONCE
-
public static ObjectHandle CreateComInstanceFrom(String assemblyName,
- String typeName)
+ String typeName)
{
return CreateComInstanceFrom(assemblyName,
typeName,
@@ -630,38 +549,11 @@ namespace System {
}
}
-#if FEATURE_REMOTING
- // This method is a helper method and delegates to the remoting
- // services to do the actual work.
- [System.Security.SecurityCritical] // auto-generated_required
- static public Object GetObject(Type type, String url)
- {
- return GetObject(type, url, null);
- }
-
- // This method is a helper method and delegates to the remoting
- // services to do the actual work.
- [System.Security.SecurityCritical] // auto-generated_required
- static public Object GetObject(Type type, String url, Object state)
- {
- if (type == null)
- throw new ArgumentNullException("type");
- Contract.EndContractBlock();
- return RemotingServices.Connect(type, url, state);
- }
-#endif
-
[System.Diagnostics.Conditional("_DEBUG")]
private static void Log(bool test, string title, string success, string failure)
{
-#if FEATURE_REMOTING
- if(test)
- BCLDebug.Trace("REMOTE", "{0}{1}", title, success);
- else
- BCLDebug.Trace("REMOTE", "{0}{1}", title, failure);
-#endif
}
-
+
void _Activator.GetTypeInfoCount(out uint pcTInfo)
{
throw new NotImplementedException();
diff --git a/src/mscorlib/src/System/AggregateException.cs b/src/mscorlib/src/System/AggregateException.cs
index 064432a..c0f2122 100644
--- a/src/mscorlib/src/System/AggregateException.cs
+++ b/src/mscorlib/src/System/AggregateException.cs
@@ -69,7 +69,7 @@ namespace System
{
if (innerException == null)
{
- throw new ArgumentNullException("innerException");
+ throw new ArgumentNullException(nameof(innerException));
}
m_innerExceptions = new ReadOnlyCollection<Exception>(new Exception[] { innerException });
@@ -149,7 +149,7 @@ namespace System
{
if (innerExceptions == null)
{
- throw new ArgumentNullException("innerExceptions");
+ throw new ArgumentNullException(nameof(innerExceptions));
}
// Copy exceptions to our internal array and validate them. We must copy them,
@@ -227,7 +227,7 @@ namespace System
{
if (innerExceptionInfos == null)
{
- throw new ArgumentNullException("innerExceptionInfos");
+ throw new ArgumentNullException(nameof(innerExceptionInfos));
}
// Copy exceptions to our internal array and validate them. We must copy them,
@@ -258,13 +258,12 @@ namespace System
/// contains contextual information about the source or destination. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="info"/> argument is null.</exception>
/// <exception cref="T:System.Runtime.Serialization.SerializationException">The exception could not be deserialized correctly.</exception>
- [SecurityCritical]
protected AggregateException(SerializationInfo info, StreamingContext context) :
base(info, context)
{
if (info == null)
{
- throw new ArgumentNullException("info");
+ throw new ArgumentNullException(nameof(info));
}
Exception[] innerExceptions = info.GetValue("InnerExceptions", typeof(Exception[])) as Exception[];
@@ -285,12 +284,11 @@ namespace System
/// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext"/> that
/// contains contextual information about the source or destination. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="info"/> argument is null.</exception>
- [SecurityCritical]
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
if (info == null)
{
- throw new ArgumentNullException("info");
+ throw new ArgumentNullException(nameof(info));
}
base.GetObjectData(info, context);
@@ -351,7 +349,7 @@ namespace System
{
if (predicate == null)
{
- throw new ArgumentNullException("predicate");
+ throw new ArgumentNullException(nameof(predicate));
}
List<Exception> unhandledExceptions = null;
@@ -379,7 +377,8 @@ namespace System
/// <summary>
- /// Flattens an <see cref="AggregateException"/> instances into a single, new instance.
+ /// Flattens the inner instances of <see cref="AggregateException"/> by expanding its contained <see cref="Exception"/> instances
+ /// into a new <see cref="AggregateException"/>
/// </summary>
/// <returns>A new, flattened <see cref="AggregateException"/>.</returns>
/// <remarks>
diff --git a/src/mscorlib/src/System/AppContext/AppContext.cs b/src/mscorlib/src/System/AppContext/AppContext.cs
index 0b0643d..41e4450 100644
--- a/src/mscorlib/src/System/AppContext/AppContext.cs
+++ b/src/mscorlib/src/System/AppContext/AppContext.cs
@@ -21,9 +21,6 @@ namespace System
public static string BaseDirectory
{
-#if FEATURE_CORECLR
- [System.Security.SecuritySafeCritical]
-#endif
get
{
// The value of APP_CONTEXT_BASE_DIRECTORY key has to be a string and it is not allowed to be any other type.
@@ -41,14 +38,53 @@ namespace System
}
}
-#if FEATURE_CORECLR
- [System.Security.SecuritySafeCritical]
-#endif
public static object GetData(string name)
{
return AppDomain.CurrentDomain.GetData(name);
}
+ public static void SetData(string name, object data)
+ {
+ AppDomain.CurrentDomain.SetData(name, data);
+ }
+
+ public static event UnhandledExceptionEventHandler UnhandledException
+ {
+ add
+ {
+ AppDomain.CurrentDomain.UnhandledException += value;
+ }
+
+ remove
+ {
+ AppDomain.CurrentDomain.UnhandledException -= value;
+ }
+ }
+
+ public static event System.EventHandler<System.Runtime.ExceptionServices.FirstChanceExceptionEventArgs> FirstChanceException
+ {
+ add
+ {
+ AppDomain.CurrentDomain.FirstChanceException += value;
+ }
+ remove
+ {
+ AppDomain.CurrentDomain.FirstChanceException -= value;
+ }
+ }
+
+ public static event System.EventHandler ProcessExit
+ {
+ add
+ {
+ AppDomain.CurrentDomain.ProcessExit += value;
+ }
+ remove
+ {
+ AppDomain.CurrentDomain.ProcessExit -= value;
+ }
+ }
+
#region Switch APIs
static AppContext()
{
@@ -65,9 +101,9 @@ namespace System
public static bool TryGetSwitch(string switchName, out bool isEnabled)
{
if (switchName == null)
- throw new ArgumentNullException("switchName");
+ throw new ArgumentNullException(nameof(switchName));
if (switchName.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "switchName");
+ throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(switchName));
// By default, the switch is not enabled.
isEnabled = false;
@@ -161,9 +197,9 @@ namespace System
public static void SetSwitch(string switchName, bool isEnabled)
{
if (switchName == null)
- throw new ArgumentNullException("switchName");
+ throw new ArgumentNullException(nameof(switchName));
if (switchName.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "switchName");
+ throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(switchName));
SwitchValueState switchValue = (isEnabled ? SwitchValueState.HasTrueValue : SwitchValueState.HasFalseValue)
| SwitchValueState.HasLookedForOverride;
diff --git a/src/mscorlib/src/System/AppContext/AppContextDefaultValues.Defaults.cs b/src/mscorlib/src/System/AppContext/AppContextDefaultValues.Defaults.cs
index c80913e..52bdf9d 100644
--- a/src/mscorlib/src/System/AppContext/AppContextDefaultValues.Defaults.cs
+++ b/src/mscorlib/src/System/AppContext/AppContextDefaultValues.Defaults.cs
@@ -12,10 +12,6 @@ namespace System
internal static readonly string SwitchNoAsyncCurrentCulture = "Switch.System.Globalization.NoAsyncCurrentCulture";
internal static readonly string SwitchThrowExceptionIfDisposedCancellationTokenSource = "Switch.System.Threading.ThrowExceptionIfDisposedCancellationTokenSource";
internal static readonly string SwitchPreserveEventListnerObjectIdentity = "Switch.System.Diagnostics.EventSource.PreserveEventListnerObjectIdentity";
-#if FEATURE_PATHCOMPAT
- internal static readonly string SwitchUseLegacyPathHandling = "Switch.System.IO.UseLegacyPathHandling";
- internal static readonly string SwitchBlockLongPaths = "Switch.System.IO.BlockLongPaths";
-#endif
// This is a partial method. Platforms can provide an implementation of it that will set override values
// from whatever mechanism is available on that platform. If no implementation is provided, the compiler is going to remove the calls
@@ -43,13 +39,7 @@ namespace System
AppContext.DefineSwitchDefault(SwitchNoAsyncCurrentCulture, true);
AppContext.DefineSwitchDefault(SwitchThrowExceptionIfDisposedCancellationTokenSource, true);
}
-#if FEATURE_PATHCOMPAT
- if (version <= 40601)
- {
- AppContext.DefineSwitchDefault(SwitchUseLegacyPathHandling, true);
- AppContext.DefineSwitchDefault(SwitchBlockLongPaths, true);
- }
-#endif
+
break;
}
case "WindowsPhone":
diff --git a/src/mscorlib/src/System/AppContext/AppContextDefaultValues.cs b/src/mscorlib/src/System/AppContext/AppContextDefaultValues.cs
index 7ab7ffb..9f00e81 100644
--- a/src/mscorlib/src/System/AppContext/AppContextDefaultValues.cs
+++ b/src/mscorlib/src/System/AppContext/AppContextDefaultValues.cs
@@ -30,7 +30,6 @@ namespace System
if (!TryParseFrameworkName(targetFrameworkMoniker, out identifier, out version, out profile))
{
-#if FEATURE_CORECLR
// If we can't parse the TFM or we don't have a TFM, default to latest behavior for all
// switches (ie. all of them false).
// If we want to use the latest behavior it is enough to set the value of the switch to string.Empty.
@@ -39,11 +38,6 @@ namespace System
// identifier we are simply saying -- don't turn on any switches, and we are going to get the latest
// behavior for all the switches
identifier = string.Empty;
-#else
- identifier = ".NETFramework";
- version = 40000;
- profile = string.Empty;
-#endif
}
}
diff --git a/src/mscorlib/src/System/AppContext/AppContextSwitches.cs b/src/mscorlib/src/System/AppContext/AppContextSwitches.cs
index 3a96ec2..5fdd2bc 100644
--- a/src/mscorlib/src/System/AppContext/AppContextSwitches.cs
+++ b/src/mscorlib/src/System/AppContext/AppContextSwitches.cs
@@ -39,36 +39,6 @@ namespace System
}
}
-#if FEATURE_PATHCOMPAT
- private static int _useLegacyPathHandling;
-
- /// <summary>
- /// Use legacy path normalization logic and blocking of extended syntax.
- /// </summary>
- public static bool UseLegacyPathHandling
- {
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- get
- {
- return GetCachedSwitchValue(AppContextDefaultValues.SwitchUseLegacyPathHandling, ref _useLegacyPathHandling);
- }
- }
-
- private static int _blockLongPaths;
-
- /// <summary>
- /// Throw PathTooLongException for paths greater than MAX_PATH or directories greater than 248 (as per CreateDirectory Win32 limitations)
- /// </summary>
- public static bool BlockLongPaths
- {
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- get
- {
- return GetCachedSwitchValue(AppContextDefaultValues.SwitchBlockLongPaths, ref _blockLongPaths);
- }
- }
-#endif // FEATURE_PATHCOMPAT
-
//
// Implementation details
//
diff --git a/src/mscorlib/src/System/AppDomain.cs b/src/mscorlib/src/System/AppDomain.cs
index abaaf48..fe524c4 100644
--- a/src/mscorlib/src/System/AppDomain.cs
+++ b/src/mscorlib/src/System/AppDomain.cs
@@ -13,46 +13,29 @@
**
=============================================================================*/
-namespace System {
+namespace System
+{
using System;
-#if FEATURE_CLICKONCE
- using System.Deployment.Internal.Isolation;
- using System.Deployment.Internal.Isolation.Manifest;
- using System.Runtime.Hosting;
-#endif
using System.Reflection;
using System.Runtime;
using System.Runtime.CompilerServices;
-#if FEATURE_REMOTING
- using System.Runtime.Remoting.Channels;
- using System.Runtime.Remoting.Contexts;
-#endif
using System.Security;
using System.Security.Permissions;
-#if FEATURE_IMPERSONATION
- using System.Security.Principal;
-#endif
using System.Security.Policy;
using System.Security.Util;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using System.Runtime.InteropServices;
- using System.Runtime.Remoting;
-#if FEATURE_REMOTING
- using Context = System.Runtime.Remoting.Contexts.Context;
-#endif
+ using System.Runtime.Remoting;
using System.Reflection.Emit;
using CultureInfo = System.Globalization.CultureInfo;
-#if !FEATURE_CORECLR
- using System.Globalization;
-#endif
using System.IO;
using AssemblyHashAlgorithm = System.Configuration.Assemblies.AssemblyHashAlgorithm;
using System.Text;
- using Microsoft.Win32;
using System.Runtime.ConstrainedExecution;
using System.Runtime.Versioning;
+ using System.Diagnostics;
using System.Diagnostics.Contracts;
#if FEATURE_EXCEPTION_NOTIFICATIONS
using System.Runtime.ExceptionServices;
@@ -107,10 +90,6 @@ namespace System {
}
}
-
- #if FEATURE_CORECLR
- [System.Security.SecurityCritical] // auto-generated
- #endif
[Serializable]
[ComVisible(true)]
public delegate Assembly ResolveEventHandler(Object sender, ResolveEventArgs args);
@@ -177,7 +156,6 @@ namespace System {
Info = itemInfo.ToArray();
}
- [System.Security.SecuritySafeCritical] // auto-generated
internal AppDomainInitializer Unwrap()
{
if (Info==null)
@@ -204,17 +182,13 @@ namespace System {
[ComDefaultInterface(typeof(System._AppDomain))]
[ComVisible(true)]
public sealed class AppDomain :
-#if FEATURE_REMOTING
- MarshalByRefObject,
-#endif
_AppDomain, IEvidenceFactory
{
// Domain security information
// These fields initialized from the other side only. (NOTE: order
// of these fields cannot be changed without changing the layout in
- // the EE)
+ // the EE- AppDomainBaseObject in this case)
- [System.Security.SecurityCritical] // auto-generated
private AppDomainManager _domainManager;
private Dictionary<String, Object[]> _LocalStore;
private AppDomainSetup _FusionStore;
@@ -225,12 +199,10 @@ namespace System {
[method: System.Security.SecurityCritical]
public event AssemblyLoadEventHandler AssemblyLoad;
- [System.Security.SecurityCritical]
private ResolveEventHandler _TypeResolve;
public event ResolveEventHandler TypeResolve
{
- [System.Security.SecurityCritical]
add
{
lock (this)
@@ -239,7 +211,6 @@ namespace System {
}
}
- [System.Security.SecurityCritical]
remove
{
lock (this)
@@ -249,12 +220,10 @@ namespace System {
}
}
- [System.Security.SecurityCritical]
private ResolveEventHandler _ResourceResolve;
public event ResolveEventHandler ResourceResolve
{
- [System.Security.SecurityCritical]
add
{
lock (this)
@@ -263,7 +232,6 @@ namespace System {
}
}
- [System.Security.SecurityCritical]
remove
{
lock (this)
@@ -273,12 +241,10 @@ namespace System {
}
}
- [System.Security.SecurityCritical]
private ResolveEventHandler _AssemblyResolve;
public event ResolveEventHandler AssemblyResolve
{
- [System.Security.SecurityCritical]
add
{
lock (this)
@@ -287,7 +253,6 @@ namespace System {
}
}
- [System.Security.SecurityCritical]
remove
{
lock (this)
@@ -302,38 +267,13 @@ namespace System {
public event ResolveEventHandler ReflectionOnlyAssemblyResolve;
#endif // FEATURE_REFLECTION_ONLY
-#if FEATURE_REMOTING
- private Context _DefaultContext;
-#endif
-
-#if FEATURE_CLICKONCE
- private ActivationContext _activationContext;
- private ApplicationIdentity _applicationIdentity;
-#endif
private ApplicationTrust _applicationTrust;
-
-#if FEATURE_IMPERSONATION
- private IPrincipal _DefaultPrincipal;
-#endif // FEATURE_IMPERSONATION
-#if FEATURE_REMOTING
- private DomainSpecificRemotingData _RemotingData;
-#endif
private EventHandler _processExit;
- #if FEATURE_CORECLR
- [System.Security.SecurityCritical]
- #endif
private EventHandler _domainUnload;
- #if FEATURE_CORECLR
- [System.Security.SecurityCritical] // auto-generated
- #endif
private UnhandledExceptionEventHandler _unhandledException;
-#if FEATURE_APTCA
- private String[] _aptcaVisibleAssemblies;
-#endif
-
// The compat flags are set at domain creation time to indicate that the given breaking
// changes (named in the strings) should not be used in this domain. We only use the
// keys, the vhe values are ignored.
@@ -346,9 +286,6 @@ namespace System {
private IntPtr _pDomain; // this is an unmanaged pointer (AppDomain * m_pDomain)` used from the VM.
-#if FEATURE_CAS_POLICY
- private PrincipalPolicy _PrincipalPolicy; // this is an enum
-#endif
private bool _HasSetPolicy;
private bool _IsFastFullTrustDomain; // quick check to see if the AppDomain is fully trusted and homogenous
private bool _compatFlagsInitialized;
@@ -378,20 +315,18 @@ namespace System {
private static APPX_FLAGS Flags
{
- [SecuritySafeCritical]
get
{
if (s_flags == 0)
s_flags = nGetAppXFlags();
- Contract.Assert(s_flags != 0);
+ Debug.Assert(s_flags != 0);
return s_flags;
}
}
internal static bool ProfileAPICheck
{
- [SecuritySafeCritical]
get
{
return (Flags & APPX_FLAGS.APPX_FLAGS_API_CHECK) != 0;
@@ -400,7 +335,6 @@ namespace System {
internal static bool IsAppXNGen
{
- [SecuritySafeCritical]
get
{
return (Flags & APPX_FLAGS.APPX_FLAGS_APPX_NGEN) != 0;
@@ -409,56 +343,37 @@ namespace System {
#endif // FEATURE_APPX
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SecurityCritical]
[SuppressUnmanagedCodeSecurity]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool DisableFusionUpdatesFromADManager(AppDomainHandle domain);
#if FEATURE_APPX
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SecurityCritical]
[SuppressUnmanagedCodeSecurity]
[return: MarshalAs(UnmanagedType.I4)]
private static extern APPX_FLAGS nGetAppXFlags();
#endif
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SecurityCritical]
[SuppressUnmanagedCodeSecurity]
private static extern void GetAppDomainManagerType(AppDomainHandle domain,
StringHandleOnStack retAssembly,
StringHandleOnStack retType);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SecurityCritical]
[SuppressUnmanagedCodeSecurity]
private static extern void SetAppDomainManagerType(AppDomainHandle domain,
string assembly,
string type);
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern void nSetHostSecurityManagerFlags (HostSecurityManagerOptions flags);
- [SecurityCritical]
[SuppressUnmanagedCodeSecurity]
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
private static extern void SetSecurityHomogeneousFlag(AppDomainHandle domain,
[MarshalAs(UnmanagedType.Bool)] bool runtimeSuppliedHomogenousGrantSet);
-#if FEATURE_CAS_POLICY
- [SecurityCritical]
- [SuppressUnmanagedCodeSecurity]
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- private static extern void SetLegacyCasPolicyEnabled(AppDomainHandle domain);
-
- [SecurityCritical]
- private void SetLegacyCasPolicyEnabled()
- {
- SetLegacyCasPolicyEnabled(GetNativeHandle());
- }
-#endif // FEATURE_CAS_POLICY
-
/// <summary>
/// Get a handle used to make a call into the VM pointing to this domain
/// </summary>
@@ -471,9 +386,6 @@ namespace System {
throw new InvalidOperationException(Environment.GetResourceString("Argument_InvalidHandle"));
}
-#if FEATURE_REMOTING
- BCLDebug.Assert(!RemotingServices.IsTransparentProxy(this), "QCalls should be made with the real AppDomain object rather than a transparent proxy");
-#endif // FEATURE_REMOTING
return new AppDomainHandle(_pDomain);
}
@@ -481,10 +393,9 @@ namespace System {
/// If this AppDomain is configured to have an AppDomain manager then create the instance of it.
/// This method is also called from the VM to create the domain manager in the default domain.
/// </summary>
- [SecuritySafeCritical]
private void CreateAppDomainManager()
{
- Contract.Assert(_domainManager == null, "_domainManager == null");
+ Debug.Assert(_domainManager == null, "_domainManager == null");
AppDomainSetup adSetup = FusionStore;
#if FEATURE_VERSIONING
@@ -566,17 +477,9 @@ namespace System {
if (notifyFusion)
SetupFusionStore(_FusionStore, FusionStoreOld); // Notify Fusion about the changes the user implementation of InitializeNewDomain may have made to the FusionStore object.
-
-#if FEATURE_APPDOMAINMANAGER_INITOPTIONS
- AppDomainManagerInitializationOptions flags = _domainManager.InitializationFlags;
- if ((flags & AppDomainManagerInitializationOptions.RegisterWithHost) == AppDomainManagerInitializationOptions.RegisterWithHost)
- {
- _domainManager.RegisterWithHost();
- }
-#endif // FEATURE_APPDOMAINMANAGER_INITOPTIONS
}
- InitializeCompatibilityFlags();
+ InitializeCompatibilityFlags();
}
/// <summary>
@@ -596,7 +499,7 @@ namespace System {
// for perf, we don't intialize the _compatFlags dictionary when we don't need to. However, we do need to make a
// note that we've run this method, because IsCompatibilityFlagsSet needs to return different values for the
// case where the compat flags have been setup.
- Contract.Assert(!_compatFlagsInitialized);
+ Debug.Assert(!_compatFlagsInitialized);
_compatFlagsInitialized = true;
CompatibilitySwitches.InitializeSwitches();
@@ -606,7 +509,6 @@ namespace System {
// either by a host in native, a host in managed using an AppDomainSetup, or by the
// TargetFrameworkAttribute on the executable (VS emits its target framework moniker using this
// attribute starting in version 4).
- [SecuritySafeCritical]
internal String GetTargetFrameworkName()
{
String targetFrameworkName = _FusionStore.TargetFrameworkName;
@@ -621,7 +523,7 @@ namespace System {
TargetFrameworkAttribute[] attrs = (TargetFrameworkAttribute[])assembly.GetCustomAttributes(typeof(TargetFrameworkAttribute));
if (attrs != null && attrs.Length > 0)
{
- Contract.Assert(attrs.Length == 1);
+ Debug.Assert(attrs.Length == 1);
targetFrameworkName = attrs[0].FrameworkName;
_FusionStore.TargetFrameworkName = targetFrameworkName;
}
@@ -635,7 +537,6 @@ namespace System {
/// <summary>
/// Returns the setting of the corresponding compatibility config switch (see CreateAppDomainManager for the impact).
/// </summary>
- [SecuritySafeCritical]
internal bool DisableFusionUpdatesFromADManager()
{
return DisableFusionUpdatesFromADManager(GetNativeHandle());
@@ -644,7 +545,6 @@ namespace System {
/// <summary>
/// Returns whether the current AppDomain follows the AppX rules.
/// </summary>
- [SecuritySafeCritical]
[Pure]
internal static bool IsAppXModel()
{
@@ -658,7 +558,6 @@ namespace System {
/// <summary>
/// Returns the setting of the AppXDevMode config switch.
/// </summary>
- [SecuritySafeCritical]
[Pure]
internal static bool IsAppXDesignMode()
{
@@ -672,7 +571,6 @@ namespace System {
/// <summary>
/// Checks (and throws on failure) if the domain supports Assembly.LoadFrom.
/// </summary>
- [SecuritySafeCritical]
[Pure]
internal static void CheckLoadFromSupported()
{
@@ -685,7 +583,6 @@ namespace System {
/// <summary>
/// Checks (and throws on failure) if the domain supports Assembly.LoadFile.
/// </summary>
- [SecuritySafeCritical]
[Pure]
internal static void CheckLoadFileSupported()
{
@@ -698,7 +595,6 @@ namespace System {
/// <summary>
/// Checks (and throws on failure) if the domain supports Assembly.ReflectionOnlyLoad.
/// </summary>
- [SecuritySafeCritical]
[Pure]
internal static void CheckReflectionOnlyLoadSupported()
{
@@ -711,7 +607,6 @@ namespace System {
/// <summary>
/// Checks (and throws on failure) if the domain supports Assembly.LoadWithPartialName.
/// </summary>
- [SecuritySafeCritical]
[Pure]
internal static void CheckLoadWithPartialNameSupported(StackCrawlMark stackMark)
{
@@ -731,7 +626,6 @@ namespace System {
/// <summary>
/// Checks (and throws on failure) if the domain supports DefinePInvokeMethod.
/// </summary>
- [SecuritySafeCritical]
[Pure]
internal static void CheckDefinePInvokeSupported()
{
@@ -745,7 +639,6 @@ namespace System {
/// <summary>
/// Checks (and throws on failure) if the domain supports Assembly.Load(byte[] ...).
/// </summary>
- [SecuritySafeCritical]
[Pure]
internal static void CheckLoadByteArraySupported()
{
@@ -758,7 +651,6 @@ namespace System {
/// <summary>
/// Checks (and throws on failure) if the domain supports AppDomain.CreateDomain.
/// </summary>
- [SecuritySafeCritical]
[Pure]
internal static void CheckCreateDomainSupported()
{
@@ -779,7 +671,6 @@ namespace System {
/// <summary>
/// Get the name of the assembly and type that act as the AppDomainManager for this domain
/// </summary>
- [SecuritySafeCritical]
internal void GetAppDomainManagerType(out string assembly, out string type)
{
// We can't just use our parameters because we need to ensure that the strings used for hte QCall
@@ -798,77 +689,16 @@ namespace System {
/// <summary>
/// Set the assembly and type which act as the AppDomainManager for this domain
/// </summary>
- [SecuritySafeCritical]
private void SetAppDomainManagerType(string assembly, string type)
{
- Contract.Assert(assembly != null, "assembly != null");
- Contract.Assert(type != null, "type != null");
+ Debug.Assert(assembly != null, "assembly != null");
+ Debug.Assert(type != null, "type != null");
SetAppDomainManagerType(GetNativeHandle(), assembly, type);
}
-#if FEATURE_APTCA
- internal String[] PartialTrustVisibleAssemblies
- {
- get { return _aptcaVisibleAssemblies; }
-
- [SecuritySafeCritical]
- set
- {
- _aptcaVisibleAssemblies = value;
-
- // Build up the canonical representaiton of this list to allow the VM to do optimizations in
- // common cases
- string canonicalConditionalAptcaList = null;
- if (value != null)
- {
- StringBuilder conditionalAptcaListBuilder = StringBuilderCache.Acquire();
- for (int i = 0; i < value.Length; ++i)
- {
- if (value[i] != null)
- {
- conditionalAptcaListBuilder.Append(value[i].ToUpperInvariant());
- if (i != value.Length - 1)
- {
- conditionalAptcaListBuilder.Append(';');
- }
- }
- }
-
- canonicalConditionalAptcaList = StringBuilderCache.GetStringAndRelease(conditionalAptcaListBuilder);
- }
-
- SetCanonicalConditionalAptcaList(canonicalConditionalAptcaList);
- }
- }
-
- [SecurityCritical]
- [SuppressUnmanagedCodeSecurity]
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- private static extern void SetCanonicalConditionalAptcaList(AppDomainHandle appDomain, string canonicalList);
-
- [SecurityCritical]
- private void SetCanonicalConditionalAptcaList(string canonicalList)
- {
- SetCanonicalConditionalAptcaList(GetNativeHandle(), canonicalList);
- }
-#endif // FEATURE_APTCA
-
-#if FEATURE_CLICKONCE
- /// <summary>
- /// If the CLR is being started up to run a ClickOnce applicaiton, setup the default AppDomain
- /// with information about that application.
- /// </summary>
- private void SetupDefaultClickOnceDomain(string fullName, string[] manifestPaths, string[] activationData)
- {
- Contract.Requires(fullName != null, "fullName != null");
- FusionStore.ActivationArguments = new ActivationArguments(fullName, manifestPaths, activationData);
- }
-#endif // FEATURE_CLICKONCE
-
/// <summary>
/// Called for every AppDomain (including the default domain) to initialize the security of the AppDomain)
/// </summary>
- [SecurityCritical]
private void InitializeDomainSecurity(Evidence providedSecurityInfo,
Evidence creatorsSecurityInfo,
bool generateDefaultEvidence,
@@ -877,91 +707,23 @@ namespace System {
{
AppDomainSetup adSetup = FusionStore;
-#if FEATURE_CAS_POLICY
- // If the AppDomain is setup to use legacy CAS policy, then set that bit in the application
- // security descriptor.
- if (CompatibilitySwitches.IsNetFx40LegacySecurityPolicy)
- {
- SetLegacyCasPolicyEnabled();
- }
-#endif // FEATURE_CAS_POLICY
-
-#if FEATURE_CLICKONCE
-
- // Check if the domain manager set an ActivationContext (Debug-In-Zone for example)
- // or if this is an AppDomain with an ApplicationTrust.
- if (adSetup.ActivationArguments != null) {
- // Merge the new evidence with the manifest's evidence if applicable
- ActivationContext activationContext = null;
- ApplicationIdentity appIdentity = null;
- string[] activationData = null;
- CmsUtils.CreateActivationContext(adSetup.ActivationArguments.ApplicationFullName,
- adSetup.ActivationArguments.ApplicationManifestPaths,
- adSetup.ActivationArguments.UseFusionActivationContext,
- out appIdentity, out activationContext);
- activationData = adSetup.ActivationArguments.ActivationData;
- providedSecurityInfo = CmsUtils.MergeApplicationEvidence(providedSecurityInfo,
- appIdentity,
- activationContext,
- activationData,
- adSetup.ApplicationTrust);
- SetupApplicationHelper(providedSecurityInfo, creatorsSecurityInfo, appIdentity, activationContext, activationData);
- }
- else
-#endif // FEATURE_CLICKONCE
- {
- bool runtimeSuppliedHomogenousGrant = false;
- ApplicationTrust appTrust = adSetup.ApplicationTrust;
-
-#if FEATURE_CAS_POLICY
- // In non-legacy CAS mode, domains should be homogenous. If the host has not specified a sandbox
- // of their own, we'll set it up to be fully trusted. We must read the IsLegacyCasPolicy
- // enabled property here rathern than just reading the switch from above because the entire
- // process may also be opted into legacy CAS policy mode.
- if (appTrust == null && !IsLegacyCasPolicyEnabled) {
- _IsFastFullTrustDomain = true;
- runtimeSuppliedHomogenousGrant = true;
- }
-#endif // FEATURE_CAS_POLICY
+ bool runtimeSuppliedHomogenousGrant = false;
+ ApplicationTrust appTrust = adSetup.ApplicationTrust;
- if (appTrust != null) {
- SetupDomainSecurityForHomogeneousDomain(appTrust, runtimeSuppliedHomogenousGrant);
- }
- else if (_IsFastFullTrustDomain) {
- SetSecurityHomogeneousFlag(GetNativeHandle(), runtimeSuppliedHomogenousGrant);
- }
+ if (appTrust != null) {
+ SetupDomainSecurityForHomogeneousDomain(appTrust, runtimeSuppliedHomogenousGrant);
+ }
+ else if (_IsFastFullTrustDomain) {
+ SetSecurityHomogeneousFlag(GetNativeHandle(), runtimeSuppliedHomogenousGrant);
}
// Get the evidence supplied for the domain. If no evidence was supplied, it means that we want
// to use the default evidence creation strategy for this domain
Evidence newAppDomainEvidence = (providedSecurityInfo != null ? providedSecurityInfo : creatorsSecurityInfo);
if (newAppDomainEvidence == null && generateDefaultEvidence) {
-#if FEATURE_CAS_POLICY
- newAppDomainEvidence = new Evidence(new AppDomainEvidenceFactory(this));
-#else // !FEATURE_CAS_POLICY
newAppDomainEvidence = new Evidence();
-#endif // FEATURE_CAS_POLICY
}
-#if FEATURE_CAS_POLICY
- if (_domainManager != null) {
- // Give the host a chance to alter the AppDomain evidence
- HostSecurityManager securityManager = _domainManager.HostSecurityManager;
- if (securityManager != null) {
- nSetHostSecurityManagerFlags (securityManager.Flags);
- if ((securityManager.Flags & HostSecurityManagerOptions.HostAppDomainEvidence) == HostSecurityManagerOptions.HostAppDomainEvidence) {
- newAppDomainEvidence = securityManager.ProvideAppDomainEvidence(newAppDomainEvidence);
- // If this is a disconnected evidence collection, then attach it to the AppDomain,
- // allowing the host security manager to get callbacks for delay generated evidence
- if (newAppDomainEvidence != null && newAppDomainEvidence.Target == null) {
- newAppDomainEvidence.Target = new AppDomainEvidenceFactory(this);
- }
- }
- }
- }
-
-#endif // FEATURE_CAS_POLICY
-
// Set the evidence on the managed side
_SecurityIdentity = newAppDomainEvidence;
@@ -971,106 +733,8 @@ namespace System {
SetupDomainSecurity(newAppDomainEvidence,
parentSecurityDescriptor,
publishAppDomain);
-
-#if FEATURE_CAS_POLICY
- // The AppDomain is now resolved. Go ahead and set the PolicyLevel
- // from the HostSecurityManager if specified.
- if (_domainManager != null)
- RunDomainManagerPostInitialization(_domainManager);
-#endif // FEATURE_CAS_POLICY
- }
-
-#if FEATURE_CAS_POLICY
- [System.Security.SecurityCritical] // auto-generated
- private void RunDomainManagerPostInitialization (AppDomainManager domainManager)
- {
- // force creation of the HostExecutionContextManager for the current AppDomain
- HostExecutionContextManager contextManager = domainManager.HostExecutionContextManager;
-
- if (IsLegacyCasPolicyEnabled)
- {
-#pragma warning disable 618
- HostSecurityManager securityManager = domainManager.HostSecurityManager;
- if (securityManager != null)
- {
- if ((securityManager.Flags & HostSecurityManagerOptions.HostPolicyLevel) == HostSecurityManagerOptions.HostPolicyLevel)
- {
- // set AppDomain policy if specified
- PolicyLevel level = securityManager.DomainPolicy;
- if (level != null)
- SetAppDomainPolicy(level);
- }
- }
-#pragma warning restore 618
- }
- }
-#endif
-
-
-#if FEATURE_CLICKONCE
-
- [System.Security.SecurityCritical] // auto-generated
- private void SetupApplicationHelper (Evidence providedSecurityInfo, Evidence creatorsSecurityInfo, ApplicationIdentity appIdentity, ActivationContext activationContext, string[] activationData) {
- Contract.Requires(providedSecurityInfo != null);
- HostSecurityManager securityManager = AppDomain.CurrentDomain.HostSecurityManager;
- ApplicationTrust appTrust = securityManager.DetermineApplicationTrust(providedSecurityInfo, creatorsSecurityInfo, new TrustManagerContext());
- if (appTrust == null || !appTrust.IsApplicationTrustedToRun)
- throw new PolicyException(Environment.GetResourceString("Policy_NoExecutionPermission"),
- System.__HResults.CORSEC_E_NO_EXEC_PERM,
- null);
-
- // The application is trusted to run. Set up the AppDomain according to the manifests.
- if (activationContext != null)
- SetupDomainForApplication(activationContext, activationData);
- SetupDomainSecurityForApplication(appIdentity, appTrust);
- }
-
- [System.Security.SecurityCritical] // auto-generated
- private void SetupDomainForApplication(ActivationContext activationContext, string[] activationData) {
- Contract.Requires(activationContext != null);
- if (IsDefaultAppDomain()) {
- // make the ActivationArguments available off the AppDomain object.
- AppDomainSetup adSetup = this.FusionStore;
- adSetup.ActivationArguments = new ActivationArguments(activationContext, activationData);
-
- // set the application base to point at where the application resides
- string entryPointPath = CmsUtils.GetEntryPointFullPath(activationContext);
- if (!String.IsNullOrEmpty(entryPointPath))
- adSetup.SetupDefaults(entryPointPath);
- else
- adSetup.ApplicationBase = activationContext.ApplicationDirectory;
-
- // update fusion context
- SetupFusionStore(adSetup, null);
- }
-
- // perform app data directory migration.
- activationContext.PrepareForExecution();
- activationContext.SetApplicationState(ActivationContext.ApplicationState.Starting);
- // set current app data directory.
- activationContext.SetApplicationState(ActivationContext.ApplicationState.Running);
-
- // make data directory path available.
- IPermission permission = null;
- string dataDirectory = activationContext.DataDirectory;
- if (dataDirectory != null && dataDirectory.Length > 0)
- permission = new FileIOPermission(FileIOPermissionAccess.PathDiscovery, dataDirectory);
- this.SetData("DataDirectory", dataDirectory, permission);
-
- _activationContext = activationContext;
- }
-
- [System.Security.SecurityCritical] // auto-generated
- private void SetupDomainSecurityForApplication(ApplicationIdentity appIdentity,
- ApplicationTrust appTrust)
- {
- // Set the Application trust on the managed side.
- _applicationIdentity = appIdentity;
- SetupDomainSecurityForHomogeneousDomain(appTrust, false);
}
-#endif // FEATURE_CLICKONCE
- [System.Security.SecurityCritical] // auto-generated
private void SetupDomainSecurityForHomogeneousDomain(ApplicationTrust appTrust,
bool runtimeSuppliedHomogenousGrantSet)
{
@@ -1084,9 +748,6 @@ namespace System {
if (runtimeSuppliedHomogenousGrantSet)
{
BCLDebug.Assert(_FusionStore.ApplicationTrust != null, "Expected to find runtime supplied ApplicationTrust");
-#if FEATURE_CAS_POLICY
- _FusionStore.ApplicationTrust = null;
-#endif // FEATURE_CAS_POLICY
}
_applicationTrust = appTrust;
@@ -1096,38 +757,13 @@ namespace System {
runtimeSuppliedHomogenousGrantSet);
}
- // This method is called from CorHost2::ExecuteApplication to activate a ClickOnce application in the default AppDomain.
-#if FEATURE_CLICKONCE
- [System.Security.SecuritySafeCritical] // auto-generated
- private int ActivateApplication () {
- ObjectHandle oh = Activator.CreateInstance(AppDomain.CurrentDomain.ActivationContext);
- return (int) oh.Unwrap();
- }
-#endif //FEATURE_CLICKONCE
-
public AppDomainManager DomainManager {
- [System.Security.SecurityCritical] // auto-generated_required
get {
return _domainManager;
}
}
-#if FEATURE_CAS_POLICY
- internal HostSecurityManager HostSecurityManager {
- [System.Security.SecurityCritical] // auto-generated
- get {
- HostSecurityManager securityManager = null;
- AppDomainManager domainManager = AppDomain.CurrentDomain.DomainManager;
- if (domainManager != null)
- securityManager = domainManager.HostSecurityManager;
-
- if (securityManager == null)
- securityManager = new HostSecurityManager();
- return securityManager;
- }
- }
-#endif // FEATURE_CAS_POLICY
-#if FEATURE_REFLECTION_ONLY_LOAD
+#if FEATURE_REFLECTION_ONLY_LOAD
private Assembly ResolveAssemblyForIntrospection(Object sender, ResolveEventArgs args)
{
Contract.Requires(args != null);
@@ -1143,7 +779,6 @@ namespace System {
_packageGraphFilePaths = packageGraphFilePaths;
}
- [System.Security.SecurityCritical]
public void ResolveNamespace(
object sender,
System.Runtime.InteropServices.WindowsRuntime.NamespaceResolveEventArgs args)
@@ -1162,7 +797,6 @@ namespace System {
}
// Called only by native function code:ValidateWorker
- [System.Security.SecuritySafeCritical]
private void EnableResolveAssembliesForIntrospection(string verifiedFileDirectory)
{
CurrentDomain.ReflectionOnlyAssemblyResolve += new ResolveEventHandler(ResolveAssemblyForIntrospection);
@@ -1183,7 +817,6 @@ namespace System {
* to have a strong name and a hash will be computed when the assembly
* is saved.
**********************************************/
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
public AssemblyBuilder DefineDynamicAssembly(
AssemblyName name,
@@ -1196,7 +829,6 @@ namespace System {
null, null, null, null, ref stackMark, null, SecurityContextSource.CurrentAssembly);
}
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
public AssemblyBuilder DefineDynamicAssembly(
AssemblyName name,
@@ -1214,7 +846,6 @@ namespace System {
}
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Due to the stack crawl mark
- [SecuritySafeCritical]
public AssemblyBuilder DefineDynamicAssembly(AssemblyName name,
AssemblyBuilderAccess access,
IEnumerable<CustomAttributeBuilder> assemblyAttributes,
@@ -1231,7 +862,6 @@ namespace System {
securityContextSource);
}
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
public AssemblyBuilder DefineDynamicAssembly(
AssemblyName name,
@@ -1248,7 +878,6 @@ namespace System {
SecurityContextSource.CurrentAssembly);
}
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
[Obsolete("Assembly level declarative security is obsolete and is no longer enforced by the CLR by default. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
public AssemblyBuilder DefineDynamicAssembly(
@@ -1266,7 +895,6 @@ namespace System {
SecurityContextSource.CurrentAssembly);
}
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
[Obsolete("Assembly level declarative security is obsolete and is no longer enforced by the CLR by default. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
public AssemblyBuilder DefineDynamicAssembly(
@@ -1288,7 +916,6 @@ namespace System {
SecurityContextSource.CurrentAssembly);
}
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
[Obsolete("Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of DefineDynamicAssembly which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkId=155570 for more information.")]
public AssemblyBuilder DefineDynamicAssembly(
@@ -1304,7 +931,6 @@ namespace System {
null, null, null, ref stackMark, null, SecurityContextSource.CurrentAssembly);
}
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
[Obsolete("Assembly level declarative security is obsolete and is no longer enforced by the CLR by default. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
public AssemblyBuilder DefineDynamicAssembly(
@@ -1327,7 +953,6 @@ namespace System {
SecurityContextSource.CurrentAssembly);
}
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
[Obsolete("Assembly level declarative security is obsolete and is no longer enforced by the CLR by default. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
public AssemblyBuilder DefineDynamicAssembly(
@@ -1351,7 +976,6 @@ namespace System {
SecurityContextSource.CurrentAssembly);
}
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
[Obsolete("Assembly level declarative security is obsolete and is no longer enforced by the CLR by default. Please see http://go.microsoft.com/fwlink/?LinkId=155570 for more information.")]
public AssemblyBuilder DefineDynamicAssembly(
@@ -1376,8 +1000,6 @@ namespace System {
SecurityContextSource.CurrentAssembly);
}
-
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
[Obsolete("Assembly level declarative security is obsolete and is no longer enforced by the CLR by default. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
public AssemblyBuilder DefineDynamicAssembly(
@@ -1405,7 +1027,6 @@ namespace System {
SecurityContextSource.CurrentAssembly);
}
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
[Obsolete("Assembly level declarative security is obsolete and is no longer enforced by the CLR by default. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
public AssemblyBuilder DefineDynamicAssembly(
@@ -1434,7 +1055,6 @@ namespace System {
SecurityContextSource.CurrentAssembly);
}
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
public AssemblyBuilder DefineDynamicAssembly(
AssemblyName name,
@@ -1458,7 +1078,6 @@ namespace System {
SecurityContextSource.CurrentAssembly);
}
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
private AssemblyBuilder InternalDefineDynamicAssembly(
AssemblyName name,
@@ -1484,7 +1103,6 @@ namespace System {
securityContextSource);
}
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern String nApplyPolicy(AssemblyName an);
@@ -1506,7 +1124,6 @@ namespace System {
return nApplyPolicy(asmName);
}
-
public ObjectHandle CreateInstance(String assemblyName,
String typeName)
@@ -1516,14 +1133,13 @@ namespace System {
throw new NullReferenceException();
if (assemblyName == null)
- throw new ArgumentNullException("assemblyName");
+ throw new ArgumentNullException(nameof(assemblyName));
Contract.EndContractBlock();
return Activator.CreateInstance(assemblyName,
typeName);
}
- [System.Security.SecurityCritical] // auto-generated
internal ObjectHandle InternalCreateInstanceWithNoSecurity (string assemblyName, string typeName) {
PermissionSet.s_fullTrust.Assert();
return CreateInstance(assemblyName, typeName);
@@ -1542,7 +1158,6 @@ namespace System {
typeName);
}
- [System.Security.SecurityCritical] // auto-generated
internal ObjectHandle InternalCreateInstanceFromWithNoSecurity (string assemblyName, string typeName) {
PermissionSet.s_fullTrust.Assert();
return CreateInstanceFrom(assemblyName, typeName);
@@ -1591,7 +1206,7 @@ namespace System {
throw new NullReferenceException();
if (assemblyName == null)
- throw new ArgumentNullException("assemblyName");
+ throw new ArgumentNullException(nameof(assemblyName));
Contract.EndContractBlock();
return Activator.CreateInstance(assemblyName,
@@ -1630,16 +1245,9 @@ namespace System {
throw new NullReferenceException();
if (assemblyName == null)
- throw new ArgumentNullException("assemblyName");
+ throw new ArgumentNullException(nameof(assemblyName));
Contract.EndContractBlock();
-#if FEATURE_CAS_POLICY
- if (securityAttributes != null && !IsLegacyCasPolicyEnabled)
- {
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_RequiresCasPolicyImplicit"));
- }
-#endif // FEATURE_CAS_POLICY
-
#pragma warning disable 618
return Activator.CreateInstance(assemblyName,
typeName,
@@ -1667,7 +1275,7 @@ namespace System {
throw new NullReferenceException();
if (assemblyName == null)
- throw new ArgumentNullException("assemblyName");
+ throw new ArgumentNullException(nameof(assemblyName));
Contract.EndContractBlock();
return Activator.CreateInstance(assemblyName,
@@ -1680,7 +1288,6 @@ namespace System {
activationAttributes);
}
- [System.Security.SecurityCritical] // auto-generated
internal ObjectHandle InternalCreateInstanceWithNoSecurity (string assemblyName,
string typeName,
bool ignoreCase,
@@ -1691,10 +1298,6 @@ namespace System {
Object[] activationAttributes,
Evidence securityAttributes)
{
-#if FEATURE_CAS_POLICY
- Contract.Assert(IsLegacyCasPolicyEnabled || securityAttributes == null);
-#endif // FEATURE_CAS_POLICY
-
PermissionSet.s_fullTrust.Assert();
#pragma warning disable 618
return CreateInstance(assemblyName, typeName, ignoreCase, bindingAttr, binder, args, culture, activationAttributes, securityAttributes);
@@ -1718,13 +1321,6 @@ namespace System {
throw new NullReferenceException();
Contract.EndContractBlock();
-#if FEATURE_CAS_POLICY
- if (securityAttributes != null && !IsLegacyCasPolicyEnabled)
- {
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_RequiresCasPolicyImplicit"));
- }
-#endif // FEATURE_CAS_POLICY
-
return Activator.CreateInstanceFrom(assemblyFile,
typeName,
ignoreCase,
@@ -1760,7 +1356,6 @@ namespace System {
activationAttributes);
}
- [System.Security.SecurityCritical] // auto-generated
internal ObjectHandle InternalCreateInstanceFromWithNoSecurity (string assemblyName,
string typeName,
bool ignoreCase,
@@ -1771,17 +1366,12 @@ namespace System {
Object[] activationAttributes,
Evidence securityAttributes)
{
-#if FEATURE_CAS_POLICY
- Contract.Assert(IsLegacyCasPolicyEnabled || securityAttributes == null);
-#endif // FEATURE_CAS_POLICY
-
PermissionSet.s_fullTrust.Assert();
#pragma warning disable 618
return CreateInstanceFrom(assemblyName, typeName, ignoreCase, bindingAttr, binder, args, culture, activationAttributes, securityAttributes);
#pragma warning restore 618
}
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
public Assembly Load(AssemblyName assemblyRef)
{
@@ -1789,7 +1379,6 @@ namespace System {
return RuntimeAssembly.InternalLoadAssemblyName(assemblyRef, null, null, ref stackMark, true /*thrownOnFileNotFound*/, false, false);
}
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
public Assembly Load(String assemblyString)
{
@@ -1797,7 +1386,6 @@ namespace System {
return RuntimeAssembly.InternalLoad(assemblyString, null, ref stackMark, false);
}
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
public Assembly Load(byte[] rawAssembly)
{
@@ -1811,7 +1399,6 @@ namespace System {
}
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
public Assembly Load(byte[] rawAssembly,
byte[] rawSymbolStore)
@@ -1825,23 +1412,12 @@ namespace System {
SecurityContextSource.CurrentAssembly);
}
- [System.Security.SecuritySafeCritical] // auto-generated
-#pragma warning disable 618
- [SecurityPermissionAttribute(SecurityAction.Demand, ControlEvidence = true)]
-#pragma warning restore 618
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
[Obsolete("Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of Load which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkId=155570 for more information.")]
public Assembly Load(byte[] rawAssembly,
byte[] rawSymbolStore,
Evidence securityEvidence)
{
-#if FEATURE_CAS_POLICY
- if (securityEvidence != null && !IsLegacyCasPolicyEnabled)
- {
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_RequiresCasPolicyImplicit"));
- }
-#endif // FEATURE_CAS_POLICY
-
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
return RuntimeAssembly.nLoadImage(rawAssembly,
rawSymbolStore,
@@ -1851,7 +1427,6 @@ namespace System {
SecurityContextSource.CurrentAssembly);
}
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
[Obsolete("Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of Load which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
public Assembly Load(AssemblyName assemblyRef,
@@ -1861,7 +1436,6 @@ namespace System {
return RuntimeAssembly.InternalLoadAssemblyName(assemblyRef, assemblySecurity, null, ref stackMark, true /*thrownOnFileNotFound*/, false, false);
}
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
[Obsolete("Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of Load which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
public Assembly Load(String assemblyString,
@@ -1888,15 +1462,8 @@ namespace System {
Evidence assemblySecurity,
String[] args)
{
-#if FEATURE_CAS_POLICY
- if (assemblySecurity != null && !IsLegacyCasPolicyEnabled)
- {
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_RequiresCasPolicyImplicit"));
- }
-#endif // FEATURE_CAS_POLICY
-
RuntimeAssembly assembly = (RuntimeAssembly)Assembly.LoadFrom(assemblyFile, assemblySecurity);
-
+
if (args == null)
args = new String[0];
@@ -1920,13 +1487,6 @@ namespace System {
byte[] hashValue,
AssemblyHashAlgorithm hashAlgorithm)
{
-#if FEATURE_CAS_POLICY
- if (assemblySecurity != null && !IsLegacyCasPolicyEnabled)
- {
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_RequiresCasPolicyImplicit"));
- }
-#endif // FEATURE_CAS_POLICY
-
RuntimeAssembly assembly = (RuntimeAssembly)Assembly.LoadFrom(assemblyFile,
assemblySecurity,
hashValue,
@@ -1951,9 +1511,6 @@ namespace System {
return nExecuteAssembly(assembly, args);
}
- #if FEATURE_CORECLR
- [System.Security.SecurityCritical] // auto-generated
- #endif
public int ExecuteAssemblyByName(String assemblyName)
{
return ExecuteAssemblyByName(assemblyName, (string[])null);
@@ -1973,15 +1530,8 @@ namespace System {
Evidence assemblySecurity,
params String[] args)
{
-#if FEATURE_CAS_POLICY
- if (assemblySecurity != null && !IsLegacyCasPolicyEnabled)
- {
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_RequiresCasPolicyImplicit"));
- }
-#endif // FEATURE_CAS_POLICY
-
RuntimeAssembly assembly = (RuntimeAssembly)Assembly.Load(assemblyName, assemblySecurity);
-
+
if (args == null)
args = new String[0];
@@ -2003,15 +1553,8 @@ namespace System {
Evidence assemblySecurity,
params String[] args)
{
-#if FEATURE_CAS_POLICY
- if (assemblySecurity != null && !IsLegacyCasPolicyEnabled)
- {
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_RequiresCasPolicyImplicit"));
- }
-#endif // FEATURE_CAS_POLICY
-
RuntimeAssembly assembly = (RuntimeAssembly)Assembly.Load(assemblyName, assemblySecurity);
-
+
if (args == null)
args = new String[0];
@@ -2036,114 +1579,28 @@ namespace System {
}
}
-#if FEATURE_CAS_POLICY
- public Evidence Evidence
- {
- [System.Security.SecuritySafeCritical] // auto-generated
- [SecurityPermissionAttribute(SecurityAction.Demand, ControlEvidence = true)]
- get {
- return EvidenceNoDemand;
- }
- }
-
- internal Evidence EvidenceNoDemand {
- [SecurityCritical]
- get {
- if (_SecurityIdentity == null) {
- if (!IsDefaultAppDomain() && nIsDefaultAppDomainForEvidence()) {
-#if !FEATURE_CORECLR
- //
- // V1.x compatibility: If this is an AppDomain created
- // by the default appdomain without an explicit evidence
- // then reuse the evidence of the default AppDomain.
- //
- return GetDefaultDomain().Evidence;
-#else
- Contract.Assert(false,"This code should not be called for core CLR");
-
- // This operation is not allowed
- throw new InvalidOperationException();
-#endif
- }
- else {
- // We can't cache this value, since the VM needs to differentiate between AppDomains
- // which have no user supplied evidence and those which do and it uses the presence
- // of Evidence on the domain to make that switch.
- return new Evidence(new AppDomainEvidenceFactory(this));
- }
- }
- else {
- return _SecurityIdentity.Clone();
- }
- }
- }
-
- internal Evidence InternalEvidence
- {
- get {
- return _SecurityIdentity;
- }
- }
-
- internal EvidenceBase GetHostEvidence(Type type)
- {
- if (_SecurityIdentity != null)
- {
- return _SecurityIdentity.GetHostEvidence(type);
- }
- else
- {
- return new Evidence(new AppDomainEvidenceFactory(this)).GetHostEvidence(type);
- }
- }
-#endif // FEATURE_CAS_POLICY
-
public String FriendlyName
{
- [System.Security.SecuritySafeCritical] // auto-generated
get { return nGetFriendlyName(); }
}
public String BaseDirectory
{
-#if FEATURE_CORECLR
- [System.Security.SecurityCritical]
-#endif
get {
return FusionStore.ApplicationBase;
}
}
-#if FEATURE_FUSION
- public String RelativeSearchPath
- {
- get { return FusionStore.PrivateBinPath; }
- }
-
- public bool ShadowCopyFiles
- {
- get {
- String s = FusionStore.ShadowCopyFiles;
- if((s != null) &&
- (String.Compare(s, "true", StringComparison.OrdinalIgnoreCase) == 0))
- return true;
- else
- return false;
- }
- }
-#endif
-
- [System.Security.SecuritySafeCritical] // auto-generated
public override String ToString()
{
StringBuilder sb = StringBuilderCache.Acquire();
-
+
String fn = nGetFriendlyName();
if (fn != null) {
sb.Append(Environment.GetResourceString("Loader_Name") + fn);
sb.Append(Environment.NewLine);
}
-
+
if(_Policies == null || _Policies.Length == 0)
sb.Append(Environment.GetResourceString("Loader_NoContextPolicies")
+ Environment.NewLine);
@@ -2164,222 +1621,67 @@ namespace System {
return nGetAssemblies(false /* forIntrospection */);
}
-
public Assembly[] ReflectionOnlyGetAssemblies()
{
return nGetAssemblies(true /* forIntrospection */);
}
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern Assembly[] nGetAssemblies(bool forIntrospection);
// this is true when we've removed the handles etc so really can't do anything
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern bool IsUnloadingForcedFinalize();
- // this is true when we've just started going through the finalizers and are forcing objects to finalize
- // so must be aware that certain infrastructure may have gone away
- [System.Security.SecuritySafeCritical] // auto-generated
+ // this is true when we've just started going through the finalizers and are forcing objects to finalize
+ // so must be aware that certain infrastructure may have gone away
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern bool IsFinalizingForUnload();
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern void PublishAnonymouslyHostedDynamicMethodsAssembly(RuntimeAssembly assemblyHandle);
-#if FEATURE_FUSION
- // Appends the following string to the private path. Valid paths
- // are of the form "bin;util/i386" etc.
- [System.Security.SecurityCritical] // auto-generated_required
- [Obsolete("AppDomain.AppendPrivatePath has been deprecated. Please investigate the use of AppDomainSetup.PrivateBinPath instead. http://go.microsoft.com/fwlink/?linkid=14202")]
- public void AppendPrivatePath(String path)
- {
- if(path == null || path.Length == 0)
- return;
-
- String current = FusionStore.Value[(int) AppDomainSetup.LoaderInformation.PrivateBinPathValue];
- StringBuilder appendPath = StringBuilderCache.Acquire();
-
- if(current != null && current.Length > 0) {
- // See if the last character is a separator
- appendPath.Append(current);
- if((current[current.Length-1] != Path.PathSeparator) &&
- (path[0] != Path.PathSeparator))
- appendPath.Append(Path.PathSeparator);
- }
- appendPath.Append(path);
-
- String result = StringBuilderCache.GetStringAndRelease(appendPath);
- InternalSetPrivateBinPath(result);
- }
-
-
- [System.Security.SecurityCritical] // auto-generated_required
- [Obsolete("AppDomain.ClearPrivatePath has been deprecated. Please investigate the use of AppDomainSetup.PrivateBinPath instead. http://go.microsoft.com/fwlink/?linkid=14202")]
- public void ClearPrivatePath()
- {
- InternalSetPrivateBinPath(String.Empty);
- }
-
- [System.Security.SecurityCritical] // auto-generated_required
- [Obsolete("AppDomain.ClearShadowCopyPath has been deprecated. Please investigate the use of AppDomainSetup.ShadowCopyDirectories instead. http://go.microsoft.com/fwlink/?linkid=14202")]
- public void ClearShadowCopyPath()
- {
- InternalSetShadowCopyPath(String.Empty);
- }
-
- [System.Security.SecurityCritical] // auto-generated_required
- [Obsolete("AppDomain.SetCachePath has been deprecated. Please investigate the use of AppDomainSetup.CachePath instead. http://go.microsoft.com/fwlink/?linkid=14202")]
- public void SetCachePath(String path)
- {
- InternalSetCachePath(path);
- }
-#endif // FEATURE_FUSION
-
- [System.Security.SecurityCritical] // auto-generated_required
public void SetData (string name, object data) {
-#if FEATURE_CORECLR
- if (!name.Equals("LOCATION_URI"))
- {
- // Only LOCATION_URI can be set using AppDomain.SetData
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SetData_OnlyLocationURI", name));
- }
-#endif // FEATURE_CORECLR
SetDataHelper(name, data, null);
}
- [System.Security.SecurityCritical] // auto-generated_required
- public void SetData (string name, object data, IPermission permission) {
-#if FEATURE_CORECLR
+ public void SetData (string name, object data, IPermission permission)
+ {
if (!name.Equals("LOCATION_URI"))
{
// Only LOCATION_URI can be set using AppDomain.SetData
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SetData_OnlyLocationURI", name));
}
-#endif // FEATURE_CORECLR
+
SetDataHelper(name, data, permission);
}
- [System.Security.SecurityCritical] // auto-generated
- private void SetDataHelper (string name, object data, IPermission permission) {
+ private void SetDataHelper (string name, object data, IPermission permission)
+ {
if (name == null)
- throw new ArgumentNullException("name");
+ throw new ArgumentNullException(nameof(name));
Contract.EndContractBlock();
- //
- // Synopsis:
- // IgnoreSystemPolicy is provided as a legacy flag to allow callers to
- // skip enterprise, machine and user policy levels. When this flag is set,
- // any demands triggered in this AppDomain will be evaluated against the
- // AppDomain CAS policy level that is set on the AppDomain.
- // Security Requirements:
- // The caller needs to be fully trusted in order to be able to set
- // this legacy mode.
- // Remarks:
- // There needs to be an AppDomain policy level set before this compat
- // switch can be set on the AppDomain.
- //
-#if FEATURE_FUSION
- if (name.Equals(TargetFrameworkNameAppCompatSetting)) {
- _FusionStore.TargetFrameworkName = (String) data;
- return;
- }
-#if FEATURE_CAS_POLICY
- if (name.Equals("IgnoreSystemPolicy")) {
- lock (this) {
- if (!_HasSetPolicy)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SetData"));
- }
- new PermissionSet(PermissionState.Unrestricted).Demand();
- }
-#endif
- int key = AppDomainSetup.Locate(name);
-
- if(key == -1) {
- lock (((ICollection)LocalStore).SyncRoot) {
- LocalStore[name] = new object[] {data, permission};
- }
- }
- else {
- if (permission != null)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SetData"));
- // Be sure to call these properties, not Value, since
- // these do more than call Value.
- switch(key) {
- case (int) AppDomainSetup.LoaderInformation.DynamicBaseValue:
- FusionStore.DynamicBase = (string) data;
- break;
- case (int) AppDomainSetup.LoaderInformation.DevPathValue:
- FusionStore.DeveloperPath = (string) data;
- break;
- case (int) AppDomainSetup.LoaderInformation.ShadowCopyDirectoriesValue:
- FusionStore.ShadowCopyDirectories = (string) data;
- break;
- case (int) AppDomainSetup.LoaderInformation.DisallowPublisherPolicyValue:
- if(data != null)
- FusionStore.DisallowPublisherPolicy = true;
- else
- FusionStore.DisallowPublisherPolicy = false;
- break;
- case (int) AppDomainSetup.LoaderInformation.DisallowCodeDownloadValue:
- if (data != null)
- FusionStore.DisallowCodeDownload = true;
- else
- FusionStore.DisallowCodeDownload = false;
- break;
- case (int) AppDomainSetup.LoaderInformation.DisallowBindingRedirectsValue:
- if(data != null)
- FusionStore.DisallowBindingRedirects = true;
- else
- FusionStore.DisallowBindingRedirects = false;
- break;
- case (int) AppDomainSetup.LoaderInformation.DisallowAppBaseProbingValue:
- if(data != null)
- FusionStore.DisallowApplicationBaseProbing = true;
- else
- FusionStore.DisallowApplicationBaseProbing = false;
- break;
- case (int) AppDomainSetup.LoaderInformation.ConfigurationBytesValue:
- FusionStore.SetConfigurationBytes((byte[]) data);
- break;
- default:
- FusionStore.Value[key] = (string) data;
- break;
- }
- }
-#else // FEATURE_FUSION
-#if FEATURE_CORECLR
// SetData should only be used to set values that don't already exist.
+ object[] currentVal;
+ lock (((ICollection)LocalStore).SyncRoot) {
+ LocalStore.TryGetValue(name, out currentVal);
+ }
+ if (currentVal != null && currentVal[0] != null)
{
- object[] currentVal;
- lock (((ICollection)LocalStore).SyncRoot) {
- LocalStore.TryGetValue(name, out currentVal);
- }
- if (currentVal != null && currentVal[0] != null)
- {
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SetData_OnlyOnce"));
- }
+ throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SetData_OnlyOnce"));
}
-#endif // FEATURE_CORECLR
lock (((ICollection)LocalStore).SyncRoot) {
LocalStore[name] = new object[] {data, permission};
}
-#endif // FEATURE_FUSION
}
[Pure]
- #if FEATURE_CORECLR
- [System.Security.SecurityCritical] // auto-generated
- #else
- [System.Security.SecuritySafeCritical]
- #endif
public Object GetData(string name)
{
if(name == null)
- throw new ArgumentNullException("name");
+ throw new ArgumentNullException(nameof(name));
Contract.EndContractBlock();
int key = AppDomainSetup.Locate(name);
@@ -2412,43 +1714,11 @@ namespace System {
return FusionStore.ApplicationBase;
case (int) AppDomainSetup.LoaderInformation.ApplicationNameValue:
return FusionStore.ApplicationName;
-#if FEATURE_FUSION
- case (int) AppDomainSetup.LoaderInformation.ConfigurationFileValue:
- return FusionStore.ConfigurationFile;
- case (int) AppDomainSetup.LoaderInformation.DynamicBaseValue:
- return FusionStore.DynamicBase;
- case (int) AppDomainSetup.LoaderInformation.DevPathValue:
- return FusionStore.DeveloperPath;
- case (int) AppDomainSetup.LoaderInformation.PrivateBinPathValue:
- return FusionStore.PrivateBinPath;
- case (int) AppDomainSetup.LoaderInformation.PrivateBinPathProbeValue:
- return FusionStore.PrivateBinPathProbe;
- case (int) AppDomainSetup.LoaderInformation.ShadowCopyDirectoriesValue:
- return FusionStore.ShadowCopyDirectories;
- case (int) AppDomainSetup.LoaderInformation.ShadowCopyFilesValue:
- return FusionStore.ShadowCopyFiles;
- case (int) AppDomainSetup.LoaderInformation.CachePathValue:
- return FusionStore.CachePath;
- case (int) AppDomainSetup.LoaderInformation.LicenseFileValue:
- return FusionStore.LicenseFile;
- case (int) AppDomainSetup.LoaderInformation.DisallowPublisherPolicyValue:
- return FusionStore.DisallowPublisherPolicy;
- case (int) AppDomainSetup.LoaderInformation.DisallowCodeDownloadValue:
- return FusionStore.DisallowCodeDownload;
- case (int) AppDomainSetup.LoaderInformation.DisallowBindingRedirectsValue:
- return FusionStore.DisallowBindingRedirects;
- case (int) AppDomainSetup.LoaderInformation.DisallowAppBaseProbingValue:
- return FusionStore.DisallowApplicationBaseProbing;
- case (int) AppDomainSetup.LoaderInformation.ConfigurationBytesValue:
- return FusionStore.GetConfigurationBytes();
-#endif //FEATURE_FUSION
-
default:
- Contract.Assert(false, "Need to handle new LoaderInformation value in AppDomain.GetData()");
+ Debug.Assert(false, "Need to handle new LoaderInformation value in AppDomain.GetData()");
return null;
}
}
-
}
// The compat flags are set at domain creation time to indicate that the given breaking
@@ -2477,84 +1747,8 @@ namespace System {
[DllImport(Microsoft.Win32.Win32Native.KERNEL32)]
public static extern int GetCurrentThreadId();
-#if FEATURE_REMOTING
- [System.Security.SecuritySafeCritical] // auto-generated
- [SecurityPermissionAttribute( SecurityAction.Demand, ControlAppDomain = true ),
- ReliabilityContract(Consistency.MayCorruptAppDomain, Cer.MayFail)]
- public static void Unload(AppDomain domain)
+ internal ApplicationTrust ApplicationTrust
{
- if (domain == null)
- throw new ArgumentNullException("domain");
- Contract.EndContractBlock();
-
- try {
- Int32 domainID = AppDomain.GetIdForUnload(domain);
- if (domainID==0)
- throw new CannotUnloadAppDomainException();
- AppDomain.nUnload(domainID);
- }
- catch(Exception e) {
- throw e; // throw it again to reset stack trace
- }
- }
-#endif
-
- // Explicitly set policy for a domain (providing policy hasn't been set
- // previously). Making this call will guarantee that previously loaded
- // assemblies will be granted permissions based on the default machine
- // policy that was in place prior to this call.
-#if FEATURE_CAS_POLICY
- [System.Security.SecurityCritical] // auto-generated_required
- [Obsolete("AppDomain policy levels are obsolete and will be removed in a future release of the .NET Framework. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
- public void SetAppDomainPolicy(PolicyLevel domainPolicy)
- {
- if (domainPolicy == null)
- throw new ArgumentNullException("domainPolicy");
- Contract.EndContractBlock();
-
- if (!IsLegacyCasPolicyEnabled)
- {
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_RequiresCasPolicyExplicit"));
- }
-
- // Check that policy has not been set previously.
- lock (this) {
- if (_HasSetPolicy)
- throw new PolicyException(Environment.GetResourceString("Policy_PolicyAlreadySet"));
- _HasSetPolicy = true;
-
- // Make sure that the loader allows us to change security policy
- // at this time (this will throw if not.)
- nChangeSecurityPolicy();
- }
-
- // Add the new policy level.
- SecurityManager.PolicyManager.AddLevel(domainPolicy);
- }
-#endif //#if !FEATURE_CAS_POLICY
-#if FEATURE_CLICKONCE
- public ActivationContext ActivationContext {
- [System.Security.SecurityCritical] // auto-generated_required
- get {
- return _activationContext;
- }
- }
-
- public ApplicationIdentity ApplicationIdentity {
- [System.Security.SecurityCritical] // auto-generated_required
- get {
- return _applicationIdentity;
- }
- }
-#endif // FEATURE_CLICKONCE
-
-
-#if FEATURE_CLICKONCE
- public ApplicationTrust ApplicationTrust {
- [System.Security.SecurityCritical] // auto-generated_required
-#else // FEATURE_CLICKONCE
- internal ApplicationTrust ApplicationTrust {
-#endif // FEATURE_CLICKONCE
get {
if (_applicationTrust == null && _IsFastFullTrustDomain) {
_applicationTrust = new ApplicationTrust(new PermissionSet(PermissionState.Unrestricted));
@@ -2564,66 +1758,8 @@ namespace System {
}
}
-#if FEATURE_IMPERSONATION
- // Set the default principal object to be attached to threads if they
- // attempt to bind to a principal while executing in this appdomain. The
- // default can only be set once.
- [System.Security.SecuritySafeCritical] // auto-generated
- [SecurityPermissionAttribute(SecurityAction.Demand, Flags=SecurityPermissionFlag.ControlPrincipal)]
- public void SetThreadPrincipal(IPrincipal principal)
- {
- if (principal == null)
- throw new ArgumentNullException("principal");
- Contract.EndContractBlock();
-
- lock (this) {
- // Check that principal has not been set previously.
- if (_DefaultPrincipal != null)
- throw new PolicyException(Environment.GetResourceString("Policy_PrincipalTwice"));
-
- _DefaultPrincipal = principal;
- }
- }
-#endif // FEATURE_IMPERSONATION
-
-#if FEATURE_CAS_POLICY
- // Similar to the above, but sets the class of principal to be created
- // instead.
- [System.Security.SecuritySafeCritical] // auto-generated
- [SecurityPermissionAttribute(SecurityAction.Demand, Flags=SecurityPermissionFlag.ControlPrincipal)]
- public void SetPrincipalPolicy(PrincipalPolicy policy)
- {
- _PrincipalPolicy = policy;
- }
-#endif
-
-
-#if FEATURE_REMOTING
- // This method gives AppDomain an infinite life time by preventing a lease from being
- // created
- [System.Security.SecurityCritical] // auto-generated_required
- public override Object InitializeLifetimeService()
- {
- return null;
- }
- // This is useful for requesting execution of some code
- // in another appDomain ... the delegate may be defined
- // on a marshal-by-value object or a marshal-by-ref or
- // contextBound object.
- public void DoCallBack(CrossAppDomainDelegate callBackDelegate)
- {
- if (callBackDelegate == null)
- throw new ArgumentNullException("callBackDelegate");
- Contract.EndContractBlock();
-
- callBackDelegate();
- }
-#endif
-
-
public String DynamicDirectory
{
- [System.Security.SecuritySafeCritical] // auto-generated
get {
String dyndir = GetDynamicDir();
if (dyndir != null)
@@ -2633,211 +1769,13 @@ namespace System {
}
}
-#if FEATURE_CAS_POLICY
- public static AppDomain CreateDomain(String friendlyName,
- Evidence securityInfo) // Optional
- {
- return CreateDomain(friendlyName,
- securityInfo,
- null);
- }
-
- public static AppDomain CreateDomain(String friendlyName,
- Evidence securityInfo, // Optional
- String appBasePath,
- String appRelativeSearchPath,
- bool shadowCopyFiles)
- {
- AppDomainSetup info = new AppDomainSetup();
- info.ApplicationBase = appBasePath;
- info.PrivateBinPath = appRelativeSearchPath;
- if(shadowCopyFiles)
- info.ShadowCopyFiles = "true";
-
- return CreateDomain(friendlyName,
- securityInfo,
- info);
- }
-#endif // #if FEATURE_CAS_POLICY (not exposed in core)
-
-
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
extern private String GetDynamicDir();
- // Private helpers called from unmanaged code.
-
-#if FEATURE_REMOTING
-
- public static AppDomain CreateDomain(String friendlyName)
- {
- return CreateDomain(friendlyName, null, null);
- }
-
-
- // Marshal a single object into a serialized blob.
- [System.Security.SecurityCritical] // auto-generated
- private static byte[] MarshalObject(Object o)
- {
- CodeAccessPermission.Assert(true);
-
- return Serialize(o);
- }
-
- // Marshal two objects into serialized blobs.
- [System.Security.SecurityCritical] // auto-generated
- private static byte[] MarshalObjects(Object o1, Object o2, out byte[] blob2)
- {
- CodeAccessPermission.Assert(true);
-
- byte[] blob1 = Serialize(o1);
- blob2 = Serialize(o2);
- return blob1;
- }
-
- // Unmarshal a single object from a serialized blob.
- [System.Security.SecurityCritical] // auto-generated
- private static Object UnmarshalObject(byte[] blob)
- {
- CodeAccessPermission.Assert(true);
-
- return Deserialize(blob);
- }
-
- // Unmarshal two objects from serialized blobs.
- [System.Security.SecurityCritical] // auto-generated
- private static Object UnmarshalObjects(byte[] blob1, byte[] blob2, out Object o2)
- {
- CodeAccessPermission.Assert(true);
-
- Object o1 = Deserialize(blob1);
- o2 = Deserialize(blob2);
- return o1;
- }
-
- // Helper routines.
- [System.Security.SecurityCritical] // auto-generated
- private static byte[] Serialize(Object o)
- {
- if (o == null)
- {
- return null;
- }
- else if (o is ISecurityEncodable)
- {
- SecurityElement element = ((ISecurityEncodable)o).ToXml();
- MemoryStream ms = new MemoryStream( 4096 );
- ms.WriteByte( 0 );
- StreamWriter writer = new StreamWriter( ms, Encoding.UTF8 );
- element.ToWriter( writer );
- writer.Flush();
- return ms.ToArray();
- }
- else
- {
- MemoryStream ms = new MemoryStream();
- ms.WriteByte( 1 );
- CrossAppDomainSerializer.SerializeObject(o, ms);
- return ms.ToArray();
- }
- }
-
- [System.Security.SecurityCritical] // auto-generated
- private static Object Deserialize(byte[] blob)
- {
- if (blob == null)
- return null;
-
- if (blob[0] == 0)
- {
- Parser parser = new Parser( blob, Tokenizer.ByteTokenEncoding.UTF8Tokens, 1 );
- SecurityElement root = parser.GetTopElement();
- if (root.Tag.Equals( "IPermission" ) || root.Tag.Equals( "Permission" ))
- {
- IPermission ip = System.Security.Util.XMLUtil.CreatePermission( root, PermissionState.None, false );
-
- if (ip == null)
- {
- return null;
- }
-
- ip.FromXml( root );
-
- return ip;
- }
- else if (root.Tag.Equals( "PermissionSet" ))
- {
- PermissionSet permissionSet = new PermissionSet();
-
- permissionSet.FromXml( root, false, false );
-
- return permissionSet;
- }
- else if (root.Tag.Equals( "PermissionToken" ))
- {
- PermissionToken pToken = new PermissionToken();
-
- pToken.FromXml( root );
-
- return pToken;
- }
- else
- {
- return null;
- }
-
- }
- else
- {
- Object obj = null;
- using(MemoryStream stream = new MemoryStream( blob, 1, blob.Length - 1 )) {
- obj = CrossAppDomainSerializer.DeserializeObject(stream);
- }
-
- Contract.Assert( !(obj is IPermission), "IPermission should be xml deserialized" );
- Contract.Assert( !(obj is PermissionSet), "PermissionSet should be xml deserialized" );
-
- return obj;
- }
- }
-
-#endif // FEATURE_REMOTING
-
-#if !FEATURE_CORECLR
- //
- // Called by the VM if ICLRExecutionManager::Pause is called with the PAUSE_APP_DOMAINS flag.
- // This mimics the behavior of the CoreCLR FAS (fast application switching) model, to ensure
- // that code that depends on things happening in a particular order will work.
- //
- [System.Security.SecurityCritical]
- internal static void Pause()
- {
- AppDomainPauseManager.Instance.Pausing();
- AppDomainPauseManager.Instance.Paused();
- }
-
- //
- // Called by the VM if ICLRExecutionManager::Resume is called after ICLRExecutionManager::Pause
- // was called with the PAUSE_APP_DOMAINS flag.
- // This mimics the behavior of the CoreCLR FAS (fast application switching) model, to ensure
- // that code that depends on things happening in a particular order will work.
- //
- [System.Security.SecurityCritical]
- internal static void Resume()
- {
- if (AppDomainPauseManager.IsPaused)
- {
- AppDomainPauseManager.Instance.Resuming();
- AppDomainPauseManager.Instance.Resumed();
- }
- }
-#endif
-
private AppDomain() {
throw new NotSupportedException(Environment.GetResourceString(ResId.NotSupported_Constructor));
}
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern int _nExecuteAssembly(RuntimeAssembly assembly, String[] args);
internal int nExecuteAssembly(RuntimeAssembly assembly, String[] args)
@@ -2849,45 +1787,18 @@ namespace System {
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern void nCreateContext();
- [System.Security.SecurityCritical]
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
private static extern void nSetupBindingPaths(String trustedPlatformAssemblies, String platformResourceRoots, String appPath, String appNiPaths, String appLocalWinMD);
- #if FEATURE_CORECLR
- [System.Security.SecurityCritical] // auto-generated
- #endif
internal void SetupBindingPaths(String trustedPlatformAssemblies, String platformResourceRoots, String appPath, String appNiPaths, String appLocalWinMD)
{
nSetupBindingPaths(trustedPlatformAssemblies, platformResourceRoots, appPath, appNiPaths, appLocalWinMD);
}
#endif // FEATURE_VERSIONING
-#if FEATURE_REMOTING
- internal void CreateRemotingData()
- {
- lock(this) {
- if (_RemotingData == null)
- _RemotingData = new DomainSpecificRemotingData();
- }
- }
-
- internal DomainSpecificRemotingData RemotingData
- {
- get
- {
- if (_RemotingData == null)
- CreateRemotingData();
-
- return _RemotingData;
- }
- }
-#endif // FEATURE_REMOTING
-
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern String nGetFriendlyName();
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern bool nIsDefaultAppDomainForEvidence();
@@ -2899,7 +1810,6 @@ namespace System {
public event EventHandler ProcessExit
{
- [System.Security.SecuritySafeCritical] // auto-generated_required
add
{
if (value != null)
@@ -2919,7 +1829,6 @@ namespace System {
public event EventHandler DomainUnload
{
- [System.Security.SecuritySafeCritical] // auto-generated_required
add
{
if (value != null)
@@ -2929,9 +1838,6 @@ namespace System {
_domainUnload += value;
}
}
-#if FEATURE_CORECLR
- [System.Security.SecuritySafeCritical]
-#endif
remove
{
lock(this)
@@ -2942,7 +1848,6 @@ namespace System {
public event UnhandledExceptionEventHandler UnhandledException
{
- [System.Security.SecurityCritical] // auto-generated_required
add
{
if (value != null)
@@ -2952,7 +1857,6 @@ namespace System {
_unhandledException += value;
}
}
- [System.Security.SecurityCritical] // auto-generated_required
remove
{
lock(this)
@@ -2967,7 +1871,6 @@ namespace System {
// To register/unregister the callback, the code must be SecurityCritical.
public event EventHandler<FirstChanceExceptionEventArgs> FirstChanceException
{
- [System.Security.SecurityCritical] // auto-generated_required
add
{
if (value != null)
@@ -2977,7 +1880,6 @@ namespace System {
_firstChanceException += value;
}
}
- [System.Security.SecurityCritical] // auto-generated_required
remove
{
lock(this)
@@ -2996,7 +1898,6 @@ namespace System {
}
// This method is called by the VM.
- [System.Security.SecurityCritical]
private RuntimeAssembly OnResourceResolveEvent(RuntimeAssembly assembly, String resourceName)
{
ResolveEventHandler eventHandler = _ResourceResolve;
@@ -3016,7 +1917,6 @@ namespace System {
}
// This method is called by the VM
- [System.Security.SecurityCritical]
private RuntimeAssembly OnTypeResolveEvent(RuntimeAssembly assembly, String typeName)
{
ResolveEventHandler eventHandler = _TypeResolve;
@@ -3036,7 +1936,6 @@ namespace System {
}
// This method is called by the VM.
- [System.Security.SecurityCritical]
private RuntimeAssembly OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)
{
ResolveEventHandler eventHandler = _AssemblyResolve;
@@ -3058,36 +1957,6 @@ namespace System {
return null;
}
-#if FEATURE_REFLECTION_ONLY_LOAD
-
- private RuntimeAssembly OnReflectionOnlyAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)
- {
- ResolveEventHandler eventHandler = ReflectionOnlyAssemblyResolve;
- if (eventHandler != null) {
-
- Delegate[] ds = eventHandler.GetInvocationList();
- int len = ds.Length;
- for (int i = 0; i < len; i++) {
- Assembly asm = ((ResolveEventHandler)ds[i])(this, new ResolveEventArgs(assemblyFullName, assembly));
- RuntimeAssembly ret = GetRuntimeAssembly(asm);
- if (ret != null)
- return ret;
- }
- }
-
- return null;
- }
-
-#if FEATURE_COMINTEROP
- // Called by VM - code:CLRPrivTypeCacheReflectionOnlyWinRT::RaiseNamespaceResolveEvent
- private RuntimeAssembly[] OnReflectionOnlyNamespaceResolveEvent(RuntimeAssembly assembly, string namespaceName)
- {
- return System.Runtime.InteropServices.WindowsRuntime.WindowsRuntimeMetadata.OnReflectionOnlyNamespaceResolveEvent(this, assembly, namespaceName);
- }
-#endif // FEATURE_COMINTEROP
-
-#endif // FEATURE_REFLECTION_ONLY_LOAD
-
#if FEATURE_COMINTEROP
// Called by VM - code:CLRPrivTypeCacheWinRT::RaiseDesignerNamespaceResolveEvent
private string[] OnDesignerNamespaceResolveEvent(string namespaceName)
@@ -3099,7 +1968,7 @@ namespace System {
internal AppDomainSetup FusionStore
{
get {
- Contract.Assert(_FusionStore != null,
+ Debug.Assert(_FusionStore != null,
"Fusion store has not been correctly setup in this domain");
return _FusionStore;
}
@@ -3133,319 +2002,33 @@ namespace System {
}
}
-#if FEATURE_FUSION
- private void TurnOnBindingRedirects()
- {
- _FusionStore.DisallowBindingRedirects = false;
- }
-#endif
-
- // This will throw a CannotUnloadAppDomainException if the appdomain is
- // in another process.
-#if FEATURE_REMOTING
- [System.Security.SecurityCritical] // auto-generated
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
- internal static Int32 GetIdForUnload(AppDomain domain)
- {
- if (RemotingServices.IsTransparentProxy(domain))
- {
- return RemotingServices.GetServerDomainIdForProxy(domain);
- }
- else
- return domain.Id;
- }
-#endif
-
// Used to determine if server object context is valid in
// x-domain remoting scenarios.
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal static extern bool IsDomainIdValid(Int32 id);
-
-#if FEATURE_REMOTING
- [System.Security.SecurityCritical] // auto-generated
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- static internal extern AppDomain GetDefaultDomain();
-#endif
-
-#if FEATURE_IMPERSONATION
- // Internal routine to retrieve the default principal object. If this is
- // called before the principal has been explicitly set, it will
- // automatically allocate a default principal based on the policy set by
- // SetPrincipalPolicy.
- internal IPrincipal GetThreadPrincipal()
- {
- IPrincipal principal = null;
- if (_DefaultPrincipal == null) {
-#if FEATURE_CAS_POLICY
- switch (_PrincipalPolicy) {
- case PrincipalPolicy.NoPrincipal:
- principal = null;
- break;
- case PrincipalPolicy.UnauthenticatedPrincipal:
- principal = new GenericPrincipal(new GenericIdentity("", ""),
- new String[] {""});
- break;
- case PrincipalPolicy.WindowsPrincipal:
- principal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
- break;
- default:
- principal = null;
- break;
- }
-#else
- principal = new GenericPrincipal(new GenericIdentity("", ""),
- new String[] {""});
-
-#endif
- }
- else
- principal = _DefaultPrincipal;
-
- return principal;
- }
-#endif // FEATURE_IMPERSONATION
-
-#if FEATURE_REMOTING
-
- [System.Security.SecurityCritical] // auto-generated
- internal void CreateDefaultContext()
- {
- lock(this) {
- // if it has not been created we ask the Context class to
- // create a new default context for this appdomain.
- if (_DefaultContext == null)
- _DefaultContext = Context.CreateDefaultContext();
- }
- }
-
- [System.Security.SecurityCritical] // auto-generated
- internal Context GetDefaultContext()
- {
- if (_DefaultContext == null)
- CreateDefaultContext();
- return _DefaultContext;
- }
-
- // Ensure that evidence provided when creating an AppDomain would not have been used to create a
- // sandbox in legacy CAS mode. If it could have been used to create a sandbox, and we're not in CAS
- // mode, then we throw an exception to prevent acciental creation of unsandboxed domains where a
- // sandbox would have been expected.
- [SecuritySafeCritical]
- internal static void CheckDomainCreationEvidence(AppDomainSetup creationDomainSetup,
- Evidence creationEvidence)
- {
- if (creationEvidence != null && !CurrentDomain.IsLegacyCasPolicyEnabled)
- {
- if (creationDomainSetup == null || creationDomainSetup.ApplicationTrust == null)
- {
- // We allow non-null evidence in CAS mode to support the common pattern of passing in
- // AppDomain.CurrentDomain.Evidence. Since the zone evidence must have been changed
- // if the user has any expectation of sandboxing the domain under legacy CAS policy,
- // we use a zone comparison to check for this pattern. A strict comparison will not
- // work, since MSDN samples for creating a domain show using a modified version of the
- // current domain's evidence and we would capturce people who copied and pasted these
- // samples without intending to sandbox.
- Zone creatorsZone = CurrentDomain.EvidenceNoDemand.GetHostEvidence<Zone>();
- SecurityZone creatorsSecurityZone = creatorsZone != null ?
- creatorsZone.SecurityZone :
- SecurityZone.MyComputer;
-
- Zone suppliedZone = creationEvidence.GetHostEvidence<Zone>();
- if (suppliedZone != null)
- {
- if (suppliedZone.SecurityZone != creatorsSecurityZone &&
- suppliedZone.SecurityZone != SecurityZone.MyComputer)
- {
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_RequiresCasPolicyImplicit"));
- }
- }
- }
- }
- }
-
-#if FEATURE_CAS_POLICY
- [System.Security.SecuritySafeCritical] // auto-generated
- [SecurityPermissionAttribute( SecurityAction.Demand, ControlAppDomain = true )]
- public static AppDomain CreateDomain(String friendlyName,
- Evidence securityInfo,
- AppDomainSetup info)
- {
- return InternalCreateDomain(friendlyName, securityInfo, info);
- }
-#else
- internal static AppDomain CreateDomain(String friendlyName,
- Evidence securityInfo,
- AppDomainSetup info)
- {
- return InternalCreateDomain(friendlyName, securityInfo, info);
- }
-#endif
-
- [System.Security.SecurityCritical] // auto-generated
- internal static AppDomain InternalCreateDomain(String friendlyName,
- Evidence securityInfo,
- AppDomainSetup info)
- {
- if (friendlyName == null)
- throw new ArgumentNullException("friendlyName", Environment.GetResourceString("ArgumentNull_String"));
-
- Contract.EndContractBlock();
-
- AppDomain.CheckCreateDomainSupported();
-
- if (info == null)
- info = new AppDomainSetup();
- if (info.TargetFrameworkName == null)
- info.TargetFrameworkName = AppDomain.CurrentDomain.GetTargetFrameworkName();
- AppDomainManager domainManager = AppDomain.CurrentDomain.DomainManager;
- if (domainManager != null)
- return domainManager.CreateDomain(friendlyName, securityInfo, info);
-
- // No AppDomainManager is set up for this domain
-
- // If evidence is provided, we check to make sure that is allowed.
- if (securityInfo != null)
- {
- new SecurityPermission(SecurityPermissionFlag.ControlEvidence).Demand();
-
- // If we're potentially trying to sandbox without using a homogenous domain, we need to reject
- // the domain creation.
- CheckDomainCreationEvidence(info, securityInfo);
- }
-
- return nCreateDomain(friendlyName,
- info,
- securityInfo,
- securityInfo == null ? AppDomain.CurrentDomain.InternalEvidence : null,
- AppDomain.CurrentDomain.GetSecurityDescriptor());
- }
-#endif // FEATURE_REMOTING
-
-#if FEATURE_CAS_POLICY
-
- public static AppDomain CreateDomain (string friendlyName,
- Evidence securityInfo,
- AppDomainSetup info,
- PermissionSet grantSet,
- params StrongName[] fullTrustAssemblies)
- {
- if (info == null)
- throw new ArgumentNullException("info");
- if (info.ApplicationBase == null)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_AppDomainSandboxAPINeedsExplicitAppBase"));
- Contract.EndContractBlock();
-
- if (fullTrustAssemblies == null)
- {
- fullTrustAssemblies = new StrongName[0];
- }
-
- info.ApplicationTrust = new ApplicationTrust(grantSet, fullTrustAssemblies);
- return CreateDomain(friendlyName, securityInfo, info);
- }
-
- public static AppDomain CreateDomain(String friendlyName,
- Evidence securityInfo, // Optional
- String appBasePath,
- String appRelativeSearchPath,
- bool shadowCopyFiles,
- AppDomainInitializer adInit,
- string[] adInitArgs)
- {
- AppDomainSetup info = new AppDomainSetup();
- info.ApplicationBase = appBasePath;
- info.PrivateBinPath = appRelativeSearchPath;
- info.AppDomainInitializer=adInit;
- info.AppDomainInitializerArguments=adInitArgs;
- if(shadowCopyFiles)
- info.ShadowCopyFiles = "true";
-
- return CreateDomain(friendlyName,
- securityInfo,
- info);
- }
-#endif // FEATURE_CAS_POLICY
-
-#if FEATURE_CORECLR
- [System.Security.SecurityCritical]
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
private static extern void nSetNativeDllSearchDirectories(string paths);
-#endif
- [System.Security.SecurityCritical] // auto-generated
private void SetupFusionStore(AppDomainSetup info, AppDomainSetup oldInfo)
{
Contract.Requires(info != null);
-#if FEATURE_FUSION
- if (oldInfo == null) {
-
- // Create the application base and configuration file from the imagelocation
- // passed in or use the Win32 Image name.
- if(info.Value[(int) AppDomainSetup.LoaderInformation.ApplicationBaseValue] == null ||
- info.Value[(int) AppDomainSetup.LoaderInformation.ConfigurationFileValue] == null )
-#else
if (info.ApplicationBase == null)
-#endif
-
{
-#if FEATURE_FUSION
- AppDomain defaultDomain = GetDefaultDomain();
- if (this == defaultDomain) {
- // The default domain gets its defaults from the main process.
- info.SetupDefaults(RuntimeEnvironment.GetModuleFileName(), imageLocationAlreadyNormalized : true);
- }
- else {
- // Other domains get their defaults from the default domain. This way, a host process
- // can use AppDomainManager to set up the defaults for every domain created in the process.
- if (info.Value[(int) AppDomainSetup.LoaderInformation.ConfigurationFileValue] == null)
- info.ConfigurationFile = defaultDomain.FusionStore.Value[(int) AppDomainSetup.LoaderInformation.ConfigurationFileValue];
- if (info.Value[(int) AppDomainSetup.LoaderInformation.ApplicationBaseValue] == null)
- info.ApplicationBase = defaultDomain.FusionStore.Value[(int) AppDomainSetup.LoaderInformation.ApplicationBaseValue];
- if (info.Value[(int) AppDomainSetup.LoaderInformation.ApplicationNameValue] == null)
- info.ApplicationName = defaultDomain.FusionStore.Value[(int) AppDomainSetup.LoaderInformation.ApplicationNameValue];
- }
-#else
info.SetupDefaults(RuntimeEnvironment.GetModuleFileName(), imageLocationAlreadyNormalized : true);
-#endif
-
- }
-
-#if FEATURE_FUSION
- // If there is no relative path then check the
- // environment
- if(info.Value[(int) AppDomainSetup.LoaderInformation.PrivateBinPathValue] == null)
- info.PrivateBinPath = Environment.nativeGetEnvironmentVariable(AppDomainSetup.PrivateBinPathEnvironmentVariable);
-
- // Add the developer path if it exists on this
- // machine.
- if(info.DeveloperPath == null)
- info.DeveloperPath = RuntimeEnvironment.GetDeveloperPath();
-
}
-
- // Set up the fusion context
- IntPtr fusionContext = GetFusionContext();
- info.SetupFusionContext(fusionContext, oldInfo);
- // Set loader optimization policy
-#else
#if FEATURE_VERSIONING
nCreateContext();
#endif // FEATURE_VERSIONING
-#endif // FEATURE_FUSION
#if FEATURE_LOADER_OPTIMIZATION
if (info.LoaderOptimization != LoaderOptimization.NotSpecified || (oldInfo != null && info.LoaderOptimization != oldInfo.LoaderOptimization))
UpdateLoaderOptimization(info.LoaderOptimization);
-#endif
-
-
-
+#endif
// This must be the last action taken
_FusionStore = info;
}
@@ -3475,7 +2058,6 @@ namespace System {
// are any remoting sinks registered, they can add non-mscorlib
// objects to the message (causing an assembly load exception when
// we try to deserialize it on the other side)
- [System.Security.SecurityCritical] // auto-generated
private static object PrepareDataForSetup(String friendlyName,
AppDomainSetup setup,
Evidence providedSecurityInfo,
@@ -3488,54 +2070,6 @@ namespace System {
byte[] serializedEvidence = null;
bool generateDefaultEvidence = false;
-#if FEATURE_CAS_POLICY
- // serialize evidence
- EvidenceCollection evidenceCollection = null;
-
- if (providedSecurityInfo != null || creatorsSecurityInfo != null)
- {
- // If we're just passing through AppDomain.CurrentDomain.Evidence, and that evidence is just
- // using the standard runtime AppDomainEvidenceFactory, don't waste time serializing it and
- // deserializing it back -- instead, we can recreate a new AppDomainEvidenceFactory in the new
- // domain. We only want to do this if there is no HostSecurityManager, otherwise the
- // HostSecurityManager could have added additional evidence on top of our standard factory.
- HostSecurityManager hsm = CurrentDomain.DomainManager != null ? CurrentDomain.DomainManager.HostSecurityManager : null;
- bool hostMayContributeEvidence = hsm != null &&
- hsm.GetType() != typeof(HostSecurityManager) &&
- (hsm.Flags & HostSecurityManagerOptions.HostAppDomainEvidence) == HostSecurityManagerOptions.HostAppDomainEvidence;
- if (!hostMayContributeEvidence)
- {
- if (providedSecurityInfo != null &&
- providedSecurityInfo.IsUnmodified &&
- providedSecurityInfo.Target != null &&
- providedSecurityInfo.Target is AppDomainEvidenceFactory)
- {
- providedSecurityInfo = null;
- generateDefaultEvidence = true;
- }
- if (creatorsSecurityInfo != null &&
- creatorsSecurityInfo.IsUnmodified &&
- creatorsSecurityInfo.Target != null &&
- creatorsSecurityInfo.Target is AppDomainEvidenceFactory)
- {
- creatorsSecurityInfo = null;
- generateDefaultEvidence = true;
- }
- }
- }
- if ((providedSecurityInfo != null) ||
- (creatorsSecurityInfo != null)) {
- evidenceCollection = new EvidenceCollection();
- evidenceCollection.ProvidedSecurityInfo = providedSecurityInfo;
- evidenceCollection.CreatorsSecurityInfo = creatorsSecurityInfo;
- }
-
- if (evidenceCollection != null) {
- serializedEvidence =
- CrossAppDomainSerializer.SerializeObject(evidenceCollection).GetBuffer();
- }
-#endif // FEATURE_CAS_POLICY
-
AppDomainInitializerInfo initializerInfo = null;
if (setup!=null && setup.AppDomainInitializer!=null)
initializerInfo=new AppDomainInitializerInfo(setup.AppDomainInitializer);
@@ -3543,7 +2077,6 @@ namespace System {
// will travel x-Ad, drop non-agile data
AppDomainSetup newSetup = new AppDomainSetup(setup, false);
-#if FEATURE_CORECLR
// Remove the special AppDomainCompatSwitch entries from the set of name value pairs
// And add them to the AppDomainSetup
//
@@ -3551,7 +2084,7 @@ namespace System {
// Desktop code should use System.AppDomain.CreateDomain() or
// System.AppDomainManager.CreateDomain() and add the flags to the AppDomainSetup
List<String> compatList = new List<String>();
-
+
if(propertyNames!=null && propertyValues != null)
{
for (int i=0; i<propertyNames.Length; i++)
@@ -3559,7 +2092,7 @@ namespace System {
if(String.Compare(propertyNames[i], "AppDomainCompatSwitch", StringComparison.OrdinalIgnoreCase) == 0)
{
compatList.Add(propertyValues[i]);
- propertyNames[i] = null;
+ propertyNames[i] = null;
propertyValues[i] = null;
}
@@ -3568,10 +2101,8 @@ namespace System {
if (compatList.Count > 0)
{
newSetup.SetCompatibilitySwitches(compatList);
- }
+ }
}
-#endif // FEATURE_CORECLR
-
return new Object[]
{
@@ -3587,8 +2118,6 @@ namespace System {
};
} // PrepareDataForSetup
-
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.NoInlining)]
private static Object Setup(Object arg)
{
@@ -3604,44 +2133,47 @@ namespace System {
AppDomainInitializerInfo initializerInfo = (AppDomainInitializerInfo)args[5];
string sandboxName = (string)args[6];
string[] propertyNames = (string[])args[7]; // can contain null elements
- string[] propertyValues = (string[])args[8]; // can contain null elements
+ string[] propertyValues = (string[])args[8]; // can contain null elements
// extract evidence
Evidence providedSecurityInfo = null;
Evidence creatorsSecurityInfo = null;
-
AppDomain ad = AppDomain.CurrentDomain;
AppDomainSetup newSetup=new AppDomainSetup(setup,false);
if(propertyNames!=null && propertyValues != null)
{
-#if FEATURE_CORECLR
- StringBuilder normalisedAppPathList = null;
-#endif // FEATURE_CORECLR
+ for (int i = 0; i < propertyNames.Length; i++)
+ {
+ // We want to set native dll probing directories before any P/Invokes have a
+ // chance to fire. The Path class, for one, has P/Invokes.
+ if (propertyNames[i] == "NATIVE_DLL_SEARCH_DIRECTORIES")
+ {
+ if (propertyValues[i] == null)
+ throw new ArgumentNullException("NATIVE_DLL_SEARCH_DIRECTORIES");
+
+ string paths = propertyValues[i];
+ if (paths.Length == 0)
+ break;
+
+ nSetNativeDllSearchDirectories(paths);
+ }
+ }
+
for (int i=0; i<propertyNames.Length; i++)
{
if(propertyNames[i]=="APPBASE") // make sure in sync with Fusion
{
if(propertyValues[i]==null)
throw new ArgumentNullException("APPBASE");
-
- if (Path.IsRelative(propertyValues[i]))
+
+ if (PathInternal.IsPartiallyQualified(propertyValues[i]))
throw new ArgumentException( Environment.GetResourceString( "Argument_AbsolutePathRequired" ) );
newSetup.ApplicationBase = NormalizePath(propertyValues[i], fullCheck: true);
-
- }
-#if FEATURE_CAS_POLICY
- else if(propertyNames[i]=="LOCATION_URI" && providedSecurityInfo==null)
- {
- providedSecurityInfo=new Evidence();
- providedSecurityInfo.AddHostEvidence(new Url(propertyValues[i]));
- ad.SetDataHelper(propertyNames[i],propertyValues[i],null);
}
-#endif // FEATURE_CAS_POLICY
#if FEATURE_LOADER_OPTIMIZATION
- else
- if(propertyNames[i]=="LOADER_OPTIMIZATION")
+ else if(propertyNames[i]=="LOADER_OPTIMIZATION")
{
if(propertyValues[i]==null)
throw new ArgumentNullException("LOADER_OPTIMIZATION");
@@ -3656,119 +2188,32 @@ namespace System {
}
}
#endif // FEATURE_LOADER_OPTIMIZATION
-#if FEATURE_CORECLR
- else
- if(propertyNames[i]=="NATIVE_DLL_SEARCH_DIRECTORIES")
- {
- if(propertyValues[i]==null)
- throw new ArgumentNullException("NATIVE_DLL_SEARCH_DIRECTORIES");
- ad.SetDataHelper(propertyNames[i],propertyValues[i],null);
- string paths = (string)propertyValues[i];
- if( paths.Length==0 )
- continue;
- nSetNativeDllSearchDirectories(paths);
- }
- else
- if(propertyNames[i]=="TRUSTED_PLATFORM_ASSEMBLIES" ||
+ else if(propertyNames[i]=="TRUSTED_PLATFORM_ASSEMBLIES" ||
propertyNames[i]=="PLATFORM_RESOURCE_ROOTS" ||
propertyNames[i]=="APP_PATHS" ||
propertyNames[i]=="APP_NI_PATHS")
{
string values = propertyValues[i];
- if(values==null)
+ if(values == null)
throw new ArgumentNullException(propertyNames[i]);
- int estimatedLength = values.Length + 1; // +1 for extra separator temporarily added at end
- if (normalisedAppPathList == null) {
- normalisedAppPathList = new StringBuilder(estimatedLength);
- }
- else {
- normalisedAppPathList.Clear();
- if (normalisedAppPathList.Capacity < estimatedLength)
- normalisedAppPathList.Capacity = estimatedLength;
- }
-
- for (int pos = 0; pos < values.Length; pos++)
- {
- string path;
-
- int nextPos = values.IndexOf(Path.PathSeparator, pos);
- if (nextPos == -1)
- {
- path = values.Substring(pos);
- pos = values.Length - 1;
- }
- else
- {
- path = values.Substring(pos, nextPos - pos);
- pos = nextPos;
- }
-
- if( path.Length==0 ) // skip empty dirs
- continue;
-
- if (Path.IsRelative(path))
- throw new ArgumentException( Environment.GetResourceString( "Argument_AbsolutePathRequired" ) );
-
- string appPath = NormalizePath(path, fullCheck: true);
- normalisedAppPathList.Append(appPath);
- normalisedAppPathList.Append(Path.PathSeparator);
- }
- // Strip the last separator
- if (normalisedAppPathList.Length > 0)
- {
- normalisedAppPathList.Remove(normalisedAppPathList.Length - 1, 1);
- }
- ad.SetDataHelper(propertyNames[i],normalisedAppPathList.ToString(),null); // not supported by fusion, so set explicitly
+ ad.SetDataHelper(propertyNames[i], NormalizeAppPaths(values), null);
}
- else
- if(propertyNames[i]!= null)
+ else if(propertyNames[i]!= null)
{
ad.SetDataHelper(propertyNames[i],propertyValues[i],null); // just propagate
}
-#endif
-
}
}
-#if !FEATURE_CORECLR
- AppDomainSortingSetupInfo sortingSetup = newSetup._AppDomainSortingSetupInfo;
-
- if(sortingSetup != null)
- {
- if(sortingSetup._pfnIsNLSDefinedString == IntPtr.Zero || sortingSetup._pfnCompareStringEx == IntPtr.Zero || sortingSetup._pfnLCMapStringEx == IntPtr.Zero || sortingSetup._pfnFindNLSStringEx == IntPtr.Zero
- || sortingSetup._pfnCompareStringOrdinal == IntPtr.Zero || sortingSetup._pfnGetNLSVersionEx == IntPtr.Zero)
- {
-
- if(!(sortingSetup._pfnIsNLSDefinedString == IntPtr.Zero && sortingSetup._pfnCompareStringEx == IntPtr.Zero && sortingSetup._pfnLCMapStringEx == IntPtr.Zero && sortingSetup._pfnFindNLSStringEx == IntPtr.Zero
- && sortingSetup._pfnCompareStringOrdinal == IntPtr.Zero && sortingSetup._pfnGetNLSVersionEx == IntPtr.Zero))
- {
- // Some functions defined but not all of them.
- throw new ArgumentException(Environment.GetResourceString("ArgumentException_NotAllCustomSortingFuncsDefined"));
- }
-
- }
- }
-#endif
-
ad.SetupFusionStore(newSetup, null); // makes FusionStore a ref to newSetup
// technically, we don't need this, newSetup refers to the same object as FusionStore
// but it's confusing since it isn't immediately obvious whether we have a ref or a copy
AppDomainSetup adSetup = ad.FusionStore;
-#if FEATURE_CORECLR
adSetup.InternalSetApplicationTrust(sandboxName);
-#endif // FEATURE_CORECLR
-
-#if !FEATURE_CORECLR // not used by coreclr
- if (serializedEvidence != null) {
- EvidenceCollection evidenceCollection = (EvidenceCollection)
- CrossAppDomainSerializer.DeserializeObject(new MemoryStream(serializedEvidence));
- providedSecurityInfo = evidenceCollection.ProvidedSecurityInfo;
- creatorsSecurityInfo = evidenceCollection.CreatorsSecurityInfo;
- }
-#endif
+
// set up the friendly name
ad.nSetupFriendlyName(friendlyName);
@@ -3785,11 +2230,6 @@ namespace System {
ad.SetAppDomainManagerType(adSetup.AppDomainManagerAssembly, adSetup.AppDomainManagerType);
}
-#if FEATURE_APTCA
- // set any conditial-aptca visible assemblies
- ad.PartialTrustVisibleAssemblies = adSetup.PartialTrustVisibleAssemblies;
-#endif // FEATURE_APTCA
-
ad.CreateAppDomainManager(); // could modify FusionStore's object
ad.InitializeDomainSecurity(providedSecurityInfo,
creatorsSecurityInfo,
@@ -3802,221 +2242,81 @@ namespace System {
adSetup.AppDomainInitializer=initializerInfo.Unwrap();
RunInitializer(adSetup);
- // Activate the application if needed.
-#if FEATURE_CLICKONCE
- ObjectHandle oh = null;
- if (adSetup.ActivationArguments != null && adSetup.ActivationArguments.ActivateInstance)
- oh = Activator.CreateInstance(ad.ActivationContext);
- return RemotingServices.MarshalInternal(oh, null, null);
-#else
return null;
-#endif // FEATURE_CLICKONCE
}
- [SecuritySafeCritical]
- internal static string NormalizePath(string path, bool fullCheck)
+ private static string NormalizeAppPaths(string values)
{
-#if FEATURE_PATHCOMPAT
- // Appcontext switches can't currently be safely hit during AppDomain bringup
- return Path.LegacyNormalizePath(
- path: path,
- fullCheck: fullCheck,
- maxPathLength: PathInternal.MaxShortPath,
- expandShortPaths: true);
-#else
- return Path.NormalizePath(
- path: path,
- fullCheck: fullCheck,
- expandShortPaths: true);
-#endif
- }
+ int estimatedLength = values.Length + 1; // +1 for extra separator temporarily added at end
+ StringBuilder sb = StringBuilderCache.Acquire(estimatedLength);
-#if FEATURE_APTCA
- // Called from DomainAssembly in Conditional APTCA cases
- [PermissionSet(SecurityAction.Assert, Unrestricted = true)]
- [SecuritySafeCritical]
- private bool IsAssemblyOnAptcaVisibleList(RuntimeAssembly assembly)
- {
- if (_aptcaVisibleAssemblies == null)
- return false;
-
- AssemblyName assemblyName = assembly.GetName();
- String name = assemblyName.GetNameWithPublicKey();
-
- name = name.ToUpperInvariant();
-
- int index = Array.BinarySearch<string>(_aptcaVisibleAssemblies, name,
- StringComparer.OrdinalIgnoreCase);
- return (index >=0);
-
- }
-
- //Used to binary search the list of C-APTCA strings for an AssemblyName. It compares assembly name
- //and public key token.
- private class CAPTCASearcher : IComparer
- {
- int IComparer.Compare(object /*string*/lhs, object /*AssemblyName*/rhs)
+ for (int pos = 0; pos < values.Length; pos++)
{
- AssemblyName captcaEntry = new AssemblyName((string)lhs);
- AssemblyName comparand = (AssemblyName)rhs;
- int nameComp = string.Compare(captcaEntry.Name,
- comparand.Name,
- StringComparison.OrdinalIgnoreCase);
- if (nameComp != 0)
- {
- return nameComp;
- }
-
- //simple names match. Compare public key tokens.
- byte[] lhsKey = captcaEntry.GetPublicKeyToken();
- byte[] rhsKey = comparand.GetPublicKeyToken();
+ string path;
- // We require both sides have a public key token
- if (lhsKey == null)
+ int nextPos = values.IndexOf(Path.PathSeparator, pos);
+ if (nextPos == -1)
{
- return -1;
+ path = values.Substring(pos);
+ pos = values.Length - 1;
}
- if (rhsKey == null)
- {
- return 1;
- }
- if (lhsKey.Length < rhsKey.Length)
- {
- return -1;
- }
- if (lhsKey.Length > rhsKey.Length)
+ else
{
- return 1;
+ path = values.Substring(pos, nextPos - pos);
+ pos = nextPos;
}
- // Tokens seem valid - make sure the compare correctly
- for (int i = 0; i < lhsKey.Length; ++i)
- {
- byte lhsByte = lhsKey[i];
- byte rhsByte = rhsKey[i];
+ // Skip empty directories
+ if (path.Length == 0)
+ continue;
- if (lhsByte < rhsByte)
- {
- return -1;
- }
- if (lhsByte > rhsByte)
- {
- return 1;
- }
- }
+ if (PathInternal.IsPartiallyQualified(path))
+ throw new ArgumentException(Environment.GetResourceString("Argument_AbsolutePathRequired"));
- //They match.
- return 0;
+ string appPath = NormalizePath(path, fullCheck: true);
+ sb.Append(appPath);
+ sb.Append(Path.PathSeparator);
}
- }
- [System.Security.SecurityCritical]
- private unsafe bool IsAssemblyOnAptcaVisibleListRaw(char * namePtr, int nameLen, byte * keyTokenPtr,
- int keyTokenLen)
- {
- //This version is used for checking ngen dependencies against the C-APTCA list. It lets us
- //reject ngen images that depend on an assembly that has been disabled in the current domain.
- //Since we only have the public key token in the ngen image, we'll check against that. The
- //rationale is that if you have a public key token collision in your process you have many
- //problems. Since the source of this public key token is an ngen image for a full trust
- //assembly, there is essentially no risk to the reduced check.
- if (_aptcaVisibleAssemblies == null)
- return false;
-
- string name = new string(namePtr, 0, nameLen);
- byte[] keyToken = new byte[keyTokenLen];
- for( int i = 0; i < keyToken.Length; ++i )
- keyToken[i] = keyTokenPtr[i];
-
- AssemblyName asmName = new AssemblyName();
- asmName.Name = name;
- asmName.SetPublicKeyToken(keyToken);
- try
+ // Strip the last separator
+ if (sb.Length > 0)
{
- int index = Array.BinarySearch(_aptcaVisibleAssemblies, asmName, new CAPTCASearcher());
- return (index >= 0);
+ sb.Remove(sb.Length - 1, 1);
}
- catch (InvalidOperationException) { /* Can happen for poorly formed assembly names */ return false; }
+
+ return StringBuilderCache.GetStringAndRelease(sb);
}
-#endif
+ internal static string NormalizePath(string path, bool fullCheck)
+ {
+ return Path.GetFullPath(path);
+ }
// This routine is called from unmanaged code to
// set the default fusion context.
- [System.Security.SecurityCritical] // auto-generated
private void SetupDomain(bool allowRedirects, String path, String configFile, String[] propertyNames, String[] propertyValues)
{
// It is possible that we could have multiple threads initializing
// the default domain. We will just take the winner of these two.
// (eg. one thread doing a com call and another doing attach for IJW)
- lock (this) {
- if(_FusionStore == null) {
+ lock (this)
+ {
+ if(_FusionStore == null)
+ {
AppDomainSetup setup = new AppDomainSetup();
-#if FEATURE_CORECLR
+
// always use internet permission set
setup.InternalSetApplicationTrust("Internet");
-#endif // FEATURE_CORECLR
-#if FEATURE_FUSION
- setup.SetupDefaults(RuntimeEnvironment.GetModuleFileName(), imageLocationAlreadyNormalized : true);
- if(path != null)
- setup.Value[(int) AppDomainSetup.LoaderInformation.ApplicationBaseValue] = path;
- if(configFile != null)
- setup.Value[(int) AppDomainSetup.LoaderInformation.ConfigurationFileValue] = configFile;
-
- // Default fusion context starts with binding redirects turned off.
- if (!allowRedirects)
- setup.DisallowBindingRedirects = true;
-#endif
-
-#if !FEATURE_CORECLR
- if (propertyNames != null) {
- BCLDebug.Assert(propertyValues != null, "propertyValues != null");
- BCLDebug.Assert(propertyNames.Length == propertyValues.Length, "propertyNames.Length == propertyValues.Length");
-
- for (int i = 0; i < propertyNames.Length; ++i) {
- if (String.Equals(propertyNames[i], "PARTIAL_TRUST_VISIBLE_ASSEMBLIES", StringComparison.Ordinal)) {
- // The value of the PARTIAL_TRUST_VISIBLE_ASSEMBLIES property is a semicolon
- // delimited list of assembly names to add to the
- // PartialTrustVisibleAssemblies setting of the domain setup
- if (propertyValues[i] != null) {
- if (propertyValues[i].Length > 0) {
- setup.PartialTrustVisibleAssemblies = propertyValues[i].Split(';');
- }
- else {
- setup.PartialTrustVisibleAssemblies = new string[0];
- }
- }
- }
- else {
- // In v4 we disallow anything but PARTIAL_TRUST_VISIBLE_ASSEMBLIES to come
- // in via the default domain properties. That restriction could be lifted
- // in a future release, at which point this assert should be removed.
- //
- // This should be kept in sync with the real externally facing filter code
- // in CorHost2::SetPropertiesForDefaultAppDomain
- BCLDebug.Assert(false, "Unexpected default domain property");
- }
- }
- }
-#endif // !FEATURE_CORECLR
-
-#if FEATURE_APTCA
- // Propigate the set of conditional APTCA assemblies that will be used in the default
- // domain onto the domain itself and also into the VM
- PartialTrustVisibleAssemblies = setup.PartialTrustVisibleAssemblies;
-#endif // FEATURE_APTCA
-
SetupFusionStore(setup, null);
}
}
}
#if FEATURE_LOADER_OPTIMIZATION
- [System.Security.SecurityCritical] // auto-generated
private void SetupLoaderOptimization(LoaderOptimization policy)
{
if(policy != LoaderOptimization.NotSpecified) {
- Contract.Assert(FusionStore.LoaderOptimization == LoaderOptimization.NotSpecified,
+ Debug.Assert(FusionStore.LoaderOptimization == LoaderOptimization.NotSpecified,
"It is illegal to change the Loader optimization on a domain");
FusionStore.LoaderOptimization = policy;
@@ -4024,36 +2324,10 @@ namespace System {
}
}
#endif
-
-#if FEATURE_FUSION
- [System.Security.SecurityCritical] // auto-generated
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal extern IntPtr GetFusionContext();
-#endif // FEATURE_FUSION
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern IntPtr GetSecurityDescriptor();
-#if FEATURE_REMOTING
- [System.Security.SecurityCritical] // auto-generated
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal static extern AppDomain nCreateDomain(String friendlyName,
- AppDomainSetup setup,
- Evidence providedSecurityInfo,
- Evidence creatorsSecurityInfo,
- IntPtr parentSecurityDescriptor);
-
- [System.Security.SecurityCritical] // auto-generated
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal static extern ObjRef nCreateInstance(String friendlyName,
- AppDomainSetup setup,
- Evidence providedSecurityInfo,
- Evidence creatorsSecurityInfo,
- IntPtr parentSecurityDescriptor);
-#endif
-
- [SecurityCritical]
private void SetupDomainSecurity(Evidence appDomainEvidence,
IntPtr creatorsSecurityDescriptor,
bool publishAppDomain)
@@ -4066,7 +2340,6 @@ namespace System {
}
- [SecurityCritical]
[SuppressUnmanagedCodeSecurity]
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
private static extern void SetupDomainSecurity(AppDomainHandle appDomain,
@@ -4074,7 +2347,6 @@ namespace System {
IntPtr creatorsSecurityDescriptor,
[MarshalAs(UnmanagedType.Bool)] bool publishAppDomain);
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern void nSetupFriendlyName(string friendlyName);
@@ -4084,39 +2356,10 @@ namespace System {
#endif // FEATURE_COMINTEROP
#if FEATURE_LOADER_OPTIMIZATION
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern void UpdateLoaderOptimization(LoaderOptimization optimization);
#endif
-#if FEATURE_FUSION
- //
- // This is just designed to prevent compiler warnings.
- // This field is used from native, but we need to prevent the compiler warnings.
- //
-
- [System.Security.SecurityCritical] // auto-generated_required
- [Obsolete("AppDomain.SetShadowCopyPath has been deprecated. Please investigate the use of AppDomainSetup.ShadowCopyDirectories instead. http://go.microsoft.com/fwlink/?linkid=14202")]
- public void SetShadowCopyPath(String path)
- {
- InternalSetShadowCopyPath(path);
- }
-
- [System.Security.SecurityCritical] // auto-generated_required
- [Obsolete("AppDomain.SetShadowCopyFiles has been deprecated. Please investigate the use of AppDomainSetup.ShadowCopyFiles instead. http://go.microsoft.com/fwlink/?linkid=14202")]
- public void SetShadowCopyFiles()
- {
- InternalSetShadowCopyFiles();
- }
-
- [System.Security.SecurityCritical] // auto-generated_required
- [Obsolete("AppDomain.SetDynamicBase has been deprecated. Please investigate the use of AppDomainSetup.DynamicBase instead. http://go.microsoft.com/fwlink/?linkid=14202")]
- public void SetDynamicBase(String path)
- {
- InternalSetDynamicBase(path);
- }
-#endif // FEATURE_FUSION
-
public AppDomainSetup SetupInformation
{
get {
@@ -4124,84 +2367,19 @@ namespace System {
}
}
-#if FEATURE_FUSION
- [System.Security.SecurityCritical] // auto-generated
- internal void InternalSetShadowCopyPath(String path)
- {
- if (path != null)
- {
- IntPtr fusionContext = GetFusionContext();
- AppDomainSetup.UpdateContextProperty(fusionContext, AppDomainSetup.ShadowCopyDirectoriesKey, path);
- }
- FusionStore.ShadowCopyDirectories = path;
- }
-
- [System.Security.SecurityCritical] // auto-generated
- internal void InternalSetShadowCopyFiles()
- {
- IntPtr fusionContext = GetFusionContext();
- AppDomainSetup.UpdateContextProperty(fusionContext, AppDomainSetup.ShadowCopyFilesKey, "true");
- FusionStore.ShadowCopyFiles = "true";
- }
-
- [System.Security.SecurityCritical] // auto-generated
- internal void InternalSetCachePath(String path)
- {
- FusionStore.CachePath = path;
- if (FusionStore.Value[(int) AppDomainSetup.LoaderInformation.CachePathValue] != null)
- {
- IntPtr fusionContext = GetFusionContext();
- AppDomainSetup.UpdateContextProperty(fusionContext, AppDomainSetup.CachePathKey,
- FusionStore.Value[(int) AppDomainSetup.LoaderInformation.CachePathValue]);
- }
- }
-
- [System.Security.SecurityCritical] // auto-generated
- internal void InternalSetPrivateBinPath(String path)
- {
- IntPtr fusionContext = GetFusionContext();
- AppDomainSetup.UpdateContextProperty(fusionContext, AppDomainSetup.PrivateBinPathKey, path);
- FusionStore.PrivateBinPath = path;
- }
-
- [System.Security.SecurityCritical] // auto-generated
- internal void InternalSetDynamicBase(String path)
- {
- FusionStore.DynamicBase = path;
- if (FusionStore.Value[(int) AppDomainSetup.LoaderInformation.DynamicBaseValue] != null)
- {
- IntPtr fusionContext = GetFusionContext();
- AppDomainSetup.UpdateContextProperty(fusionContext, AppDomainSetup.DynamicBaseKey,
- FusionStore.Value[(int) AppDomainSetup.LoaderInformation.DynamicBaseValue]);
- }
- }
-#endif // FEATURE_FUSION
-
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern String IsStringInterned(String str);
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern String GetOrInternString(String str);
- [SecurityCritical]
[SuppressUnmanagedCodeSecurity]
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
private static extern void GetGrantSet(AppDomainHandle domain, ObjectHandleOnStack retGrantSet);
-#if FEATURE_CAS_POLICY
- [SecurityCritical]
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- [return: MarshalAs(UnmanagedType.Bool)]
- private static extern bool GetIsLegacyCasPolicyEnabled(AppDomainHandle domain);
-#endif // FEATURE_CAS_POLICY
-
public PermissionSet PermissionSet
{
// SecurityCritical because permissions can contain sensitive information such as paths
- [SecurityCritical]
get
{
PermissionSet grantSet = null;
@@ -4220,7 +2398,6 @@ namespace System {
public bool IsFullyTrusted
{
- [SecuritySafeCritical]
get
{
PermissionSet grantSet = null;
@@ -4239,62 +2416,9 @@ namespace System {
}
}
-#if FEATURE_CAS_POLICY
- internal bool IsLegacyCasPolicyEnabled
- {
- [SecuritySafeCritical]
- get
- {
- return GetIsLegacyCasPolicyEnabled(GetNativeHandle());
- }
- }
-
- // Determine what this homogenous domain thinks the grant set should be for a specific set of evidence
- [SecuritySafeCritical]
- internal PermissionSet GetHomogenousGrantSet(Evidence evidence)
- {
- Contract.Assert(evidence != null);
- Contract.Assert(IsHomogenous);
- Contract.Assert(evidence.GetHostEvidence<GacInstalled>() == null);
-
- if (_IsFastFullTrustDomain)
- {
- return new PermissionSet(PermissionState.Unrestricted);
- }
-
- // If the ApplicationTrust's full trust list calls out the assembly, then it is fully trusted
- if (evidence.GetDelayEvaluatedHostEvidence<StrongName>() != null)
- {
- foreach (StrongName fullTrustAssembly in ApplicationTrust.FullTrustAssemblies)
- {
- StrongNameMembershipCondition sn = new StrongNameMembershipCondition(fullTrustAssembly.PublicKey,
- fullTrustAssembly.Name,
- fullTrustAssembly.Version);
-
- object usedEvidence = null;
- if ((sn as IReportMatchMembershipCondition).Check(evidence, out usedEvidence))
- {
- IDelayEvaluatedEvidence delayEvidence = usedEvidence as IDelayEvaluatedEvidence;
- if (usedEvidence != null)
- {
- delayEvidence.MarkUsed();
- }
-
- return new PermissionSet(PermissionState.Unrestricted);
- }
- }
- }
-
- // Otherwise, the grant set is just the default grant set
- return ApplicationTrust.DefaultGrantSet.PermissionSet.Copy();
- }
-#endif // FEATURE_CAS_POLICY
-
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern void nChangeSecurityPolicy();
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
[ReliabilityContract(Consistency.MayCorruptAppDomain, Cer.MayFail)]
internal static extern void nUnload(Int32 domainInternal);
@@ -4309,7 +2433,6 @@ namespace System {
return oh.Unwrap();
} // CreateInstanceAndUnwrap
-
public Object CreateInstanceAndUnwrap(String assemblyName,
String typeName,
Object[] activationAttributes)
@@ -4454,7 +2577,6 @@ namespace System {
}
}
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal extern Int32 GetId();
@@ -4468,76 +2590,35 @@ namespace System {
return false;
}
-#if FEATURE_FUSION
- private static AppDomainSetup InternalCreateDomainSetup(String imageLocation)
- {
- int i = imageLocation.LastIndexOf('\\');
-
- Contract.Assert(i != -1, "invalid image location");
-
- AppDomainSetup info = new AppDomainSetup();
- info.ApplicationBase = imageLocation.Substring(0, i+1);
-
- StringBuilder config = new StringBuilder(imageLocation.Substring(i+1));
- config.Append(AppDomainSetup.ConfigurationExtension);
- info.ConfigurationFile = config.ToString();
-
- return info;
- }
-
- // Used by the validator for testing but not executing an assembly
- private static AppDomain InternalCreateDomain(String imageLocation)
- {
- AppDomainSetup info = InternalCreateDomainSetup(imageLocation);
- return CreateDomain("Validator",
- null,
- info);
- }
-
- [System.Security.SecurityCritical] // auto-generated
- private void InternalSetDomainContext(String imageLocation)
- {
- SetupFusionStore(InternalCreateDomainSetup(imageLocation), null);
- }
-#endif
-
#if FEATURE_APPDOMAIN_RESOURCE_MONITORING
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern void nEnableMonitoring();
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern bool nMonitoringIsEnabled();
// return -1 if ARM is not supported.
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern Int64 nGetTotalProcessorTime();
// return -1 if ARM is not supported.
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern Int64 nGetTotalAllocatedMemorySize();
// return -1 if ARM is not supported.
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern Int64 nGetLastSurvivedMemorySize();
// return -1 if ARM is not supported.
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern Int64 nGetLastSurvivedProcessMemorySize();
public static bool MonitoringIsEnabled
{
- [System.Security.SecurityCritical]
get {
return nMonitoringIsEnabled();
}
- [System.Security.SecurityCritical]
set {
if (value == false)
{
@@ -4554,7 +2635,6 @@ namespace System {
// Throws NotSupportedException if ARM is not enabled.
public TimeSpan MonitoringTotalProcessorTime
{
- [System.Security.SecurityCritical]
get {
Int64 i64ProcessorTime = nGetTotalProcessorTime();
if (i64ProcessorTime == -1)
@@ -4570,7 +2650,6 @@ namespace System {
// Throws NotSupportedException if ARM is not enabled.
public Int64 MonitoringTotalAllocatedMemorySize
{
- [System.Security.SecurityCritical]
get {
Int64 i64AllocatedMemory = nGetTotalAllocatedMemorySize();
if (i64AllocatedMemory == -1)
@@ -4588,7 +2667,6 @@ namespace System {
// Throws NotSupportedException if ARM is not enabled.
public Int64 MonitoringSurvivedMemorySize
{
- [System.Security.SecurityCritical]
get {
Int64 i64LastSurvivedMemory = nGetLastSurvivedMemorySize();
if (i64LastSurvivedMemory == -1)
@@ -4608,7 +2686,6 @@ namespace System {
// Throws NotSupportedException if ARM is not enabled.
public static Int64 MonitoringSurvivedProcessMemorySize
{
- [System.Security.SecurityCritical]
get {
Int64 i64LastSurvivedProcessMemory = nGetLastSurvivedProcessMemorySize();
if (i64LastSurvivedProcessMemory == -1)
@@ -4619,49 +2696,8 @@ namespace System {
}
}
#endif
-
-#if !FEATURE_CORECLR
- // this method is required so Object.GetType is not made virtual by the compiler
- // _AppDomain.GetType()
- public new Type GetType()
- {
- return base.GetType();
- }
-
- void _AppDomain.GetTypeInfoCount(out uint pcTInfo)
- {
- throw new NotImplementedException();
- }
-
- void _AppDomain.GetTypeInfo(uint iTInfo, uint lcid, IntPtr ppTInfo)
- {
- throw new NotImplementedException();
- }
-
- void _AppDomain.GetIDsOfNames([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
- {
- throw new NotImplementedException();
- }
-
- // If you implement this method, make sure to include _AppDomain.Invoke in VM\DangerousAPIs.h and
- // include _AppDomain in SystemDomain::IsReflectionInvocationMethod in AppDomain.cpp.
- void _AppDomain.Invoke(uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
- {
- throw new NotImplementedException();
- }
-#endif
}
- // CallBacks provide a facility to request execution of some code
- // in another context/appDomain.
- // CrossAppDomainDelegate type is defined for appdomain call backs.
- // The delegate used to request a callbak through the DoCallBack method
- // must be of CrossContextDelegate type.
-#if FEATURE_REMOTING
-[System.Runtime.InteropServices.ComVisible(true)]
- public delegate void CrossAppDomainDelegate();
-#endif
-
/// <summary>
/// Handle used to marshal an AppDomain to the VM (eg QCall). When marshaled via a QCall, the target
/// method in the VM will recieve a QCall::AppDomainHandle parameter.
diff --git a/src/mscorlib/src/System/AppDomainManager.cs b/src/mscorlib/src/System/AppDomainManager.cs
index 291099e..71bc088 100644
--- a/src/mscorlib/src/System/AppDomainManager.cs
+++ b/src/mscorlib/src/System/AppDomainManager.cs
@@ -8,151 +8,28 @@
// participate in the creation and control the settings of new AppDomains.
//
-namespace System {
- using System.Collections;
- using System.Globalization;
- using System.IO;
+namespace System
+{
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
- using System.Security.Permissions;
- using System.Security.Policy;
- using System.Threading;
-#if FEATURE_CLICKONCE
- using System.Runtime.Hosting;
-#endif
- using System.Runtime.Versioning;
using System.Runtime.InteropServices;
- using System.Diagnostics.Contracts;
-#if FEATURE_APPDOMAINMANAGER_INITOPTIONS
- [Flags]
[System.Runtime.InteropServices.ComVisible(true)]
- public enum AppDomainManagerInitializationOptions {
- None = 0x0000,
- RegisterWithHost = 0x0001
- }
-#endif // FEATURE_APPDOMAINMANAGER_INITOPTIONS
-
- [System.Security.SecurityCritical] // auto-generated_required
- [System.Runtime.InteropServices.ComVisible(true)]
-#if !FEATURE_CORECLR
- [SecurityPermissionAttribute(SecurityAction.InheritanceDemand, Flags = SecurityPermissionFlag.Infrastructure)]
-#endif
-#if FEATURE_REMOTING
- public class AppDomainManager : MarshalByRefObject {
-#else // FEATURE_REMOTING
- public class AppDomainManager {
-#endif // FEATURE_REMOTING
+ public class AppDomainManager : MarshalByRefObject
+ {
public AppDomainManager () {}
-#if FEATURE_REMOTING
- [System.Security.SecurityCritical] // auto-generated
- public virtual AppDomain CreateDomain (string friendlyName,
- Evidence securityInfo,
- AppDomainSetup appDomainInfo) {
- return CreateDomainHelper(friendlyName, securityInfo, appDomainInfo);
- }
-
- [System.Security.SecurityCritical] // auto-generated_required
- [SecurityPermissionAttribute(SecurityAction.Demand, ControlAppDomain = true)]
- protected static AppDomain CreateDomainHelper (string friendlyName,
- Evidence securityInfo,
- AppDomainSetup appDomainInfo) {
- if (friendlyName == null)
- throw new ArgumentNullException("friendlyName", Environment.GetResourceString("ArgumentNull_String"));
-
- Contract.EndContractBlock();
- // If evidence is provided, we check to make sure that is allowed.
- if (securityInfo != null) {
- new SecurityPermission(SecurityPermissionFlag.ControlEvidence).Demand();
-
- // Check the evidence to ensure that if it expects a sandboxed domain, it actually gets one.
- AppDomain.CheckDomainCreationEvidence(appDomainInfo, securityInfo);
- }
-
- if (appDomainInfo == null) {
- appDomainInfo = new AppDomainSetup();
- }
-
- // If there was no specified AppDomainManager for the new domain, default it to being the same
- // as the current domain's AppDomainManager.
- if (appDomainInfo.AppDomainManagerAssembly == null || appDomainInfo.AppDomainManagerType == null) {
- string inheritedDomainManagerAssembly;
- string inheritedDomainManagerType;
-
- AppDomain.CurrentDomain.GetAppDomainManagerType(out inheritedDomainManagerAssembly,
- out inheritedDomainManagerType);
- if (appDomainInfo.AppDomainManagerAssembly == null) {
- appDomainInfo.AppDomainManagerAssembly = inheritedDomainManagerAssembly;
- }
- if (appDomainInfo.AppDomainManagerType == null) {
- appDomainInfo.AppDomainManagerType = inheritedDomainManagerType;
- }
- }
-
- // If there was no specified TargetFrameworkName for the new domain, default it to the current domain's.
- if (appDomainInfo.TargetFrameworkName == null)
- appDomainInfo.TargetFrameworkName = AppDomain.CurrentDomain.GetTargetFrameworkName();
-
- return AppDomain.nCreateDomain(friendlyName,
- appDomainInfo,
- securityInfo,
- securityInfo == null ? AppDomain.CurrentDomain.InternalEvidence : null,
- AppDomain.CurrentDomain.GetSecurityDescriptor());
- }
-#endif // FEATURE_REMOTING
-
- [System.Security.SecurityCritical]
- public virtual void InitializeNewDomain (AppDomainSetup appDomainInfo) {
+ public virtual void InitializeNewDomain (AppDomainSetup appDomainInfo)
+ {
// By default, InitializeNewDomain does nothing. AppDomain.CreateAppDomainManager relies on this fact.
}
-#if FEATURE_APPDOMAINMANAGER_INITOPTIONS
-
- private AppDomainManagerInitializationOptions m_flags = AppDomainManagerInitializationOptions.None;
- public AppDomainManagerInitializationOptions InitializationFlags {
- get {
- return m_flags;
- }
- set {
- m_flags = value;
- }
- }
-#endif // FEATURE_APPDOMAINMANAGER_INITOPTIONS
-
-#if FEATURE_CLICKONCE
- private ApplicationActivator m_appActivator = null;
- public virtual ApplicationActivator ApplicationActivator {
- get {
- if (m_appActivator == null)
- m_appActivator = new ApplicationActivator();
- return m_appActivator;
- }
- }
-#endif //#if FEATURE_CLICKONCE
-
-#if FEATURE_CAS_POLICY
- public virtual HostSecurityManager HostSecurityManager {
- get {
- return null;
- }
- }
-
- public virtual HostExecutionContextManager HostExecutionContextManager {
- get {
- // By default, the AppDomainManager returns the HostExecutionContextManager.
- return HostExecutionContextManager.GetInternalHostExecutionContextManager();
- }
- }
-#endif // FEATURE_CAS_POLICY
-
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
private static extern void GetEntryAssembly(ObjectHandleOnStack retAssembly);
private Assembly m_entryAssembly = null;
public virtual Assembly EntryAssembly {
- [System.Security.SecurityCritical] // auto-generated
get {
// The default AppDomainManager sets the EntryAssembly depending on whether the
// AppDomain is a manifest application domain or not. In the first case, we parse
@@ -160,14 +37,6 @@ namespace System {
// In the second case, we maintain the old behavior by calling GetEntryAssembly().
if (m_entryAssembly == null)
{
-
-#if FEATURE_CLICKONCE
- AppDomain domain = AppDomain.CurrentDomain;
- if (domain.IsDefaultAppDomain() && domain.ActivationContext != null) {
- ManifestRunner runner = new ManifestRunner(domain, domain.ActivationContext);
- m_entryAssembly = runner.EntryAssembly;
- } else
-#endif //#if FEATURE_CLICKONCE
{
RuntimeAssembly entryAssembly = null;
GetEntryAssembly(JitHelpers.GetObjectHandleOnStack(ref entryAssembly));
@@ -179,7 +48,6 @@ namespace System {
}
internal static AppDomainManager CurrentAppDomainManager {
- [System.Security.SecurityCritical] // auto-generated
get {
return AppDomain.CurrentDomain.DomainManager;
}
@@ -189,32 +57,5 @@ namespace System {
{
return false;
}
-
-#if FEATURE_APPDOMAINMANAGER_INITOPTIONS
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern bool HasHost();
-
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SecurityCritical]
- [SuppressUnmanagedCodeSecurity]
- private static extern void RegisterWithHost(IntPtr appDomainManager);
-
- internal void RegisterWithHost() {
- if (HasHost()) {
- IntPtr punkAppDomainManager = IntPtr.Zero;
-
- RuntimeHelpers.PrepareConstrainedRegions();
- try {
- punkAppDomainManager = Marshal.GetIUnknownForObject(this);
- RegisterWithHost(punkAppDomainManager);
- }
- finally {
- if (!punkAppDomainManager.IsNull()) {
- Marshal.Release(punkAppDomainManager);
- }
- }
- }
- }
-#endif // FEATURE_APPDOMAINMANAGER_INITOPTIONS
}
}
diff --git a/src/mscorlib/src/System/AppDomainSetup.cs b/src/mscorlib/src/System/AppDomainSetup.cs
index f1057da..fc8a64c 100644
--- a/src/mscorlib/src/System/AppDomainSetup.cs
+++ b/src/mscorlib/src/System/AppDomainSetup.cs
@@ -13,28 +13,16 @@
**
=============================================================================*/
-namespace System {
- using System;
-#if FEATURE_CLICKONCE
- using System.Deployment.Internal.Isolation;
- using System.Deployment.Internal.Isolation.Manifest;
- using System.Runtime.Hosting;
-#endif
- using System.Runtime.CompilerServices;
- using System.Runtime;
+namespace System
+{
using System.Text;
- using System.Threading;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
- using System.Reflection;
using System.Security;
- using System.Security.Permissions;
using System.Security.Policy;
- using System.Globalization;
using Path = System.IO.Path;
- using System.Runtime.Versioning;
+ using System.Diagnostics;
using System.Diagnostics.Contracts;
- using System.Collections;
using System.Collections.Generic;
[Serializable]
@@ -75,10 +63,6 @@ namespace System {
private const string MACHINE_CONFIGURATION_FILE = "config\\machine.config";
private const string ACTAG_HOST_CONFIG_FILE = "HOST_CONFIG";
-#if FEATURE_FUSION
- private const string LICENSE_FILE = "LICENSE_FILE";
-#endif
-
// Constants from fusionpriv.h
private const string ACTAG_APP_CONFIG_FILE = "APP_CONFIG_FILE";
private const string ACTAG_MACHINE_CONFIG = "MACHINE_CONFIG";
@@ -109,14 +93,9 @@ namespace System {
private AppDomainInitializer _AppDomainInitializer;
[OptionalField(VersionAdded = 2)]
private string[] _AppDomainInitializerArguments;
-#if FEATURE_CLICKONCE
- [OptionalField(VersionAdded = 2)]
- private ActivationArguments _ActivationArguments;
-#endif
-#if FEATURE_CORECLR
+
// On the CoreCLR, this contains just the name of the permission set that we install in the new appdomain.
// Not the ToXml().ToString() of an ApplicationTrust object.
-#endif
[OptionalField(VersionAdded = 2)]
private string _ApplicationTrust;
[OptionalField(VersionAdded = 2)]
@@ -130,11 +109,6 @@ namespace System {
[OptionalField(VersionAdded = 4)]
private string _AppDomainManagerType;
-#if FEATURE_APTCA
- [OptionalField(VersionAdded = 4)]
- private string[] _AptcaVisibleAssemblies;
-#endif
-
// A collection of strings used to indicate which breaking changes shouldn't be applied
// to an AppDomain. We only use the keys, the values are ignored.
[OptionalField(VersionAdded = 4)]
@@ -143,11 +117,6 @@ namespace System {
[OptionalField(VersionAdded = 5)] // This was added in .NET FX v4.5
private String _TargetFrameworkName;
-#if !FEATURE_CORECLR
- [NonSerialized]
- internal AppDomainSortingSetupInfo _AppDomainSortingSetupInfo;
-#endif
-
[OptionalField(VersionAdded = 5)] // This was added in .NET FX v4.5
private bool _CheckedForTargetFrameworkName;
@@ -156,7 +125,6 @@ namespace System {
private bool _UseRandomizedStringHashing;
#endif
- [SecuritySafeCritical]
internal AppDomainSetup(AppDomainSetup copy, bool copyDomainBoundData)
{
string[] mine = Value;
@@ -180,10 +148,8 @@ namespace System {
_LoaderOptimization = copy._LoaderOptimization;
_AppDomainInitializerArguments = copy.AppDomainInitializerArguments;
-#if FEATURE_CLICKONCE
- _ActivationArguments = copy.ActivationArguments;
-#endif
_ApplicationTrust = copy._ApplicationTrust;
+
if (copyDomainBoundData)
_AppDomainInitializer = copy.AppDomainInitializer;
else
@@ -195,21 +161,12 @@ namespace System {
#endif // FEATURE_COMINTEROP
_AppDomainManagerAssembly = copy.AppDomainManagerAssembly;
_AppDomainManagerType = copy.AppDomainManagerType;
-#if FEATURE_APTCA
- _AptcaVisibleAssemblies = copy.PartialTrustVisibleAssemblies;
-#endif
if (copy._CompatFlags != null)
{
SetCompatibilitySwitches(copy._CompatFlags.Keys);
}
-#if !FEATURE_CORECLR
- if(copy._AppDomainSortingSetupInfo != null)
- {
- _AppDomainSortingSetupInfo = new AppDomainSortingSetupInfo(copy._AppDomainSortingSetupInfo);
- }
-#endif
_TargetFrameworkName = copy._TargetFrameworkName;
#if FEATURE_RANDOMIZED_STRING_HASHING
@@ -226,32 +183,6 @@ namespace System {
_LoaderOptimization = LoaderOptimization.NotSpecified;
}
-#if FEATURE_CLICKONCE
- // Creates an AppDomainSetup object from an application identity.
- public AppDomainSetup (ActivationContext activationContext) : this (new ActivationArguments(activationContext)) {}
-
- [System.Security.SecuritySafeCritical] // auto-generated
- public AppDomainSetup (ActivationArguments activationArguments) {
- if (activationArguments == null)
- throw new ArgumentNullException("activationArguments");
- Contract.EndContractBlock();
-
- _LoaderOptimization = LoaderOptimization.NotSpecified;
- ActivationArguments = activationArguments;
-
- Contract.Assert(activationArguments.ActivationContext != null, "Cannot set base directory without activation context");
- string entryPointPath = CmsUtils.GetEntryPointFullPath(activationArguments);
- if (!String.IsNullOrEmpty(entryPointPath))
- SetupDefaults(entryPointPath);
- else
- ApplicationBase = activationArguments.ActivationContext.ApplicationDirectory;
-
- }
-#endif // !FEATURE_CLICKONCE
-
- #if FEATURE_CORECLR
- [System.Security.SecurityCritical] // auto-generated
- #endif
internal void SetupDefaults(string imageLocation, bool imageLocationAlreadyNormalized = false) {
char[] sep = {'\\', '/'};
int i = imageLocation.LastIndexOfAny(sep);
@@ -297,37 +228,13 @@ namespace System {
set { _AppDomainManagerType = value; }
}
-#if FEATURE_APTCA
- public string[] PartialTrustVisibleAssemblies
- {
- get { return _AptcaVisibleAssemblies; }
- set {
- if (value != null) {
- _AptcaVisibleAssemblies = (string[])value.Clone();
- Array.Sort<string>(_AptcaVisibleAssemblies, StringComparer.OrdinalIgnoreCase);
- }
- else {
- _AptcaVisibleAssemblies = null;
- }
- }
- }
-#endif
-
public String ApplicationBase
{
- #if FEATURE_CORECLR
- [System.Security.SecurityCritical] // auto-generated
- #else
- [System.Security.SecuritySafeCritical]
- #endif
[Pure]
get {
return VerifyDir(GetUnsecureApplicationBase(), false);
}
- #if FEATURE_CORECLR
- [System.Security.SecurityCritical] // auto-generated
- #endif
set {
Value[(int) LoaderInformation.ApplicationBaseValue] = NormalizePath(value, false);
}
@@ -550,7 +457,6 @@ namespace System {
public String ConfigurationFile
{
- [System.Security.SecuritySafeCritical] // auto-generated
get {
return VerifyDir(Value[(int) LoaderInformation.ConfigurationFileValue], true);
}
@@ -604,15 +510,6 @@ namespace System {
public void SetCompatibilitySwitches(IEnumerable<String> switches)
{
-
-#if !FEATURE_CORECLR
- if(_AppDomainSortingSetupInfo != null)
- {
- _AppDomainSortingSetupInfo._useV2LegacySorting = false;
- _AppDomainSortingSetupInfo._useV4LegacySorting = false;
- }
-#endif
-
#if FEATURE_RANDOMIZED_STRING_HASHING
_UseRandomizedStringHashing = false;
#endif
@@ -621,30 +518,11 @@ namespace System {
_CompatFlags = new Dictionary<string, object>();
foreach (String str in switches)
{
-#if !FEATURE_CORECLR
- if(StringComparer.OrdinalIgnoreCase.Equals("NetFx40_Legacy20SortingBehavior", str)) {
- if(_AppDomainSortingSetupInfo == null)
- {
- _AppDomainSortingSetupInfo = new AppDomainSortingSetupInfo();
- }
- _AppDomainSortingSetupInfo._useV2LegacySorting = true;
- }
-
- if(StringComparer.OrdinalIgnoreCase.Equals("NetFx45_Legacy40SortingBehavior", str)) {
- if(_AppDomainSortingSetupInfo == null)
- {
- _AppDomainSortingSetupInfo = new AppDomainSortingSetupInfo();
- }
- _AppDomainSortingSetupInfo._useV4LegacySorting = true;
- }
-#endif
-
#if FEATURE_RANDOMIZED_STRING_HASHING
if(StringComparer.OrdinalIgnoreCase.Equals("UseRandomizedStringHashAlgorithm", str)) {
_UseRandomizedStringHashing = true;
}
#endif
-
_CompatFlags.Add(str, null);
}
}
@@ -671,82 +549,12 @@ namespace System {
set { _CheckedForTargetFrameworkName = value; }
}
-#if !FEATURE_CORECLR
- [SecurityCritical]
- public void SetNativeFunction(string functionName, int functionVersion, IntPtr functionPointer)
- {
- if(functionName == null)
- {
- throw new ArgumentNullException("functionName");
- }
-
- if(functionPointer == IntPtr.Zero)
- {
- throw new ArgumentNullException("functionPointer");
- }
-
- if(String.IsNullOrWhiteSpace(functionName))
- {
- throw new ArgumentException(Environment.GetResourceString("Argument_NPMSInvalidName"), "functionName");
- }
-
- Contract.EndContractBlock();
-
- if(functionVersion < 1)
- {
- throw new ArgumentException(Environment.GetResourceString("ArgumentException_MinSortingVersion", 1, functionName));
- }
-
- if(_AppDomainSortingSetupInfo == null)
- {
- _AppDomainSortingSetupInfo = new AppDomainSortingSetupInfo();
- }
-
- if(String.Equals(functionName, "IsNLSDefinedString", StringComparison.OrdinalIgnoreCase))
- {
- _AppDomainSortingSetupInfo._pfnIsNLSDefinedString = functionPointer;
- }
-
- if (String.Equals(functionName, "CompareStringEx", StringComparison.OrdinalIgnoreCase))
- {
- _AppDomainSortingSetupInfo._pfnCompareStringEx = functionPointer;
- }
-
- if (String.Equals(functionName, "LCMapStringEx", StringComparison.OrdinalIgnoreCase))
- {
- _AppDomainSortingSetupInfo._pfnLCMapStringEx = functionPointer;
- }
-
- if (String.Equals(functionName, "FindNLSStringEx", StringComparison.OrdinalIgnoreCase))
- {
- _AppDomainSortingSetupInfo._pfnFindNLSStringEx = functionPointer;
- }
-
- if (String.Equals(functionName, "CompareStringOrdinal", StringComparison.OrdinalIgnoreCase))
- {
- _AppDomainSortingSetupInfo._pfnCompareStringOrdinal = functionPointer;
- }
-
- if (String.Equals(functionName, "GetNLSVersionEx", StringComparison.OrdinalIgnoreCase))
- {
- _AppDomainSortingSetupInfo._pfnGetNLSVersionEx = functionPointer;
- }
-
- if (String.Equals(functionName, "FindStringOrdinal", StringComparison.OrdinalIgnoreCase))
- {
- _AppDomainSortingSetupInfo._pfnFindStringOrdinal = functionPointer;
- }
- }
-#endif
-
public String DynamicBase
{
- [System.Security.SecuritySafeCritical] // auto-generated
get {
return VerifyDir(Value[(int) LoaderInformation.DynamicBaseValue], true);
}
- [System.Security.SecuritySafeCritical] // auto-generated
set {
if (value == null)
Value[(int) LoaderInformation.DynamicBaseValue] = null;
@@ -772,7 +580,6 @@ namespace System {
}
}
-
public bool DisallowPublisherPolicy
{
get
@@ -835,7 +642,6 @@ namespace System {
}
}
- [System.Security.SecurityCritical] // auto-generated
private String VerifyDir(String dir, bool normalize)
{
if (dir != null) {
@@ -844,22 +650,12 @@ namespace System {
else {
if (normalize)
dir = NormalizePath(dir, true);
-
- // The only way AppDomainSetup is exposed in coreclr is through the AppDomainManager
- // and the AppDomainManager is a SecurityCritical type. Also, all callers of callstacks
- // leading from VerifyDir are SecurityCritical. So we can remove the Demand because
- // we have validated that all callers are SecurityCritical
-#if !FEATURE_CORECLR
- if (IsFilePath(dir))
- new FileIOPermission( FileIOPermissionAccess.PathDiscovery, dir ).Demand();
-#endif // !FEATURE_CORECLR
}
}
return dir;
}
- [System.Security.SecurityCritical] // auto-generated
private void VerifyDirList(String dirs)
{
if (dirs != null) {
@@ -873,7 +669,6 @@ namespace System {
internal String DeveloperPath
{
- [System.Security.SecurityCritical] // auto-generated
get {
String dirs = Value[(int) LoaderInformation.DevPathValue];
VerifyDirList(dirs);
@@ -896,7 +691,7 @@ namespace System {
else
fDelimiter = true;
- newPath.Append(Path.GetFullPathInternal(directories[i]));
+ newPath.Append(Path.GetFullPath(directories[i]));
}
}
@@ -988,83 +783,29 @@ namespace System {
}
}
-#if FEATURE_CLICKONCE
- [XmlIgnoreMember]
- public ActivationArguments ActivationArguments {
- [Pure]
- get {
- return _ActivationArguments;
- }
- set {
- _ActivationArguments = value;
- }
- }
-#endif // !FEATURE_CLICKONCE
-
internal ApplicationTrust InternalGetApplicationTrust()
{
-
if (_ApplicationTrust == null) return null;
-
-
-#if FEATURE_CORECLR
ApplicationTrust grantSet = new ApplicationTrust(NamedPermissionSet.GetBuiltInSet(_ApplicationTrust));
-#else
- SecurityElement securityElement = SecurityElement.FromString(_ApplicationTrust);
- ApplicationTrust grantSet = new ApplicationTrust();
- grantSet.FromXml(securityElement);
-#endif
return grantSet;
}
-#if FEATURE_CORECLR
internal void InternalSetApplicationTrust(String permissionSetName)
{
_ApplicationTrust = permissionSetName;
}
-#else
- internal void InternalSetApplicationTrust(ApplicationTrust value)
- {
- if (value != null)
- {
- _ApplicationTrust = value.ToXml().ToString();
- }
- else
- {
- _ApplicationTrust = null;
- }
- }
-#endif
-#if FEATURE_CLICKONCE
- [XmlIgnoreMember]
- public ApplicationTrust ApplicationTrust
- {
- get {
- return InternalGetApplicationTrust();
- }
- set {
- InternalSetApplicationTrust(value);
- }
- }
-#else // FEATURE_CLICKONCE
[XmlIgnoreMember]
internal ApplicationTrust ApplicationTrust
{
- get {
+ get
+ {
return InternalGetApplicationTrust();
}
-#if !FEATURE_CORECLR
- set {
- InternalSetApplicationTrust(value);
- }
-#endif
}
-#endif // FEATURE_CLICKONCE
public String PrivateBinPath
{
- [System.Security.SecuritySafeCritical] // auto-generated
get {
String dirs = Value[(int) LoaderInformation.PrivateBinPathValue];
VerifyDirList(dirs);
@@ -1083,7 +824,6 @@ namespace System {
}
}
-
public String PrivateBinPathProbe
{
get {
@@ -1104,7 +844,6 @@ namespace System {
public String ShadowCopyDirectories
{
- [System.Security.SecuritySafeCritical] // auto-generated
get {
String dirs = Value[(int) LoaderInformation.ShadowCopyDirectoriesValue];
VerifyDirList(dirs);
@@ -1147,7 +886,6 @@ namespace System {
public String CachePath
{
- [System.Security.SecuritySafeCritical] // auto-generated
get {
return VerifyDir(Value[(int) LoaderInformation.CachePathValue], false);
}
@@ -1166,7 +904,6 @@ namespace System {
public String LicenseFile
{
- [System.Security.SecuritySafeCritical] // auto-generated
get {
return VerifyDir(Value[(int) LoaderInformation.LicenseFileValue], true);
}
@@ -1229,203 +966,17 @@ namespace System {
}
}
-#if FEATURE_FUSION
- [SecurityCritical]
- internal bool UpdateContextPropertyIfNeeded(LoaderInformation FieldValue, String FieldKey, String UpdatedField, IntPtr fusionContext, AppDomainSetup oldADS)
- {
- String FieldString = Value[(int) FieldValue],
- OldFieldString = (oldADS == null ? null : oldADS.Value[(int) FieldValue]);
- if (FieldString != OldFieldString) { // Compare references since strings are immutable
- UpdateContextProperty(fusionContext, FieldKey, UpdatedField == null ? FieldString : UpdatedField);
- return true;
- }
-
- return false;
- }
-
- [SecurityCritical]
- internal void UpdateBooleanContextPropertyIfNeeded(LoaderInformation FieldValue, String FieldKey, IntPtr fusionContext, AppDomainSetup oldADS)
- {
- if (Value[(int) FieldValue] != null)
- UpdateContextProperty(fusionContext, FieldKey, "true");
- else if (oldADS != null && oldADS.Value[(int) FieldValue] != null)
- UpdateContextProperty(fusionContext, FieldKey, "false");
- }
-
- [SecurityCritical]
- internal static bool ByteArraysAreDifferent(Byte[] A, Byte[] B)
- {
- int length = A.Length;
- if (length != B.Length)
- return true;
-
- for(int i = 0; i < length; i++) {
- if (A[i] != B[i])
- return true;
- }
-
- return false;
- }
-
- [System.Security.SecurityCritical] // auto-generated
- internal static void UpdateByteArrayContextPropertyIfNeeded(Byte[] NewArray, Byte[] OldArray, String FieldKey, IntPtr fusionContext)
- {
- if ((NewArray != null && OldArray == null) ||
- (NewArray == null && OldArray != null) ||
- (NewArray != null && OldArray != null && ByteArraysAreDifferent(NewArray, OldArray)))
- UpdateContextProperty(fusionContext, FieldKey, NewArray);
- }
-
- [System.Security.SecurityCritical] // auto-generated
- internal void SetupFusionContext(IntPtr fusionContext, AppDomainSetup oldADS)
- {
- UpdateContextPropertyIfNeeded(LoaderInformation.ApplicationBaseValue, ApplicationBaseKey, null, fusionContext, oldADS);
- UpdateContextPropertyIfNeeded(LoaderInformation.PrivateBinPathValue, PrivateBinPathKey, null, fusionContext, oldADS);
- UpdateContextPropertyIfNeeded(LoaderInformation.DevPathValue, DeveloperPathKey, null, fusionContext, oldADS);
-
- UpdateBooleanContextPropertyIfNeeded(LoaderInformation.DisallowPublisherPolicyValue, DisallowPublisherPolicyKey, fusionContext, oldADS);
- UpdateBooleanContextPropertyIfNeeded(LoaderInformation.DisallowCodeDownloadValue, DisallowCodeDownloadKey, fusionContext, oldADS);
- UpdateBooleanContextPropertyIfNeeded(LoaderInformation.DisallowBindingRedirectsValue, DisallowBindingRedirectsKey, fusionContext, oldADS);
- UpdateBooleanContextPropertyIfNeeded(LoaderInformation.DisallowAppBaseProbingValue, DisallowAppBaseProbingKey, fusionContext, oldADS);
-
- if(UpdateContextPropertyIfNeeded(LoaderInformation.ShadowCopyFilesValue, ShadowCopyFilesKey, ShadowCopyFiles, fusionContext, oldADS)) {
-
- // If we are asking for shadow copy directories then default to
- // only to the ones that are in the private bin path.
- if(Value[(int) LoaderInformation.ShadowCopyDirectoriesValue] == null)
- ShadowCopyDirectories = BuildShadowCopyDirectories();
-
- UpdateContextPropertyIfNeeded(LoaderInformation.ShadowCopyDirectoriesValue, ShadowCopyDirectoriesKey, null, fusionContext, oldADS);
- }
-
- UpdateContextPropertyIfNeeded(LoaderInformation.CachePathValue, CachePathKey, null, fusionContext, oldADS);
- UpdateContextPropertyIfNeeded(LoaderInformation.PrivateBinPathProbeValue, PrivateBinPathProbeKey, PrivateBinPathProbe, fusionContext, oldADS);
- UpdateContextPropertyIfNeeded(LoaderInformation.ConfigurationFileValue, ConfigurationFileKey, null, fusionContext, oldADS);
-
- UpdateByteArrayContextPropertyIfNeeded(_ConfigurationBytes, oldADS == null ? null : oldADS.GetConfigurationBytes(), ConfigurationBytesKey, fusionContext);
-
- UpdateContextPropertyIfNeeded(LoaderInformation.ApplicationNameValue, ApplicationNameKey, ApplicationName, fusionContext, oldADS);
- UpdateContextPropertyIfNeeded(LoaderInformation.DynamicBaseValue, DynamicBaseKey, null, fusionContext, oldADS);
-
- // Always add the runtime configuration file to the appdomain
- UpdateContextProperty(fusionContext, MachineConfigKey, RuntimeEnvironment.GetRuntimeDirectoryImpl() + RuntimeConfigurationFile);
-
- String hostBindingFile = RuntimeEnvironment.GetHostBindingFile();
- if(hostBindingFile != null || oldADS != null) // If oldADS != null, we don't know the old value of the hostBindingFile, so we force an update even when hostBindingFile == null.
- UpdateContextProperty(fusionContext, HostBindingKey, hostBindingFile);
- }
-
- [System.Security.SecurityCritical] // auto-generated
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal static extern void UpdateContextProperty(IntPtr fusionContext, string key, Object value);
-#endif // FEATURE_FUSION
-
static internal int Locate(String s)
{
if(String.IsNullOrEmpty(s))
return -1;
-#if FEATURE_FUSION
-
- // verify assumptions hardcoded into the switch below
- Contract.Assert('A' == ACTAG_APP_CONFIG_FILE[0] , "Assumption violated");
- Contract.Assert('A' == ACTAG_APP_NAME[0] , "Assumption violated");
- Contract.Assert('A' == ACTAG_APP_BASE_URL[0] , "Assumption violated");
- Contract.Assert('B' == ACTAG_BINPATH_PROBE_ONLY[0] , "Assumption violated");
- Contract.Assert('C' == ACTAG_APP_CACHE_BASE[0] , "Assumption violated");
- Contract.Assert('D' == ACTAG_DEV_PATH[0] , "Assumption violated");
- Contract.Assert('D' == ACTAG_APP_DYNAMIC_BASE[0] , "Assumption violated");
- Contract.Assert('F' == ACTAG_FORCE_CACHE_INSTALL[0] , "Assumption violated");
- Contract.Assert('L' == LICENSE_FILE[0] , "Assumption violated");
- Contract.Assert('P' == ACTAG_APP_PRIVATE_BINPATH[0] , "Assumption violated");
- Contract.Assert('S' == ACTAG_APP_SHADOW_COPY_DIRS[0], "Assumption violated");
- Contract.Assert('D' == ACTAG_DISALLOW_APPLYPUBLISHERPOLICY[0], "Assumption violated");
- Contract.Assert('C' == ACTAG_CODE_DOWNLOAD_DISABLED[0], "Assumption violated");
- Contract.Assert('D' == ACTAG_DISALLOW_APP_BINDING_REDIRECTS[0], "Assumption violated");
- Contract.Assert('D' == ACTAG_DISALLOW_APP_BASE_PROBING[0], "Assumption violated");
- Contract.Assert('A' == ACTAG_APP_CONFIG_BLOB[0], "Assumption violated");
-
- switch (s[0]) {
- case 'A':
- if (s == ACTAG_APP_CONFIG_FILE) return (int)LoaderInformation.ConfigurationFileValue;
- if (s == ACTAG_APP_NAME) return (int)LoaderInformation.ApplicationNameValue;
- if (s == ACTAG_APP_BASE_URL) return (int)LoaderInformation.ApplicationBaseValue;
- if (s == ACTAG_APP_CONFIG_BLOB) return (int)LoaderInformation.ConfigurationBytesValue;
- break;
- case 'B':
- if (s == ACTAG_BINPATH_PROBE_ONLY) return (int)LoaderInformation.PrivateBinPathProbeValue;
- break;
- case 'C':
- if (s == ACTAG_APP_CACHE_BASE) return (int)LoaderInformation.CachePathValue;
- if (s == ACTAG_CODE_DOWNLOAD_DISABLED) return (int)LoaderInformation.DisallowCodeDownloadValue;
- break;
- case 'D':
- if (s == ACTAG_DEV_PATH) return (int)LoaderInformation.DevPathValue;
- if (s == ACTAG_APP_DYNAMIC_BASE) return (int)LoaderInformation.DynamicBaseValue;
- if (s == ACTAG_DISALLOW_APPLYPUBLISHERPOLICY) return (int)LoaderInformation.DisallowPublisherPolicyValue;
- if (s == ACTAG_DISALLOW_APP_BINDING_REDIRECTS) return (int)LoaderInformation.DisallowBindingRedirectsValue;
- if (s == ACTAG_DISALLOW_APP_BASE_PROBING) return (int)LoaderInformation.DisallowAppBaseProbingValue;
- break;
- case 'F':
- if (s == ACTAG_FORCE_CACHE_INSTALL) return (int)LoaderInformation.ShadowCopyFilesValue;
- break;
- case 'L':
- if (s == LICENSE_FILE) return (int)LoaderInformation.LicenseFileValue;
- break;
- case 'P':
- if (s == ACTAG_APP_PRIVATE_BINPATH) return (int)LoaderInformation.PrivateBinPathValue;
- break;
- case 'S':
- if (s == ACTAG_APP_SHADOW_COPY_DIRS) return (int)LoaderInformation.ShadowCopyDirectoriesValue;
- break;
- }
-#else
- Contract.Assert('A' == ACTAG_APP_BASE_URL[0] , "Assumption violated");
+
+ Debug.Assert('A' == ACTAG_APP_BASE_URL[0] , "Assumption violated");
if (s[0]=='A' && s == ACTAG_APP_BASE_URL)
return (int)LoaderInformation.ApplicationBaseValue;
-#endif //FEATURE_FUSION
-
return -1;
}
-#if FEATURE_FUSION
- private string BuildShadowCopyDirectories()
- {
- // Default to only to the ones that are in the private bin path.
- String binPath = Value[(int) LoaderInformation.PrivateBinPathValue];
- if(binPath == null)
- return null;
-
- StringBuilder result = StringBuilderCache.Acquire();
- String appBase = Value[(int) LoaderInformation.ApplicationBaseValue];
- if(appBase != null) {
- char[] sep = {';'};
- string[] directories = binPath.Split(sep);
- int size = directories.Length;
- bool appendSlash = !( (appBase[appBase.Length-1] == '/') ||
- (appBase[appBase.Length-1] == '\\') );
-
- if (size == 0) {
- result.Append(appBase);
- if (appendSlash)
- result.Append('\\');
- result.Append(binPath);
- }
- else {
- for(int i = 0; i < size; i++) {
- result.Append(appBase);
- if (appendSlash)
- result.Append('\\');
- result.Append(directories[i]);
-
- if (i < size-1)
- result.Append(';');
- }
- }
- }
-
- return StringBuilderCache.GetStringAndRelease(result);
- }
-#endif // FEATURE_FUSION
#if FEATURE_COMINTEROP
public bool SandboxInterop
diff --git a/src/mscorlib/src/System/ApplicationId.cs b/src/mscorlib/src/System/ApplicationId.cs
index fa8be95..93fc37d 100644
--- a/src/mscorlib/src/System/ApplicationId.cs
+++ b/src/mscorlib/src/System/ApplicationId.cs
@@ -33,13 +33,13 @@ namespace System {
public ApplicationId (byte[] publicKeyToken, string name, Version version, string processorArchitecture, string culture) {
if (name == null)
- throw new ArgumentNullException("name");
+ throw new ArgumentNullException(nameof(name));
if (name.Length == 0)
throw new ArgumentException(Environment.GetResourceString("Argument_EmptyApplicationName"));
if (version == null)
- throw new ArgumentNullException("version");
+ throw new ArgumentNullException(nameof(version));
if (publicKeyToken == null)
- throw new ArgumentNullException("publicKeyToken");
+ throw new ArgumentNullException(nameof(publicKeyToken));
Contract.EndContractBlock();
m_publicKeyToken = new byte[publicKeyToken.Length];
diff --git a/src/mscorlib/src/System/ArgIterator.cs b/src/mscorlib/src/System/ArgIterator.cs
index 0ce27ed..c5bc379 100644
--- a/src/mscorlib/src/System/ArgIterator.cs
+++ b/src/mscorlib/src/System/ArgIterator.cs
@@ -16,19 +16,16 @@ namespace System {
[StructLayout(LayoutKind.Sequential)]
public struct ArgIterator
{
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern ArgIterator(IntPtr arglist);
// create an arg iterator that points at the first argument that
// is not statically declared (that is the first ... arg)
// 'arglist' is the value returned by the ARGLIST instruction
- [System.Security.SecuritySafeCritical] // auto-generated
public ArgIterator(RuntimeArgumentHandle arglist) : this(arglist.Value)
{
}
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private unsafe extern ArgIterator(IntPtr arglist, void *ptr);
@@ -36,7 +33,6 @@ namespace System {
// 'arglist' is the value returned by the ARGLIST instruction
// This is much like the C va_start macro
- [System.Security.SecurityCritical] // auto-generated
[CLSCompliant(false)]
public unsafe ArgIterator(RuntimeArgumentHandle arglist, void* ptr) : this(arglist.Value, ptr)
@@ -45,7 +41,6 @@ namespace System {
// Fetch an argument as a typed referece, advance the iterator.
// Throws an exception if past end of argument list
- [System.Security.SecuritySafeCritical] // auto-generated
[CLSCompliant(false)]
public TypedReference GetNextArg()
{
@@ -58,14 +53,12 @@ namespace System {
return result;
}
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
// reference to TypedReference is banned, so have to pass result as void pointer
private unsafe extern void FCallGetNextArg(void * result);
// Alternate version of GetNextArg() intended primarily for IJW code
// generated by VC's "va_arg()" construct.
- [System.Security.SecuritySafeCritical] // auto-generated
[CLSCompliant(false)]
public TypedReference GetNextArg(RuntimeTypeHandle rth)
{
@@ -96,7 +89,6 @@ namespace System {
}
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
// reference to TypedReference is banned, so have to pass result as void pointer
private unsafe extern void InternalGetNextArg(void * result, RuntimeType rt);
@@ -107,16 +99,13 @@ namespace System {
}
// How many arguments are left in the list
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern int GetRemainingCount();
// Gets the type of the current arg, does NOT advance the iterator
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern unsafe void* _GetNextArgType();
- [System.Security.SecuritySafeCritical] // auto-generated
public unsafe RuntimeTypeHandle GetNextArgType()
{
return new RuntimeTypeHandle(Type.GetTypeFromHandleUnsafe((IntPtr)_GetNextArgType()));
diff --git a/src/mscorlib/src/System/ArgumentException.cs b/src/mscorlib/src/System/ArgumentException.cs
index 8edb7e4..f37b769 100644
--- a/src/mscorlib/src/System/ArgumentException.cs
+++ b/src/mscorlib/src/System/ArgumentException.cs
@@ -82,10 +82,9 @@ namespace System {
get { return m_paramName; }
}
- [System.Security.SecurityCritical] // auto-generated_required
public override void GetObjectData(SerializationInfo info, StreamingContext context) {
if (info==null) {
- throw new ArgumentNullException("info");
+ throw new ArgumentNullException(nameof(info));
}
Contract.EndContractBlock();
base.GetObjectData(info, context);
diff --git a/src/mscorlib/src/System/ArgumentNullException.cs b/src/mscorlib/src/System/ArgumentNullException.cs
index 4bcb537..661ebd2 100644
--- a/src/mscorlib/src/System/ArgumentNullException.cs
+++ b/src/mscorlib/src/System/ArgumentNullException.cs
@@ -48,7 +48,6 @@ namespace System {
SetErrorCode(__HResults.E_POINTER);
}
- [System.Security.SecurityCritical] // auto-generated_required
protected ArgumentNullException(SerializationInfo info, StreamingContext context) : base(info, context) {
}
}
diff --git a/src/mscorlib/src/System/ArgumentOutOfRangeException.cs b/src/mscorlib/src/System/ArgumentOutOfRangeException.cs
index a54380b..78a90db 100644
--- a/src/mscorlib/src/System/ArgumentOutOfRangeException.cs
+++ b/src/mscorlib/src/System/ArgumentOutOfRangeException.cs
@@ -89,10 +89,9 @@ namespace System {
get { return m_actualValue; }
}
- [System.Security.SecurityCritical] // auto-generated_required
public override void GetObjectData(SerializationInfo info, StreamingContext context) {
if (info==null) {
- throw new ArgumentNullException("info");
+ throw new ArgumentNullException(nameof(info));
}
Contract.EndContractBlock();
base.GetObjectData(info, context);
diff --git a/src/mscorlib/src/System/Array.cs b/src/mscorlib/src/System/Array.cs
index 0879049..7bb6ebb 100644
--- a/src/mscorlib/src/System/Array.cs
+++ b/src/mscorlib/src/System/Array.cs
@@ -19,6 +19,7 @@ namespace System {
using System.Runtime.ConstrainedExecution;
using System.Runtime.Versioning;
using System.Security;
+ using System.Diagnostics;
using System.Security.Permissions;
using System.Diagnostics.Contracts;
@@ -64,13 +65,12 @@ namespace System {
}
// Create instance will create an array
- [System.Security.SecuritySafeCritical] // auto-generated
public unsafe static Array CreateInstance(Type elementType, int length)
{
if ((object)elementType == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.elementType);
if (length < 0)
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
+ ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum();
Contract.Ensures(Contract.Result<Array>() != null);
Contract.Ensures(Contract.Result<Array>().Length == length);
Contract.Ensures(Contract.Result<Array>().Rank == 1);
@@ -82,7 +82,6 @@ namespace System {
return InternalCreate((void*)t.TypeHandle.Value,1,&length,null);
}
- [System.Security.SecuritySafeCritical] // auto-generated
public unsafe static Array CreateInstance(Type elementType, int length1, int length2)
{
if ((object)elementType == null)
@@ -105,7 +104,6 @@ namespace System {
return InternalCreate((void*)t.TypeHandle.Value,2,pLengths,null);
}
- [System.Security.SecuritySafeCritical] // auto-generated
public unsafe static Array CreateInstance(Type elementType, int length1, int length2, int length3)
{
if ((object)elementType == null)
@@ -132,7 +130,6 @@ namespace System {
return InternalCreate((void*)t.TypeHandle.Value,3,pLengths,null);
}
- [System.Security.SecuritySafeCritical] // auto-generated
public unsafe static Array CreateInstance(Type elementType, params int[] lengths)
{
if ((object)elementType == null)
@@ -186,7 +183,6 @@ namespace System {
}
- [System.Security.SecuritySafeCritical] // auto-generated
public unsafe static Array CreateInstance(Type elementType, int[] lengths,int[] lowerBounds)
{
if (elementType == null)
@@ -219,41 +215,25 @@ namespace System {
fixed(int* pLowerBounds = lowerBounds)
return InternalCreate((void*)t.TypeHandle.Value,lengths.Length,pLengths,pLowerBounds);
}
- [System.Security.SecurityCritical] // auto-generated
+
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private unsafe static extern Array InternalCreate(void* elementType,int rank,int *pLengths,int *pLowerBounds);
- [SecurityCritical]
-#if !FEATURE_CORECLR
- [PermissionSet(SecurityAction.Assert, Unrestricted = true)]
-#endif
internal static Array UnsafeCreateInstance(Type elementType, int length)
{
return CreateInstance(elementType, length);
}
- [SecurityCritical]
-#if !FEATURE_CORECLR
- [PermissionSet(SecurityAction.Assert, Unrestricted = true)]
-#endif
internal static Array UnsafeCreateInstance(Type elementType, int length1, int length2)
{
return CreateInstance(elementType, length1, length2);
}
- [SecurityCritical]
-#if !FEATURE_CORECLR
- [PermissionSet(SecurityAction.Assert, Unrestricted = true)]
-#endif
internal static Array UnsafeCreateInstance(Type elementType, params int[] lengths)
{
return CreateInstance(elementType, lengths);
}
- [SecurityCritical]
-#if !FEATURE_CORECLR
- [PermissionSet(SecurityAction.Assert, Unrestricted = true)]
-#endif
internal static Array UnsafeCreateInstance(Type elementType, int[] lengths, int[] lowerBounds)
{
return CreateInstance(elementType, lengths, lowerBounds);
@@ -262,7 +242,6 @@ namespace System {
// Copies length elements from sourceArray, starting at index 0, to
// destinationArray, starting at index 0.
//
- [System.Security.SecuritySafeCritical] // auto-generated
[ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Copy(Array sourceArray, Array destinationArray, int length)
{
@@ -284,7 +263,6 @@ namespace System {
// Copies length elements from sourceArray, starting at sourceIndex, to
// destinationArray, starting at destinationIndex.
//
- [System.Security.SecuritySafeCritical] // auto-generated
[ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Copy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length)
{
@@ -295,7 +273,6 @@ namespace System {
// instance & might fail when called from within a CER, or if the
// reliable flag is true, it will either always succeed or always
// throw an exception with no side effects.
- [System.Security.SecurityCritical] // auto-generated
[ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern void Copy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length, bool reliable);
@@ -305,7 +282,6 @@ namespace System {
// compatible array types based on the array element type - this
// method does not support casting, boxing, or primitive widening.
// It will up-cast, assuming the array types are correct.
- [System.Security.SecuritySafeCritical] // auto-generated
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static void ConstrainedCopy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length)
{
@@ -338,13 +314,11 @@ namespace System {
// Sets length elements in array to 0 (or null for Object arrays), starting
// at index.
//
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static extern void Clear(Array array, int index, int length);
// The various Get values...
- [System.Security.SecuritySafeCritical] // auto-generated
public unsafe Object GetValue(params int[] indices)
{
if (indices == null)
@@ -359,7 +333,6 @@ namespace System {
return TypedReference.InternalToObject(&elemref);
}
- [System.Security.SecuritySafeCritical] // auto-generated
public unsafe Object GetValue(int index)
{
if (Rank != 1)
@@ -371,7 +344,6 @@ namespace System {
return TypedReference.InternalToObject(&elemref);
}
- [System.Security.SecuritySafeCritical] // auto-generated
public unsafe Object GetValue(int index1, int index2)
{
if (Rank != 2)
@@ -387,7 +359,6 @@ namespace System {
return TypedReference.InternalToObject(&elemref);
}
- [System.Security.SecuritySafeCritical] // auto-generated
public unsafe Object GetValue(int index1, int index2, int index3)
{
if (Rank != 3)
@@ -463,7 +434,6 @@ namespace System {
}
- [System.Security.SecuritySafeCritical] // auto-generated
public unsafe void SetValue(Object value,int index)
{
if (Rank != 1)
@@ -475,7 +445,6 @@ namespace System {
InternalSetValue(&elemref,value);
}
- [System.Security.SecuritySafeCritical] // auto-generated
public unsafe void SetValue(Object value,int index1, int index2)
{
if (Rank != 2)
@@ -491,7 +460,6 @@ namespace System {
InternalSetValue(&elemref,value);
}
- [System.Security.SecuritySafeCritical] // auto-generated
public unsafe void SetValue(Object value,int index1, int index2, int index3)
{
if (Rank != 3)
@@ -508,7 +476,6 @@ namespace System {
InternalSetValue(&elemref,value);
}
- [System.Security.SecuritySafeCritical] // auto-generated
public unsafe void SetValue(Object value,params int[] indices)
{
if (indices == null)
@@ -581,20 +548,17 @@ namespace System {
this.SetValue(value, intIndices);
}
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
// reference to TypedReference is banned, so have to pass result as pointer
private unsafe extern void InternalGetReference(void * elemRef, int rank, int * pIndices);
// Ideally, we would like to use TypedReference.SetValue instead. Unfortunately, TypedReference.SetValue
// always throws not-supported exception
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private unsafe extern static void InternalSetValue(void * target, Object value);
public extern int Length {
[Pure]
- [System.Security.SecuritySafeCritical] // auto-generated
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[MethodImpl(MethodImplOptions.InternalCall)]
get;
@@ -604,7 +568,7 @@ namespace System {
private static int GetMedian(int low, int hi) {
// Note both may be negative, if we are dealing with arrays w/ negative lower bounds.
Contract.Requires(low <= hi);
- Contract.Assert( hi - low >= 0, "Length overflow!");
+ Debug.Assert( hi - low >= 0, "Length overflow!");
return low + ((hi - low) >> 1);
}
@@ -619,14 +583,12 @@ namespace System {
[ComVisible(false)]
public extern long LongLength {
[Pure]
- [System.Security.SecuritySafeCritical] // auto-generated
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[MethodImpl(MethodImplOptions.InternalCall)]
get;
}
[Pure]
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern int GetLength(int dimension);
@@ -639,25 +601,21 @@ namespace System {
public extern int Rank {
[Pure]
- [System.Security.SecuritySafeCritical] // auto-generated
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
get;
}
- [System.Security.SecuritySafeCritical] // auto-generated
[Pure]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public extern int GetUpperBound(int dimension);
- [System.Security.SecuritySafeCritical] // auto-generated
[Pure]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern int GetLowerBound(int dimension);
- [System.Security.SecurityCritical] // auto-generated
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern int GetDataPtrOffsetInternal();
@@ -894,7 +852,6 @@ namespace System {
// is larger than the given search value.
//
[Pure]
- [System.Security.SecuritySafeCritical] // auto-generated
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public static int BinarySearch(Array array, int index, int length, Object value, IComparer comparer) {
if (array==null)
@@ -904,7 +861,7 @@ namespace System {
if (index < lb)
ThrowHelper.ThrowIndexArgumentOutOfRange_NeedNonNegNumException();
if (length < 0)
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
+ ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum();
if (array.Length - (index - lb) < length)
ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen);
if (array.Rank != 1)
@@ -965,7 +922,6 @@ namespace System {
return ~lo;
}
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
private static extern bool TrySZBinarySearch(Array sourceArray, int sourceIndex, int count, Object value, out int retVal);
@@ -1002,7 +958,7 @@ namespace System {
if (index < 0)
ThrowHelper.ThrowIndexArgumentOutOfRange_NeedNonNegNumException();
if (length < 0)
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
+ ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum();
if (array.Length - index < length)
ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen);
@@ -1073,6 +1029,42 @@ namespace System {
return Array.FindIndex(array, match) != -1;
}
+ public static void Fill<T>(T[] array, T value)
+ {
+ if (array == null)
+ {
+ ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
+ }
+
+ for (int i = 0; i < array.Length; i++)
+ {
+ array[i] = value;
+ }
+ }
+
+ public static void Fill<T>(T[] array, T value, int startIndex, int count)
+ {
+ if (array == null)
+ {
+ ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
+ }
+
+ if (startIndex < 0 || startIndex > array.Length)
+ {
+ ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index();
+ }
+
+ if (count < 0 || startIndex > array.Length - count)
+ {
+ ThrowHelper.ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count();
+ }
+
+ for (int i = startIndex; i < startIndex + count; i++)
+ {
+ array[i] = value;
+ }
+ }
+
public static T Find<T>(T[] array, Predicate<T> match) {
if( array == null) {
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
@@ -1136,11 +1128,11 @@ namespace System {
}
if( startIndex < 0 || startIndex > array.Length ) {
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.startIndex, ExceptionResource.ArgumentOutOfRange_Index);
+ ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index();
}
if (count < 0 || startIndex > array.Length - count) {
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.count, ExceptionResource.ArgumentOutOfRange_Count);
+ ThrowHelper.ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count();
}
if( match == null) {
@@ -1205,19 +1197,19 @@ namespace System {
if(array.Length == 0) {
// Special case for 0 length List
if( startIndex != -1) {
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.startIndex, ExceptionResource.ArgumentOutOfRange_Index);
+ ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index();
}
}
else {
// Make sure we're not out of range
if ( startIndex < 0 || startIndex >= array.Length) {
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.startIndex, ExceptionResource.ArgumentOutOfRange_Index);
+ ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index();
}
}
// 2nd have of this also catches when startIndex == MAXINT, so MAXINT - 0 + 1 == -1, which is < 0.
if (count < 0 || startIndex - count + 1 < 0) {
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.count, ExceptionResource.ArgumentOutOfRange_Count);
+ ThrowHelper.ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count();
}
int endIndex = startIndex - count;
@@ -1293,7 +1285,6 @@ namespace System {
// elements of the array are compared to the given value using the
// Object.Equals method.
//
- [System.Security.SecuritySafeCritical] // auto-generated
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public static int IndexOf(Array array, Object value, int startIndex, int count) {
if (array==null)
@@ -1305,9 +1296,9 @@ namespace System {
int lb = array.GetLowerBound(0);
if (startIndex < lb || startIndex > array.Length + lb)
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.startIndex, ExceptionResource.ArgumentOutOfRange_Index);
+ ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index();
if (count < 0 || count > array.Length - startIndex + lb)
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.count, ExceptionResource.ArgumentOutOfRange_Count);
+ ThrowHelper.ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count();
// Try calling a quick native method to handle primitive types.
int retVal;
@@ -1376,11 +1367,11 @@ namespace System {
}
if (startIndex < 0 || startIndex > array.Length ) {
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.startIndex, ExceptionResource.ArgumentOutOfRange_Index);
+ ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index();
}
if (count < 0 || count > array.Length - startIndex) {
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.count, ExceptionResource.ArgumentOutOfRange_Count);
+ ThrowHelper.ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count();
}
Contract.Ensures(Contract.Result<int>() < array.Length);
Contract.EndContractBlock();
@@ -1388,7 +1379,6 @@ namespace System {
return EqualityComparer<T>.Default.IndexOf(array, value, startIndex, count);
}
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
private static extern bool TrySZIndexOf(Array sourceArray, int sourceIndex, int count, Object value, out int retVal);
@@ -1429,7 +1419,6 @@ namespace System {
// the array are compared to the given value using the Object.Equals
// method.
//
- [System.Security.SecuritySafeCritical] // auto-generated
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public static int LastIndexOf(Array array, Object value, int startIndex, int count) {
if (array==null)
@@ -1442,9 +1431,9 @@ namespace System {
}
if (startIndex < lb || startIndex >= array.Length + lb)
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.startIndex, ExceptionResource.ArgumentOutOfRange_Index);
+ ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index();
if (count < 0)
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.count, ExceptionResource.ArgumentOutOfRange_Count);
+ ThrowHelper.ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count();
if (count > startIndex - lb + 1)
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.endIndex, ExceptionResource.ArgumentOutOfRange_EndIndexStartIndex);
if (array.Rank != 1)
@@ -1518,30 +1507,29 @@ namespace System {
// accept -1 and 0 as valid startIndex for compablility reason.
//
if( startIndex != -1 && startIndex != 0) {
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.startIndex, ExceptionResource.ArgumentOutOfRange_Index);
+ ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index();
}
// only 0 is a valid value for count if array is empty
if( count != 0) {
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.count, ExceptionResource.ArgumentOutOfRange_Count);
+ ThrowHelper.ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count();
}
return -1;
}
// Make sure we're not out of range
if ( startIndex < 0 || startIndex >= array.Length) {
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.startIndex, ExceptionResource.ArgumentOutOfRange_Index);
+ ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index();
}
// 2nd have of this also catches when startIndex == MAXINT, so MAXINT - 0 + 1 == -1, which is < 0.
if (count < 0 || startIndex - count + 1 < 0) {
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.count, ExceptionResource.ArgumentOutOfRange_Count);
+ ThrowHelper.ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count();
}
return EqualityComparer<T>.Default.LastIndexOf(array, value, startIndex, count);
}
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
private static extern bool TrySZLastIndexOf(Array sourceArray, int sourceIndex, int count, Object value, out int retVal);
@@ -1566,7 +1554,6 @@ namespace System {
// index index + (index + count - i - 1).
// Reliability note: This may fail because it may have to box objects.
//
- [System.Security.SecuritySafeCritical] // auto-generated
[ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Reverse(Array array, int index, int length) {
if (array==null)
@@ -1575,7 +1562,7 @@ namespace System {
if (index < lowerBound)
ThrowHelper.ThrowIndexArgumentOutOfRange_NeedNonNegNumException();
if (length < 0)
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
+ ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum();
if (array.Length - (index - lowerBound) < length)
ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen);
@@ -1610,11 +1597,44 @@ namespace System {
}
}
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
[ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
private static extern bool TrySZReverse(Array array, int index, int count);
-
+
+ [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
+ public static void Reverse<T>(T[] array)
+ {
+ if (array == null)
+ ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
+ Contract.EndContractBlock();
+ Reverse(array, 0, array.Length);
+ }
+
+ [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
+ public static void Reverse<T>(T[] array, int index, int length)
+ {
+ if (array == null)
+ ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
+ if (index < 0)
+ ThrowHelper.ThrowIndexArgumentOutOfRange_NeedNonNegNumException();
+ if (length < 0)
+ ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum();
+ if (array.Length - index < length)
+ ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen);
+ Contract.EndContractBlock();
+
+ int i = index;
+ int j = index + length - 1;
+ while (i < j)
+ {
+ T temp = array[i];
+ array[i] = array[j];
+ array[j] = temp;
+ i++;
+ j--;
+ }
+ }
+
// Sorts the elements of an array. The sort compares the elements to each
// other using the IComparable interface, which must be implemented
// by all elements of the array.
@@ -1710,7 +1730,6 @@ namespace System {
// the IComparable interface, which in that case must be implemented
// by all elements of the given section of the keys array.
//
- [System.Security.SecuritySafeCritical] // auto-generated
[ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Sort(Array keys, Array items, int index, int length, IComparer comparer) {
if (keys==null)
@@ -1723,7 +1742,7 @@ namespace System {
if (index < keysLowerBound)
ThrowHelper.ThrowIndexArgumentOutOfRange_NeedNonNegNumException();
if (length < 0)
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
+ ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum();
if (keys.Length - (index - keysLowerBound) < length || (items != null && (index - keysLowerBound) > items.Length - length))
ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen);
@@ -1752,7 +1771,6 @@ namespace System {
}
}
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
[ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
private static extern bool TrySZSort(Array keys, Array items, int left, int right);
@@ -1799,7 +1817,6 @@ namespace System {
Sort<TKey, TValue>(keys, items, 0, keys.Length, comparer);
}
- [System.Security.SecuritySafeCritical] // auto-generated
[ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Sort<T>(T[] array, int index, int length, System.Collections.Generic.IComparer<T> comparer) {
if (array==null)
@@ -1807,7 +1824,7 @@ namespace System {
if (index < 0)
ThrowHelper.ThrowIndexArgumentOutOfRange_NeedNonNegNumException();
if (length < 0)
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
+ ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum();
if (array.Length - index < length)
ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen);
Contract.EndContractBlock();
@@ -1823,7 +1840,6 @@ namespace System {
}
}
- [System.Security.SecuritySafeCritical] // auto-generated
[ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Sort<TKey, TValue>(TKey[] keys, TValue[] items, int index, int length, System.Collections.Generic.IComparer<TKey> comparer) {
if (keys==null)
@@ -1831,7 +1847,7 @@ namespace System {
if (index < 0)
ThrowHelper.ThrowIndexArgumentOutOfRange_NeedNonNegNumException();
if (length < 0)
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
+ ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum();
if (keys.Length - index < length || (items != null && index > items.Length - length))
ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen);
Contract.EndContractBlock();
@@ -1863,8 +1879,7 @@ namespace System {
}
Contract.EndContractBlock();
- IComparer<T> comparer = Comparer<T>.Create(comparison);
- Array.Sort(array, comparer);
+ ArraySortHelper<T>.Sort(array, 0, array.Length, comparison);
}
public static bool TrueForAll<T>(T[] array, Predicate<T> match) {
@@ -1935,120 +1950,7 @@ namespace System {
internal void Sort(int left, int length)
{
-#if FEATURE_CORECLR
- // Since QuickSort and IntrospectiveSort produce different sorting sequence for equal keys the upgrade
- // to IntrospectiveSort was quirked. However since the phone builds always shipped with the new sort aka
- // IntrospectiveSort and we would want to continue using this sort moving forward CoreCLR always uses the new sort.
-
IntrospectiveSort(left, length);
-#else
- if (BinaryCompatibility.TargetsAtLeast_Desktop_V4_5)
- {
- IntrospectiveSort(left, length);
- }
- else
- {
- DepthLimitedQuickSort(left, length + left - 1, IntrospectiveSortUtilities.QuickSortDepthThreshold);
- }
-#endif
- }
-
- private void DepthLimitedQuickSort(int left, int right, int depthLimit)
- {
- // Can use the much faster jit helpers for array access.
- do
- {
- if (depthLimit == 0)
- {
- // Add a try block here to detect IComparers (or their
- // underlying IComparables, etc) that are bogus.
- try
- {
- Heapsort(left, right);
- return;
- }
- catch (IndexOutOfRangeException)
- {
- ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_BogusIComparer, ExceptionArgument.comparer);
- }
- catch (Exception e)
- {
- ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_IComparerFailed, e);
- }
- }
-
- int i = left;
- int j = right;
-
- // pre-sort the low, middle (pivot), and high values in place.
- // this improves performance in the face of already sorted data, or
- // data that is made up of multiple sorted runs appended together.
- int middle = GetMedian(i, j);
-
- // Add a try block here to detect IComparers (or their
- // underlying IComparables, etc) that are bogus.
- try
- {
- SwapIfGreaterWithItems(i, middle); // swap the low with the mid point
- SwapIfGreaterWithItems(i, j); // swap the low with the high
- SwapIfGreaterWithItems(middle, j); // swap the middle with the high
- }
- catch (Exception e)
- {
- ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_IComparerFailed, e);
- }
- Object x = keys[middle];
- do
- {
- // Add a try block here to detect IComparers (or their
- // underlying IComparables, etc) that are bogus.
- try
- {
- while (comparer.Compare(keys[i], x) < 0) i++;
- while (comparer.Compare(x, keys[j]) < 0) j--;
- }
- catch (IndexOutOfRangeException)
- {
- ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_BogusIComparer, ExceptionArgument.comparer);
- }
- catch (Exception e)
- {
- ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_IComparerFailed, e);
- }
- Contract.Assert(i >= left && j <= right, "(i>=left && j<=right) Sort failed - Is your IComparer bogus?");
- if (i > j) break;
- if (i < j)
- {
- Object key = keys[i];
- keys[i] = keys[j];
- keys[j] = key;
- if (items != null)
- {
- Object item = items[i];
- items[i] = items[j];
- items[j] = item;
- }
- }
- i++;
- j--;
- } while (i <= j);
-
- // The next iteration of the while loop is to "recursively" sort the larger half of the array and the
- // following calls recursively sort the smaller half. So we subtract one from depthLimit here so
- // both sorts see the new value.
- depthLimit--;
-
- if (j - left <= right - i)
- {
- if (left < j) DepthLimitedQuickSort(left, j, depthLimit);
- left = i;
- }
- else
- {
- if (i < right) DepthLimitedQuickSort(i, right, depthLimit);
- right = j;
- }
- } while (left < right);
}
private void IntrospectiveSort(int left, int length)
@@ -2254,118 +2156,7 @@ namespace System {
internal void Sort(int left, int length)
{
-#if FEATURE_CORECLR
- // Since QuickSort and IntrospectiveSort produce different sorting sequence for equal keys the upgrade
- // to IntrospectiveSort was quirked. However since the phone builds always shipped with the new sort aka
- // IntrospectiveSort and we would want to continue using this sort moving forward CoreCLR always uses the new sort.
-
IntrospectiveSort(left, length);
-#else
- if (BinaryCompatibility.TargetsAtLeast_Desktop_V4_5)
- {
- IntrospectiveSort(left, length);
- }
- else
- {
- DepthLimitedQuickSort(left, length + left - 1, IntrospectiveSortUtilities.QuickSortDepthThreshold);
- }
-#endif
- }
-
- private void DepthLimitedQuickSort(int left, int right, int depthLimit)
- {
- // Must use slow Array accessors (GetValue & SetValue)
- do
- {
- if (depthLimit == 0)
- {
- // Add a try block here to detect IComparers (or their
- // underlying IComparables, etc) that are bogus.
- try
- {
- Heapsort(left, right);
- return;
- }
- catch (IndexOutOfRangeException)
- {
- ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_BogusIComparer, ExceptionArgument.comparer);
- }
- catch (Exception e)
- {
- ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_IComparerFailed, e);
- }
- }
-
- int i = left;
- int j = right;
-
- // pre-sort the low, middle (pivot), and high values in place.
- // this improves performance in the face of already sorted data, or
- // data that is made up of multiple sorted runs appended together.
- int middle = GetMedian(i, j);
- try
- {
- SwapIfGreaterWithItems(i, middle); // swap the low with the mid point
- SwapIfGreaterWithItems(i, j); // swap the low with the high
- SwapIfGreaterWithItems(middle, j); // swap the middle with the high
- }
- catch (Exception e)
- {
- ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_IComparerFailed, e);
- }
-
- Object x = keys.GetValue(middle);
- do
- {
- // Add a try block here to detect IComparers (or their
- // underlying IComparables, etc) that are bogus.
- try
- {
- while (comparer.Compare(keys.GetValue(i), x) < 0) i++;
- while (comparer.Compare(x, keys.GetValue(j)) < 0) j--;
- }
- catch (IndexOutOfRangeException)
- {
- ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_BogusIComparer, ExceptionArgument.comparer);
- }
- catch (Exception e)
- {
- ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_IComparerFailed, e);
- }
- Contract.Assert(i >= left && j <= right, "(i>=left && j<=right) Sort failed - Is your IComparer bogus?");
- if (i > j) break;
- if (i < j)
- {
- Object key = keys.GetValue(i);
- keys.SetValue(keys.GetValue(j), i);
- keys.SetValue(key, j);
- if (items != null)
- {
- Object item = items.GetValue(i);
- items.SetValue(items.GetValue(j), i);
- items.SetValue(item, j);
- }
- }
- if (i != Int32.MaxValue) ++i;
- if (j != Int32.MinValue) --j;
- } while (i <= j);
-
- // The next iteration of the while loop is to "recursively" sort the larger half of the array and the
- // following calls recursively sort the smaller half. So we subtract one from depthLimit here so
- // both sorts see the new value.
- depthLimit--;
-
- if (j - left <= right - i)
- {
- if (left < j) DepthLimitedQuickSort(left, j, depthLimit);
- left = i;
- }
- else
- {
- if (i < right) DepthLimitedQuickSort(i, right, depthLimit);
- right = j;
- }
- } while (left < right);
}
private void IntrospectiveSort(int left, int length)
@@ -2530,7 +2321,7 @@ namespace System {
private int _endIndex; // cache array length, since it's a little slow.
internal SZArrayEnumerator(Array array) {
- Contract.Assert(array.Rank == 1 && array.GetLowerBound(0) == 0, "SZArrayEnumerator only works on single dimension arrays w/ a lower bound of zero.");
+ Debug.Assert(array.Rank == 1 && array.GetLowerBound(0) == 0, "SZArrayEnumerator only works on single dimension arrays w/ a lower bound of zero.");
_array = array;
_index = -1;
_endIndex = array.Length;
@@ -2551,8 +2342,8 @@ namespace System {
public Object Current {
get {
- if (_index < 0) ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_EnumNotStarted);
- if (_index >= _endIndex) ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_EnumEnded);
+ if (_index < 0) ThrowHelper.ThrowInvalidOperationException_InvalidOperation_EnumNotStarted();
+ if (_index >= _endIndex) ThrowHelper.ThrowInvalidOperationException_InvalidOperation_EnumEnded();
return _array.GetValue(_index);
}
}
@@ -2629,8 +2420,8 @@ namespace System {
public Object Current {
get {
- if (index < startIndex) ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_EnumNotStarted);
- if (_complete) ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_EnumEnded);
+ if (index < startIndex) ThrowHelper.ThrowInvalidOperationException_InvalidOperation_EnumNotStarted();
+ if (_complete) ThrowHelper.ThrowInvalidOperationException_InvalidOperation_EnumEnded();
return array.GetValue(_indices);
}
}
@@ -2652,7 +2443,6 @@ namespace System {
// if this is an array of value classes and that value class has a default constructor
// then this calls this default constructor on every element in the value class array.
// otherwise this is a no-op. Generally this method is called automatically by the compiler
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern void Initialize();
}
@@ -2689,13 +2479,12 @@ namespace System {
sealed class SZArrayHelper {
// It is never legal to instantiate this class.
private SZArrayHelper() {
- Contract.Assert(false, "Hey! How'd I get here?");
+ Debug.Assert(false, "Hey! How'd I get here?");
}
// -----------------------------------------------------------
// ------- Implement IEnumerable<T> interface methods --------
// -----------------------------------------------------------
- [SecuritySafeCritical]
internal IEnumerator<T> GetEnumerator<T>() {
//! Warning: "this" is an array, not an SZArrayHelper. See comments above
//! or you may introduce a security hole!
@@ -2707,7 +2496,6 @@ namespace System {
// -----------------------------------------------------------
// ------- Implement ICollection<T> interface methods --------
// -----------------------------------------------------------
- [SecuritySafeCritical]
void CopyTo<T>(T[] array, int index) {
//! Warning: "this" is an array, not an SZArrayHelper. See comments above
//! or you may introduce a security hole!
@@ -2716,7 +2504,6 @@ namespace System {
Array.Copy(_this, 0, array, index, _this.Length);
}
- [SecuritySafeCritical]
internal int get_Count<T>() {
//! Warning: "this" is an array, not an SZArrayHelper. See comments above
//! or you may introduce a security hole!
@@ -2727,7 +2514,6 @@ namespace System {
// -----------------------------------------------------------
// ---------- Implement IList<T> interface methods -----------
// -----------------------------------------------------------
- [SecuritySafeCritical]
internal T get_Item<T>(int index) {
//! Warning: "this" is an array, not an SZArrayHelper. See comments above
//! or you may introduce a security hole!
@@ -2739,7 +2525,6 @@ namespace System {
return _this[index];
}
- [SecuritySafeCritical]
internal void set_Item<T>(int index, T value) {
//! Warning: "this" is an array, not an SZArrayHelper. See comments above
//! or you may introduce a security hole!
@@ -2756,12 +2541,11 @@ namespace System {
ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection);
}
- [SecuritySafeCritical]
bool Contains<T>(T value) {
//! Warning: "this" is an array, not an SZArrayHelper. See comments above
//! or you may introduce a security hole!
T[] _this = JitHelpers.UnsafeCast<T[]>(this);
- return Array.IndexOf(_this, value) != -1;
+ return Array.IndexOf(_this, value, 0, _this.Length) >= 0;
}
bool get_IsReadOnly<T>() {
@@ -2775,12 +2559,11 @@ namespace System {
ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
}
- [SecuritySafeCritical]
int IndexOf<T>(T value) {
//! Warning: "this" is an array, not an SZArrayHelper. See comments above
//! or you may introduce a security hole!
T[] _this = JitHelpers.UnsafeCast<T[]>(this);
- return Array.IndexOf(_this, value);
+ return Array.IndexOf(_this, value, 0, _this.Length);
}
void Insert<T>(int index, T value) {
@@ -2812,7 +2595,7 @@ namespace System {
internal SZGenericArrayEnumerator(T[] array, int endIndex) {
// We allow passing null array in case of empty enumerator.
- Contract.Assert(array != null || endIndex == -1, "endIndex should be -1 in the case of a null array (for the empty enumerator).");
+ Debug.Assert(array != null || endIndex == -1, "endIndex should be -1 in the case of a null array (for the empty enumerator).");
_array = array;
_index = -1;
_endIndex = endIndex;
@@ -2828,8 +2611,8 @@ namespace System {
public T Current {
get {
- if (_index < 0) ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_EnumNotStarted);
- if (_index >= _endIndex) ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_EnumEnded);
+ if (_index < 0) ThrowHelper.ThrowInvalidOperationException_InvalidOperation_EnumNotStarted();
+ if (_index >= _endIndex) ThrowHelper.ThrowInvalidOperationException_InvalidOperation_EnumEnded();
return _array[_index];
}
}
diff --git a/src/mscorlib/src/System/ArraySegment.cs b/src/mscorlib/src/System/ArraySegment.cs
index bc39c24..b767e7b 100644
--- a/src/mscorlib/src/System/ArraySegment.cs
+++ b/src/mscorlib/src/System/ArraySegment.cs
@@ -16,6 +16,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
+using System.Diagnostics;
using System.Diagnostics.Contracts;
namespace System
@@ -28,10 +29,10 @@ namespace System
[Serializable]
public struct ArraySegment<T> : IList<T>, IReadOnlyList<T>
{
- private T[] _array;
- private int _offset;
- private int _count;
-
+ private readonly T[] _array;
+ private readonly int _offset;
+ private readonly int _count;
+
public ArraySegment(T[] array)
{
if (array == null)
@@ -64,10 +65,10 @@ namespace System
{
get
{
- Contract.Assert( (null == _array && 0 == _offset && 0 == _count)
+ Debug.Assert( (null == _array && 0 == _offset && 0 == _count)
|| (null != _array && _offset >= 0 && _count >= 0 && _offset + _count <= _array.Length),
"ArraySegment is invalid");
-
+
return _array;
}
}
@@ -83,7 +84,7 @@ namespace System
// after reading each field out of an ArraySegment into their stack.
Contract.Ensures(Contract.Result<int>() >= 0);
- Contract.Assert( (null == _array && 0 == _offset && 0 == _count)
+ Debug.Assert( (null == _array && 0 == _offset && 0 == _count)
|| (null != _array && _offset >= 0 && _count >= 0 && _offset + _count <= _array.Length),
"ArraySegment is invalid");
@@ -102,19 +103,38 @@ namespace System
// after reading each field out of an ArraySegment into their stack.
Contract.Ensures(Contract.Result<int>() >= 0);
- Contract.Assert( (null == _array && 0 == _offset && 0 == _count)
+ Debug.Assert( (null == _array && 0 == _offset && 0 == _count)
|| (null != _array && _offset >= 0 && _count >= 0 && _offset + _count <= _array.Length),
"ArraySegment is invalid");
return _count;
}
}
-
+
+ public Enumerator GetEnumerator()
+ {
+ if (_array == null)
+ ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_NullArray);
+ Contract.EndContractBlock();
+
+ return new Enumerator(this);
+ }
+
public override int GetHashCode()
{
- return null == _array
- ? 0
- : _array.GetHashCode() ^ _offset ^ _count;
+ if (_array == null)
+ {
+ return 0;
+ }
+
+ int hash = 5381;
+ hash = System.Numerics.Hashing.HashHelpers.Combine(hash, _offset);
+ hash = System.Numerics.Hashing.HashHelpers.Combine(hash, _count);
+
+ // The array hash is expected to be an evenly-distributed mixture of bits,
+ // so rather than adding the cost of another rotation we just xor it.
+ hash ^= _array.GetHashCode();
+ return hash;
}
public override bool Equals(Object obj)
@@ -174,7 +194,7 @@ namespace System
int index = System.Array.IndexOf<T>(_array, item, _offset, _count);
- Contract.Assert(index == -1 ||
+ Debug.Assert(index == -1 ||
(index >= _offset && index < _offset + _count));
return index >= 0 ? index - _offset : -1;
@@ -236,7 +256,7 @@ namespace System
int index = System.Array.IndexOf<T>(_array, item, _offset, _count);
- Contract.Assert(index == -1 ||
+ Debug.Assert(index == -1 ||
(index >= _offset && index < _offset + _count));
return index >= 0;
@@ -259,46 +279,34 @@ namespace System
#endregion
#region IEnumerable<T>
- IEnumerator<T> IEnumerable<T>.GetEnumerator()
- {
- if (_array == null)
- ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_NullArray);
- Contract.EndContractBlock();
- return new ArraySegmentEnumerator(this);
- }
+ IEnumerator<T> IEnumerable<T>.GetEnumerator() => GetEnumerator();
#endregion
#region IEnumerable
- IEnumerator IEnumerable.GetEnumerator()
- {
- if (_array == null)
- ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_NullArray);
- Contract.EndContractBlock();
- return new ArraySegmentEnumerator(this);
- }
+ IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
#endregion
[Serializable]
- private sealed class ArraySegmentEnumerator : IEnumerator<T>
+ public struct Enumerator : IEnumerator<T>
{
- private T[] _array;
- private int _start;
- private int _end;
+ private readonly T[] _array;
+ private readonly int _start;
+ private readonly int _end; // cache Offset + Count, since it's a little slow
private int _current;
- internal ArraySegmentEnumerator(ArraySegment<T> arraySegment)
+ internal Enumerator(ArraySegment<T> arraySegment)
{
Contract.Requires(arraySegment.Array != null);
Contract.Requires(arraySegment.Offset >= 0);
Contract.Requires(arraySegment.Count >= 0);
Contract.Requires(arraySegment.Offset + arraySegment.Count <= arraySegment.Array.Length);
- _array = arraySegment._array;
- _start = arraySegment._offset;
- _end = _start + arraySegment._count;
- _current = _start - 1;
+ _array = arraySegment.Array;
+ _start = arraySegment.Offset;
+ _end = arraySegment.Offset + arraySegment.Count;
+ _current = arraySegment.Offset - 1;
}
public bool MoveNext()
@@ -315,19 +323,15 @@ namespace System
{
get
{
- if (_current < _start) ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_EnumNotStarted);
- if (_current >= _end) ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_EnumEnded);
+ if (_current < _start)
+ ThrowHelper.ThrowInvalidOperationException_InvalidOperation_EnumNotStarted();
+ if (_current >= _end)
+ ThrowHelper.ThrowInvalidOperationException_InvalidOperation_EnumEnded();
return _array[_current];
}
}
- object IEnumerator.Current
- {
- get
- {
- return Current;
- }
- }
+ object IEnumerator.Current => Current;
void IEnumerator.Reset()
{
diff --git a/src/mscorlib/src/System/Attribute.cs b/src/mscorlib/src/System/Attribute.cs
index 6475d8d..e77450e 100644
--- a/src/mscorlib/src/System/Attribute.cs
+++ b/src/mscorlib/src/System/Attribute.cs
@@ -10,6 +10,7 @@ namespace System {
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Globalization;
+ using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Security;
using System.Security.Permissions;
@@ -436,7 +437,6 @@ namespace System {
Environment.GetResourceString("Format_AttributeUsage", type));
}
- [System.Security.SecuritySafeCritical]
private static Attribute[] CreateAttributeArrayHelper(Type elementType, int elementCount)
{
return (Attribute[])Array.UnsafeCreateInstance(elementType, elementCount);
@@ -456,10 +456,10 @@ namespace System {
public static Attribute[] GetCustomAttributes(MemberInfo element, Type type, bool inherit)
{
if (element == null)
- throw new ArgumentNullException("element");
+ throw new ArgumentNullException(nameof(element));
if (type == null)
- throw new ArgumentNullException("type");
+ throw new ArgumentNullException(nameof(type));
if (!type.IsSubclassOf(typeof(Attribute)) && type != typeof(Attribute))
throw new ArgumentException(Environment.GetResourceString("Argument_MustHaveAttributeBaseClass"));
@@ -486,7 +486,7 @@ namespace System {
public static Attribute[] GetCustomAttributes(MemberInfo element, bool inherit)
{
if (element == null)
- throw new ArgumentNullException("element");
+ throw new ArgumentNullException(nameof(element));
Contract.EndContractBlock();
switch (element.MemberType)
@@ -511,10 +511,10 @@ namespace System {
{
// Returns true if a custom attribute subclass of attributeType class/interface with inheritance walk
if (element == null)
- throw new ArgumentNullException("element");
+ throw new ArgumentNullException(nameof(element));
if (attributeType == null)
- throw new ArgumentNullException("attributeType");
+ throw new ArgumentNullException(nameof(attributeType));
if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute))
throw new ArgumentException(Environment.GetResourceString("Argument_MustHaveAttributeBaseClass"));
@@ -568,16 +568,16 @@ namespace System {
public static Attribute[] GetCustomAttributes(ParameterInfo element, Type attributeType, bool inherit)
{
if (element == null)
- throw new ArgumentNullException("element");
+ throw new ArgumentNullException(nameof(element));
if (attributeType == null)
- throw new ArgumentNullException("attributeType");
+ throw new ArgumentNullException(nameof(attributeType));
if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute))
throw new ArgumentException(Environment.GetResourceString("Argument_MustHaveAttributeBaseClass"));
if (element.Member == null)
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidParameterInfo"), "element");
+ throw new ArgumentException(Environment.GetResourceString("Argument_InvalidParameterInfo"), nameof(element));
Contract.EndContractBlock();
@@ -591,10 +591,10 @@ namespace System {
public static Attribute[] GetCustomAttributes(ParameterInfo element, bool inherit)
{
if (element == null)
- throw new ArgumentNullException("element");
+ throw new ArgumentNullException(nameof(element));
if (element.Member == null)
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidParameterInfo"), "element");
+ throw new ArgumentException(Environment.GetResourceString("Argument_InvalidParameterInfo"), nameof(element));
Contract.EndContractBlock();
@@ -614,10 +614,10 @@ namespace System {
{
// Returns true is a custom attribute subclass of attributeType class/interface with inheritance walk
if (element == null)
- throw new ArgumentNullException("element");
+ throw new ArgumentNullException(nameof(element));
if (attributeType == null)
- throw new ArgumentNullException("attributeType");
+ throw new ArgumentNullException(nameof(attributeType));
if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute))
throw new ArgumentException(Environment.GetResourceString("Argument_MustHaveAttributeBaseClass"));
@@ -637,7 +637,7 @@ namespace System {
return element.IsDefined(attributeType, false);
default:
- Contract.Assert(false, "Invalid type for ParameterInfo member in Attribute class");
+ Debug.Assert(false, "Invalid type for ParameterInfo member in Attribute class");
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidParamInfo"));
}
}
@@ -681,7 +681,7 @@ namespace System {
public static Attribute[] GetCustomAttributes(Module element, bool inherit)
{
if (element == null)
- throw new ArgumentNullException("element");
+ throw new ArgumentNullException(nameof(element));
Contract.EndContractBlock();
return (Attribute[])element.GetCustomAttributes(typeof(Attribute), inherit);
@@ -690,10 +690,10 @@ namespace System {
public static Attribute[] GetCustomAttributes(Module element, Type attributeType, bool inherit)
{
if (element == null)
- throw new ArgumentNullException("element");
+ throw new ArgumentNullException(nameof(element));
if (attributeType == null)
- throw new ArgumentNullException("attributeType");
+ throw new ArgumentNullException(nameof(attributeType));
if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute))
throw new ArgumentException(Environment.GetResourceString("Argument_MustHaveAttributeBaseClass"));
@@ -711,10 +711,10 @@ namespace System {
{
// Returns true is a custom attribute subclass of attributeType class/interface with no inheritance walk
if (element == null)
- throw new ArgumentNullException("element");
+ throw new ArgumentNullException(nameof(element));
if (attributeType == null)
- throw new ArgumentNullException("attributeType");
+ throw new ArgumentNullException(nameof(attributeType));
if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute))
throw new ArgumentException(Environment.GetResourceString("Argument_MustHaveAttributeBaseClass"));
@@ -754,10 +754,10 @@ namespace System {
public static Attribute[] GetCustomAttributes(Assembly element, Type attributeType, bool inherit)
{
if (element == null)
- throw new ArgumentNullException("element");
+ throw new ArgumentNullException(nameof(element));
if (attributeType == null)
- throw new ArgumentNullException("attributeType");
+ throw new ArgumentNullException(nameof(attributeType));
if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute))
throw new ArgumentException(Environment.GetResourceString("Argument_MustHaveAttributeBaseClass"));
@@ -774,7 +774,7 @@ namespace System {
public static Attribute[] GetCustomAttributes(Assembly element, bool inherit)
{
if (element == null)
- throw new ArgumentNullException("element");
+ throw new ArgumentNullException(nameof(element));
Contract.EndContractBlock();
return (Attribute[])element.GetCustomAttributes(typeof(Attribute), inherit);
@@ -789,10 +789,10 @@ namespace System {
{
// Returns true is a custom attribute subclass of attributeType class/interface with no inheritance walk
if (element == null)
- throw new ArgumentNullException("element");
+ throw new ArgumentNullException(nameof(element));
if (attributeType == null)
- throw new ArgumentNullException("attributeType");
+ throw new ArgumentNullException(nameof(attributeType));
if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute))
throw new ArgumentException(Environment.GetResourceString("Argument_MustHaveAttributeBaseClass"));
@@ -830,14 +830,13 @@ namespace System {
#endregion
#region Object Overrides
- [SecuritySafeCritical]
public override bool Equals(Object obj)
{
if (obj == null)
return false;
- RuntimeType thisType = (RuntimeType)this.GetType();
- RuntimeType thatType = (RuntimeType)obj.GetType();
+ Type thisType = this.GetType();
+ Type thatType = obj.GetType();
if (thatType != thisType)
return false;
@@ -845,18 +844,22 @@ namespace System {
Object thisObj = this;
Object thisResult, thatResult;
- FieldInfo[] thisFields = thisType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
-
- for (int i = 0; i < thisFields.Length; i++)
+ while (thisType != typeof(Attribute))
{
- // Visibility check and consistency check are not necessary.
- thisResult = ((RtFieldInfo)thisFields[i]).UnsafeGetValue(thisObj);
- thatResult = ((RtFieldInfo)thisFields[i]).UnsafeGetValue(obj);
+ FieldInfo[] thisFields = thisType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly);
- if (!AreFieldValuesEqual(thisResult, thatResult))
+ for (int i = 0; i < thisFields.Length; i++)
{
- return false;
+ // Visibility check and consistency check are not necessary.
+ thisResult = ((RtFieldInfo)thisFields[i]).UnsafeGetValue(thisObj);
+ thatResult = ((RtFieldInfo)thisFields[i]).UnsafeGetValue(obj);
+
+ if (!AreFieldValuesEqual(thisResult, thatResult))
+ {
+ return false;
+ }
}
+ thisType = thisType.BaseType;
}
return true;
@@ -887,7 +890,7 @@ namespace System {
// Attributes can only contain single-dimension arrays, so we don't need to worry about
// multidimensional arrays.
- Contract.Assert(thisValueArray.Rank == 1 && thatValueArray.Rank == 1);
+ Debug.Assert(thisValueArray.Rank == 1 && thatValueArray.Rank == 1);
for (int j = 0; j < thisValueArray.Length; j++)
{
if (!AreFieldValuesEqual(thisValueArray.GetValue(j), thatValueArray.GetValue(j)))
@@ -901,7 +904,7 @@ namespace System {
// An object of type Attribute will cause a stack overflow.
// However, this should never happen because custom attributes cannot contain values other than
// constants, single-dimensional arrays and typeof expressions.
- Contract.Assert(!(thisValue is Attribute));
+ Debug.Assert(!(thisValue is Attribute));
if (!thisValue.Equals(thatValue))
return false;
}
@@ -909,32 +912,36 @@ namespace System {
return true;
}
- [SecuritySafeCritical]
public override int GetHashCode()
{
Type type = GetType();
- FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
- Object vThis = null;
-
- for (int i = 0; i < fields.Length; i++)
+ while (type != typeof(Attribute))
{
- // Visibility check and consistency check are not necessary.
- Object fieldValue = ((RtFieldInfo)fields[i]).UnsafeGetValue(this);
+ FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly);
+ Object vThis = null;
- // The hashcode of an array ignores the contents of the array, so it can produce
- // different hashcodes for arrays with the same contents.
- // Since we do deep comparisons of arrays in Equals(), this means Equals and GetHashCode will
- // be inconsistent for arrays. Therefore, we ignore hashes of arrays.
- if (fieldValue != null && !fieldValue.GetType().IsArray)
- vThis = fieldValue;
+ for (int i = 0; i < fields.Length; i++)
+ {
+ // Visibility check and consistency check are not necessary.
+ Object fieldValue = ((RtFieldInfo)fields[i]).UnsafeGetValue(this);
+
+ // The hashcode of an array ignores the contents of the array, so it can produce
+ // different hashcodes for arrays with the same contents.
+ // Since we do deep comparisons of arrays in Equals(), this means Equals and GetHashCode will
+ // be inconsistent for arrays. Therefore, we ignore hashes of arrays.
+ if (fieldValue != null && !fieldValue.GetType().IsArray)
+ vThis = fieldValue;
+
+ if (vThis != null)
+ break;
+ }
if (vThis != null)
- break;
- }
+ return vThis.GetHashCode();
- if (vThis != null)
- return vThis.GetHashCode();
+ type = type.BaseType;
+ }
return type.GetHashCode();
}
@@ -949,27 +956,5 @@ namespace System {
#region Public Members
public virtual bool IsDefaultAttribute() { return false; }
#endregion
-
-#if !FEATURE_CORECLR
- void _Attribute.GetTypeInfoCount(out uint pcTInfo)
- {
- throw new NotImplementedException();
- }
-
- void _Attribute.GetTypeInfo(uint iTInfo, uint lcid, IntPtr ppTInfo)
- {
- throw new NotImplementedException();
- }
-
- void _Attribute.GetIDsOfNames([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
- {
- throw new NotImplementedException();
- }
-
- void _Attribute.Invoke(uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
- {
- throw new NotImplementedException();
- }
-#endif
}
}
diff --git a/src/mscorlib/src/System/BCLDebug.cs b/src/mscorlib/src/System/BCLDebug.cs
index 9b2ade2..0ca6e61 100644
--- a/src/mscorlib/src/System/BCLDebug.cs
+++ b/src/mscorlib/src/System/BCLDebug.cs
@@ -119,7 +119,6 @@ namespace System {
[Pure]
[Conditional("_LOGGING")]
- [SecuritySafeCritical]
static public void Log(String message) {
if (AppDomain.CurrentDomain.IsUnloadingForcedFinalize())
return;
@@ -132,7 +131,6 @@ namespace System {
[Pure]
[Conditional("_LOGGING")]
- [SecuritySafeCritical]
static public void Log(String switchName, String message) {
if (AppDomain.CurrentDomain.IsUnloadingForcedFinalize())
return;
@@ -160,7 +158,6 @@ namespace System {
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern static int GetRegistryLoggingValues(out bool loggingEnabled, out bool logToConsole, out int logLevel, out bool perfWarnings, out bool correctnessWarnings, out bool safeHandleStackTraces);
- [SecuritySafeCritical]
private static void CheckRegistry() {
if (AppDomain.CurrentDomain.IsUnloadingForcedFinalize())
return;
@@ -207,7 +204,6 @@ namespace System {
}
}
- [SecuritySafeCritical]
internal static bool CheckEnabled(String switchName) {
if (AppDomain.CurrentDomain.IsUnloadingForcedFinalize())
return false;
@@ -220,7 +216,6 @@ namespace System {
return ((int)logSwitch.MinimumLevel<=(int)LogLevel.Trace);
}
- [SecuritySafeCritical]
private static bool CheckEnabled(String switchName, LogLevel level, out LogSwitch logSwitch) {
if (AppDomain.CurrentDomain.IsUnloadingForcedFinalize())
{
@@ -236,7 +231,6 @@ namespace System {
[Pure]
[Conditional("_LOGGING")]
- [SecuritySafeCritical]
public static void Log(String switchName, LogLevel level, params Object[]messages) {
if (AppDomain.CurrentDomain.IsUnloadingForcedFinalize())
return;
@@ -338,33 +332,9 @@ namespace System {
System.Diagnostics.Log.LogMessage(LoggingLevels.TraceLevel0, logSwitch, trace.ToString());
}
- // For logging errors related to the console - we often can't expect to
- // write to stdout if it doesn't exist.
- [SecuritySafeCritical]
- [Conditional("_DEBUG")]
- internal static void ConsoleError(String msg)
- {
- if (AppDomain.CurrentDomain.IsUnloadingForcedFinalize())
- return;
-
- if (m_MakeConsoleErrorLoggingWork == null) {
- PermissionSet perms = new PermissionSet();
- perms.AddPermission(new EnvironmentPermission(PermissionState.Unrestricted));
- perms.AddPermission(new FileIOPermission(FileIOPermissionAccess.AllAccess, Path.GetFullPath(".")));
- m_MakeConsoleErrorLoggingWork = perms;
- }
- m_MakeConsoleErrorLoggingWork.Assert();
-
- using (TextWriter err = File.AppendText("ConsoleErrors.log"))
- {
- err.WriteLine(msg);
- }
- }
-
// For perf-related asserts. On a debug build, set the registry key
// BCLPerfWarnings to non-zero.
[Conditional("_DEBUG")]
- [SecuritySafeCritical]
internal static void Perf(bool expr, String msg)
{
if (AppDomain.CurrentDomain.IsUnloadingForcedFinalize())
@@ -384,7 +354,6 @@ namespace System {
// BCLCorrectnessWarnings to non-zero.
[Conditional("_DEBUG")]
#if _DEBUG
- [SecuritySafeCritical]
#endif
internal static void Correctness(bool expr, String msg)
{
@@ -409,7 +378,6 @@ namespace System {
}
#if !BIT64 // 32
- [SecuritySafeCritical]
#endif
internal static bool CorrectnessEnabled()
{
diff --git a/src/mscorlib/src/System/BadImageFormatException.cs b/src/mscorlib/src/System/BadImageFormatException.cs
index b71fcc3..3f3f4a5 100644
--- a/src/mscorlib/src/System/BadImageFormatException.cs
+++ b/src/mscorlib/src/System/BadImageFormatException.cs
@@ -132,14 +132,11 @@ namespace System {
}
public String FusionLog {
- [System.Security.SecuritySafeCritical] // auto-generated
#pragma warning disable CS0618 // Type or member is obsolete
- [SecurityPermissionAttribute( SecurityAction.Demand, Flags = SecurityPermissionFlag.ControlEvidence | SecurityPermissionFlag.ControlPolicy)]
#pragma warning restore CS0618 // Type or member is obsolete
get { return _fusionLog; }
}
- [System.Security.SecurityCritical] // auto-generated_required
public override void GetObjectData(SerializationInfo info, StreamingContext context) {
// Serialize data for our base classes. base will verify info != null.
base.GetObjectData(info, context);
diff --git a/src/mscorlib/src/System/BitConverter.cs b/src/mscorlib/src/System/BitConverter.cs
index e4bb9dd..3a6d1c0 100644
--- a/src/mscorlib/src/System/BitConverter.cs
+++ b/src/mscorlib/src/System/BitConverter.cs
@@ -15,6 +15,7 @@ namespace System {
using System;
using System.Runtime.CompilerServices;
+ using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Security;
@@ -56,7 +57,6 @@ namespace System {
// Converts a short into an array of bytes with length
// two.
- [System.Security.SecuritySafeCritical] // auto-generated
public unsafe static byte[] GetBytes(short value)
{
Contract.Ensures(Contract.Result<byte[]>() != null);
@@ -70,7 +70,6 @@ namespace System {
// Converts an int into an array of bytes with length
// four.
- [System.Security.SecuritySafeCritical] // auto-generated
public unsafe static byte[] GetBytes(int value)
{
Contract.Ensures(Contract.Result<byte[]>() != null);
@@ -84,7 +83,6 @@ namespace System {
// Converts a long into an array of bytes with length
// eight.
- [System.Security.SecuritySafeCritical] // auto-generated
public unsafe static byte[] GetBytes(long value)
{
Contract.Ensures(Contract.Result<byte[]>() != null);
@@ -128,7 +126,6 @@ namespace System {
// Converts a float into an array of bytes with length
// four.
- [System.Security.SecuritySafeCritical] // auto-generated
public unsafe static byte[] GetBytes(float value)
{
Contract.Ensures(Contract.Result<byte[]>() != null);
@@ -139,7 +136,6 @@ namespace System {
// Converts a double into an array of bytes with length
// eight.
- [System.Security.SecuritySafeCritical] // auto-generated
public unsafe static byte[] GetBytes(double value)
{
Contract.Ensures(Contract.Result<byte[]>() != null);
@@ -156,7 +152,7 @@ namespace System {
}
if ((uint)startIndex >= value.Length) {
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.startIndex, ExceptionResource.ArgumentOutOfRange_Index);
+ ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index();
}
if (startIndex > value.Length - 2) {
@@ -168,14 +164,13 @@ namespace System {
}
// Converts an array of bytes into a short.
- [System.Security.SecuritySafeCritical] // auto-generated
public static unsafe short ToInt16(byte[] value, int startIndex) {
if( value == null) {
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.value);
}
if ((uint) startIndex >= value.Length) {
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.startIndex, ExceptionResource.ArgumentOutOfRange_Index);
+ ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index();
}
if (startIndex > value.Length -2) {
@@ -200,14 +195,13 @@ namespace System {
}
// Converts an array of bytes into an int.
- [System.Security.SecuritySafeCritical] // auto-generated
public static unsafe int ToInt32 (byte[] value, int startIndex) {
if( value == null) {
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.value);
}
if ((uint) startIndex >= value.Length) {
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.startIndex, ExceptionResource.ArgumentOutOfRange_Index);
+ ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index();
}
if (startIndex > value.Length -4) {
@@ -231,14 +225,13 @@ namespace System {
}
// Converts an array of bytes into a long.
- [System.Security.SecuritySafeCritical] // auto-generated
public static unsafe long ToInt64 (byte[] value, int startIndex) {
if (value == null) {
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.value);
}
if ((uint) startIndex >= value.Length) {
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.startIndex, ExceptionResource.ArgumentOutOfRange_Index);
+ ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index();
}
if (startIndex > value.Length -8) {
@@ -274,7 +267,7 @@ namespace System {
if (value == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.value);
if ((uint)startIndex >= value.Length)
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.startIndex, ExceptionResource.ArgumentOutOfRange_Index);
+ ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index();
if (startIndex > value.Length - 2)
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_ArrayPlusOffTooSmall);
Contract.EndContractBlock();
@@ -290,7 +283,7 @@ namespace System {
if (value == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.value);
if ((uint)startIndex >= value.Length)
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.startIndex, ExceptionResource.ArgumentOutOfRange_Index);
+ ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index();
if (startIndex > value.Length - 4)
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_ArrayPlusOffTooSmall);
Contract.EndContractBlock();
@@ -306,7 +299,7 @@ namespace System {
if (value == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.value);
if ((uint)startIndex >= value.Length)
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.startIndex, ExceptionResource.ArgumentOutOfRange_Index);
+ ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index();
if (startIndex > value.Length - 8)
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_ArrayPlusOffTooSmall);
Contract.EndContractBlock();
@@ -315,13 +308,12 @@ namespace System {
}
// Converts an array of bytes into a float.
- [System.Security.SecuritySafeCritical] // auto-generated
unsafe public static float ToSingle (byte[] value, int startIndex)
{
if (value == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.value);
if ((uint)startIndex >= value.Length)
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.startIndex, ExceptionResource.ArgumentOutOfRange_Index);
+ ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index();
if (startIndex > value.Length - 4)
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_ArrayPlusOffTooSmall);
Contract.EndContractBlock();
@@ -331,13 +323,12 @@ namespace System {
}
// Converts an array of bytes into a double.
- [System.Security.SecuritySafeCritical] // auto-generated
unsafe public static double ToDouble (byte[] value, int startIndex)
{
if (value == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.value);
if ((uint)startIndex >= value.Length)
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.startIndex, ExceptionResource.ArgumentOutOfRange_Index);
+ ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index();
if (startIndex > value.Length - 8)
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_ArrayPlusOffTooSmall);
Contract.EndContractBlock();
@@ -347,7 +338,7 @@ namespace System {
}
private static char GetHexValue(int i) {
- Contract.Assert( i >=0 && i <16, "i is out of range.");
+ Debug.Assert( i >=0 && i <16, "i is out of range.");
if (i<10) {
return (char)(i + '0');
}
@@ -358,15 +349,15 @@ namespace System {
// Converts an array of bytes into a String.
public static String ToString (byte[] value, int startIndex, int length) {
if (value == null) {
- throw new ArgumentNullException("value");
+ throw new ArgumentNullException(nameof(value));
}
if (startIndex < 0 || startIndex >= value.Length && startIndex > 0) { // Don't throw for a 0 length array.
- throw new ArgumentOutOfRangeException("startIndex", Environment.GetResourceString("ArgumentOutOfRange_StartIndex"));
+ throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_StartIndex"));
}
if (length < 0) {
- throw new ArgumentOutOfRangeException("length", Environment.GetResourceString("ArgumentOutOfRange_GenericPositive"));
+ throw new ArgumentOutOfRangeException(nameof(length), Environment.GetResourceString("ArgumentOutOfRange_GenericPositive"));
}
if (startIndex > value.Length - length) {
@@ -380,7 +371,7 @@ namespace System {
if (length > (Int32.MaxValue / 3)) {
// (Int32.MaxValue / 3) == 715,827,882 Bytes == 699 MB
- throw new ArgumentOutOfRangeException("length", Environment.GetResourceString("ArgumentOutOfRange_LengthTooLarge", (Int32.MaxValue / 3)));
+ throw new ArgumentOutOfRangeException(nameof(length), Environment.GetResourceString("ArgumentOutOfRange_LengthTooLarge", (Int32.MaxValue / 3)));
}
int chArrayLength = length * 3;
@@ -402,7 +393,7 @@ namespace System {
// Converts an array of bytes into a String.
public static String ToString(byte [] value) {
if (value == null)
- throw new ArgumentNullException("value");
+ throw new ArgumentNullException(nameof(value));
Contract.Ensures(Contract.Result<String>() != null);
Contract.EndContractBlock();
return ToString(value, 0, value.Length);
@@ -411,7 +402,7 @@ namespace System {
// Converts an array of bytes into a String.
public static String ToString (byte [] value, int startIndex) {
if (value == null)
- throw new ArgumentNullException("value");
+ throw new ArgumentNullException(nameof(value));
Contract.Ensures(Contract.Result<String>() != null);
Contract.EndContractBlock();
return ToString(value, startIndex, value.Length - startIndex);
@@ -428,24 +419,30 @@ namespace System {
// Converts an array of bytes into a boolean.
public static bool ToBoolean(byte[] value, int startIndex) {
if (value==null)
- throw new ArgumentNullException("value");
+ throw new ArgumentNullException(nameof(value));
if (startIndex < 0)
- throw new ArgumentOutOfRangeException("startIndex", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
if (startIndex > value.Length - 1)
- throw new ArgumentOutOfRangeException("startIndex", Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_Index"));
Contract.EndContractBlock();
return (value[startIndex]==0)?false:true;
}
- [SecuritySafeCritical]
public static unsafe long DoubleToInt64Bits(double value) {
return *((long *)&value);
}
- [SecuritySafeCritical]
public static unsafe double Int64BitsToDouble(long value) {
return *((double*)&value);
- }
+ }
+
+ public static unsafe int SingleToInt32Bits(float value) {
+ return *((int*)&value);
+ }
+
+ public static unsafe float Int32BitsToSingle(int value) {
+ return *((float*)&value);
+ }
}
}
diff --git a/src/mscorlib/src/System/Boolean.cs b/src/mscorlib/src/System/Boolean.cs
index c5cd45a..9aaec9a 100644
--- a/src/mscorlib/src/System/Boolean.cs
+++ b/src/mscorlib/src/System/Boolean.cs
@@ -151,7 +151,7 @@ namespace System {
// Determines whether a String represents true or false.
//
public static Boolean Parse (String value) {
- if (value==null) throw new ArgumentNullException("value");
+ if (value==null) throw new ArgumentNullException(nameof(value));
Contract.EndContractBlock();
Boolean result = false;
if (!TryParse(value, out result)) {
diff --git a/src/mscorlib/src/System/Buffer.cs b/src/mscorlib/src/System/Buffer.cs
index ea647f1..eee2a81 100644
--- a/src/mscorlib/src/System/Buffer.cs
+++ b/src/mscorlib/src/System/Buffer.cs
@@ -11,6 +11,7 @@ namespace System {
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
+ using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Security;
using System.Runtime;
@@ -28,7 +29,6 @@ namespace System {
// respecting types. This calls memmove internally. The count and
// offset parameters here are in bytes. If you want to use traditional
// array element indices and counts, use Array.Copy.
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern void BlockCopy(Array src, int srcOffset,
Array dst, int dstOffset, int count);
@@ -37,7 +37,6 @@ namespace System {
// parameter validation has already been done. The count and offset
// parameters here are in bytes. If you want to use traditional
// array element indices and counts, use Array.Copy.
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern void InternalBlockCopy(Array src, int srcOffsetBytes,
Array dst, int dstOffsetBytes, int byteCount);
@@ -47,10 +46,9 @@ namespace System {
// It is however cross platform as the CRT hasn't ported their fast version to 64-bit
// platforms.
//
- [System.Security.SecurityCritical] // auto-generated
internal unsafe static int IndexOfByte(byte* src, byte value, int index, int count)
{
- Contract.Assert(src != null, "src should not be null");
+ Debug.Assert(src != null, "src should not be null");
byte* pByte = src + index;
@@ -122,7 +120,6 @@ namespace System {
// Returns a bool to indicate if the array is of primitive data types
// or not.
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern bool IsPrimitiveTypeArray(Array array);
@@ -132,24 +129,22 @@ namespace System {
// This essentially does the following:
// return ((byte*)array) + index.
//
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern byte _GetByte(Array array, int index);
- [System.Security.SecuritySafeCritical] // auto-generated
public static byte GetByte(Array array, int index)
{
// Is the array present?
if (array == null)
- throw new ArgumentNullException("array");
+ throw new ArgumentNullException(nameof(array));
// Is it of primitive types?
if (!IsPrimitiveTypeArray(array))
- throw new ArgumentException(Environment.GetResourceString("Arg_MustBePrimArray"), "array");
+ throw new ArgumentException(Environment.GetResourceString("Arg_MustBePrimArray"), nameof(array));
// Is the index in valid range of the array?
if (index < 0 || index >= _ByteLength(array))
- throw new ArgumentOutOfRangeException("index");
+ throw new ArgumentOutOfRangeException(nameof(index));
return _GetByte(array, index);
}
@@ -160,24 +155,22 @@ namespace System {
// This essentially does the following:
// *(((byte*)array) + index) = value.
//
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern void _SetByte(Array array, int index, byte value);
- [System.Security.SecuritySafeCritical] // auto-generated
public static void SetByte(Array array, int index, byte value)
{
// Is the array present?
if (array == null)
- throw new ArgumentNullException("array");
+ throw new ArgumentNullException(nameof(array));
// Is it of primitive types?
if (!IsPrimitiveTypeArray(array))
- throw new ArgumentException(Environment.GetResourceString("Arg_MustBePrimArray"), "array");
+ throw new ArgumentException(Environment.GetResourceString("Arg_MustBePrimArray"), nameof(array));
// Is the index in valid range of the array?
if (index < 0 || index >= _ByteLength(array))
- throw new ArgumentOutOfRangeException("index");
+ throw new ArgumentOutOfRangeException(nameof(index));
// Make the FCall to do the work
_SetByte(array, index, value);
@@ -190,36 +183,32 @@ namespace System {
// This essentially does the following:
// return array.length * sizeof(array.UnderlyingElementType).
//
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern int _ByteLength(Array array);
- [System.Security.SecuritySafeCritical] // auto-generated
public static int ByteLength(Array array)
{
// Is the array present?
if (array == null)
- throw new ArgumentNullException("array");
+ throw new ArgumentNullException(nameof(array));
// Is it of primitive types?
if (!IsPrimitiveTypeArray(array))
- throw new ArgumentException(Environment.GetResourceString("Arg_MustBePrimArray"), "array");
+ throw new ArgumentException(Environment.GetResourceString("Arg_MustBePrimArray"), nameof(array));
return _ByteLength(array);
}
- [System.Security.SecurityCritical] // auto-generated
internal unsafe static void ZeroMemory(byte* src, long len)
{
while(len-- > 0)
*(src + len) = 0;
}
- [System.Security.SecurityCritical] // auto-generated
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal unsafe static void Memcpy(byte[] dest, int destIndex, byte* src, int srcIndex, int len) {
- Contract.Assert( (srcIndex >= 0) && (destIndex >= 0) && (len >= 0), "Index and length must be non-negative!");
- Contract.Assert(dest.Length - destIndex >= len, "not enough bytes in dest");
+ Debug.Assert( (srcIndex >= 0) && (destIndex >= 0) && (len >= 0), "Index and length must be non-negative!");
+ Debug.Assert(dest.Length - destIndex >= len, "not enough bytes in dest");
// If dest has 0 elements, the fixed statement will throw an
// IndexOutOfRangeException. Special-case 0-byte copies.
if (len==0)
@@ -229,12 +218,11 @@ namespace System {
}
}
- [SecurityCritical]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal unsafe static void Memcpy(byte* pDest, int destIndex, byte[] src, int srcIndex, int len)
{
- Contract.Assert( (srcIndex >= 0) && (destIndex >= 0) && (len >= 0), "Index and length must be non-negative!");
- Contract.Assert(src.Length - srcIndex >= len, "not enough bytes in src");
+ Debug.Assert( (srcIndex >= 0) && (destIndex >= 0) && (len >= 0), "Index and length must be non-negative!");
+ Debug.Assert(src.Length - srcIndex >= len, "not enough bytes in src");
// If dest has 0 elements, the fixed statement will throw an
// IndexOutOfRangeException. Special-case 0-byte copies.
if (len==0)
@@ -254,7 +242,6 @@ namespace System {
// 1. This method is given access to other internal dlls and this close to release we do not want to change it.
// 2. It is difficult to get this right for arm and again due to release dates we would like to visit it later.
[FriendAccessAllowed]
- [System.Security.SecurityCritical]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
#if ARM
[MethodImplAttribute(MethodImplOptions.InternalCall)]
@@ -262,13 +249,12 @@ namespace System {
#else // ARM
[MethodImplAttribute(MethodImplOptions.AggressiveInlining)]
internal unsafe static void Memcpy(byte* dest, byte* src, int len) {
- Contract.Assert(len >= 0, "Negative length in memcopy!");
+ Debug.Assert(len >= 0, "Negative length in memcopy!");
Memmove(dest, src, (uint)len);
}
#endif // ARM
// This method has different signature for x64 and other platforms and is done for performance reasons.
- [System.Security.SecurityCritical]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal unsafe static void Memmove(byte* dest, byte* src, nuint len)
{
@@ -524,7 +510,7 @@ namespace System {
// We know due to the above switch-case that this loop will always run 1 iteration; max
// bytes we copy before checking is 23 (7 to align the pointers, 16 for 1 iteration) so
// the switch handles lengths 0-22.
- Contract.Assert(end >= 7 && i <= end);
+ Debug.Assert(end >= 7 && i <= end);
// This is separated out into a different variable, so the i + 16 addition can be
// performed at the start of the pipeline and the loop condition does not have
@@ -595,7 +581,6 @@ namespace System {
// Non-inlinable wrapper around the QCall that avoids poluting the fast path
// with P/Invoke prolog/epilog.
- [SecurityCritical]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[MethodImplAttribute(MethodImplOptions.NoInlining)]
private unsafe static void _Memmove(byte* dest, byte* src, nuint len)
@@ -605,13 +590,11 @@ namespace System {
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
- [SecurityCritical]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
extern private unsafe static void __Memmove(byte* dest, byte* src, nuint len);
// The attributes on this method are chosen for best JIT performance.
// Please do not edit unless intentional.
- [System.Security.SecurityCritical]
[MethodImplAttribute(MethodImplOptions.AggressiveInlining)]
[CLSCompliant(false)]
public static unsafe void MemoryCopy(void* source, void* destination, long destinationSizeInBytes, long sourceBytesToCopy)
@@ -626,7 +609,6 @@ namespace System {
// The attributes on this method are chosen for best JIT performance.
// Please do not edit unless intentional.
- [System.Security.SecurityCritical]
[MethodImplAttribute(MethodImplOptions.AggressiveInlining)]
[CLSCompliant(false)]
public static unsafe void MemoryCopy(void* source, void* destination, ulong destinationSizeInBytes, ulong sourceBytesToCopy)
diff --git a/src/mscorlib/src/System/ByReference.cs b/src/mscorlib/src/System/ByReference.cs
new file mode 100644
index 0000000..6f8bb22
--- /dev/null
+++ b/src/mscorlib/src/System/ByReference.cs
@@ -0,0 +1,31 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Runtime.CompilerServices;
+
+namespace System
+{
+ // ByReference<T> is meant to be used to represent "ref T" fields. It is working
+ // around lack of first class support for byref fields in C# and IL. The JIT and
+ // type loader has special handling for it that turns it into a thin wrapper around ref T.
+ internal struct ByReference<T>
+ {
+ private IntPtr _value;
+
+ public ByReference(ref T value)
+ {
+ // TODO-SPAN: This has GC hole. It needs to be JIT intrinsic instead
+ unsafe { _value = (IntPtr)Unsafe.AsPointer(ref value); }
+ }
+
+ public ref T Value
+ {
+ get
+ {
+ // TODO-SPAN: This has GC hole. It needs to be JIT intrinsic instead
+ unsafe { return ref Unsafe.As<IntPtr, T>(ref *(IntPtr*)_value); }
+ }
+ }
+ }
+}
diff --git a/src/mscorlib/src/System/Byte.cs b/src/mscorlib/src/System/Byte.cs
index 2c24bf6..980412b 100644
--- a/src/mscorlib/src/System/Byte.cs
+++ b/src/mscorlib/src/System/Byte.cs
@@ -139,28 +139,24 @@ namespace System {
}
[Pure]
- [System.Security.SecuritySafeCritical] // auto-generated
public override String ToString() {
Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatInt32(m_value, null, NumberFormatInfo.CurrentInfo);
}
[Pure]
- [System.Security.SecuritySafeCritical] // auto-generated
public String ToString(String format) {
Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatInt32(m_value, format, NumberFormatInfo.CurrentInfo);
}
[Pure]
- [System.Security.SecuritySafeCritical] // auto-generated
public String ToString(IFormatProvider provider) {
Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatInt32(m_value, null, NumberFormatInfo.GetInstance(provider));
}
[Pure]
- [System.Security.SecuritySafeCritical] // auto-generated
public String ToString(String format, IFormatProvider provider) {
Contract.Ensures(Contract.Result<String>() != null);
return Number.FormatInt32(m_value, format, NumberFormatInfo.GetInstance(provider));
diff --git a/src/mscorlib/src/System/CLRConfig.cs b/src/mscorlib/src/System/CLRConfig.cs
index 0831c4b..01ad7c3 100644
--- a/src/mscorlib/src/System/CLRConfig.cs
+++ b/src/mscorlib/src/System/CLRConfig.cs
@@ -19,12 +19,10 @@ namespace System {
internal class CLRConfig {
[FriendAccessAllowed]
- [System.Security.SecurityCritical]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
[SuppressUnmanagedCodeSecurity]
internal static extern bool CheckLegacyManagedDeflateStream();
- [System.Security.SecurityCritical]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
[SuppressUnmanagedCodeSecurity]
internal static extern bool CheckThrowUnobservedTaskExceptions();
diff --git a/src/mscorlib/src/System/CfgParser.cs b/src/mscorlib/src/System/CfgParser.cs
index ef368a9..b21da7f 100644
--- a/src/mscorlib/src/System/CfgParser.cs
+++ b/src/mscorlib/src/System/CfgParser.cs
@@ -213,7 +213,6 @@ namespace System
int textLength,
int prefixLength);
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern void RunParser(String fileName);
}
@@ -245,11 +244,10 @@ namespace System
return Parse(fileName, configPath, false);
}
- [System.Security.SecuritySafeCritical] // auto-generated
internal ConfigNode Parse(String fileName, String configPath, bool skipSecurityStuff)
{
if (fileName == null)
- throw new ArgumentNullException("fileName");
+ throw new ArgumentNullException(nameof(fileName));
Contract.EndContractBlock();
this.fileName = fileName;
if (configPath[0] == '/'){
@@ -264,7 +262,7 @@ namespace System
}
if (!skipSecurityStuff) {
- (new FileIOPermission( FileIOPermissionAccess.Read, System.IO.Path.GetFullPathInternal( fileName ) )).Demand();
+ (new FileIOPermission(FileIOPermissionAccess.Read, Path.GetFullPath(fileName))).Demand();
}
#pragma warning disable 618
(new SecurityPermission(SecurityPermissionFlag.UnmanagedCode)).Assert();
@@ -291,11 +289,7 @@ namespace System
// Neither Exception nor ApplicationException are the "right" exceptions here.
// Desktop throws ApplicationException for backwards compatibility.
// On Silverlight we don't have ApplicationException, so fall back to Exception.
-#if FEATURE_CORECLR
throw new Exception(message, inner);
-#else
- throw new ApplicationException(message, inner);
-#endif
}
return rootNode;
}
@@ -440,11 +434,7 @@ namespace System
// Neither Exception nor ApplicationException are the "right" exceptions here.
// Desktop throws ApplicationException for backwards compatibility.
// On Silverlight we don't have ApplicationException, so fall back to Exception.
-#if FEATURE_CORECLR
throw new Exception(message);
-#else
- throw new ApplicationException(message);
-#endif
}
}
}
diff --git a/src/mscorlib/src/System/Char.cs b/src/mscorlib/src/System/Char.cs
index ff936c6..b9c9305 100644
--- a/src/mscorlib/src/System/Char.cs
+++ b/src/mscorlib/src/System/Char.cs
@@ -18,6 +18,7 @@ namespace System {
using System.Runtime;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
+ using System.Diagnostics;
using System.Diagnostics.Contracts;
[System.Runtime.InteropServices.ComVisible(true)]
@@ -86,7 +87,7 @@ namespace System {
// Return the Unicode category for Unicode character <= 0x00ff.
private static UnicodeCategory GetLatin1UnicodeCategory(char ch) {
- Contract.Assert(IsLatin1(ch), "Char.GetLatin1UnicodeCategory(): ch should be <= 007f");
+ Debug.Assert(IsLatin1(ch), "Char.GetLatin1UnicodeCategory(): ch should be <= 007f");
return (UnicodeCategory)(categoryForLatin1[(int)ch]);
}
@@ -167,7 +168,7 @@ namespace System {
public static char Parse(String s) {
if (s==null) {
- throw new ArgumentNullException("s");
+ throw new ArgumentNullException(nameof(s));
}
Contract.EndContractBlock();
@@ -364,7 +365,7 @@ namespace System {
// <;<;Not fully implemented>;>;
public static char ToUpper(char c, CultureInfo culture) {
if (culture==null)
- throw new ArgumentNullException("culture");
+ throw new ArgumentNullException(nameof(culture));
Contract.EndContractBlock();
return culture.TextInfo.ToUpper(c);
}
@@ -393,7 +394,7 @@ namespace System {
// <;<;Not fully implemented>;>;
public static char ToLower(char c, CultureInfo culture) {
if (culture==null)
- throw new ArgumentNullException("culture");
+ throw new ArgumentNullException(nameof(culture));
Contract.EndContractBlock();
return culture.TextInfo.ToLower(c);
}
@@ -508,9 +509,9 @@ namespace System {
public static bool IsControl(String s, int index) {
if (s==null)
- throw new ArgumentNullException("s");
+ throw new ArgumentNullException(nameof(s));
if (((uint)index)>=((uint)s.Length)) {
- throw new ArgumentOutOfRangeException("index");
+ throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
char c = s[index];
@@ -524,9 +525,9 @@ namespace System {
public static bool IsDigit(String s, int index)
{
if (s==null)
- throw new ArgumentNullException("s");
+ throw new ArgumentNullException(nameof(s));
if (((uint)index)>=((uint)s.Length)) {
- throw new ArgumentOutOfRangeException("index");
+ throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
char c = s[index];
@@ -539,9 +540,9 @@ namespace System {
public static bool IsLetter(String s, int index)
{
if (s==null)
- throw new ArgumentNullException("s");
+ throw new ArgumentNullException(nameof(s));
if (((uint)index)>=((uint)s.Length)) {
- throw new ArgumentOutOfRangeException("index");
+ throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
char c = s[index];
@@ -558,9 +559,9 @@ namespace System {
public static bool IsLetterOrDigit(String s, int index)
{
if (s==null)
- throw new ArgumentNullException("s");
+ throw new ArgumentNullException(nameof(s));
if (((uint)index)>=((uint)s.Length)) {
- throw new ArgumentOutOfRangeException("index");
+ throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
char c = s[index];
@@ -573,9 +574,9 @@ namespace System {
public static bool IsLower(String s, int index)
{
if (s==null)
- throw new ArgumentNullException("s");
+ throw new ArgumentNullException(nameof(s));
if (((uint)index)>=((uint)s.Length)) {
- throw new ArgumentOutOfRangeException("index");
+ throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
char c = s[index];
@@ -617,9 +618,9 @@ namespace System {
public static bool IsNumber(String s, int index)
{
if (s==null)
- throw new ArgumentNullException("s");
+ throw new ArgumentNullException(nameof(s));
if (((uint)index)>=((uint)s.Length)) {
- throw new ArgumentOutOfRangeException("index");
+ throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
char c = s[index];
@@ -643,9 +644,9 @@ namespace System {
public static bool IsPunctuation (String s, int index)
{
if (s==null)
- throw new ArgumentNullException("s");
+ throw new ArgumentNullException(nameof(s));
if (((uint)index)>=((uint)s.Length)) {
- throw new ArgumentOutOfRangeException("index");
+ throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
char c = s[index];
@@ -688,9 +689,9 @@ namespace System {
public static bool IsSeparator(String s, int index)
{
if (s==null)
- throw new ArgumentNullException("s");
+ throw new ArgumentNullException(nameof(s));
if (((uint)index)>=((uint)s.Length)) {
- throw new ArgumentOutOfRangeException("index");
+ throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
char c = s[index];
@@ -710,10 +711,10 @@ namespace System {
public static bool IsSurrogate(String s, int index)
{
if (s==null) {
- throw new ArgumentNullException("s");
+ throw new ArgumentNullException(nameof(s));
}
if (((uint)index)>=((uint)s.Length)) {
- throw new ArgumentOutOfRangeException("index");
+ throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
return (IsSurrogate(s[index]));
@@ -745,9 +746,9 @@ namespace System {
public static bool IsSymbol(String s, int index)
{
if (s==null)
- throw new ArgumentNullException("s");
+ throw new ArgumentNullException(nameof(s));
if (((uint)index)>=((uint)s.Length)) {
- throw new ArgumentOutOfRangeException("index");
+ throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
if (IsLatin1(s[index])) {
@@ -760,9 +761,9 @@ namespace System {
public static bool IsUpper(String s, int index)
{
if (s==null)
- throw new ArgumentNullException("s");
+ throw new ArgumentNullException(nameof(s));
if (((uint)index)>=((uint)s.Length)) {
- throw new ArgumentOutOfRangeException("index");
+ throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
char c = s[index];
@@ -779,9 +780,9 @@ namespace System {
public static bool IsWhiteSpace(String s, int index)
{
if (s==null)
- throw new ArgumentNullException("s");
+ throw new ArgumentNullException(nameof(s));
if (((uint)index)>=((uint)s.Length)) {
- throw new ArgumentOutOfRangeException("index");
+ throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
@@ -803,9 +804,9 @@ namespace System {
public static UnicodeCategory GetUnicodeCategory(String s, int index)
{
if (s==null)
- throw new ArgumentNullException("s");
+ throw new ArgumentNullException(nameof(s));
if (((uint)index)>=((uint)s.Length)) {
- throw new ArgumentOutOfRangeException("index");
+ throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
if (IsLatin1(s[index])) {
@@ -822,9 +823,9 @@ namespace System {
public static double GetNumericValue(String s, int index)
{
if (s==null)
- throw new ArgumentNullException("s");
+ throw new ArgumentNullException(nameof(s));
if (((uint)index)>=((uint)s.Length)) {
- throw new ArgumentOutOfRangeException("index");
+ throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
return CharUnicodeInfo.GetNumericValue(s, index);
@@ -842,10 +843,10 @@ namespace System {
[Pure]
public static bool IsHighSurrogate(String s, int index) {
if (s == null) {
- throw new ArgumentNullException("s");
+ throw new ArgumentNullException(nameof(s));
}
if (index < 0 || index >= s.Length) {
- throw new ArgumentOutOfRangeException("index");
+ throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
return (IsHighSurrogate(s[index]));
@@ -862,10 +863,10 @@ namespace System {
[Pure]
public static bool IsLowSurrogate(String s, int index) {
if (s == null) {
- throw new ArgumentNullException("s");
+ throw new ArgumentNullException(nameof(s));
}
if (index < 0 || index >= s.Length) {
- throw new ArgumentOutOfRangeException("index");
+ throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
return (IsLowSurrogate(s[index]));
@@ -877,10 +878,10 @@ namespace System {
[Pure]
public static bool IsSurrogatePair(String s, int index) {
if (s == null) {
- throw new ArgumentNullException("s");
+ throw new ArgumentNullException(nameof(s));
}
if (index < 0 || index >= s.Length) {
- throw new ArgumentOutOfRangeException("index");
+ throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
if (index + 1 < s.Length) {
@@ -911,13 +912,12 @@ namespace System {
** Convert an UTF32 value into a surrogate pair.
==============================================================================*/
- [System.Security.SecuritySafeCritical]
public static String ConvertFromUtf32(int utf32)
{
// For UTF32 values from U+00D800 ~ U+00DFFF, we should throw. They
// are considered as irregular code unit sequence, but they are not illegal.
if ((utf32 < 0 || utf32 > UNICODE_PLANE16_END) || (utf32 >= HIGH_SURROGATE_START && utf32 <= LOW_SURROGATE_END)) {
- throw new ArgumentOutOfRangeException("utf32", Environment.GetResourceString("ArgumentOutOfRange_InvalidUTF32"));
+ throw new ArgumentOutOfRangeException(nameof(utf32), Environment.GetResourceString("ArgumentOutOfRange_InvalidUTF32"));
}
Contract.EndContractBlock();
@@ -945,10 +945,10 @@ namespace System {
public static int ConvertToUtf32(char highSurrogate, char lowSurrogate) {
if (!IsHighSurrogate(highSurrogate)) {
- throw new ArgumentOutOfRangeException("highSurrogate", Environment.GetResourceString("ArgumentOutOfRange_InvalidHighSurrogate"));
+ throw new ArgumentOutOfRangeException(nameof(highSurrogate), Environment.GetResourceString("ArgumentOutOfRange_InvalidHighSurrogate"));
}
if (!IsLowSurrogate(lowSurrogate)) {
- throw new ArgumentOutOfRangeException("lowSurrogate", Environment.GetResourceString("ArgumentOutOfRange_InvalidLowSurrogate"));
+ throw new ArgumentOutOfRangeException(nameof(lowSurrogate), Environment.GetResourceString("ArgumentOutOfRange_InvalidLowSurrogate"));
}
Contract.EndContractBlock();
return (((highSurrogate - CharUnicodeInfo.HIGH_SURROGATE_START) * 0x400) + (lowSurrogate - CharUnicodeInfo.LOW_SURROGATE_START) + UNICODE_PLANE01_START);
@@ -964,11 +964,11 @@ namespace System {
public static int ConvertToUtf32(String s, int index) {
if (s == null) {
- throw new ArgumentNullException("s");
+ throw new ArgumentNullException(nameof(s));
}
if (index < 0 || index >= s.Length) {
- throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index"));
}
Contract.EndContractBlock();
// Check if the character at index is a high surrogate.
@@ -983,15 +983,15 @@ namespace System {
// Found a low surrogate.
return ((temp1 * 0x400) + temp2 + UNICODE_PLANE01_START);
} else {
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidHighSurrogate", index), "s");
+ throw new ArgumentException(Environment.GetResourceString("Argument_InvalidHighSurrogate", index), nameof(s));
}
} else {
// Found a high surrogate at the end of the string.
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidHighSurrogate", index), "s");
+ throw new ArgumentException(Environment.GetResourceString("Argument_InvalidHighSurrogate", index), nameof(s));
}
} else {
// Find a low surrogate at the character pointed by index.
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidLowSurrogate", index), "s");
+ throw new ArgumentException(Environment.GetResourceString("Argument_InvalidLowSurrogate", index), nameof(s));
}
}
// Not a high-surrogate or low-surrogate. Genereate the UTF32 value for the BMP characters.
diff --git a/src/mscorlib/src/System/Collections/ArrayList.cs b/src/mscorlib/src/System/Collections/ArrayList.cs
index 94f4dc7..e7f1213 100644
--- a/src/mscorlib/src/System/Collections/ArrayList.cs
+++ b/src/mscorlib/src/System/Collections/ArrayList.cs
@@ -31,9 +31,7 @@ namespace System.Collections {
// of the ArrayList is automatically increased as required by reallocating the
// internal array.
//
-#if FEATURE_CORECLR
[FriendAccessAllowed]
-#endif
[DebuggerTypeProxy(typeof(System.Collections.ArrayList.ArrayListDebugView))]
[DebuggerDisplay("Count = {Count}")]
[Serializable]
@@ -68,7 +66,7 @@ namespace System.Collections {
// before any reallocations are required.
//
public ArrayList(int capacity) {
- if (capacity < 0) throw new ArgumentOutOfRangeException("capacity", Environment.GetResourceString("ArgumentOutOfRange_MustBeNonNegNum", "capacity"));
+ if (capacity < 0) throw new ArgumentOutOfRangeException(nameof(capacity), Environment.GetResourceString("ArgumentOutOfRange_MustBeNonNegNum", nameof(capacity)));
Contract.EndContractBlock();
if (capacity == 0)
@@ -83,7 +81,7 @@ namespace System.Collections {
//
public ArrayList(ICollection c) {
if (c==null)
- throw new ArgumentNullException("c", Environment.GetResourceString("ArgumentNull_Collection"));
+ throw new ArgumentNullException(nameof(c), Environment.GetResourceString("ArgumentNull_Collection"));
Contract.EndContractBlock();
int count = c.Count;
@@ -108,7 +106,7 @@ namespace System.Collections {
}
set {
if (value < _size) {
- throw new ArgumentOutOfRangeException("value", Environment.GetResourceString("ArgumentOutOfRange_SmallCapacity"));
+ throw new ArgumentOutOfRangeException(nameof(value), Environment.GetResourceString("ArgumentOutOfRange_SmallCapacity"));
}
Contract.Ensures(Capacity >= 0);
Contract.EndContractBlock();
@@ -166,12 +164,12 @@ namespace System.Collections {
//
public virtual Object this[int index] {
get {
- if (index < 0 || index >= _size) throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ if (index < 0 || index >= _size) throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index"));
Contract.EndContractBlock();
return _items[index];
}
set {
- if (index < 0 || index >= _size) throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ if (index < 0 || index >= _size) throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index"));
Contract.EndContractBlock();
_items[index] = value;
_version++;
@@ -188,7 +186,7 @@ namespace System.Collections {
//
public static ArrayList Adapter(IList list) {
if (list==null)
- throw new ArgumentNullException("list");
+ throw new ArgumentNullException(nameof(list));
Contract.Ensures(Contract.Result<ArrayList>() != null);
Contract.EndContractBlock();
return new IListWrapper(list);
@@ -236,9 +234,9 @@ namespace System.Collections {
//
public virtual int BinarySearch(int index, int count, Object value, IComparer comparer) {
if (index < 0)
- throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
if (count < 0)
- throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
if (_size - index < count)
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
Contract.Ensures(Contract.Result<int>() < Count);
@@ -356,7 +354,7 @@ namespace System.Collections {
//
public static IList FixedSize(IList list) {
if (list==null)
- throw new ArgumentNullException("list");
+ throw new ArgumentNullException(nameof(list));
Contract.Ensures(Contract.Result<IList>() != null);
Contract.EndContractBlock();
return new FixedSizeList(list);
@@ -367,7 +365,7 @@ namespace System.Collections {
//
public static ArrayList FixedSize(ArrayList list) {
if (list==null)
- throw new ArgumentNullException("list");
+ throw new ArgumentNullException(nameof(list));
Contract.Ensures(Contract.Result<ArrayList>() != null);
Contract.EndContractBlock();
return new FixedSizeArrayList(list);
@@ -390,9 +388,9 @@ namespace System.Collections {
//
public virtual IEnumerator GetEnumerator(int index, int count) {
if (index < 0)
- throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
if (count < 0)
- throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
if (_size - index < count)
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
Contract.Ensures(Contract.Result<IEnumerator>() != null);
@@ -425,7 +423,7 @@ namespace System.Collections {
//
public virtual int IndexOf(Object value, int startIndex) {
if (startIndex > _size)
- throw new ArgumentOutOfRangeException("startIndex", Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_Index"));
Contract.Ensures(Contract.Result<int>() < Count);
Contract.EndContractBlock();
return Array.IndexOf((Array)_items, value, startIndex, _size - startIndex);
@@ -442,8 +440,8 @@ namespace System.Collections {
//
public virtual int IndexOf(Object value, int startIndex, int count) {
if (startIndex > _size)
- throw new ArgumentOutOfRangeException("startIndex", Environment.GetResourceString("ArgumentOutOfRange_Index"));
- if (count <0 || startIndex > _size - count) throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_Count"));
+ throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ if (count <0 || startIndex > _size - count) throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_Count"));
Contract.Ensures(Contract.Result<int>() < Count);
Contract.EndContractBlock();
return Array.IndexOf((Array)_items, value, startIndex, count);
@@ -455,7 +453,7 @@ namespace System.Collections {
//
public virtual void Insert(int index, Object value) {
// Note that insertions at the end are legal.
- if (index < 0 || index > _size) throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_ArrayListInsert"));
+ if (index < 0 || index > _size) throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_ArrayListInsert"));
//Contract.Ensures(Count == Contract.OldValue(Count) + 1);
Contract.EndContractBlock();
@@ -475,8 +473,8 @@ namespace System.Collections {
//
public virtual void InsertRange(int index, ICollection c) {
if (c==null)
- throw new ArgumentNullException("c", Environment.GetResourceString("ArgumentNull_Collection"));
- if (index < 0 || index > _size) throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ throw new ArgumentNullException(nameof(c), Environment.GetResourceString("ArgumentNull_Collection"));
+ if (index < 0 || index > _size) throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index"));
//Contract.Ensures(Count == Contract.OldValue(Count) + c.Count);
Contract.EndContractBlock();
@@ -522,7 +520,7 @@ namespace System.Collections {
public virtual int LastIndexOf(Object value, int startIndex)
{
if (startIndex >= _size)
- throw new ArgumentOutOfRangeException("startIndex", Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_Index"));
Contract.Ensures(Contract.Result<int>() < Count);
Contract.EndContractBlock();
return LastIndexOf(value, startIndex, startIndex + 1);
@@ -539,7 +537,7 @@ namespace System.Collections {
//
public virtual int LastIndexOf(Object value, int startIndex, int count) {
if (Count != 0 && (startIndex < 0 || count < 0))
- throw new ArgumentOutOfRangeException((startIndex<0 ? "startIndex" : "count"), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException((startIndex<0 ? nameof(startIndex) : nameof(count)), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
Contract.Ensures(Contract.Result<int>() < Count);
Contract.EndContractBlock();
@@ -547,19 +545,17 @@ namespace System.Collections {
return -1;
if (startIndex >= _size || count > startIndex + 1)
- throw new ArgumentOutOfRangeException((startIndex>=_size ? "startIndex" : "count"), Environment.GetResourceString("ArgumentOutOfRange_BiggerThanCollection"));
+ throw new ArgumentOutOfRangeException((startIndex>=_size ? nameof(startIndex) : nameof(count)), Environment.GetResourceString("ArgumentOutOfRange_BiggerThanCollection"));
return Array.LastIndexOf((Array)_items, value, startIndex, count);
}
// Returns a read-only IList wrapper for the given IList.
//
-#if FEATURE_CORECLR
[FriendAccessAllowed]
-#endif
public static IList ReadOnly(IList list) {
if (list==null)
- throw new ArgumentNullException("list");
+ throw new ArgumentNullException(nameof(list));
Contract.Ensures(Contract.Result<IList>() != null);
Contract.EndContractBlock();
return new ReadOnlyList(list);
@@ -569,7 +565,7 @@ namespace System.Collections {
//
public static ArrayList ReadOnly(ArrayList list) {
if (list==null)
- throw new ArgumentNullException("list");
+ throw new ArgumentNullException(nameof(list));
Contract.Ensures(Contract.Result<ArrayList>() != null);
Contract.EndContractBlock();
return new ReadOnlyArrayList(list);
@@ -591,7 +587,7 @@ namespace System.Collections {
// decreased by one.
//
public virtual void RemoveAt(int index) {
- if (index < 0 || index >= _size) throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ if (index < 0 || index >= _size) throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index"));
Contract.Ensures(Count >= 0);
//Contract.Ensures(Count == Contract.OldValue(Count) - 1);
Contract.EndContractBlock();
@@ -608,9 +604,9 @@ namespace System.Collections {
//
public virtual void RemoveRange(int index, int count) {
if (index < 0)
- throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
if (count < 0)
- throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
if (_size - index < count)
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
Contract.Ensures(Count >= 0);
@@ -632,7 +628,7 @@ namespace System.Collections {
//
public static ArrayList Repeat(Object value, int count) {
if (count < 0)
- throw new ArgumentOutOfRangeException("count",Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException(nameof(count),Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
Contract.Ensures(Contract.Result<ArrayList>() != null);
Contract.EndContractBlock();
@@ -657,9 +653,9 @@ namespace System.Collections {
//
public virtual void Reverse(int index, int count) {
if (index < 0)
- throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
if (count < 0)
- throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
if (_size - index < count)
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
Contract.EndContractBlock();
@@ -671,10 +667,10 @@ namespace System.Collections {
// given collection.
//
public virtual void SetRange(int index, ICollection c) {
- if (c==null) throw new ArgumentNullException("c", Environment.GetResourceString("ArgumentNull_Collection"));
+ if (c==null) throw new ArgumentNullException(nameof(c), Environment.GetResourceString("ArgumentNull_Collection"));
Contract.EndContractBlock();
int count = c.Count;
- if (index < 0 || index > _size - count) throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ if (index < 0 || index > _size - count) throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index"));
if (count > 0) {
c.CopyTo(_items, index);
@@ -684,7 +680,7 @@ namespace System.Collections {
public virtual ArrayList GetRange(int index, int count) {
if (index < 0 || count < 0)
- throw new ArgumentOutOfRangeException((index<0 ? "index" : "count"), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException((index<0 ? nameof(index) : nameof(count)), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
if (_size - index < count)
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
Contract.Ensures(Contract.Result<ArrayList>() != null);
@@ -716,9 +712,9 @@ namespace System.Collections {
//
public virtual void Sort(int index, int count, IComparer comparer) {
if (index < 0)
- throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
if (count < 0)
- throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
if (_size - index < count)
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
Contract.EndContractBlock();
@@ -729,10 +725,9 @@ namespace System.Collections {
// Returns a thread-safe wrapper around an IList.
//
- [HostProtection(Synchronization=true)]
public static IList Synchronized(IList list) {
if (list==null)
- throw new ArgumentNullException("list");
+ throw new ArgumentNullException(nameof(list));
Contract.Ensures(Contract.Result<IList>() != null);
Contract.EndContractBlock();
return new SyncIList(list);
@@ -740,10 +735,9 @@ namespace System.Collections {
// Returns a thread-safe wrapper around a ArrayList.
//
- [HostProtection(Synchronization=true)]
public static ArrayList Synchronized(ArrayList list) {
if (list==null)
- throw new ArgumentNullException("list");
+ throw new ArgumentNullException(nameof(list));
Contract.Ensures(Contract.Result<ArrayList>() != null);
Contract.EndContractBlock();
return new SyncArrayList(list);
@@ -764,10 +758,9 @@ namespace System.Collections {
// downcasting all elements. This copy may fail and is an O(n) operation.
// Internally, this implementation calls Array.Copy.
//
- [SecuritySafeCritical]
public virtual Array ToArray(Type type) {
if (type==null)
- throw new ArgumentNullException("type");
+ throw new ArgumentNullException(nameof(type));
Contract.Ensures(Contract.Result<Array>() != null);
Contract.EndContractBlock();
Array array = Array.UnsafeCreateInstance(type, _size);
@@ -804,7 +797,7 @@ namespace System.Collections {
public override int Capacity {
get { return _list.Count; }
set {
- if (value < Count) throw new ArgumentOutOfRangeException("value", Environment.GetResourceString("ArgumentOutOfRange_SmallCapacity"));
+ if (value < Count) throw new ArgumentOutOfRangeException(nameof(value), Environment.GetResourceString("ArgumentOutOfRange_SmallCapacity"));
Contract.EndContractBlock();
}
}
@@ -854,7 +847,7 @@ namespace System.Collections {
public override int BinarySearch(int index, int count, Object value, IComparer comparer)
{
if (index < 0 || count < 0)
- throw new ArgumentOutOfRangeException((index<0 ? "index" : "count"), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException((index<0 ? nameof(index) : nameof(count)), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
if (this.Count - index < count)
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
Contract.EndContractBlock();
@@ -906,11 +899,11 @@ namespace System.Collections {
public override void CopyTo(int index, Array array, int arrayIndex, int count) {
if (array==null)
- throw new ArgumentNullException("array");
+ throw new ArgumentNullException(nameof(array));
if (index < 0 || arrayIndex < 0)
- throw new ArgumentOutOfRangeException((index < 0) ? "index" : "arrayIndex", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException((index < 0) ? nameof(index) : nameof(arrayIndex), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
if( count < 0)
- throw new ArgumentOutOfRangeException( "count" , Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException( nameof(count) , Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
if (array.Length - arrayIndex < count)
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
if (array.Rank != 1)
@@ -930,7 +923,7 @@ namespace System.Collections {
public override IEnumerator GetEnumerator(int index, int count) {
if (index < 0 || count < 0)
- throw new ArgumentOutOfRangeException((index<0 ? "index" : "count"), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException((index<0 ? nameof(index) : nameof(count)), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
Contract.EndContractBlock();
if (_list.Count - index < count)
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
@@ -948,8 +941,8 @@ namespace System.Collections {
}
public override int IndexOf(Object value, int startIndex, int count) {
- if (startIndex < 0 || startIndex > this.Count) throw new ArgumentOutOfRangeException("startIndex", Environment.GetResourceString("ArgumentOutOfRange_Index"));
- if (count < 0 || startIndex > this.Count - count) throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_Count"));
+ if (startIndex < 0 || startIndex > this.Count) throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ if (count < 0 || startIndex > this.Count - count) throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_Count"));
Contract.EndContractBlock();
int endIndex = startIndex + count;
@@ -973,8 +966,8 @@ namespace System.Collections {
public override void InsertRange(int index, ICollection c) {
if (c==null)
- throw new ArgumentNullException("c", Environment.GetResourceString("ArgumentNull_Collection"));
- if (index < 0 || index > this.Count) throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ throw new ArgumentNullException(nameof(c), Environment.GetResourceString("ArgumentNull_Collection"));
+ if (index < 0 || index > this.Count) throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index"));
Contract.EndContractBlock();
if( c.Count > 0) {
@@ -1009,8 +1002,8 @@ namespace System.Collections {
if (_list.Count == 0)
return -1;
- if (startIndex < 0 || startIndex >= _list.Count) throw new ArgumentOutOfRangeException("startIndex", Environment.GetResourceString("ArgumentOutOfRange_Index"));
- if (count < 0 || count > startIndex + 1) throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_Count"));
+ if (startIndex < 0 || startIndex >= _list.Count) throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ if (count < 0 || count > startIndex + 1) throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_Count"));
int endIndex = startIndex - count + 1;
if (value == null) {
@@ -1039,7 +1032,7 @@ namespace System.Collections {
public override void RemoveRange(int index, int count) {
if (index < 0 || count < 0)
- throw new ArgumentOutOfRangeException((index<0 ? "index" : "count"), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException((index<0 ? nameof(index) : nameof(count)), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
Contract.EndContractBlock();
if (_list.Count - index < count)
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
@@ -1055,7 +1048,7 @@ namespace System.Collections {
public override void Reverse(int index, int count) {
if (index < 0 || count < 0)
- throw new ArgumentOutOfRangeException((index<0 ? "index" : "count"), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException((index<0 ? nameof(index) : nameof(count)), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
Contract.EndContractBlock();
if (_list.Count - index < count)
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
@@ -1073,12 +1066,12 @@ namespace System.Collections {
public override void SetRange(int index, ICollection c) {
if (c==null) {
- throw new ArgumentNullException("c", Environment.GetResourceString("ArgumentNull_Collection"));
+ throw new ArgumentNullException(nameof(c), Environment.GetResourceString("ArgumentNull_Collection"));
}
Contract.EndContractBlock();
if (index < 0 || index > _list.Count - c.Count) {
- throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index"));
}
if( c.Count > 0) {
@@ -1092,7 +1085,7 @@ namespace System.Collections {
public override ArrayList GetRange(int index, int count) {
if (index < 0 || count < 0)
- throw new ArgumentOutOfRangeException((index<0 ? "index" : "count"), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException((index<0 ? nameof(index) : nameof(count)), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
Contract.EndContractBlock();
if (_list.Count - index < count)
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
@@ -1101,7 +1094,7 @@ namespace System.Collections {
public override void Sort(int index, int count, IComparer comparer) {
if (index < 0 || count < 0)
- throw new ArgumentOutOfRangeException((index<0 ? "index" : "count"), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException((index<0 ? nameof(index) : nameof(count)), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
Contract.EndContractBlock();
if (_list.Count - index < count)
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
@@ -1122,11 +1115,10 @@ namespace System.Collections {
return array;
}
- [SecuritySafeCritical]
public override Array ToArray(Type type)
{
if (type==null)
- throw new ArgumentNullException("type");
+ throw new ArgumentNullException(nameof(type));
Contract.EndContractBlock();
Array array = Array.UnsafeCreateInstance(type, _list.Count);
_list.CopyTo(array, 0);
@@ -1806,7 +1798,7 @@ namespace System.Collections {
public override ArrayList GetRange(int index, int count) {
if (index < 0 || count < 0)
- throw new ArgumentOutOfRangeException((index<0 ? "index" : "count"), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException((index<0 ? nameof(index) : nameof(count)), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
if (Count - index < count)
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
Contract.EndContractBlock();
@@ -2062,7 +2054,7 @@ namespace System.Collections {
public override ArrayList GetRange(int index, int count) {
if (index < 0 || count < 0)
- throw new ArgumentOutOfRangeException((index<0 ? "index" : "count"), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException((index<0 ? nameof(index) : nameof(count)), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
if (Count - index < count)
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
Contract.EndContractBlock();
@@ -2191,7 +2183,7 @@ namespace System.Collections {
public override void AddRange(ICollection c) {
if( c == null ) {
- throw new ArgumentNullException("c");
+ throw new ArgumentNullException(nameof(c));
}
Contract.EndContractBlock();
@@ -2207,7 +2199,7 @@ namespace System.Collections {
// Other overloads with automatically work
public override int BinarySearch(int index, int count, Object value, IComparer comparer) {
if (index < 0 || count < 0)
- throw new ArgumentOutOfRangeException((index<0 ? "index" : "count"), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException((index<0 ? nameof(index) : nameof(count)), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
if (_baseSize - index < count)
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
Contract.EndContractBlock();
@@ -2224,7 +2216,7 @@ namespace System.Collections {
}
set {
- if (value < Count) throw new ArgumentOutOfRangeException("value", Environment.GetResourceString("ArgumentOutOfRange_SmallCapacity"));
+ if (value < Count) throw new ArgumentOutOfRangeException(nameof(value), Environment.GetResourceString("ArgumentOutOfRange_SmallCapacity"));
Contract.EndContractBlock();
}
}
@@ -2265,11 +2257,11 @@ namespace System.Collections {
public override void CopyTo(Array array, int index) {
if (array==null)
- throw new ArgumentNullException("array");
+ throw new ArgumentNullException(nameof(array));
if (array.Rank != 1)
throw new ArgumentException(Environment.GetResourceString("Arg_RankMultiDimNotSupported"));
if (index < 0)
- throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
if (array.Length - index < _baseSize)
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
Contract.EndContractBlock();
@@ -2280,11 +2272,11 @@ namespace System.Collections {
public override void CopyTo(int index, Array array, int arrayIndex, int count) {
if (array==null)
- throw new ArgumentNullException("array");
+ throw new ArgumentNullException(nameof(array));
if (array.Rank != 1)
throw new ArgumentException(Environment.GetResourceString("Arg_RankMultiDimNotSupported"));
if (index < 0 || count < 0)
- throw new ArgumentOutOfRangeException((index<0 ? "index" : "count"), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException((index<0 ? nameof(index) : nameof(count)), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
if (array.Length - arrayIndex < count)
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
if (_baseSize - index < count)
@@ -2320,7 +2312,7 @@ namespace System.Collections {
public override IEnumerator GetEnumerator(int index, int count) {
if (index < 0 || count < 0)
- throw new ArgumentOutOfRangeException((index<0 ? "index" : "count"), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException((index<0 ? nameof(index) : nameof(count)), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
if (_baseSize - index < count)
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
Contract.EndContractBlock();
@@ -2331,7 +2323,7 @@ namespace System.Collections {
public override ArrayList GetRange(int index, int count) {
if (index < 0 || count < 0)
- throw new ArgumentOutOfRangeException((index<0 ? "index" : "count"), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException((index<0 ? nameof(index) : nameof(count)), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
if (_baseSize - index < count)
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
Contract.EndContractBlock();
@@ -2356,9 +2348,9 @@ namespace System.Collections {
public override int IndexOf(Object value, int startIndex) {
if (startIndex < 0)
- throw new ArgumentOutOfRangeException("startIndex", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
if (startIndex > _baseSize)
- throw new ArgumentOutOfRangeException("startIndex", Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_Index"));
Contract.EndContractBlock();
InternalUpdateRange();
@@ -2369,10 +2361,10 @@ namespace System.Collections {
public override int IndexOf(Object value, int startIndex, int count) {
if (startIndex < 0 || startIndex > _baseSize)
- throw new ArgumentOutOfRangeException("startIndex", Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_Index"));
if (count < 0 || (startIndex > _baseSize - count))
- throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_Count"));
+ throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_Count"));
Contract.EndContractBlock();
InternalUpdateRange();
@@ -2382,7 +2374,7 @@ namespace System.Collections {
}
public override void Insert(int index, Object value) {
- if (index < 0 || index > _baseSize) throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ if (index < 0 || index > _baseSize) throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index"));
Contract.EndContractBlock();
InternalUpdateRange();
@@ -2392,9 +2384,9 @@ namespace System.Collections {
}
public override void InsertRange(int index, ICollection c) {
- if (index < 0 || index > _baseSize) throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ if (index < 0 || index > _baseSize) throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index"));
if( c == null) {
- throw new ArgumentNullException("c");
+ throw new ArgumentNullException(nameof(c));
}
Contract.EndContractBlock();
@@ -2426,9 +2418,9 @@ namespace System.Collections {
return -1;
if (startIndex >= _baseSize)
- throw new ArgumentOutOfRangeException("startIndex", Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_Index"));
if (startIndex < 0)
- throw new ArgumentOutOfRangeException("startIndex", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
int i = _baseList.LastIndexOf(value, _baseIndex + startIndex, count);
if (i >= 0) return i - _baseIndex;
@@ -2438,7 +2430,7 @@ namespace System.Collections {
// Don't need to override Remove
public override void RemoveAt(int index) {
- if (index < 0 || index >= _baseSize) throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ if (index < 0 || index >= _baseSize) throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index"));
Contract.EndContractBlock();
InternalUpdateRange();
@@ -2449,7 +2441,7 @@ namespace System.Collections {
public override void RemoveRange(int index, int count) {
if (index < 0 || count < 0)
- throw new ArgumentOutOfRangeException((index<0 ? "index" : "count"), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException((index<0 ? nameof(index) : nameof(count)), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
if (_baseSize - index < count)
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
Contract.EndContractBlock();
@@ -2466,7 +2458,7 @@ namespace System.Collections {
public override void Reverse(int index, int count) {
if (index < 0 || count < 0)
- throw new ArgumentOutOfRangeException((index<0 ? "index" : "count"), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException((index<0 ? nameof(index) : nameof(count)), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
if (_baseSize - index < count)
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
Contract.EndContractBlock();
@@ -2479,7 +2471,7 @@ namespace System.Collections {
[SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
public override void SetRange(int index, ICollection c) {
InternalUpdateRange();
- if (index < 0 || index >= _baseSize) throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ if (index < 0 || index >= _baseSize) throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index"));
_baseList.SetRange(_baseIndex + index, c);
if( c.Count > 0) {
InternalUpdateVersion();
@@ -2488,7 +2480,7 @@ namespace System.Collections {
public override void Sort(int index, int count, IComparer comparer) {
if (index < 0 || count < 0)
- throw new ArgumentOutOfRangeException((index<0 ? "index" : "count"), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException((index<0 ? nameof(index) : nameof(count)), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
if (_baseSize - index < count)
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
Contract.EndContractBlock();
@@ -2501,12 +2493,12 @@ namespace System.Collections {
public override Object this[int index] {
get {
InternalUpdateRange();
- if (index < 0 || index >= _baseSize) throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ if (index < 0 || index >= _baseSize) throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index"));
return _baseList[_baseIndex + index];
}
set {
InternalUpdateRange();
- if (index < 0 || index >= _baseSize) throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ if (index < 0 || index >= _baseSize) throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index"));
_baseList[_baseIndex + index] = value;
InternalUpdateVersion();
}
@@ -2519,10 +2511,9 @@ namespace System.Collections {
return array;
}
- [SecuritySafeCritical]
public override Array ToArray(Type type) {
if (type==null)
- throw new ArgumentNullException("type");
+ throw new ArgumentNullException(nameof(type));
Contract.EndContractBlock();
InternalUpdateRange();
@@ -2619,7 +2610,7 @@ namespace System.Collections {
public ArrayListDebugView( ArrayList arrayList) {
if( arrayList == null)
- throw new ArgumentNullException("arrayList");
+ throw new ArgumentNullException(nameof(arrayList));
this.arrayList = arrayList;
}
diff --git a/src/mscorlib/src/System/Collections/BitArray.cs b/src/mscorlib/src/System/Collections/BitArray.cs
deleted file mode 100644
index 2f565f8..0000000
--- a/src/mscorlib/src/System/Collections/BitArray.cs
+++ /dev/null
@@ -1,524 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*=============================================================================
-**
-**
-**
-**
-**
-** Purpose: The BitArray class manages a compact array of bit values.
-**
-**
-=============================================================================*/
-namespace System.Collections {
-
- using System;
- using System.Security.Permissions;
- using System.Diagnostics.Contracts;
- // A vector of bits. Use this to store bits efficiently, without having to do bit
- // shifting yourself.
-[System.Runtime.InteropServices.ComVisible(true)]
- [Serializable()] public sealed class BitArray : ICollection, ICloneable {
- private BitArray() {
- }
-
- /*=========================================================================
- ** Allocates space to hold length bit values. All of the values in the bit
- ** array are set to false.
- **
- ** Exceptions: ArgumentException if length < 0.
- =========================================================================*/
- public BitArray(int length)
- : this(length, false) {
- }
-
- /*=========================================================================
- ** Allocates space to hold length bit values. All of the values in the bit
- ** array are set to defaultValue.
- **
- ** Exceptions: ArgumentOutOfRangeException if length < 0.
- =========================================================================*/
- public BitArray(int length, bool defaultValue) {
- if (length < 0) {
- throw new ArgumentOutOfRangeException(nameof(length), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
- }
- Contract.EndContractBlock();
-
- m_array = new int[GetArrayLength(length, BitsPerInt32)];
- m_length = length;
-
- int fillValue = defaultValue ? unchecked(((int)0xffffffff)) : 0;
- for (int i = 0; i < m_array.Length; i++) {
- m_array[i] = fillValue;
- }
-
- _version = 0;
- }
-
- /*=========================================================================
- ** Allocates space to hold the bit values in bytes. bytes[0] represents
- ** bits 0 - 7, bytes[1] represents bits 8 - 15, etc. The LSB of each byte
- ** represents the lowest index value; bytes[0] & 1 represents bit 0,
- ** bytes[0] & 2 represents bit 1, bytes[0] & 4 represents bit 2, etc.
- **
- ** Exceptions: ArgumentException if bytes == null.
- =========================================================================*/
- public BitArray(byte[] bytes) {
- if (bytes == null) {
- throw new ArgumentNullException(nameof(bytes));
- }
- Contract.EndContractBlock();
- // this value is chosen to prevent overflow when computing m_length.
- // m_length is of type int32 and is exposed as a property, so
- // type of m_length can't be changed to accommodate.
- if (bytes.Length > Int32.MaxValue / BitsPerByte) {
- throw new ArgumentException(Environment.GetResourceString("Argument_ArrayTooLarge", BitsPerByte), nameof(bytes));
- }
-
- m_array = new int[GetArrayLength(bytes.Length, BytesPerInt32)];
- m_length = bytes.Length * BitsPerByte;
-
- int i = 0;
- int j = 0;
- while (bytes.Length - j >= 4) {
- m_array[i++] = (bytes[j] & 0xff) |
- ((bytes[j + 1] & 0xff) << 8) |
- ((bytes[j + 2] & 0xff) << 16) |
- ((bytes[j + 3] & 0xff) << 24);
- j += 4;
- }
-
- Contract.Assert(bytes.Length - j >= 0, "BitArray byteLength problem");
- Contract.Assert(bytes.Length - j < 4, "BitArray byteLength problem #2");
-
- switch (bytes.Length - j) {
- case 3:
- m_array[i] = ((bytes[j + 2] & 0xff) << 16);
- goto case 2;
- // fall through
- case 2:
- m_array[i] |= ((bytes[j + 1] & 0xff) << 8);
- goto case 1;
- // fall through
- case 1:
- m_array[i] |= (bytes[j] & 0xff);
- break;
- }
-
- _version = 0;
- }
-
- public BitArray(bool[] values) {
- if (values == null) {
- throw new ArgumentNullException(nameof(values));
- }
- Contract.EndContractBlock();
-
- m_array = new int[GetArrayLength(values.Length, BitsPerInt32)];
- m_length = values.Length;
-
- for (int i = 0;i<values.Length;i++) {
- if (values[i])
- m_array[i/32] |= (1 << (i%32));
- }
-
- _version = 0;
-
- }
-
- /*=========================================================================
- ** Allocates space to hold the bit values in values. values[0] represents
- ** bits 0 - 31, values[1] represents bits 32 - 63, etc. The LSB of each
- ** integer represents the lowest index value; values[0] & 1 represents bit
- ** 0, values[0] & 2 represents bit 1, values[0] & 4 represents bit 2, etc.
- **
- ** Exceptions: ArgumentException if values == null.
- =========================================================================*/
- public BitArray(int[] values) {
- if (values == null) {
- throw new ArgumentNullException(nameof(values));
- }
- Contract.EndContractBlock();
- // this value is chosen to prevent overflow when computing m_length
- if (values.Length > Int32.MaxValue / BitsPerInt32) {
- throw new ArgumentException(Environment.GetResourceString("Argument_ArrayTooLarge", BitsPerInt32), nameof(values));
- }
-
- m_array = new int[values.Length];
- m_length = values.Length * BitsPerInt32;
-
- Array.Copy(values, m_array, values.Length);
-
- _version = 0;
- }
-
- /*=========================================================================
- ** Allocates a new BitArray with the same length and bit values as bits.
- **
- ** Exceptions: ArgumentException if bits == null.
- =========================================================================*/
- public BitArray(BitArray bits) {
- if (bits == null) {
- throw new ArgumentNullException(nameof(bits));
- }
- Contract.EndContractBlock();
-
- int arrayLength = GetArrayLength(bits.m_length, BitsPerInt32);
- m_array = new int[arrayLength];
- m_length = bits.m_length;
-
- Array.Copy(bits.m_array, m_array, arrayLength);
-
- _version = bits._version;
- }
-
- public bool this[int index] {
- get {
- return Get(index);
- }
- set {
- Set(index,value);
- }
- }
-
- /*=========================================================================
- ** Returns the bit value at position index.
- **
- ** Exceptions: ArgumentOutOfRangeException if index < 0 or
- ** index >= GetLength().
- =========================================================================*/
- public bool Get(int index) {
- if (index < 0 || index >= Length) {
- throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index"));
- }
- Contract.EndContractBlock();
-
- return (m_array[index / 32] & (1 << (index % 32))) != 0;
- }
-
- /*=========================================================================
- ** Sets the bit value at position index to value.
- **
- ** Exceptions: ArgumentOutOfRangeException if index < 0 or
- ** index >= GetLength().
- =========================================================================*/
- public void Set(int index, bool value) {
- if (index < 0 || index >= Length) {
- throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index"));
- }
- Contract.EndContractBlock();
-
- if (value) {
- m_array[index / 32] |= (1 << (index % 32));
- } else {
- m_array[index / 32] &= ~(1 << (index % 32));
- }
-
- _version++;
- }
-
- /*=========================================================================
- ** Sets all the bit values to value.
- =========================================================================*/
- public void SetAll(bool value) {
- int fillValue = value ? unchecked(((int)0xffffffff)) : 0;
- int ints = GetArrayLength(m_length, BitsPerInt32);
- for (int i = 0; i < ints; i++) {
- m_array[i] = fillValue;
- }
-
- _version++;
- }
-
- /*=========================================================================
- ** Returns a reference to the current instance ANDed with value.
- **
- ** Exceptions: ArgumentException if value == null or
- ** value.Length != this.Length.
- =========================================================================*/
- public BitArray And(BitArray value) {
- if (value==null)
- throw new ArgumentNullException(nameof(value));
- if (Length != value.Length)
- throw new ArgumentException(Environment.GetResourceString("Arg_ArrayLengthsDiffer"));
- Contract.EndContractBlock();
-
- int ints = GetArrayLength(m_length, BitsPerInt32);
- for (int i = 0; i < ints; i++) {
- m_array[i] &= value.m_array[i];
- }
-
- _version++;
- return this;
- }
-
- /*=========================================================================
- ** Returns a reference to the current instance ORed with value.
- **
- ** Exceptions: ArgumentException if value == null or
- ** value.Length != this.Length.
- =========================================================================*/
- public BitArray Or(BitArray value) {
- if (value==null)
- throw new ArgumentNullException(nameof(value));
- if (Length != value.Length)
- throw new ArgumentException(Environment.GetResourceString("Arg_ArrayLengthsDiffer"));
- Contract.EndContractBlock();
-
- int ints = GetArrayLength(m_length, BitsPerInt32);
- for (int i = 0; i < ints; i++) {
- m_array[i] |= value.m_array[i];
- }
-
- _version++;
- return this;
- }
-
- /*=========================================================================
- ** Returns a reference to the current instance XORed with value.
- **
- ** Exceptions: ArgumentException if value == null or
- ** value.Length != this.Length.
- =========================================================================*/
- public BitArray Xor(BitArray value) {
- if (value==null)
- throw new ArgumentNullException(nameof(value));
- if (Length != value.Length)
- throw new ArgumentException(Environment.GetResourceString("Arg_ArrayLengthsDiffer"));
- Contract.EndContractBlock();
-
- int ints = GetArrayLength(m_length, BitsPerInt32);
- for (int i = 0; i < ints; i++) {
- m_array[i] ^= value.m_array[i];
- }
-
- _version++;
- return this;
- }
-
- /*=========================================================================
- ** Inverts all the bit values. On/true bit values are converted to
- ** off/false. Off/false bit values are turned on/true. The current instance
- ** is updated and returned.
- =========================================================================*/
- public BitArray Not() {
- int ints = GetArrayLength(m_length, BitsPerInt32);
- for (int i = 0; i < ints; i++) {
- m_array[i] = ~m_array[i];
- }
-
- _version++;
- return this;
- }
-
- public int Length {
- get {
- Contract.Ensures(Contract.Result<int>() >= 0);
- return m_length;
- }
- set {
- if (value < 0) {
- throw new ArgumentOutOfRangeException(nameof(value), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
- }
- Contract.EndContractBlock();
-
- int newints = GetArrayLength(value, BitsPerInt32);
- if (newints > m_array.Length || newints + _ShrinkThreshold < m_array.Length) {
- // grow or shrink (if wasting more than _ShrinkThreshold ints)
- int[] newarray = new int[newints];
- Array.Copy(m_array, newarray, newints > m_array.Length ? m_array.Length : newints);
- m_array = newarray;
- }
-
- if (value > m_length) {
- // clear high bit values in the last int
- int last = GetArrayLength(m_length, BitsPerInt32) - 1;
- int bits = m_length % 32;
- if (bits > 0) {
- m_array[last] &= (1 << bits) - 1;
- }
-
- // clear remaining int values
- Array.Clear(m_array, last + 1, newints - last - 1);
- }
-
- m_length = value;
- _version++;
- }
- }
-
- // ICollection implementation
- public void CopyTo(Array array, int index)
- {
- if (array == null)
- throw new ArgumentNullException(nameof(array));
-
- if (index < 0)
- throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
-
- if (array.Rank != 1)
- throw new ArgumentException(Environment.GetResourceString("Arg_RankMultiDimNotSupported"), nameof(array));
-
- Contract.EndContractBlock();
-
- if (array is int[])
- {
- Array.Copy(m_array, 0, array, index, GetArrayLength(m_length, BitsPerInt32));
- }
- else if (array is byte[])
- {
- int arrayLength = GetArrayLength(m_length, BitsPerByte);
- if ((array.Length - index) < arrayLength)
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
-
- byte [] b = (byte[])array;
- for (int i = 0; i < arrayLength; i++)
- b[index + i] = (byte)((m_array[i/4] >> ((i%4)*8)) & 0x000000FF); // Shift to bring the required byte to LSB, then mask
- }
- else if (array is bool[])
- {
- if (array.Length - index < m_length)
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
-
- bool [] b = (bool[])array;
- for (int i = 0;i<m_length;i++)
- b[index + i] = ((m_array[i/32] >> (i%32)) & 0x00000001) != 0;
- }
- else
- throw new ArgumentException(Environment.GetResourceString("Arg_BitArrayTypeUnsupported"), nameof(array));
- }
-
- public int Count
- {
- get
- {
- Contract.Ensures(Contract.Result<int>() >= 0);
-
- return m_length;
- }
- }
-
- public Object Clone()
- {
- Contract.Ensures(Contract.Result<Object>() != null);
- Contract.Ensures(((BitArray)Contract.Result<Object>()).Length == this.Length);
-
- return new BitArray(this);
- }
-
- public Object SyncRoot
- {
- get
- {
- if( _syncRoot == null) {
- System.Threading.Interlocked.CompareExchange<Object>(ref _syncRoot, new Object(), null);
- }
- return _syncRoot;
- }
- }
-
- public bool IsReadOnly
- {
- get
- {
- return false;
- }
- }
-
- public bool IsSynchronized
- {
- get
- {
- return false;
- }
- }
-
- public IEnumerator GetEnumerator()
- {
- return new BitArrayEnumeratorSimple(this);
- }
-
- // XPerY=n means that n Xs can be stored in 1 Y.
- private const int BitsPerInt32 = 32;
- private const int BytesPerInt32 = 4;
- private const int BitsPerByte = 8;
-
- /// <summary>
- /// Used for conversion between different representations of bit array.
- /// Returns (n+(div-1))/div, rearranged to avoid arithmetic overflow.
- /// For example, in the bit to int case, the straightforward calc would
- /// be (n+31)/32, but that would cause overflow. So instead it's
- /// rearranged to ((n-1)/32) + 1, with special casing for 0.
- ///
- /// Usage:
- /// GetArrayLength(77, BitsPerInt32): returns how many ints must be
- /// allocated to store 77 bits.
- /// </summary>
- /// <param name="n"></param>
- /// <param name="div">use a conversion constant, e.g. BytesPerInt32 to get
- /// how many ints are required to store n bytes</param>
- /// <returns></returns>
- private static int GetArrayLength(int n, int div) {
- Contract.Assert(div > 0, "GetArrayLength: div arg must be greater than 0");
- return n > 0 ? (((n - 1) / div) + 1) : 0;
- }
-
- [Serializable]
- private class BitArrayEnumeratorSimple : IEnumerator, ICloneable
- {
- private BitArray bitarray;
- private int index;
- private int version;
- private bool currentElement;
-
- internal BitArrayEnumeratorSimple(BitArray bitarray) {
- this.bitarray = bitarray;
- this.index = -1;
- version = bitarray._version;
- }
-
- public Object Clone() {
- return MemberwiseClone();
- }
-
- public virtual bool MoveNext() {
- if (version != bitarray._version) throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumFailedVersion));
- if (index < (bitarray.Count-1)) {
- index++;
- currentElement = bitarray.Get(index);
- return true;
- }
- else
- index = bitarray.Count;
-
- return false;
- }
-
- public virtual Object Current {
- get {
- if (index == -1)
- throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumNotStarted));
- if (index >= bitarray.Count)
- throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumEnded));
- return currentElement;
- }
- }
-
- public void Reset() {
- if (version != bitarray._version) throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumFailedVersion));
- index = -1;
- }
- }
-
- private int[] m_array;
- private int m_length;
- private int _version;
- [NonSerialized]
- private Object _syncRoot;
-
- private const int _ShrinkThreshold = 256;
- }
-
-}
diff --git a/src/mscorlib/src/System/Collections/CollectionBase.cs b/src/mscorlib/src/System/Collections/CollectionBase.cs
index 1bb08af..ae0c0d3 100644
--- a/src/mscorlib/src/System/Collections/CollectionBase.cs
+++ b/src/mscorlib/src/System/Collections/CollectionBase.cs
@@ -62,7 +62,7 @@ namespace System.Collections {
public void RemoveAt(int index) {
if (index < 0 || index >= Count)
- throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index"));
Contract.EndContractBlock();
Object temp = InnerList[index];
OnValidate(temp);
@@ -101,13 +101,13 @@ namespace System.Collections {
Object IList.this[int index] {
get {
if (index < 0 || index >= Count)
- throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index"));
Contract.EndContractBlock();
return InnerList[index];
}
set {
if (index < 0 || index >= Count)
- throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index"));
Contract.EndContractBlock();
OnValidate(value);
Object temp = InnerList[index];
@@ -163,7 +163,7 @@ namespace System.Collections {
void IList.Insert(int index, Object value) {
if (index < 0 || index > Count)
- throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index"));
Contract.EndContractBlock();
OnValidate(value);
OnInsert(index, value);
@@ -194,7 +194,7 @@ namespace System.Collections {
}
protected virtual void OnValidate(Object value) {
- if (value == null) throw new ArgumentNullException("value");
+ if (value == null) throw new ArgumentNullException(nameof(value));
Contract.EndContractBlock();
}
diff --git a/src/mscorlib/src/System/Collections/Comparer.cs b/src/mscorlib/src/System/Collections/Comparer.cs
index 11e2625..0e3c78b 100644
--- a/src/mscorlib/src/System/Collections/Comparer.cs
+++ b/src/mscorlib/src/System/Collections/Comparer.cs
@@ -36,7 +36,7 @@ namespace System.Collections {
public Comparer(CultureInfo culture) {
if (culture==null) {
- throw new ArgumentNullException("culture");
+ throw new ArgumentNullException(nameof(culture));
}
Contract.EndContractBlock();
m_compareInfo = culture.CompareInfo;
@@ -83,10 +83,9 @@ namespace System.Collections {
throw new ArgumentException(Environment.GetResourceString("Argument_ImplementIComparable"));
}
- [System.Security.SecurityCritical] // auto-generated_required
public void GetObjectData(SerializationInfo info, StreamingContext context) {
if (info==null) {
- throw new ArgumentNullException("info");
+ throw new ArgumentNullException(nameof(info));
}
Contract.EndContractBlock();
diff --git a/src/mscorlib/src/System/Collections/CompatibleComparer.cs b/src/mscorlib/src/System/Collections/CompatibleComparer.cs
index 85e6c3f..e5d3961 100644
--- a/src/mscorlib/src/System/Collections/CompatibleComparer.cs
+++ b/src/mscorlib/src/System/Collections/CompatibleComparer.cs
@@ -39,7 +39,7 @@ namespace System.Collections {
public int GetHashCode(Object obj) {
if( obj == null) {
- throw new ArgumentNullException("obj");
+ throw new ArgumentNullException(nameof(obj));
}
Contract.EndContractBlock();
diff --git a/src/mscorlib/src/System/Collections/Concurrent/ConcurrentDictionary.cs b/src/mscorlib/src/System/Collections/Concurrent/ConcurrentDictionary.cs
index d805dc8..c1a6f75 100644
--- a/src/mscorlib/src/System/Collections/Concurrent/ConcurrentDictionary.cs
+++ b/src/mscorlib/src/System/Collections/Concurrent/ConcurrentDictionary.cs
@@ -28,7 +28,6 @@ using System.Security.Permissions;
namespace System.Collections.Concurrent
{
-
/// <summary>
/// Represents a thread-safe collection of keys and values.
/// </summary>
@@ -38,13 +37,9 @@ namespace System.Collections.Concurrent
/// All public and protected members of <see cref="ConcurrentDictionary{TKey,TValue}"/> are thread-safe and may be used
/// concurrently from multiple threads.
/// </remarks>
-#if !FEATURE_CORECLR
- [Serializable]
-#endif
[ComVisible(false)]
[DebuggerTypeProxy(typeof(Mscorlib_DictionaryDebugView<,>))]
[DebuggerDisplay("Count = {Count}")]
- [HostProtection(Synchronization = true, ExternalThreading = true)]
public class ConcurrentDictionary<TKey, TValue> : IDictionary<TKey, TValue>, IDictionary, IReadOnlyDictionary<TKey, TValue>
{
/// <summary>
@@ -68,41 +63,20 @@ namespace System.Collections.Concurrent
m_comparer = comparer;
}
}
-#if !FEATURE_CORECLR
- [NonSerialized]
-#endif
+
private volatile Tables m_tables; // Internal tables of the dictionary
// NOTE: this is only used for compat reasons to serialize the comparer.
// This should not be accessed from anywhere else outside of the serialization methods.
internal IEqualityComparer<TKey> m_comparer;
-#if !FEATURE_CORECLR
- [NonSerialized]
-#endif
private readonly bool m_growLockArray; // Whether to dynamically increase the size of the striped lock
// How many times we resized becaused of collisions.
// This is used to make sure we don't resize the dictionary because of multi-threaded Add() calls
// that generate collisions. Whenever a GrowTable() should be the only place that changes this
-#if !FEATURE_CORECLR
- // The field should be have been marked as NonSerialized but because we shipped it without that attribute in 4.5.1.
- // we can't add it back without breaking compat. To maximize compat we are going to keep the OptionalField attribute
- // This will prevent cases where the field was not serialized.
- [OptionalField]
-#endif
private int m_keyRehashCount;
-#if !FEATURE_CORECLR
- [NonSerialized]
-#endif
private int m_budget; // The maximum number of elements per lock before a resize operation is triggered
-#if !FEATURE_CORECLR // These fields are not used in CoreCLR
- private KeyValuePair<TKey, TValue>[] m_serializationArray; // Used for custom serialization
-
- private int m_serializationConcurrencyLevel; // used to save the concurrency level in serialization
-
- private int m_serializationCapacity; // used to save the capacity in serialization
-#endif
// The default concurrency level is DEFAULT_CONCURRENCY_MULTIPLIER * #CPUs. The higher the
// DEFAULT_CONCURRENCY_MULTIPLIER, the more concurrent writes can take place without interference
// and blocking, but also the more expensive operations that require all locks become (e.g. table
@@ -229,7 +203,7 @@ namespace System.Collections.Concurrent
public ConcurrentDictionary(IEnumerable<KeyValuePair<TKey, TValue>> collection, IEqualityComparer<TKey> comparer)
: this(comparer)
{
- if (collection == null) throw new ArgumentNullException("collection");
+ if (collection == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.collection);
InitializeFromCollection(collection);
}
@@ -259,8 +233,8 @@ namespace System.Collections.Concurrent
int concurrencyLevel, IEnumerable<KeyValuePair<TKey, TValue>> collection, IEqualityComparer<TKey> comparer)
: this(concurrencyLevel, DEFAULT_CAPACITY, false, comparer)
{
- if (collection == null) throw new ArgumentNullException("collection");
- if (comparer == null) throw new ArgumentNullException("comparer");
+ if (collection == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.collection);
+ if (comparer == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.comparer);
InitializeFromCollection(collection);
}
@@ -270,11 +244,11 @@ namespace System.Collections.Concurrent
TValue dummy;
foreach (KeyValuePair<TKey, TValue> pair in collection)
{
- if (pair.Key == null) throw new ArgumentNullException("key");
+ if (pair.Key == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key);
if (!TryAddInternal(pair.Key, pair.Value, false, false, out dummy))
{
- throw new ArgumentException(GetResource("ConcurrentDictionary_SourceContainsDuplicateKeys"));
+ ThrowHelper.ThrowArgumentException(ExceptionResource.ConcurrentDictionary_SourceContainsDuplicateKeys);
}
}
@@ -312,13 +286,13 @@ namespace System.Collections.Concurrent
{
if (concurrencyLevel < 1)
{
- throw new ArgumentOutOfRangeException("concurrencyLevel", GetResource("ConcurrentDictionary_ConcurrencyLevelMustBePositive"));
+ ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.concurrencyLevel, ExceptionResource.ConcurrentDictionary_ConcurrencyLevelMustBePositive);
}
if (capacity < 0)
{
- throw new ArgumentOutOfRangeException("capacity", GetResource("ConcurrentDictionary_CapacityMustNotBeNegative"));
+ ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.capacity, ExceptionResource.ConcurrentDictionary_CapacityMustNotBeNegative);
}
- if (comparer == null) throw new ArgumentNullException("comparer");
+ if (comparer == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.comparer);
// The capacity should be at least as large as the concurrency level. Otherwise, we would have locks that don't guard
// any buckets.
@@ -358,7 +332,7 @@ namespace System.Collections.Concurrent
/// contains too many elements.</exception>
public bool TryAdd(TKey key, TValue value)
{
- if (key == null) throw new ArgumentNullException("key");
+ if (key == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key);
TValue dummy;
return TryAddInternal(key, value, false, true, out dummy);
}
@@ -375,7 +349,7 @@ namespace System.Collections.Concurrent
/// (Nothing in Visual Basic).</exception>
public bool ContainsKey(TKey key)
{
- if (key == null) throw new ArgumentNullException("key");
+ if (key == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key);
TValue throwAwayValue;
return TryGetValue(key, out throwAwayValue);
@@ -395,7 +369,7 @@ namespace System.Collections.Concurrent
/// (Nothing in Visual Basic).</exception>
public bool TryRemove(TKey key, out TValue value)
{
- if (key == null) throw new ArgumentNullException("key");
+ if (key == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key);
return TryRemoveInternal(key, out value, false, default(TValue));
}
@@ -486,7 +460,7 @@ namespace System.Collections.Concurrent
[SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "Reviewed for thread safety")]
public bool TryGetValue(TKey key, out TValue value)
{
- if (key == null) throw new ArgumentNullException("key");
+ if (key == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key);
int bucketNo, lockNoUnused;
@@ -531,7 +505,7 @@ namespace System.Collections.Concurrent
[SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "Reviewed for thread safety")]
public bool TryUpdate(TKey key, TValue newValue, TValue comparisonValue)
{
- if (key == null) throw new ArgumentNullException("key");
+ if (key == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key);
IEqualityComparer<TValue> valueComparer = EqualityComparer<TValue>.Default;
@@ -642,8 +616,8 @@ namespace System.Collections.Concurrent
[SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "ConcurrencyCop just doesn't know about these locks")]
void ICollection<KeyValuePair<TKey, TValue>>.CopyTo(KeyValuePair<TKey, TValue>[] array, int index)
{
- if (array == null) throw new ArgumentNullException("array");
- if (index < 0) throw new ArgumentOutOfRangeException("index", GetResource("ConcurrentDictionary_IndexIsNegative"));
+ if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
+ if (index < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ConcurrentDictionary_IndexIsNegative);
int locksAcquired = 0;
try
@@ -659,7 +633,7 @@ namespace System.Collections.Concurrent
if (array.Length - count < index || count < 0) //"count" itself or "count + index" can overflow
{
- throw new ArgumentException(GetResource("ConcurrentDictionary_ArrayNotLargeEnough"));
+ ThrowHelper.ThrowArgumentException(ExceptionResource.ConcurrentDictionary_ArrayNotLargeEnough);
}
CopyToPairs(array, index);
@@ -803,11 +777,6 @@ namespace System.Collections.Concurrent
bool resizeDesired = false;
bool lockTaken = false;
-#if FEATURE_RANDOMIZED_STRING_HASHING
-#if !FEATURE_CORECLR
- bool resizeDueToCollisions = false;
-#endif // !FEATURE_CORECLR
-#endif
try
{
@@ -821,12 +790,6 @@ namespace System.Collections.Concurrent
continue;
}
-#if FEATURE_RANDOMIZED_STRING_HASHING
-#if !FEATURE_CORECLR
- int collisionCount = 0;
-#endif // !FEATURE_CORECLR
-#endif
-
// Try to find this key in the bucket
Node prev = null;
for (Node node = tables.m_buckets[bucketNo]; node != null; node = node.m_next)
@@ -864,23 +827,7 @@ namespace System.Collections.Concurrent
return false;
}
prev = node;
-
-#if FEATURE_RANDOMIZED_STRING_HASHING
-#if !FEATURE_CORECLR
- collisionCount++;
-#endif // !FEATURE_CORECLR
-#endif
- }
-
-#if FEATURE_RANDOMIZED_STRING_HASHING
-#if !FEATURE_CORECLR
- if(collisionCount > HashHelpers.HashCollisionThreshold && HashHelpers.IsWellKnownEqualityComparer(comparer))
- {
- resizeDesired = true;
- resizeDueToCollisions = true;
}
-#endif // !FEATURE_CORECLR
-#endif
// The key was not found in the bucket. Insert the key-value pair.
Volatile.Write<Node>(ref tables.m_buckets[bucketNo], new Node(key, value, hashcode, tables.m_buckets[bucketNo]));
@@ -916,16 +863,7 @@ namespace System.Collections.Concurrent
if (resizeDesired)
{
#if FEATURE_RANDOMIZED_STRING_HASHING
-#if !FEATURE_CORECLR
- if (resizeDueToCollisions)
- {
- GrowTable(tables, (IEqualityComparer<TKey>)HashHelpers.GetRandomizedEqualityComparer(comparer), true, m_keyRehashCount);
- }
- else
-#endif // !FEATURE_CORECLR
- {
- GrowTable(tables, tables.m_comparer, false, m_keyRehashCount);
- }
+ GrowTable(tables, tables.m_comparer, false, m_keyRehashCount);
#else
GrowTable(tables, tables.m_comparer, false, m_keyRehashCount);
#endif
@@ -956,13 +894,13 @@ namespace System.Collections.Concurrent
TValue value;
if (!TryGetValue(key, out value))
{
- throw new KeyNotFoundException();
+ ThrowHelper.ThrowKeyNotFoundException();
}
return value;
}
set
{
- if (key == null) throw new ArgumentNullException("key");
+ if (key == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key);
TValue dummy;
TryAddInternal(key, value, true, true, out dummy);
}
@@ -1026,8 +964,8 @@ namespace System.Collections.Concurrent
/// if the key was not in the dictionary.</returns>
public TValue GetOrAdd(TKey key, Func<TKey, TValue> valueFactory)
{
- if (key == null) throw new ArgumentNullException("key");
- if (valueFactory == null) throw new ArgumentNullException("valueFactory");
+ if (key == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key);
+ if (valueFactory == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.valueFactory);
TValue resultingValue;
if (TryGetValue(key, out resultingValue))
@@ -1052,7 +990,7 @@ namespace System.Collections.Concurrent
/// key is already in the dictionary, or the new value if the key was not in the dictionary.</returns>
public TValue GetOrAdd(TKey key, TValue value)
{
- if (key == null) throw new ArgumentNullException("key");
+ if (key == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key);
TValue resultingValue;
TryAddInternal(key, value, false, true, out resultingValue);
@@ -1080,9 +1018,9 @@ namespace System.Collections.Concurrent
/// absent) or the result of updateValueFactory (if the key was present).</returns>
public TValue AddOrUpdate(TKey key, Func<TKey, TValue> addValueFactory, Func<TKey, TValue, TValue> updateValueFactory)
{
- if (key == null) throw new ArgumentNullException("key");
- if (addValueFactory == null) throw new ArgumentNullException("addValueFactory");
- if (updateValueFactory == null) throw new ArgumentNullException("updateValueFactory");
+ if (key == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key);
+ if (addValueFactory == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.addValueFactory);
+ if (updateValueFactory == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.updateValueFactory);
TValue newValue, resultingValue;
while (true)
@@ -1127,8 +1065,8 @@ namespace System.Collections.Concurrent
/// absent) or the result of updateValueFactory (if the key was present).</returns>
public TValue AddOrUpdate(TKey key, TValue addValue, Func<TKey, TValue, TValue> updateValueFactory)
{
- if (key == null) throw new ArgumentNullException("key");
- if (updateValueFactory == null) throw new ArgumentNullException("updateValueFactory");
+ if (key == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key);
+ if (updateValueFactory == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.updateValueFactory);
TValue newValue, resultingValue;
while (true)
{
@@ -1207,7 +1145,7 @@ namespace System.Collections.Concurrent
{
if (!TryAdd(key, value))
{
- throw new ArgumentException(GetResource("ConcurrentDictionary_KeyAlreadyExisted"));
+ ThrowHelper.ThrowArgumentException(ExceptionResource.ConcurrentDictionary_KeyAlreadyExisted);
}
}
@@ -1340,8 +1278,7 @@ namespace System.Collections.Concurrent
/// name="keyValuePair"/> is a null reference (Nothing in Visual Basic).</exception>
bool ICollection<KeyValuePair<TKey, TValue>>.Remove(KeyValuePair<TKey, TValue> keyValuePair)
{
- if (keyValuePair.Key == null) throw new ArgumentNullException(GetResource("ConcurrentDictionary_ItemKeyIsNull"));
-
+ if (keyValuePair.Key == null) ThrowHelper.ThrowArgumentNullException(ExceptionResource.ConcurrentDictionary_ItemKeyIsNull);
TValue throwAwayValue;
return TryRemoveInternal(keyValuePair.Key, out throwAwayValue, true, keyValuePair.Value);
}
@@ -1387,17 +1324,17 @@ namespace System.Collections.Concurrent
/// </exception>
void IDictionary.Add(object key, object value)
{
- if (key == null) throw new ArgumentNullException("key");
- if (!(key is TKey)) throw new ArgumentException(GetResource("ConcurrentDictionary_TypeOfKeyIncorrect"));
+ if (key == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key);
+ if (!(key is TKey)) ThrowHelper.ThrowArgumentException(ExceptionResource.ConcurrentDictionary_TypeOfKeyIncorrect);
- TValue typedValue;
+ TValue typedValue = default(TValue);
try
{
typedValue = (TValue)value;
}
catch (InvalidCastException)
{
- throw new ArgumentException(GetResource("ConcurrentDictionary_TypeOfValueIncorrect"));
+ ThrowHelper.ThrowArgumentException(ExceptionResource.ConcurrentDictionary_TypeOfValueIncorrect);
}
((IDictionary<TKey, TValue>)this).Add((TKey)key, typedValue);
@@ -1415,7 +1352,7 @@ namespace System.Collections.Concurrent
/// (Nothing in Visual Basic).</exception>
bool IDictionary.Contains(object key)
{
- if (key == null) throw new ArgumentNullException("key");
+ if (key == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key);
return (key is TKey) && ((ConcurrentDictionary<TKey, TValue>)this).ContainsKey((TKey)key);
}
@@ -1475,7 +1412,7 @@ namespace System.Collections.Concurrent
/// (Nothing in Visual Basic).</exception>
void IDictionary.Remove(object key)
{
- if (key == null) throw new ArgumentNullException("key");
+ if (key == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key);
TValue throwAwayValue;
if (key is TKey)
@@ -1517,7 +1454,7 @@ namespace System.Collections.Concurrent
{
get
{
- if (key == null) throw new ArgumentNullException("key");
+ if (key == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key);
TValue value;
if (key is TKey && this.TryGetValue((TKey)key, out value))
@@ -1529,10 +1466,10 @@ namespace System.Collections.Concurrent
}
set
{
- if (key == null) throw new ArgumentNullException("key");
+ if (key == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key);
- if (!(key is TKey)) throw new ArgumentException(GetResource("ConcurrentDictionary_TypeOfKeyIncorrect"));
- if (!(value is TValue)) throw new ArgumentException(GetResource("ConcurrentDictionary_TypeOfValueIncorrect"));
+ if (!(key is TKey)) ThrowHelper.ThrowArgumentException(ExceptionResource.ConcurrentDictionary_TypeOfKeyIncorrect);
+ if (!(value is TValue)) ThrowHelper.ThrowArgumentException(ExceptionResource.ConcurrentDictionary_TypeOfValueIncorrect);
((ConcurrentDictionary<TKey, TValue>)this)[(TKey)key] = (TValue)value;
}
@@ -1563,8 +1500,8 @@ namespace System.Collections.Concurrent
[SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "ConcurrencyCop just doesn't know about these locks")]
void ICollection.CopyTo(Array array, int index)
{
- if (array == null) throw new ArgumentNullException("array");
- if (index < 0) throw new ArgumentOutOfRangeException("index", GetResource("ConcurrentDictionary_IndexIsNegative"));
+ if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
+ if (index < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ConcurrentDictionary_IndexIsNegative);
int locksAcquired = 0;
try
@@ -1581,7 +1518,7 @@ namespace System.Collections.Concurrent
if (array.Length - count < index || count < 0) //"count" itself or "count + index" can overflow
{
- throw new ArgumentException(GetResource("ConcurrentDictionary_ArrayNotLargeEnough"));
+ ThrowHelper.ThrowArgumentException(ExceptionResource.ConcurrentDictionary_ArrayNotLargeEnough);
}
// To be consistent with the behavior of ICollection.CopyTo() in Dictionary<TKey,TValue>,
@@ -1611,7 +1548,7 @@ namespace System.Collections.Concurrent
return;
}
- throw new ArgumentException(GetResource("ConcurrentDictionary_ArrayIncorrectType"), "array");
+ ThrowHelper.ThrowArgumentException(ExceptionResource.ConcurrentDictionary_ArrayIncorrectType, ExceptionArgument.array);
}
finally
{
@@ -1641,7 +1578,8 @@ namespace System.Collections.Concurrent
{
get
{
- throw new NotSupportedException(Environment.GetResourceString("ConcurrentCollection_SyncRoot_NotSupported"));
+ ThrowHelper.ThrowNotSupportedException(ExceptionResource.ConcurrentCollection_SyncRoot_NotSupported);
+ return default(object);
}
}
@@ -1850,13 +1788,6 @@ namespace System.Collections.Concurrent
/// </summary>
private void AcquireAllLocks(ref int locksAcquired)
{
-#if !FEATURE_CORECLR
- if (CDSCollectionETWBCLProvider.Log.IsEnabled())
- {
- CDSCollectionETWBCLProvider.Log.ConcurrentDictionary_AcquiringAllLocks(m_tables.m_buckets.Length);
- }
-#endif //!FEATURE_CORECLR
-
// First, acquire lock 0
AcquireLocks(0, 1, ref locksAcquired);
@@ -1973,19 +1904,7 @@ namespace System.Collections.Concurrent
[Conditional("DEBUG")]
private void Assert(bool condition)
{
- Contract.Assert(condition);
- }
-
- /// <summary>
- /// A helper function to obtain the string for a particular resource key.
- /// </summary>
- /// <param name="key"></param>
- /// <returns></returns>
- private string GetResource(string key)
- {
- Assert(key != null);
-
- return Environment.GetResourceString(key);
+ Debug.Assert(condition);
}
/// <summary>
@@ -2050,46 +1969,5 @@ namespace System.Collections.Concurrent
m_enumerator.Reset();
}
}
-
-#if !FEATURE_CORECLR
- /// <summary>
- /// Get the data array to be serialized
- /// </summary>
- [OnSerializing]
- private void OnSerializing(StreamingContext context)
- {
- Tables tables = m_tables;
-
- // save the data into the serialization array to be saved
- m_serializationArray = ToArray();
- m_serializationConcurrencyLevel = tables.m_locks.Length;
- m_serializationCapacity = tables.m_buckets.Length;
- m_comparer = (IEqualityComparer<TKey>)HashHelpers.GetEqualityComparerForSerialization(tables.m_comparer);
- }
-
- /// <summary>
- /// Construct the dictionary from a previously serialized one
- /// </summary>
- [OnDeserialized]
- private void OnDeserialized(StreamingContext context)
- {
- KeyValuePair<TKey, TValue>[] array = m_serializationArray;
-
- var buckets = new Node[m_serializationCapacity];
- var countPerLock = new int[m_serializationConcurrencyLevel];
-
- var locks = new object[m_serializationConcurrencyLevel];
- for (int i = 0; i < locks.Length; i++)
- {
- locks[i] = new object();
- }
-
- m_tables = new Tables(buckets, locks, countPerLock, m_comparer);
-
- InitializeFromCollection(array);
- m_serializationArray = null;
-
- }
-#endif
}
}
diff --git a/src/mscorlib/src/System/Collections/Concurrent/ConcurrentQueue.cs b/src/mscorlib/src/System/Collections/Concurrent/ConcurrentQueue.cs
index 9164ead..7aa5971 100644
--- a/src/mscorlib/src/System/Collections/Concurrent/ConcurrentQueue.cs
+++ b/src/mscorlib/src/System/Collections/Concurrent/ConcurrentQueue.cs
@@ -38,7 +38,6 @@ namespace System.Collections.Concurrent
[ComVisible(false)]
[DebuggerDisplay("Count = {Count}")]
[DebuggerTypeProxy(typeof(SystemCollectionsConcurrent_ProducerConsumerCollectionDebugView<>))]
- [HostProtection(Synchronization = true, ExternalThreading = true)]
[Serializable]
public class ConcurrentQueue<T> : IProducerConsumerCollection<T>, IReadOnlyCollection<T>
{
@@ -77,7 +76,7 @@ namespace System.Collections.Concurrent
int index = 0;
foreach (T element in collection)
{
- Contract.Assert(index >= 0 && index < SEGMENT_SIZE);
+ Debug.Assert(index >= 0 && index < SEGMENT_SIZE);
localTail.UnsafeAdd(element);
index++;
@@ -103,7 +102,7 @@ namespace System.Collections.Concurrent
{
if (collection == null)
{
- throw new ArgumentNullException("collection");
+ throw new ArgumentNullException(nameof(collection));
}
InitializeFromCollection(collection);
@@ -125,7 +124,7 @@ namespace System.Collections.Concurrent
[OnDeserialized]
private void OnDeserialized(StreamingContext context)
{
- Contract.Assert(m_serializationArray != null);
+ Debug.Assert(m_serializationArray != null);
InitializeFromCollection(m_serializationArray);
m_serializationArray = null;
}
@@ -160,7 +159,7 @@ namespace System.Collections.Concurrent
// Validate arguments.
if (array == null)
{
- throw new ArgumentNullException("array");
+ throw new ArgumentNullException(nameof(array));
}
// We must be careful not to corrupt the array, so we will first accumulate an
@@ -441,7 +440,7 @@ namespace System.Collections.Concurrent
{
if (array == null)
{
- throw new ArgumentNullException("array");
+ throw new ArgumentNullException(nameof(array));
}
// We must be careful not to corrupt the array, so we will first accumulate an
@@ -689,7 +688,7 @@ namespace System.Collections.Concurrent
m_array = new T[SEGMENT_SIZE];
m_state = new VolatileBool[SEGMENT_SIZE]; //all initialized to false
m_high = -1;
- Contract.Assert(index >= 0);
+ Debug.Assert(index >= 0);
m_index = index;
m_source = source;
}
@@ -721,7 +720,7 @@ namespace System.Collections.Concurrent
/// <param name="value"></param>
internal void UnsafeAdd(T value)
{
- Contract.Assert(m_high < SEGMENT_SIZE - 1);
+ Debug.Assert(m_high < SEGMENT_SIZE - 1);
m_high++;
m_array[m_high] = value;
m_state[m_high].m_value = true;
@@ -737,7 +736,7 @@ namespace System.Collections.Concurrent
/// <returns>the reference to the new Segment</returns>
internal Segment UnsafeGrow()
{
- Contract.Assert(m_high >= SEGMENT_SIZE - 1);
+ Debug.Assert(m_high >= SEGMENT_SIZE - 1);
Segment newSegment = new Segment(m_index + 1, m_source); //m_index is Int64, we don't need to worry about overflow
m_next = newSegment;
return newSegment;
@@ -753,7 +752,7 @@ namespace System.Collections.Concurrent
//no CAS is needed, since there is no contention (other threads are blocked, busy waiting)
Segment newSegment = new Segment(m_index + 1, m_source); //m_index is Int64, we don't need to worry about overflow
m_next = newSegment;
- Contract.Assert(m_source.m_tail == this);
+ Debug.Assert(m_source.m_tail == this);
m_source.m_tail = m_next;
}
@@ -860,7 +859,7 @@ namespace System.Collections.Concurrent
{
spinLocal.SpinOnce();
}
- Contract.Assert(m_source.m_head == this);
+ Debug.Assert(m_source.m_head == this);
m_source.m_head = m_next;
}
return true;
diff --git a/src/mscorlib/src/System/Collections/Concurrent/ConcurrentStack.cs b/src/mscorlib/src/System/Collections/Concurrent/ConcurrentStack.cs
index 15d4176..c36d96c 100644
--- a/src/mscorlib/src/System/Collections/Concurrent/ConcurrentStack.cs
+++ b/src/mscorlib/src/System/Collections/Concurrent/ConcurrentStack.cs
@@ -45,10 +45,6 @@ namespace System.Collections.Concurrent
/// </remarks>
[DebuggerDisplay("Count = {Count}")]
[DebuggerTypeProxy(typeof(SystemCollectionsConcurrent_ProducerConsumerCollectionDebugView<>))]
- [HostProtection(Synchronization = true, ExternalThreading = true)]
-#if !FEATURE_CORECLR
- [Serializable]
-#endif //!FEATURE_CORECLR
public class ConcurrentStack<T> : IProducerConsumerCollection<T>, IReadOnlyCollection<T>
{
/// <summary>
@@ -70,15 +66,8 @@ namespace System.Collections.Concurrent
}
}
-#if !FEATURE_CORECLR
- [NonSerialized]
-#endif //!FEATURE_CORECLR
private volatile Node m_head; // The stack is a singly linked list, and only remembers the head.
-#if !FEATURE_CORECLR
- private T[] m_serializationArray; // Used for custom serialization.
-#endif //!FEATURE_CORECLR
-
private const int BACKOFF_MAX_YIELDS = 8; // Arbitrary number to cap backoff.
/// <summary>
@@ -101,7 +90,7 @@ namespace System.Collections.Concurrent
{
if (collection == null)
{
- throw new ArgumentNullException("collection");
+ throw new ArgumentNullException(nameof(collection));
}
InitializeFromCollection(collection);
}
@@ -124,50 +113,6 @@ namespace System.Collections.Concurrent
m_head = lastNode;
}
-#if !FEATURE_CORECLR
- /// <summary>
- /// Get the data array to be serialized
- /// </summary>
- [OnSerializing]
- private void OnSerializing(StreamingContext context)
- {
- // save the data into the serialization array to be saved
- m_serializationArray = ToArray();
- }
-
- /// <summary>
- /// Construct the stack from a previously seiralized one
- /// </summary>
- [OnDeserialized]
- private void OnDeserialized(StreamingContext context)
- {
- Contract.Assert(m_serializationArray != null);
- // Add the elements to our stack. We need to add them from head-to-tail, to
- // preserve the original ordering of the stack before serialization.
- Node prevNode = null;
- Node head = null;
- for (int i = 0; i < m_serializationArray.Length; i++)
- {
- Node currNode = new Node(m_serializationArray[i]);
-
- if (prevNode == null)
- {
- head = currNode;
- }
- else
- {
- prevNode.m_next = currNode;
- }
-
- prevNode = currNode;
- }
-
- m_head = head;
- m_serializationArray = null;
- }
-#endif //!FEATURE_CORECLR
-
-
/// <summary>
/// Gets a value that indicates whether the <see cref="ConcurrentStack{T}"/> is empty.
/// </summary>
@@ -221,7 +166,6 @@ namespace System.Collections.Concurrent
}
}
-
/// <summary>
/// Gets a value indicating whether access to the <see cref="T:System.Collections.ICollection"/> is
/// synchronized with the SyncRoot.
@@ -293,7 +237,7 @@ namespace System.Collections.Concurrent
// Validate arguments.
if (array == null)
{
- throw new ArgumentNullException("array");
+ throw new ArgumentNullException(nameof(array));
}
// We must be careful not to corrupt the array, so we will first accumulate an
@@ -327,7 +271,7 @@ namespace System.Collections.Concurrent
{
if (array == null)
{
- throw new ArgumentNullException("array");
+ throw new ArgumentNullException(nameof(array));
}
// We must be careful not to corrupt the array, so we will first accumulate an
@@ -379,7 +323,7 @@ namespace System.Collections.Concurrent
{
if (items == null)
{
- throw new ArgumentNullException("items");
+ throw new ArgumentNullException(nameof(items));
}
PushRange(items, 0, items.Length);
}
@@ -455,13 +399,6 @@ namespace System.Collections.Concurrent
}
while (Interlocked.CompareExchange(
ref m_head, head, tail.m_next) != tail.m_next);
-
-#if !FEATURE_CORECLR
- if (CDSCollectionETWBCLProvider.Log.IsEnabled())
- {
- CDSCollectionETWBCLProvider.Log.ConcurrentStack_FastPushFailed(spin.Count);
- }
-#endif // !FEATURE_CORECLR
}
/// <summary>
@@ -471,16 +408,16 @@ namespace System.Collections.Concurrent
{
if (items == null)
{
- throw new ArgumentNullException("items");
+ throw new ArgumentNullException(nameof(items));
}
if (count < 0)
{
- throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ConcurrentStack_PushPopRange_CountOutOfRange"));
+ throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ConcurrentStack_PushPopRange_CountOutOfRange"));
}
int length = items.Length;
if (startIndex >= length || startIndex < 0)
{
- throw new ArgumentOutOfRangeException("startIndex", Environment.GetResourceString("ConcurrentStack_PushPopRange_StartOutOfRange"));
+ throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ConcurrentStack_PushPopRange_StartOutOfRange"));
}
if (length - count < startIndex) //instead of (startIndex + count > items.Length) to prevent overflow
{
@@ -584,7 +521,7 @@ namespace System.Collections.Concurrent
{
if (items == null)
{
- throw new ArgumentNullException("items");
+ throw new ArgumentNullException(nameof(items));
}
return TryPopRange(items, 0, items.Length);
@@ -683,12 +620,6 @@ namespace System.Collections.Concurrent
// Is the stack empty?
if (head == null)
{
-#if !FEATURE_CORECLR
- if (count == 1 && CDSCollectionETWBCLProvider.Log.IsEnabled())
- {
- CDSCollectionETWBCLProvider.Log.ConcurrentStack_FastPopFailed(spin.Count);
- }
-#endif //!FEATURE_CORECLR
poppedHead = null;
return 0;
}
@@ -702,12 +633,6 @@ namespace System.Collections.Concurrent
// Try to swap the new head. If we succeed, break out of the loop.
if (Interlocked.CompareExchange(ref m_head, next.m_next, head) == head)
{
-#if !FEATURE_CORECLR
- if (count == 1 && CDSCollectionETWBCLProvider.Log.IsEnabled())
- {
- CDSCollectionETWBCLProvider.Log.ConcurrentStack_FastPopFailed(spin.Count);
- }
-#endif //!FEATURE_CORECLR
// Return the popped Node.
poppedHead = head;
return nodesCount;
diff --git a/src/mscorlib/src/System/Collections/Concurrent/IProducerConsumerCollection.cs b/src/mscorlib/src/System/Collections/Concurrent/IProducerConsumerCollection.cs
index a74f690..56be775 100644
--- a/src/mscorlib/src/System/Collections/Concurrent/IProducerConsumerCollection.cs
+++ b/src/mscorlib/src/System/Collections/Concurrent/IProducerConsumerCollection.cs
@@ -97,7 +97,7 @@ namespace System.Collections.Concurrent
{
if (collection == null)
{
- throw new ArgumentNullException("collection");
+ throw new ArgumentNullException(nameof(collection));
}
m_collection = collection;
diff --git a/src/mscorlib/src/System/Collections/Concurrent/OrderablePartitioner.cs b/src/mscorlib/src/System/Collections/Concurrent/OrderablePartitioner.cs
index 02263b7..33e3c88 100644
--- a/src/mscorlib/src/System/Collections/Concurrent/OrderablePartitioner.cs
+++ b/src/mscorlib/src/System/Collections/Concurrent/OrderablePartitioner.cs
@@ -61,7 +61,6 @@ namespace System.Collections.Concurrent
/// </ol>
/// </para>
/// </remarks>
- [HostProtection(Synchronization = true, ExternalThreading = true)]
public abstract class OrderablePartitioner<TSource> : Partitioner<TSource>
{
/// <summary>
diff --git a/src/mscorlib/src/System/Collections/Concurrent/Partitioner.cs b/src/mscorlib/src/System/Collections/Concurrent/Partitioner.cs
index 3d54c14..0192b19 100644
--- a/src/mscorlib/src/System/Collections/Concurrent/Partitioner.cs
+++ b/src/mscorlib/src/System/Collections/Concurrent/Partitioner.cs
@@ -44,7 +44,6 @@ namespace System.Collections.Concurrent
/// </ol>
/// </para>
/// </remarks>
- [HostProtection(Synchronization = true, ExternalThreading = true)]
public abstract class Partitioner<TSource>
{
/// <summary>
diff --git a/src/mscorlib/src/System/Collections/Concurrent/PartitionerStatic.cs b/src/mscorlib/src/System/Collections/Concurrent/PartitionerStatic.cs
index 2169c6d..9b36c05 100644
--- a/src/mscorlib/src/System/Collections/Concurrent/PartitionerStatic.cs
+++ b/src/mscorlib/src/System/Collections/Concurrent/PartitionerStatic.cs
@@ -14,6 +14,7 @@
using System.Collections.Generic;
using System.Security.Permissions;
using System.Threading;
+using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
@@ -26,9 +27,6 @@ namespace System.Collections.Concurrent
/// non-blocking. These behaviors can be overridden via this enumeration.
/// </summary>
[Flags]
-#if !FEATURE_CORECLR
- [Serializable]
-#endif
public enum EnumerablePartitionerOptions
{
/// <summary>
@@ -71,7 +69,6 @@ namespace System.Collections.Concurrent
/// thread.
/// </para>
/// </remarks>
- [HostProtection(Synchronization = true, ExternalThreading = true)]
public static class Partitioner
{
/// <summary>
@@ -91,7 +88,7 @@ namespace System.Collections.Concurrent
{
if (list == null)
{
- throw new ArgumentNullException("list");
+ throw new ArgumentNullException(nameof(list));
}
if (loadBalance)
{
@@ -122,7 +119,7 @@ namespace System.Collections.Concurrent
if (array == null)
{
- throw new ArgumentNullException("array");
+ throw new ArgumentNullException(nameof(array));
}
if (loadBalance)
{
@@ -172,11 +169,11 @@ namespace System.Collections.Concurrent
{
if (source == null)
{
- throw new ArgumentNullException("source");
+ throw new ArgumentNullException(nameof(source));
}
if ((partitionerOptions & (~EnumerablePartitionerOptions.NoBuffering)) != 0)
- throw new ArgumentOutOfRangeException("partitionerOptions");
+ throw new ArgumentOutOfRangeException(nameof(partitionerOptions));
return (new DynamicPartitionerForIEnumerable<TSource>(source, partitionerOptions));
}
@@ -194,7 +191,7 @@ namespace System.Collections.Concurrent
// load balancing on a busy system if you make it higher than 1.
int coreOversubscriptionRate = 3;
- if (toExclusive <= fromInclusive) throw new ArgumentOutOfRangeException("toExclusive");
+ if (toExclusive <= fromInclusive) throw new ArgumentOutOfRangeException(nameof(toExclusive));
long rangeSize = (toExclusive - fromInclusive) /
(PlatformHelper.ProcessorCount * coreOversubscriptionRate);
if (rangeSize == 0) rangeSize = 1;
@@ -212,8 +209,8 @@ namespace System.Collections.Concurrent
/// less than or equal to 0.</exception>
public static OrderablePartitioner<Tuple<long, long>> Create(long fromInclusive, long toExclusive, long rangeSize)
{
- if (toExclusive <= fromInclusive) throw new ArgumentOutOfRangeException("toExclusive");
- if (rangeSize <= 0) throw new ArgumentOutOfRangeException("rangeSize");
+ if (toExclusive <= fromInclusive) throw new ArgumentOutOfRangeException(nameof(toExclusive));
+ if (rangeSize <= 0) throw new ArgumentOutOfRangeException(nameof(rangeSize));
return Partitioner.Create(CreateRanges(fromInclusive, toExclusive, rangeSize), EnumerablePartitionerOptions.NoBuffering); // chunk one range at a time
}
@@ -251,7 +248,7 @@ namespace System.Collections.Concurrent
// load balancing on a busy system if you make it higher than 1.
int coreOversubscriptionRate = 3;
- if (toExclusive <= fromInclusive) throw new ArgumentOutOfRangeException("toExclusive");
+ if (toExclusive <= fromInclusive) throw new ArgumentOutOfRangeException(nameof(toExclusive));
int rangeSize = (toExclusive - fromInclusive) /
(PlatformHelper.ProcessorCount * coreOversubscriptionRate);
if (rangeSize == 0) rangeSize = 1;
@@ -269,8 +266,8 @@ namespace System.Collections.Concurrent
/// less than or equal to 0.</exception>
public static OrderablePartitioner<Tuple<int, int>> Create(int fromInclusive, int toExclusive, int rangeSize)
{
- if (toExclusive <= fromInclusive) throw new ArgumentOutOfRangeException("toExclusive");
- if (rangeSize <= 0) throw new ArgumentOutOfRangeException("rangeSize");
+ if (toExclusive <= fromInclusive) throw new ArgumentOutOfRangeException(nameof(toExclusive));
+ if (rangeSize <= 0) throw new ArgumentOutOfRangeException(nameof(rangeSize));
return Partitioner.Create(CreateRanges(fromInclusive, toExclusive, rangeSize), EnumerablePartitionerOptions.NoBuffering); // chunk one range at a time
}
@@ -431,7 +428,7 @@ namespace System.Collections.Concurrent
//perform deferred allocating of the local variables.
if (m_localOffset == null)
{
- Contract.Assert(m_currentChunkSize == null);
+ Debug.Assert(m_currentChunkSize == null);
m_localOffset = new SharedInt(-1);
m_currentChunkSize = new SharedInt(0);
m_doublingCountdown = CHUNK_DOUBLING_RATE;
@@ -449,7 +446,7 @@ namespace System.Collections.Concurrent
{
// The second part of the || condition is necessary to handle the case when MoveNext() is called
// after a previous MoveNext call returned false.
- Contract.Assert(m_localOffset.Value == m_currentChunkSize.Value - 1 || m_currentChunkSize.Value == 0);
+ Debug.Assert(m_localOffset.Value == m_currentChunkSize.Value - 1 || m_currentChunkSize.Value == 0);
//set the requested chunk size to a proper value
int requestedChunkSize;
@@ -470,11 +467,11 @@ namespace System.Collections.Concurrent
// Decrement your doubling countdown
m_doublingCountdown--;
- Contract.Assert(requestedChunkSize > 0 && requestedChunkSize <= m_maxChunkSize);
+ Debug.Assert(requestedChunkSize > 0 && requestedChunkSize <= m_maxChunkSize);
//GrabNextChunk will update the value of m_currentChunkSize
if (GrabNextChunk(requestedChunkSize))
{
- Contract.Assert(m_currentChunkSize.Value <= requestedChunkSize && m_currentChunkSize.Value > 0);
+ Debug.Assert(m_currentChunkSize.Value <= requestedChunkSize && m_currentChunkSize.Value > 0);
m_localOffset.Value = 0;
return true;
}
@@ -517,7 +514,7 @@ namespace System.Collections.Concurrent
{
if (partitionCount <= 0)
{
- throw new ArgumentOutOfRangeException("partitionCount");
+ throw new ArgumentOutOfRangeException(nameof(partitionCount));
}
IEnumerator<KeyValuePair<long, TSource>>[] partitions
= new IEnumerator<KeyValuePair<long, TSource>>[partitionCount];
@@ -715,10 +712,10 @@ namespace System.Collections.Concurrent
/// </returns>
internal bool GrabChunk_Single(KeyValuePair<long,TSource>[] destArray, int requestedChunkSize, ref int actualNumElementsGrabbed)
{
- Contract.Assert(m_useSingleChunking, "Expected m_useSingleChecking to be true");
- Contract.Assert(requestedChunkSize == 1, "Got requested chunk size of " + requestedChunkSize + " when single-chunking was on");
- Contract.Assert(actualNumElementsGrabbed == 0, "Expected actualNumElementsGrabbed == 0, instead it is " + actualNumElementsGrabbed);
- Contract.Assert(destArray.Length == 1, "Expected destArray to be of length 1, instead its length is " + destArray.Length);
+ Debug.Assert(m_useSingleChunking, "Expected m_useSingleChecking to be true");
+ Debug.Assert(requestedChunkSize == 1, "Got requested chunk size of " + requestedChunkSize + " when single-chunking was on");
+ Debug.Assert(actualNumElementsGrabbed == 0, "Expected actualNumElementsGrabbed == 0, instead it is " + actualNumElementsGrabbed);
+ Debug.Assert(destArray.Length == 1, "Expected destArray to be of length 1, instead its length is " + destArray.Length);
lock (m_sharedLock)
{
@@ -764,8 +761,8 @@ namespace System.Collections.Concurrent
/// </returns>
internal bool GrabChunk_Buffered(KeyValuePair<long,TSource>[] destArray, int requestedChunkSize, ref int actualNumElementsGrabbed)
{
- Contract.Assert(requestedChunkSize > 0);
- Contract.Assert(!m_useSingleChunking, "Did not expect to be in single-chunking mode");
+ Debug.Assert(requestedChunkSize > 0);
+ Debug.Assert(!m_useSingleChunking, "Did not expect to be in single-chunking mode");
TryCopyFromFillBuffer(destArray, requestedChunkSize, ref actualNumElementsGrabbed);
@@ -803,7 +800,7 @@ namespace System.Collections.Concurrent
while( m_activeCopiers > 0) sw.SpinOnce();
}
- Contract.Assert(m_sharedIndex != null); //already been allocated in MoveNext() before calling GrabNextChunk
+ Debug.Assert(m_sharedIndex != null); //already been allocated in MoveNext() before calling GrabNextChunk
// Now's the time to actually enumerate the source
@@ -940,7 +937,7 @@ namespace System.Collections.Concurrent
/// </returns>
override protected bool GrabNextChunk(int requestedChunkSize)
{
- Contract.Assert(requestedChunkSize > 0);
+ Debug.Assert(requestedChunkSize > 0);
if (HasNoElementsLeft)
{
@@ -973,8 +970,8 @@ namespace System.Collections.Concurrent
{
//we only set it from false to true once
//we should never set it back in any circumstances
- Contract.Assert(value);
- Contract.Assert(!m_hasNoElementsLeft.Value);
+ Debug.Assert(value);
+ Debug.Assert(!m_hasNoElementsLeft.Value);
m_hasNoElementsLeft.Value = true;
}
}
@@ -988,8 +985,8 @@ namespace System.Collections.Concurrent
{
throw new InvalidOperationException(Environment.GetResourceString("PartitionerStatic_CurrentCalledBeforeMoveNext"));
}
- Contract.Assert(m_localList != null);
- Contract.Assert(m_localOffset.Value >= 0 && m_localOffset.Value < m_currentChunkSize.Value);
+ Debug.Assert(m_localList != null);
+ Debug.Assert(m_localOffset.Value >= 0 && m_localOffset.Value < m_currentChunkSize.Value);
return (m_localList[m_localOffset.Value]);
}
}
@@ -1053,7 +1050,7 @@ namespace System.Collections.Concurrent
{
if (partitionCount <= 0)
{
- throw new ArgumentOutOfRangeException("partitionCount");
+ throw new ArgumentOutOfRangeException(nameof(partitionCount));
}
IEnumerator<KeyValuePair<long, TSource>>[] partitions
= new IEnumerator<KeyValuePair<long, TSource>>[partitionCount];
@@ -1127,11 +1124,11 @@ namespace System.Collections.Concurrent
/// </returns>
override protected bool GrabNextChunk(int requestedChunkSize)
{
- Contract.Assert(requestedChunkSize > 0);
+ Debug.Assert(requestedChunkSize > 0);
while (!HasNoElementsLeft)
{
- Contract.Assert(m_sharedIndex != null);
+ Debug.Assert(m_sharedIndex != null);
// use the new Volatile.Read method because it is cheaper than Interlocked.Read on AMD64 architecture
long oldSharedIndex = Volatile.Read(ref m_sharedIndex.Value);
@@ -1173,13 +1170,13 @@ namespace System.Collections.Concurrent
{
get
{
- Contract.Assert(m_sharedIndex != null);
+ Debug.Assert(m_sharedIndex != null);
// use the new Volatile.Read method because it is cheaper than Interlocked.Read on AMD64 architecture
return Volatile.Read(ref m_sharedIndex.Value) >= SourceCount - 1;
}
set
{
- Contract.Assert(false);
+ Debug.Assert(false);
}
}
@@ -1268,7 +1265,7 @@ namespace System.Collections.Concurrent
throw new InvalidOperationException(Environment.GetResourceString("PartitionerStatic_CurrentCalledBeforeMoveNext"));
}
- Contract.Assert(m_localOffset.Value >= 0 && m_localOffset.Value < m_currentChunkSize.Value);
+ Debug.Assert(m_localOffset.Value >= 0 && m_localOffset.Value < m_currentChunkSize.Value);
return new KeyValuePair<long, TSource>(m_startIndex + m_localOffset.Value,
m_sharedReader[m_startIndex + m_localOffset.Value]);
}
@@ -1352,7 +1349,7 @@ namespace System.Collections.Concurrent
throw new InvalidOperationException(Environment.GetResourceString("PartitionerStatic_CurrentCalledBeforeMoveNext"));
}
- Contract.Assert(m_localOffset.Value >= 0 && m_localOffset.Value < m_currentChunkSize.Value);
+ Debug.Assert(m_localOffset.Value >= 0 && m_localOffset.Value < m_currentChunkSize.Value);
return new KeyValuePair<long, TSource>(m_startIndex + m_localOffset.Value,
m_sharedReader[m_startIndex + m_localOffset.Value]);
}
@@ -1417,7 +1414,7 @@ namespace System.Collections.Concurrent
{
if (partitionCount <= 0)
{
- throw new ArgumentOutOfRangeException("partitionCount");
+ throw new ArgumentOutOfRangeException(nameof(partitionCount));
}
int quotient, remainder;
@@ -1539,7 +1536,7 @@ namespace System.Collections.Concurrent
internal StaticIndexRangePartitionerForIList(IList<TSource> list)
: base()
{
- Contract.Assert(list != null);
+ Debug.Assert(list != null);
m_list = list;
}
override protected int SourceCount
@@ -1565,7 +1562,7 @@ namespace System.Collections.Concurrent
internal StaticIndexRangePartitionForIList(IList<TSource> list, int startIndex, int endIndex)
: base(startIndex, endIndex)
{
- Contract.Assert(startIndex >= 0 && endIndex <= list.Count - 1);
+ Debug.Assert(startIndex >= 0 && endIndex <= list.Count - 1);
m_list = list;
}
@@ -1579,7 +1576,7 @@ namespace System.Collections.Concurrent
throw new InvalidOperationException(Environment.GetResourceString("PartitionerStatic_CurrentCalledBeforeMoveNext"));
}
- Contract.Assert(m_offset >= m_startIndex && m_offset <= m_endIndex);
+ Debug.Assert(m_offset >= m_startIndex && m_offset <= m_endIndex);
return (new KeyValuePair<long, TSource>(m_offset, m_list[m_offset]));
}
}
@@ -1597,7 +1594,7 @@ namespace System.Collections.Concurrent
internal StaticIndexRangePartitionerForArray(TSource[] array)
: base()
{
- Contract.Assert(array != null);
+ Debug.Assert(array != null);
m_array = array;
}
override protected int SourceCount
@@ -1622,7 +1619,7 @@ namespace System.Collections.Concurrent
internal StaticIndexRangePartitionForArray(TSource[] array, int startIndex, int endIndex)
: base(startIndex, endIndex)
{
- Contract.Assert(startIndex >= 0 && endIndex <= array.Length - 1);
+ Debug.Assert(startIndex >= 0 && endIndex <= array.Length - 1);
m_array = array;
}
@@ -1636,7 +1633,7 @@ namespace System.Collections.Concurrent
throw new InvalidOperationException(Environment.GetResourceString("PartitionerStatic_CurrentCalledBeforeMoveNext"));
}
- Contract.Assert(m_offset >= m_startIndex && m_offset <= m_endIndex);
+ Debug.Assert(m_offset >= m_startIndex && m_offset <= m_endIndex);
return (new KeyValuePair<long, TSource>(m_offset, m_array[m_offset]));
}
}
@@ -1704,30 +1701,15 @@ namespace System.Collections.Concurrent
if (typeof(TSource).IsValueType)
{
-#if !FEATURE_CORECLR // Marshal.SizeOf is not supported in CoreCLR
-
- if (typeof(TSource).StructLayoutAttribute.Value == LayoutKind.Explicit)
- {
- chunkSize = Math.Max(1, DEFAULT_BYTES_PER_CHUNK / Marshal.SizeOf(typeof(TSource)));
- }
- else
- {
- // We choose '128' because this ensures, no matter the actual size of the value type,
- // the total bytes used will be a multiple of 128. This ensures it's cache aligned.
- chunkSize = 128;
- }
-#else
chunkSize = 128;
-#endif
}
else
{
- Contract.Assert((DEFAULT_BYTES_PER_CHUNK % IntPtr.Size) == 0, "bytes per chunk should be a multiple of pointer size");
+ Debug.Assert((DEFAULT_BYTES_PER_CHUNK % IntPtr.Size) == 0, "bytes per chunk should be a multiple of pointer size");
chunkSize = (DEFAULT_BYTES_PER_CHUNK / IntPtr.Size);
}
return chunkSize;
}
#endregion
-
}
}
diff --git a/src/mscorlib/src/System/Collections/DictionaryEntry.cs b/src/mscorlib/src/System/Collections/DictionaryEntry.cs
index fc1d57f..3ee392b 100644
--- a/src/mscorlib/src/System/Collections/DictionaryEntry.cs
+++ b/src/mscorlib/src/System/Collections/DictionaryEntry.cs
@@ -51,5 +51,12 @@ namespace System.Collections {
_value = value;
}
}
+
+ // BLOCKED (do not add now): [EditorBrowsable(EditorBrowsableState.Never)]
+ public void Deconstruct(out object key, out object value)
+ {
+ key = Key;
+ value = Value;
+ }
}
}
diff --git a/src/mscorlib/src/System/Collections/EmptyReadOnlyDictionaryInternal.cs b/src/mscorlib/src/System/Collections/EmptyReadOnlyDictionaryInternal.cs
index 6e28493..a610fce 100644
--- a/