Merge pull request #9229 from sandreenko/increase_gtCallMoreFlags_size
authorsandreenko <seandree@microsoft.com>
Thu, 2 Feb 2017 22:07:59 +0000 (14:07 -0800)
committerGitHub <noreply@github.com>
Thu, 2 Feb 2017 22:07:59 +0000 (14:07 -0800)
increase gtCallMoreFlags size

198 files changed:
Documentation/botr/clr-abi.md
dependencies.props
netci.groovy
src/ToolBox/SOS/lldbplugin/services.cpp
src/debug/daccess/dacdbiimplstackwalk.cpp
src/debug/ee/debugger.inl
src/debug/ee/i386/x86walker.cpp
src/debug/shared/i386/primitives.cpp
src/gc/gc.cpp
src/inc/regdisp.h
src/mscorlib/corefx/SR.cs
src/mscorlib/corefx/System/Globalization/Calendar.cs
src/mscorlib/corefx/System/Globalization/CalendarWeekRule.cs
src/mscorlib/corefx/System/Globalization/CalendricalCalculationsHelper.cs
src/mscorlib/corefx/System/Globalization/CharUnicodeInfo.cs
src/mscorlib/corefx/System/Globalization/ChineseLunisolarCalendar.cs
src/mscorlib/corefx/System/Globalization/CompareInfo.Windows.cs
src/mscorlib/corefx/System/Globalization/CultureData.Windows.cs
src/mscorlib/corefx/System/Globalization/CultureNotFoundException.cs
src/mscorlib/corefx/System/Globalization/CultureTypes.cs
src/mscorlib/corefx/System/Globalization/DigitShapes.cs
src/mscorlib/corefx/System/Globalization/EastAsianLunisolarCalendar.cs
src/mscorlib/corefx/System/Globalization/GregorianCalendar.cs
src/mscorlib/corefx/System/Globalization/HebrewCalendar.cs
src/mscorlib/corefx/System/Globalization/HijriCalendar.Win32.cs
src/mscorlib/corefx/System/Globalization/HijriCalendar.cs
src/mscorlib/corefx/System/Globalization/IdnMapping.Windows.cs
src/mscorlib/corefx/System/Globalization/JapaneseCalendar.Win32.cs
src/mscorlib/corefx/System/Globalization/JapaneseCalendar.cs
src/mscorlib/corefx/System/Globalization/JapaneseLunisolarCalendar.cs
src/mscorlib/corefx/System/Globalization/JulianCalendar.cs
src/mscorlib/corefx/System/Globalization/KoreanCalendar.cs
src/mscorlib/corefx/System/Globalization/KoreanLunisolarCalendar.cs
src/mscorlib/corefx/System/Globalization/SortKey.cs
src/mscorlib/corefx/System/Globalization/SortVersion.cs
src/mscorlib/corefx/System/Globalization/StringInfo.cs
src/mscorlib/corefx/System/Globalization/TaiwanCalendar.cs
src/mscorlib/corefx/System/Globalization/TaiwanLunisolarCalendar.cs
src/mscorlib/corefx/System/Globalization/TextElementEnumerator.cs
src/mscorlib/corefx/System/Globalization/TextInfo.cs
src/mscorlib/corefx/System/Globalization/ThaiBuddhistCalendar.cs
src/mscorlib/corefx/System/Globalization/UmAlQuraCalendar.cs
src/mscorlib/corefx/System/IO/FileStream.NetStandard17.cs [deleted file]
src/mscorlib/corefx/System/IO/FileStream.cs
src/mscorlib/model.xml
src/mscorlib/mscorlib.shared.sources.props
src/mscorlib/ref/mscorlib.cs
src/mscorlib/src/System.Private.CoreLib.txt
src/mscorlib/src/System/AccessViolationException.cs
src/mscorlib/src/System/Action.cs
src/mscorlib/src/System/Activator.cs
src/mscorlib/src/System/AppDomain.cs
src/mscorlib/src/System/ApplicationException.cs
src/mscorlib/src/System/ArgIterator.cs
src/mscorlib/src/System/ArgumentException.cs
src/mscorlib/src/System/ArgumentNullException.cs
src/mscorlib/src/System/ArithmeticException.cs
src/mscorlib/src/System/ArrayTypeMismatchException.cs
src/mscorlib/src/System/AsyncCallback.cs
src/mscorlib/src/System/Attribute.cs
src/mscorlib/src/System/AttributeTargets.cs
src/mscorlib/src/System/CLSCompliantAttribute.cs
src/mscorlib/src/System/CharEnumerator.cs
src/mscorlib/src/System/Collections/Concurrent/ConcurrentQueue.cs
src/mscorlib/src/System/DataMisalignedException.cs
src/mscorlib/src/System/DateTimeKind.cs
src/mscorlib/src/System/DayOfWeek.cs
src/mscorlib/src/System/DivideByZeroException.cs
src/mscorlib/src/System/DuplicateWaitObjectException.cs
src/mscorlib/src/System/EntryPointNotFoundException.cs
src/mscorlib/src/System/EventArgs.cs
src/mscorlib/src/System/EventHandler.cs
src/mscorlib/src/System/ExecutionEngineException.cs
src/mscorlib/src/System/FieldAccessException.cs
src/mscorlib/src/System/FlagsAttribute.cs
src/mscorlib/src/System/FormatException.cs
src/mscorlib/src/System/FormattableString.cs
src/mscorlib/src/System/IAppDomain.cs [deleted file]
src/mscorlib/src/System/IAsyncResult.cs
src/mscorlib/src/System/IComparable.cs
src/mscorlib/src/System/IConvertible.cs
src/mscorlib/src/System/ICustomFormatter.cs
src/mscorlib/src/System/IDisposable.cs
src/mscorlib/src/System/IEquatable.cs
src/mscorlib/src/System/IFormatProvider.cs
src/mscorlib/src/System/IFormattable.cs
src/mscorlib/src/System/IO/File.cs
src/mscorlib/src/System/IO/StreamReader.cs
src/mscorlib/src/System/IObservable.cs
src/mscorlib/src/System/IObserver.cs
src/mscorlib/src/System/IProgress.cs
src/mscorlib/src/System/IndexOutOfRangeException.cs
src/mscorlib/src/System/InsufficientExecutionStackException.cs
src/mscorlib/src/System/InvalidCastException.cs
src/mscorlib/src/System/InvalidOperationException.cs
src/mscorlib/src/System/InvalidProgramException.cs
src/mscorlib/src/System/InvalidTimeZoneException.cs
src/mscorlib/src/System/MarshalByRefObject.cs
src/mscorlib/src/System/MemberAccessException.cs
src/mscorlib/src/System/MethodAccessException.cs
src/mscorlib/src/System/MidpointRounding.cs
src/mscorlib/src/System/MulticastNotSupportedException.cs
src/mscorlib/src/System/NotFiniteNumberException.cs
src/mscorlib/src/System/NotImplementedException.cs
src/mscorlib/src/System/NotSupportedException.cs
src/mscorlib/src/System/NullReferenceException.cs
src/mscorlib/src/System/ObjectDisposedException.cs
src/mscorlib/src/System/ObsoleteAttribute.cs
src/mscorlib/src/System/OverflowException.cs
src/mscorlib/src/System/ParamArrayAttribute.cs
src/mscorlib/src/System/PlatformNotSupportedException.cs
src/mscorlib/src/System/Progress.cs
src/mscorlib/src/System/RankException.cs
src/mscorlib/src/System/ReadOnlySpan.cs
src/mscorlib/src/System/Reflection/Assembly.cs
src/mscorlib/src/System/Reflection/AssemblyName.cs
src/mscorlib/src/System/Reflection/ComInterfaces.cs [deleted file]
src/mscorlib/src/System/Reflection/ConstructorInfo.cs
src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs
src/mscorlib/src/System/Reflection/Emit/ComInterfaces.cs [deleted file]
src/mscorlib/src/System/Reflection/Emit/ConstructorBuilder.cs
src/mscorlib/src/System/Reflection/Emit/CustomAttributeBuilder.cs
src/mscorlib/src/System/Reflection/Emit/EnumBuilder.cs
src/mscorlib/src/System/Reflection/Emit/EventBuilder.cs
src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs
src/mscorlib/src/System/Reflection/Emit/ILGenerator.cs
src/mscorlib/src/System/Reflection/Emit/LocalBuilder.cs
src/mscorlib/src/System/Reflection/Emit/MethodBuilder.cs
src/mscorlib/src/System/Reflection/Emit/ModuleBuilder.cs
src/mscorlib/src/System/Reflection/Emit/ParameterBuilder.cs
src/mscorlib/src/System/Reflection/Emit/PropertyBuilder.cs
src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs
src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs
src/mscorlib/src/System/Reflection/EventInfo.cs
src/mscorlib/src/System/Reflection/FieldInfo.cs
src/mscorlib/src/System/Reflection/MemberInfo.cs
src/mscorlib/src/System/Reflection/MethodBase.cs
src/mscorlib/src/System/Reflection/MethodInfo.cs
src/mscorlib/src/System/Reflection/Module.cs
src/mscorlib/src/System/Reflection/ParameterInfo.cs
src/mscorlib/src/System/Reflection/PropertyInfo.cs
src/mscorlib/src/System/Resources/ResourceReader.cs
src/mscorlib/src/System/Span.cs
src/mscorlib/src/System/StackOverflowException.cs
src/mscorlib/src/System/StringComparison.cs
src/mscorlib/src/System/StringSplitOptions.cs
src/mscorlib/src/System/SystemException.cs
src/mscorlib/src/System/ThreadAttributes.cs
src/mscorlib/src/System/ThreadStaticAttribute.cs
src/mscorlib/src/System/Threading/SpinLock.cs
src/mscorlib/src/System/Threading/Thread.cs
src/mscorlib/src/System/Threading/ThreadPool.cs
src/mscorlib/src/System/TimeZoneNotFoundException.cs
src/mscorlib/src/System/TimeoutException.cs
src/mscorlib/src/System/TupleExtensions.cs
src/mscorlib/src/System/Type.cs
src/mscorlib/src/System/TypeAccessException.cs
src/mscorlib/src/System/TypeCode.cs
src/mscorlib/src/System/TypeInitializationException.cs
src/mscorlib/src/System/UnauthorizedAccessException.cs
src/mscorlib/src/System/UnhandledExceptionEventArgs.cs
src/mscorlib/src/System/UnhandledExceptionEventHandler.cs
src/mscorlib/src/System/ValueTuple.cs
src/mscorlib/src/System/Void.cs
src/mscorlib/src/System/_LocalDataStore.cs [deleted file]
src/mscorlib/src/System/_LocalDataStoreMgr.cs [deleted file]
src/mscorlib/src/System/cominterfaces.cs [deleted file]
src/pal/inc/pal.h
src/pal/tools/clang-compiler-override-arm.txt [new file with mode: 0644]
src/pal/tools/gen-buildsys-clang.sh
src/unwinder/i386/unwinder_i386.cpp
src/vm/appdomain.cpp
src/vm/argdestination.h
src/vm/ecalllist.h
src/vm/eetwain.cpp
src/vm/frames.cpp
src/vm/gccover.cpp
src/vm/i386/cgencpu.h
src/vm/i386/cgenx86.cpp
src/vm/methodtable.cpp
src/vm/proftoeeinterfaceimpl.cpp
src/vm/siginfo.cpp
src/vm/stackwalk.cpp
tests/src/Common/build_against_pkg_dependencies/project.json
tests/src/Common/empty/project.json
tests/src/Common/netcoreapp/project.json
tests/src/Common/targeting_pack_ref/project.json
tests/src/Common/test_dependencies/project.json
tests/src/Common/test_runtime/project.json
tests/src/JIT/config/benchmark+roslyn/project.json
tests/src/JIT/config/benchmark+serialize/project.json
tests/src/JIT/config/benchmark/project.json
tests/src/JIT/config/extra/project.json
tests/src/JIT/config/minimal/project.json
tests/src/JIT/config/threading+thread/project.json
tests/src/JIT/config/threading/project.json
tests/src/TestWrappersConfig/project.json
tests/src/performance/project.json

index b100ee9..6719522 100644 (file)
@@ -285,7 +285,7 @@ The PSPSym is a pointer-sized local variable in the frame of the main function a
 
 The VM uses the PSPSym to find other locals it cares about (such as the generics context in a funclet frame). The JIT uses it to re-establish the frame pointer register, so that the frame pointer is the same value in a funclet as it is in the main function body.
 
-When a funclet is called, it is passed the *Establisher Frame Pointer*. For AMD64 this is true for all funclets and it is passed as the first argument in RCX, but for ARM and ARM64 this is only true for first pass funclets (currently just filters) and it is passed as the second argument in R1. The Establisher Frame Pointer is a stack pointer of an interesting "parent" frame in the exception processing system. For the CLR, it points either to the main function frame or a dynamically enclosing funclet frame from the same function, for the funclet being invoked. The value of the Establisher Frame Pointer is Initial-SP on AMD64, Caller-SP on ARM and ARM64.
+When a funclet is called, it is passed the *Establisher Frame Pointer*. For AMD64 this is true for all funclets and it is passed as the first argument in RCX, but for ARM and ARM64 this is only true for first pass funclets (currently just filters) and it is passed as the second argument in R1. The Establisher Frame Pointer is a stack pointer of an interesting "parent" frame in the exception processing system. For the CLR, it points either to the main function frame or a dynamically enclosing funclet frame from the same function, for the funclet being invoked. The value of the Establisher Frame Pointer is Initial-SP on AMD64, Caller-SP on x86, ARM, and ARM64.
 
 Using the establisher frame, the funclet wants to load the value of the PSPSym. Since we don't know if the Establisher Frame is from the main function or a funclet, we design the main function and funclet frame layouts to place the PSPSym at an identical, small, constant offset from the Establisher Frame in each case. (This is also required because we only report a single offset to the PSPSym in the GC information, and that offset must be valid for the main function and all of its funclets). Then, the funclet uses this known offset to compute the PSPSym address and read its value. From this, it can compute the value of the frame pointer (which is a constant offset from the PSPSym value) and set the frame register to be the same as the parent function. Also, the funclet writes the value of the PSPSym to its own frame's PSPSym. This "copying" of the PSPSym happens for every funclet invocation, in particular, for every nested funclet invocation.
 
index 2b5cb2c..3fb7168 100644 (file)
@@ -1,18 +1,18 @@
 <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <!-- Source of truth for dependency tooling: the commit hash of the dotnet/versions master branch as of the last auto-upgrade. -->
   <PropertyGroup>
-    <CoreFxCurrentRef>f18ab2c7e097abfdd49580f9cb7fdf3a883f5c99</CoreFxCurrentRef>
-    <CoreClrCurrentRef>b0bc0a1565fac8663262ec875665da189fa71b55</CoreClrCurrentRef>
+    <CoreFxCurrentRef>e04a8c7d7012055d5d8d2f06d1e1bd3cc5f0d98f</CoreFxCurrentRef>
+    <CoreClrCurrentRef>e61a2eaecad04acea728883fa725375a1c0e8418</CoreClrCurrentRef>
   </PropertyGroup>
 
   <!-- Auto-upgraded properties for each build info dependency. -->
   <PropertyGroup>
-    <CoreFxExpectedPrerelease>beta-24931-02</CoreFxExpectedPrerelease>
+    <CoreFxExpectedPrerelease>beta-25001-02</CoreFxExpectedPrerelease>
   </PropertyGroup>
 
   <!-- Full package version strings that are used in other parts of the build. -->
   <PropertyGroup>
-    <CoreClrPackageVersion>2.0.0-beta-24930-03</CoreClrPackageVersion>
+    <CoreClrPackageVersion>2.0.0-beta-25002-03</CoreClrPackageVersion>
     <XunitPackageVersion>2.2.0-beta2-build3300</XunitPackageVersion>
   </PropertyGroup>
 
index b594302..c3521b4 100755 (executable)
@@ -1920,8 +1920,8 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR
                                 setTestJobTimeOut(newJob, scenario)
 
                                 // Archive and process (only) the test results
-                                Utilities.addArchival(newJob, "${workspaceRelativeFxRoot}/bin/tests/**/testResults.xml")
-                                Utilities.addXUnitDotNETResults(newJob, "${workspaceRelativeFxRoot}/bin/tests/**/testResults.xml")
+                                Utilities.addArchival(newJob, "${workspaceRelativeFxRoot}/bin/**/testResults.xml")
+                                Utilities.addXUnitDotNETResults(newJob, "${workspaceRelativeFxRoot}/bin/**/testResults.xml")
                             }
                             else {
                                 buildCommands += "%WORKSPACE%\\tests\\runtest.cmd ${runtestArguments} TestEnv ${stepScriptLocation}"
@@ -2095,8 +2095,8 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR
                         setTestJobTimeOut(newJob, scenario)
 
                         // Archive and process (only) the test results
-                        Utilities.addArchival(newJob, "${workspaceRelativeFxRoot}/bin/tests/**/testResults.xml")
-                        Utilities.addXUnitDotNETResults(newJob, "${workspaceRelativeFxRoot}/bin/tests/**/testResults.xml")
+                        Utilities.addArchival(newJob, "${workspaceRelativeFxRoot}/bin/**/testResults.xml")
+                        Utilities.addXUnitDotNETResults(newJob, "${workspaceRelativeFxRoot}/bin/**/testResults.xml")
                     }
                     break
                 case 'arm64':
index 3b235ba..e3eee4f 100644 (file)
@@ -413,6 +413,8 @@ LLDBServices::GetExecutingProcessorType(
     *type = IMAGE_FILE_MACHINE_ARMNT;
 #elif DBG_TARGET_ARM64
     *type = IMAGE_FILE_MACHINE_ARM64;
+#elif DBG_TARGET_X86
+    *type = IMAGE_FILE_MACHINE_I386;
 #else
 #error "Unsupported target"
 #endif
index 7ab7ac7..29c9626 100644 (file)
@@ -1156,13 +1156,13 @@ void DacDbiInterfaceImpl::UpdateContextFromRegDisp(REGDISPLAY * pRegDisp,
     // Do a partial copy first.
     pContext->ContextFlags = (CONTEXT_INTEGER | CONTEXT_CONTROL);
 
-    pContext->Edi = *pRegDisp->pEdi;
-    pContext->Esi = *pRegDisp->pEsi;
-    pContext->Ebx = *pRegDisp->pEbx;
-    pContext->Ebp = *pRegDisp->pEbp;
-    pContext->Eax = *pRegDisp->pEax;
-    pContext->Ecx = *pRegDisp->pEcx;
-    pContext->Edx = *pRegDisp->pEdx;
+    pContext->Edi = *pRegDisp->GetEdiLocation();
+    pContext->Esi = *pRegDisp->GetEsiLocation();
+    pContext->Ebx = *pRegDisp->GetEbxLocation();
+    pContext->Ebp = *pRegDisp->GetEbpLocation();
+    pContext->Eax = *pRegDisp->GetEaxLocation();
+    pContext->Ecx = *pRegDisp->GetEcxLocation();
+    pContext->Edx = *pRegDisp->GetEdxLocation();
     pContext->Esp = pRegDisp->SP;
     pContext->Eip = pRegDisp->ControlPC;
 
index 54ac8b9..5737286 100644 (file)
@@ -235,13 +235,13 @@ inline void FuncEvalFrame::UpdateRegDisplay(const PREGDISPLAY pRD)
     // Update all registers in the reg display from the CONTEXT we stored when the thread was hijacked for this func
     // eval. We have to update all registers, not just the callee saved registers, because we can hijack a thread at any
     // point for a func eval, not just at a call site.
-    pRD->pEdi = &(pDE->m_context.Edi);
-    pRD->pEsi = &(pDE->m_context.Esi);
-    pRD->pEbx = &(pDE->m_context.Ebx);
-    pRD->pEdx = &(pDE->m_context.Edx);
-    pRD->pEcx = &(pDE->m_context.Ecx);
-    pRD->pEax = &(pDE->m_context.Eax);
-    pRD->pEbp = &(pDE->m_context.Ebp);
+    pRD->SetEdiLocation(&(pDE->m_context.Edi));
+    pRD->SetEsiLocation(&(pDE->m_context.Esi));
+    pRD->SetEbxLocation(&(pDE->m_context.Ebx));
+    pRD->SetEdxLocation(&(pDE->m_context.Edx));
+    pRD->SetEcxLocation(&(pDE->m_context.Ecx));
+    pRD->SetEaxLocation(&(pDE->m_context.Eax));
+    pRD->SetEbpLocation(&(pDE->m_context.Ebp));
     pRD->SP   = (DWORD)GetSP(&pDE->m_context);
     pRD->PCTAddr = GetReturnAddressPtr();
     pRD->ControlPC = *PTR_PCODE(pRD->PCTAddr);
index 5266668..8b62797 100644 (file)
@@ -292,28 +292,28 @@ DWORD NativeWalker::GetRegisterValue(int registerNumber)
     switch (registerNumber)
     {
     case 0:
-        return *m_registers->pEax;
+        return *m_registers->GetEaxLocation();
         break;
     case 1:
-        return *m_registers->pEcx;
+        return *m_registers->GetEcxLocation();
         break;
     case 2:
-        return *m_registers->pEdx;
+        return *m_registers->GetEdxLocation();
         break;
     case 3:
-        return *m_registers->pEbx;
+        return *m_registers->GetEbxLocation();
         break;
     case 4:
         return m_registers->SP;
         break;
     case 5:
-        return *m_registers->pEbp;
+        return *m_registers->GetEbpLocation();
         break;
     case 6:
-        return *m_registers->pEsi;
+        return *m_registers->GetEsiLocation();
         break;
     case 7:
-        return *m_registers->pEdi;
+        return *m_registers->GetEdiLocation();
         break;
     default:
         _ASSERTE(!"Invalid register number!");
index d3c7c76..ab22a5d 100644 (file)
@@ -88,12 +88,12 @@ void SetDebuggerREGDISPLAYFromREGDISPLAY(DebuggerREGDISPLAY* pDRD, REGDISPLAY* p
     // Frame pointer        
     LPVOID FPAddress = GetRegdisplayFPAddress(pRD);
     pDRD->FP  = (FPAddress == NULL ? 0 : *((SIZE_T *)FPAddress));
-    pDRD->Edi  = (pRD->pEdi == NULL ? 0 : *(pRD->pEdi));
-    pDRD->Esi  = (pRD->pEsi == NULL ? 0 : *(pRD->pEsi));
-    pDRD->Ebx  = (pRD->pEbx == NULL ? 0 : *(pRD->pEbx));
-    pDRD->Edx  = (pRD->pEdx == NULL ? 0 : *(pRD->pEdx));
-    pDRD->Ecx  = (pRD->pEcx == NULL ? 0 : *(pRD->pEcx));
-    pDRD->Eax  = (pRD->pEax == NULL ? 0 : *(pRD->pEax));
+    pDRD->Edi = (pRD->GetEdiLocation() == NULL ? 0 : *pRD->GetEdiLocation());
+    pDRD->Esi = (pRD->GetEsiLocation() == NULL ? 0 : *pRD->GetEsiLocation());
+    pDRD->Ebx = (pRD->GetEbxLocation() == NULL ? 0 : *pRD->GetEbxLocation());
+    pDRD->Edx = (pRD->GetEdxLocation() == NULL ? 0 : *pRD->GetEdxLocation());
+    pDRD->Ecx = (pRD->GetEcxLocation() == NULL ? 0 : *pRD->GetEcxLocation());
+    pDRD->Eax = (pRD->GetEsiLocation() == NULL ? 0 : *pRD->GetEaxLocation());
 
 #if defined(USE_REMOTE_REGISTER_ADDRESS)
     pDRD->pFP = PushedRegAddr(pRD, FPAddress);
index df77170..66c8b6a 100644 (file)
@@ -7042,6 +7042,7 @@ int gc_heap::grow_brick_card_tables (uint8_t* start,
     uint8_t* ha = g_gc_highest_address;
     uint8_t* saved_g_lowest_address = min (start, g_gc_lowest_address);
     uint8_t* saved_g_highest_address = max (end, g_gc_highest_address);
+    seg_mapping* new_seg_mapping_table = nullptr;
 #ifdef BACKGROUND_GC
     // This value is only for logging purpose - it's not necessarily exactly what we 
     // would commit for mark array but close enough for diagnostics purpose.
@@ -7202,14 +7203,18 @@ int gc_heap::grow_brick_card_tables (uint8_t* start,
 
 #ifdef GROWABLE_SEG_MAPPING_TABLE
         {
-            seg_mapping* new_seg_mapping_table = (seg_mapping*)(mem + st_table_offset_aligned);
+            new_seg_mapping_table = (seg_mapping*)(mem + st_table_offset_aligned);
             new_seg_mapping_table = (seg_mapping*)((uint8_t*)new_seg_mapping_table -
                                               size_seg_mapping_table_of (0, (align_lower_segment (saved_g_lowest_address))));
             memcpy(&new_seg_mapping_table[seg_mapping_word_of(g_gc_lowest_address)],
                 &seg_mapping_table[seg_mapping_word_of(g_gc_lowest_address)],
                 size_seg_mapping_table_of(g_gc_lowest_address, g_gc_highest_address));
 
-            seg_mapping_table = new_seg_mapping_table;
+            // new_seg_mapping_table gets assigned to seg_mapping_table at the bottom of this function,
+            // not here. The reason for this is that, if we fail at mark array committing (OOM) and we've
+            // already switched seg_mapping_table to point to the new mapping table, we'll decommit it and
+            // run into trouble. By not assigning here, we're making sure that we will not change seg_mapping_table
+            // if an OOM occurs.
         }
 #endif //GROWABLE_SEG_MAPPING_TABLE
 
@@ -7223,7 +7228,7 @@ int gc_heap::grow_brick_card_tables (uint8_t* start,
         translated_ct = translate_card_table (ct);
 
         dprintf (GC_TABLE_LOG, ("card table: %Ix(translated: %Ix), seg map: %Ix, mark array: %Ix", 
-            (size_t)ct, (size_t)translated_ct, (size_t)seg_mapping_table, (size_t)card_table_mark_array (ct)));
+            (size_t)ct, (size_t)translated_ct, (size_t)new_seg_mapping_table, (size_t)card_table_mark_array (ct)));
 
 #ifdef BACKGROUND_GC
         if (hp->should_commit_mark_array())
@@ -7301,6 +7306,9 @@ int gc_heap::grow_brick_card_tables (uint8_t* start,
             g_gc_card_table = translated_ct;
         }
 
+        seg_mapping_table = new_seg_mapping_table;
+
+        GCToOSInterface::FlushProcessWriteBuffers();
         g_gc_lowest_address = saved_g_lowest_address;
         g_gc_highest_address = saved_g_highest_address;
 
index 6f98920..d7693cb 100644 (file)
@@ -62,7 +62,6 @@ struct REGDISPLAY : public REGDISPLAY_BASE {
     PCONTEXT pContextForUnwind; // scratch context for unwinding
                                 // used to preserve context saved in the frame that
                                 // could be otherwise wiped by the unwinding
-#endif // !WIN64EXCEPTIONS
 
     DWORD * pEdi;
     DWORD * pEsi;
@@ -72,6 +71,33 @@ struct REGDISPLAY : public REGDISPLAY_BASE {
     DWORD * pEax;
 
     DWORD * pEbp;
+#endif // !WIN64EXCEPTIONS
+
+#ifndef WIN64EXCEPTIONS
+
+#define REG_METHODS(reg) \
+    inline PDWORD Get##reg##Location(void) { return p##reg;  } \
+    inline void   Set##reg##Location(PDWORD p##reg) { this->p##reg = p##reg; }
+
+#else // !WIN64EXCEPTIONS
+
+#define REG_METHODS(reg) \
+    inline PDWORD Get##reg##Location(void) { return pCurrentContextPointers->reg; } \
+    inline void   Set##reg##Location(PDWORD p##reg) { pCurrentContextPointers->reg = p##reg; }
+
+#endif // WIN64EXCEPTIONS
+
+    REG_METHODS(Eax)
+    REG_METHODS(Ecx)
+    REG_METHODS(Edx)
+
+    REG_METHODS(Ebx)
+    REG_METHODS(Esi)
+    REG_METHODS(Edi)
+    REG_METHODS(Ebp)
+
+#undef REG_METHODS
+
     TADDR   PCTAddr;
 };
 
@@ -90,13 +116,13 @@ inline void SetRegdisplaySP(REGDISPLAY *display, LPVOID sp ) {
 inline TADDR GetRegdisplayFP(REGDISPLAY *display) {
     LIMITED_METHOD_DAC_CONTRACT;
 
-    return (TADDR)*(display->pEbp);
+    return (TADDR)*display->GetEbpLocation();
 }
 
 inline LPVOID GetRegdisplayFPAddress(REGDISPLAY *display) {
     LIMITED_METHOD_CONTRACT;
     
-    return (LPVOID)display->pEbp;
+    return (LPVOID)display->GetEbpLocation();
 }
 
 inline PCODE GetControlPC(REGDISPLAY *display) {
@@ -393,10 +419,10 @@ inline void FillRegDisplay(const PREGDISPLAY pRD, PT_CONTEXT pctx, PT_CONTEXT pC
 
     pRD->ctxPtrsOne.Lr = &pctx->Lr;
 #elif defined(_TARGET_X86_) // _TARGET_ARM_
-    pRD->ctxPtrsOne.Ebx = &pctx->Ebx;
-    pRD->ctxPtrsOne.Esi = &pctx->Esi;
-    pRD->ctxPtrsOne.Edi = &pctx->Edi;
-    pRD->ctxPtrsOne.Ebp = &pctx->Ebp;
+    for (int i = 0; i < 7; i++)
+    {
+        *(&pRD->ctxPtrsOne.Esi + i) = (&pctx->Esi + i);
+    }
 #else // _TARGET_X86_
     PORTABILITY_ASSERT("FillRegDisplay");
 #endif // _TARGET_???_ (ELSE)
index 23890e0..686de82 100644 (file)
@@ -595,4 +595,224 @@ internal static class SR
     {
         get { return Environment.GetResourceString("ArgumentException_ValueTupleLastArgumentNotATuple"); }
     }
+
+    internal static string SpinLock_TryEnter_ArgumentOutOfRange
+    {
+        get { return Environment.GetResourceString("SpinLock_TryEnter_ArgumentOutOfRange"); }
+    }
+
+    internal static string SpinLock_TryReliableEnter_ArgumentException
+    {
+        get { return Environment.GetResourceString("SpinLock_TryReliableEnter_ArgumentException"); }
+    }
+
+    internal static string SpinLock_TryEnter_LockRecursionException
+    {
+        get { return Environment.GetResourceString("SpinLock_TryEnter_LockRecursionException"); }
+    }
+
+    internal static string SpinLock_Exit_SynchronizationLockException
+    {
+        get { return Environment.GetResourceString("SpinLock_Exit_SynchronizationLockException"); }
+    }
+
+    internal static string SpinLock_IsHeldByCurrentThread
+    {
+        get { return Environment.GetResourceString("SpinLock_IsHeldByCurrentThread"); }
+    }
+
+    internal static string ObjectDisposed_StreamIsClosed
+    {
+        get { return Environment.GetResourceString("ObjectDisposed_StreamIsClosed"); }
+    }
+
+    internal static string Arg_SystemException
+    {
+        get { return Environment.GetResourceString("Arg_SystemException"); }
+    }
+
+    internal static string Arg_StackOverflowException
+    {
+        get { return Environment.GetResourceString("Arg_StackOverflowException"); }
+    }
+
+    internal static string Arg_DataMisalignedException
+    {
+        get { return Environment.GetResourceString("Arg_DataMisalignedException"); }
+    }
+
+    internal static string Arg_ExecutionEngineException
+    {
+        get { return Environment.GetResourceString("Arg_ExecutionEngineException"); }
+    }
+
+    internal static string Arg_AccessException
+    {
+        get { return Environment.GetResourceString("Arg_AccessException"); }
+    }
+
+    internal static string Arg_AccessViolationException
+    {
+        get { return Environment.GetResourceString("Arg_AccessViolationException"); }
+    }
+
+    internal static string Arg_ApplicationException
+    {
+        get { return Environment.GetResourceString("Arg_ApplicationException"); }
+    }
+
+    internal static string Arg_ArgumentException
+    {
+        get { return Environment.GetResourceString("Arg_ArgumentException"); }
+    }
+
+    internal static string Arg_ParamName_Name
+    {
+        get { return Environment.GetResourceString("Arg_ParamName_Name"); }
+    }
+
+    internal static string ArgumentNull_Generic
+    {
+        get { return Environment.GetResourceString("ArgumentNull_Generic"); }
+    }
+
+    internal static string Arg_ArithmeticException
+    {
+        get { return Environment.GetResourceString("Arg_ArithmeticException"); }
+    }
+
+    internal static string Arg_ArrayTypeMismatchException
+    {
+        get { return Environment.GetResourceString("Arg_ArrayTypeMismatchException"); }
+    }
+
+    internal static string Arg_DivideByZero
+    {
+        get { return Environment.GetResourceString("Arg_DivideByZero"); }
+    }
+
+    internal static string Arg_DuplicateWaitObjectException
+    {
+        get { return Environment.GetResourceString("Arg_DuplicateWaitObjectException"); }
+    }
+
+    internal static string Arg_EntryPointNotFoundException
+    {
+        get { return Environment.GetResourceString("Arg_EntryPointNotFoundException"); }
+    }
+
+    internal static string Arg_FieldAccessException
+    {
+        get { return Environment.GetResourceString("Arg_FieldAccessException"); }
+    }
+
+    internal static string Arg_FormatException
+    {
+        get { return Environment.GetResourceString("Arg_FormatException"); }
+    }
+
+    internal static string Arg_IndexOutOfRangeException
+    {
+        get { return Environment.GetResourceString("Arg_IndexOutOfRangeException"); }
+    }
+
+    internal static string Arg_InsufficientExecutionStackException
+    {
+        get { return Environment.GetResourceString("Arg_InsufficientExecutionStackException"); }
+    }
+
+    internal static string Arg_InvalidCastException
+    {
+        get { return Environment.GetResourceString("Arg_InvalidCastException"); }
+    }
+
+    internal static string Arg_InvalidOperationException
+    {
+        get { return Environment.GetResourceString("Arg_InvalidOperationException"); }
+    }
+
+    internal static string InvalidProgram_Default
+    {
+        get { return Environment.GetResourceString("InvalidProgram_Default"); }
+    }
+
+    internal static string Arg_MethodAccessException
+    {
+        get { return Environment.GetResourceString("Arg_MethodAccessException"); }
+    }
+
+    internal static string Arg_MulticastNotSupportedException
+    {
+        get { return Environment.GetResourceString("Arg_MulticastNotSupportedException"); }
+    }
+
+    internal static string Arg_NotFiniteNumberException
+    {
+        get { return Environment.GetResourceString("Arg_NotFiniteNumberException"); }
+    }
+
+    internal static string Arg_NotImplementedException
+    {
+        get { return Environment.GetResourceString("Arg_NotImplementedException"); }
+    }
+
+    internal static string Arg_NotSupportedException
+    {
+        get { return Environment.GetResourceString("Arg_NotSupportedException"); }
+    }
+
+    internal static string Arg_NullReferenceException
+    {
+        get { return Environment.GetResourceString("Arg_NullReferenceException"); }
+    }
+
+    internal static string ObjectDisposed_Generic
+    {
+        get { return Environment.GetResourceString("ObjectDisposed_Generic"); }
+    }
+
+    internal static string ObjectDisposed_ObjectName_Name
+    {
+        get { return Environment.GetResourceString("ObjectDisposed_ObjectName_Name"); }
+    }
+
+    internal static string Arg_OverflowException
+    {
+        get { return Environment.GetResourceString("Arg_OverflowException"); }
+    }
+
+    internal static string Arg_PlatformNotSupported
+    {
+        get { return Environment.GetResourceString("Arg_PlatformNotSupported"); }
+    }
+
+    internal static string Arg_RankException
+    {
+        get { return Environment.GetResourceString("Arg_RankException"); }
+    }
+
+    internal static string Arg_TimeoutException
+    {
+        get { return Environment.GetResourceString("Arg_TimeoutException"); }
+    }
+
+    internal static string Arg_TypeAccessException
+    {
+        get { return Environment.GetResourceString("Arg_TypeAccessException"); }
+    }
+
+    internal static string TypeInitialization_Default
+    {
+        get { return Environment.GetResourceString("TypeInitialization_Default"); }
+    }
+
+    internal static string TypeInitialization_Type
+    {
+        get { return Environment.GetResourceString("TypeInitialization_Type"); }
+    }
+
+    internal static string Arg_UnauthorizedAccessException
+    {
+        get { return Environment.GetResourceString("Arg_UnauthorizedAccessException"); }
+    }
 }
index 78e9f00..0ff5040 100644 (file)
@@ -29,7 +29,6 @@ namespace System.Globalization
     // since most of the calendars (or all?) have the same way of calcuating hour/minute/second.
 
     [Serializable]
-    [System.Runtime.InteropServices.ComVisible(true)]
     public abstract partial class Calendar : ICloneable
     {
         // Number of 100ns (10E-7 second) ticks per time unit
@@ -77,7 +76,6 @@ namespace System.Globalization
 
         // The minimum supported DateTime range for the calendar.
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public virtual DateTime MinSupportedDateTime
         {
             get
@@ -88,7 +86,6 @@ namespace System.Globalization
 
         // The maximum supported DateTime range for the calendar.
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public virtual DateTime MaxSupportedDateTime
         {
             get
@@ -97,7 +94,6 @@ namespace System.Globalization
             }
         }
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public virtual CalendarAlgorithmType AlgorithmType
         {
             get
@@ -138,7 +134,6 @@ namespace System.Globalization
         //  Detect if the object is readonly.
         //
         ////////////////////////////////////////////////////////////////////////
-        [System.Runtime.InteropServices.ComVisible(false)]
         public bool IsReadOnly
         {
             get { return (_isReadOnly); }
@@ -151,7 +146,6 @@ namespace System.Globalization
         //  Is the implementation of ICloneable.
         //
         ////////////////////////////////////////////////////////////////////////
-        [System.Runtime.InteropServices.ComVisible(false)]
         public virtual object Clone()
         {
             object o = MemberwiseClone();
@@ -167,7 +161,6 @@ namespace System.Globalization
         //  readonly.
         //
         ////////////////////////////////////////////////////////////////////////
-        [System.Runtime.InteropServices.ComVisible(false)]
         public static Calendar ReadOnly(Calendar calendar)
         {
             if (calendar == null) { throw new ArgumentNullException(nameof(calendar)); }
@@ -708,7 +701,6 @@ namespace System.Globalization
         // if this calendar does not have leap month, or this year is not a leap year.
         //
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public virtual int GetLeapMonth(int year)
         {
             return (GetLeapMonth(year, CurrentEra));
@@ -718,7 +710,6 @@ namespace System.Globalization
         // if this calendar does not have leap month, or this year is not a leap year.
         //
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public virtual int GetLeapMonth(int year, int era)
         {
             if (!IsLeapYear(year, era))
index 490951e..4013ce7 100644 (file)
@@ -7,7 +7,6 @@ using System;
 namespace System.Globalization
 {
     [Serializable]
-    [System.Runtime.InteropServices.ComVisible(true)]
     public enum CalendarWeekRule
     {
         FirstDay = 0,           // Week 1 begins on the first day of the year
index 149e63c..7de75d6 100644 (file)
@@ -22,8 +22,8 @@ namespace System.Globalization
         private const int SecondsPerMinute = 60;
         private const int MinutesPerDegree = 60;
 
-        private static readonly long StartOf1810 = GetNumberOfDays(new DateTime(1810, 1, 1));
-        private static readonly long StartOf1900Century = GetNumberOfDays(new DateTime(1900, 1, 1));
+        private static readonly long s_startOf1810 = GetNumberOfDays(new DateTime(1810, 1, 1));
+        private static readonly long s_startOf1900Century = GetNumberOfDays(new DateTime(1900, 1, 1));
 
         private static readonly double[] s_coefficients1900to1987 = new double[] { -0.00002, 0.000297, 0.025184, -0.181133, 0.553040, -0.861938, 0.677066, -0.212591 };
         private static readonly double[] s_coefficients1800to1899 = new double[] { -0.000009, 0.003844, 0.083563, 0.865736, 4.867575, 15.845535, 31.332267, 38.291999, 28.316289, 11.636204, 2.043794 };
@@ -146,7 +146,7 @@ namespace System.Globalization
         private static double CenturiesFrom1900(int gregorianYear)
         {
             long july1stOfYear = GetNumberOfDays(new DateTime(gregorianYear, 7, 1));
-            return (double)(july1stOfYear - StartOf1900Century) / DaysInUniformLengthCentury;
+            return (double)(july1stOfYear - s_startOf1900Century) / DaysInUniformLengthCentury;
         }
 
         // the following formulas defines a polynomial function which gives us the amount that the earth is slowing down for specific year ranges
@@ -154,7 +154,7 @@ namespace System.Globalization
         {
             Debug.Assert(gregorianYear < 1620 || 2020 <= gregorianYear);
             long january1stOfYear = GetNumberOfDays(new DateTime(gregorianYear, 1, 1));
-            double daysSinceStartOf1810 = january1stOfYear - StartOf1810;
+            double daysSinceStartOf1810 = january1stOfYear - s_startOf1810;
             double x = TwelveHours + daysSinceStartOf1810;
             return ((Math.Pow(x, 2) / 41048480) - 15) / SecondsPerDay;
         }
index dc38ca4..38ce441 100644 (file)
@@ -194,7 +194,7 @@ namespace System.Globalization
             // Get the level 2 WORD offset from the 4 - 7 bit of ch.  This provides the base offset of the level 3 table.
             // Note that & has the lower precedence than addition, so don't forget the parathesis.
             index = s_pNumericLevel1Index[index + ((ch >> 4) & 0x000f)];
-            
+
             fixed (ushort* pUshortPtr = &(s_pNumericLevel1Index[index]))
             {
                 byte* pBytePtr = (byte*)pUshortPtr;
@@ -238,46 +238,46 @@ namespace System.Globalization
             return (InternalGetNumericValue(InternalConvertToUtf32(s, index)));
         }
 
-        public static int GetDecimalDigitValue(char ch) 
+        public static int GetDecimalDigitValue(char ch)
         {
-            return (sbyte) (InternalGetDigitValues(ch) >> 8);
+            return (sbyte)(InternalGetDigitValues(ch) >> 8);
         }
 
-        public static int GetDecimalDigitValue(String s, int index) 
+        public static int GetDecimalDigitValue(String s, int index)
         {
-            if (s == null) 
+            if (s == null)
             {
                 throw new ArgumentNullException(nameof(s));
             }
-            
-            if (index < 0 || index >= s.Length) 
+
+            if (index < 0 || index >= s.Length)
             {
                 throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index);
             }
             Contract.EndContractBlock();
 
-            return (sbyte) (InternalGetDigitValues(InternalConvertToUtf32(s, index)) >> 8);
+            return (sbyte)(InternalGetDigitValues(InternalConvertToUtf32(s, index)) >> 8);
         }
-        
+
         public static int GetDigitValue(char ch)
         {
-            return (sbyte) (InternalGetDigitValues(ch) & 0x00FF);
+            return (sbyte)(InternalGetDigitValues(ch) & 0x00FF);
         }
 
-        public static int GetDigitValue(String s, int index) 
+        public static int GetDigitValue(String s, int index)
         {
-            if (s == null) 
+            if (s == null)
             {
                 throw new ArgumentNullException(nameof(s));
             }
-            
-            if (index < 0 || index >= s.Length) 
+
+            if (index < 0 || index >= s.Length)
             {
                 throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index);
             }
-            
+
             Contract.EndContractBlock();
-            return (sbyte) (InternalGetDigitValues(InternalConvertToUtf32(s, index)) & 0x00FF);
+            return (sbyte)(InternalGetDigitValues(InternalConvertToUtf32(s, index)) & 0x00FF);
         }
 
         public static UnicodeCategory GetUnicodeCategory(char ch)
index 271d980..5002555 100644 (file)
@@ -42,7 +42,6 @@ namespace System.Globalization
         internal static DateTime minDate = new DateTime(MIN_GREGORIAN_YEAR, MIN_GREGORIAN_MONTH, MIN_GREGORIAN_DAY);
         internal static DateTime maxDate = new DateTime((new DateTime(MAX_GREGORIAN_YEAR, MAX_GREGORIAN_MONTH, MAX_GREGORIAN_DAY, 23, 59, 59, 999)).Ticks + 9999);
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override DateTime MinSupportedDateTime
         {
             get
@@ -52,7 +51,6 @@ namespace System.Globalization
         }
 
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override DateTime MaxSupportedDateTime
         {
             get
@@ -318,9 +316,9 @@ namespace System.Globalization
             }
         }
 
-        internal override int GetYearInfo(int LunarYear, int Index)
+        internal override int GetYearInfo(int lunarYear, int index)
         {
-            if ((LunarYear < MIN_LUNISOLAR_YEAR) || (LunarYear > MAX_LUNISOLAR_YEAR))
+            if ((lunarYear < MIN_LUNISOLAR_YEAR) || (lunarYear > MAX_LUNISOLAR_YEAR))
             {
                 throw new ArgumentOutOfRangeException(
                             "year",
@@ -330,7 +328,7 @@ namespace System.Globalization
             }
             Contract.EndContractBlock();
 
-            return s_yinfo[LunarYear - MIN_LUNISOLAR_YEAR, Index];
+            return s_yinfo[lunarYear - MIN_LUNISOLAR_YEAR, index];
         }
 
         internal override int GetYear(int year, DateTime time)
@@ -362,7 +360,6 @@ namespace System.Globalization
         {
         }
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override int GetEra(DateTime time)
         {
             CheckTicksRange(time.Ticks);
@@ -387,7 +384,6 @@ namespace System.Globalization
         }
 
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override int[] Eras
         {
             get
index 4ebaf9c..d493652 100644 (file)
@@ -351,7 +351,7 @@ namespace System.Globalization
 
         private unsafe SortKey CreateSortKey(String source, CompareOptions options)
         {
-            if (source==null) { throw new ArgumentNullException(nameof(source)); }
+            if (source == null) { throw new ArgumentNullException(nameof(source)); }
             Contract.EndContractBlock();
 
             if ((options & ValidSortkeyCtorMaskOffFlags) != 0)
@@ -362,7 +362,7 @@ namespace System.Globalization
             throw new NotImplementedException();
         }
 
-        private static unsafe bool IsSortable(char *text, int length)
+        private static unsafe bool IsSortable(chartext, int length)
         {
             // CompareInfo c = CultureInfo.InvariantCulture.CompareInfo;
             // return (InternalIsSortable(c.m_dataHandle, c.m_handleOrigin, c.m_sortName, text, text.Length));
index d1c99da..0c264e5 100644 (file)
@@ -663,11 +663,10 @@ namespace System.Globalization
         {
             get { throw new NotImplementedException(); }
         }
-        
+
         internal bool IsReplacementCulture
         {
             get { throw new NotImplementedException(); }
         }
-        
     }
 }
index 64782d2..d296ad8 100644 (file)
@@ -3,14 +3,13 @@
 // See the LICENSE file in the project root for more information.
 
 using System;
-using System.Threading;
 using System.Runtime.Serialization;
+using System.Threading;
 
 namespace System.Globalization
 {
     [Serializable]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public partial class CultureNotFoundException : ArgumentException, ISerializable
+    public class CultureNotFoundException : ArgumentException, ISerializable
     {
         private string _invalidCultureName; // unrecognized culture name
         private int? _invalidCultureId;     // unrecognized culture Lcid
@@ -66,14 +65,8 @@ namespace System.Globalization
             _invalidCultureName = (string)info.GetValue("InvalidCultureName", typeof(string));
         }
 
-        [System.Security.SecurityCritical]  // auto-generated_required
         public override void GetObjectData(SerializationInfo info, StreamingContext context)
         {
-            if (info == null)
-            {
-                throw new ArgumentNullException(nameof(info));
-            }
-
             base.GetObjectData(info, context);
             info.AddValue("InvalidCultureId", _invalidCultureId, typeof(int?));
             info.AddValue("InvalidCultureName", _invalidCultureName, typeof(string));
index 80b588a..35ddff6 100644 (file)
@@ -7,7 +7,7 @@
 // the rest are obsolete or not valid on Linux
 
 namespace System.Globalization
-{    
+{
     [Serializable]
     [Flags]
     public enum CultureTypes
@@ -25,4 +25,4 @@ namespace System.Globalization
         [Obsolete("This value has been deprecated.  Please use other values in CultureTypes.")]
         FrameworkCultures           = 0x0040,               // will return only the v2 cultures marked as Framework culture.
     }
-}    
+}
index 7e40033..0e4dcc8 100644 (file)
@@ -5,6 +5,7 @@
 //
 // The enumeration constants used in NumberFormatInfo.DigitSubstitution.
 //
+
 namespace System.Globalization
 {
     [Serializable]
index 84a44a9..f82fad8 100644 (file)
@@ -14,7 +14,6 @@ namespace System.Globalization
     ////////////////////////////////////////////////////////////////////////////
 
     [Serializable]
-    [System.Runtime.InteropServices.ComVisible(true)]
     public abstract class EastAsianLunisolarCalendar : Calendar
     {
         internal const int LeapMonth = 0;
index c2ed2e0..be5b65b 100644 (file)
@@ -19,7 +19,6 @@ namespace System.Globalization
     // 1 BeforeCurrentEra (BC)
 
     [Serializable]
-    [System.Runtime.InteropServices.ComVisible(true)]
 
     public class GregorianCalendar : Calendar
     {
@@ -66,7 +65,6 @@ namespace System.Globalization
             }
         }
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override DateTime MinSupportedDateTime
         {
             get
@@ -75,7 +73,6 @@ namespace System.Globalization
             }
         }
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override DateTime MaxSupportedDateTime
         {
             get
@@ -84,7 +81,6 @@ namespace System.Globalization
             }
         }
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override CalendarAlgorithmType AlgorithmType
         {
             get
@@ -510,7 +506,6 @@ namespace System.Globalization
         // if this calendar does not have leap month, or this year is not a leap year.
         //
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override int GetLeapMonth(int year, int era)
         {
             if (era != CurrentEra && era != ADEra)
index 7e63708..b4f54f8 100644 (file)
@@ -63,7 +63,6 @@ namespace System.Globalization
 
 
     [Serializable]
-    [System.Runtime.InteropServices.ComVisible(true)]
     public class HebrewCalendar : Calendar
     {
         public static readonly int HebrewEra = 1;
index 5f46dce..869b809 100644 (file)
@@ -8,9 +8,10 @@ namespace System.Globalization
 {
     public partial class HijriCalendar : Calendar
     {
-        private static int GetHijriDateAdjustment()
+        private int GetHijriDateAdjustment()
         {
-            if (_hijriAdvance == Int32.MinValue) {
+            if (_hijriAdvance == Int32.MinValue)
+            {
                 // Never been set before.  Use the system value from registry.
                 _hijriAdvance = GetAdvanceHijriDate();
             }
@@ -36,11 +37,13 @@ namespace System.Globalization
         **      "AddHijriDate+1"  =>  Add +1 days to the current calculated Hijri date.
         **      "AddHijriDate+2"  =>  Add +2 days to the current calculated Hijri date.
         ============================================================================*/
-        private static int GetAdvanceHijriDate() {
+        private static int GetAdvanceHijriDate()
+        {
             int hijriAdvance = 0;
             Microsoft.Win32.RegistryKey key = null;
 
-            try {
+            try
+            {
                 // Open in read-only mode.
                 // Use InternalOpenSubKey so that we avoid the security check.
                 key = RegistryKey.GetBaseKey(RegistryKey.HKEY_CURRENT_USER).OpenSubKey(InternationalRegKey, false);
@@ -49,21 +52,28 @@ namespace System.Globalization
             catch (ObjectDisposedException) { return 0; }
             catch (ArgumentException) { return 0; }
 
-            if (key != null) {
-                try {
+            if (key != null)
+            {
+                try
+                {
                     Object value = key.InternalGetValue(HijriAdvanceRegKeyEntry, null, false, false);
-                    if (value == null) {
+                    if (value == null)
+                    {
                         return (0);
                     }
                     String str = value.ToString();
-                    if (String.Compare(str, 0, HijriAdvanceRegKeyEntry, 0, HijriAdvanceRegKeyEntry.Length, StringComparison.OrdinalIgnoreCase) == 0) {
+                    if (String.Compare(str, 0, HijriAdvanceRegKeyEntry, 0, HijriAdvanceRegKeyEntry.Length, StringComparison.OrdinalIgnoreCase) == 0)
+                    {
                         if (str.Length == HijriAdvanceRegKeyEntry.Length)
                             hijriAdvance = -1;
-                        else {
+                        else
+                        {
                             str = str.Substring(HijriAdvanceRegKeyEntry.Length);
-                            try {
+                            try
+                            {
                                 int advance = Int32.Parse(str.ToString(), CultureInfo.InvariantCulture);
-                                if ((advance >= MinAdvancedHijri) && (advance <= MaxAdvancedHijri)) {
+                                if ((advance >= MinAdvancedHijri) && (advance <= MaxAdvancedHijri))
+                                {
                                     hijriAdvance = advance;
                                 }
                             }
@@ -75,10 +85,10 @@ namespace System.Globalization
                         }
                     }
                 }
-                finally {
+                finally
+                {
                     key.Close();
                 }
-
             }
             return (hijriAdvance);
         }
index 156b210..0c72d9e 100644 (file)
@@ -45,7 +45,6 @@ namespace System.Globalization
     */
 
     [Serializable]
-    [System.Runtime.InteropServices.ComVisible(true)]
     public partial class HijriCalendar : Calendar
     {
         public static readonly int HijriEra = 1;
@@ -72,7 +71,6 @@ namespace System.Globalization
         internal static readonly DateTime calendarMaxValue = DateTime.MaxValue;
 
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override DateTime MinSupportedDateTime
         {
             get
@@ -82,7 +80,6 @@ namespace System.Globalization
         }
 
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override DateTime MaxSupportedDateTime
         {
             get
@@ -91,7 +88,6 @@ namespace System.Globalization
             }
         }
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override CalendarAlgorithmType AlgorithmType
         {
             get
@@ -565,7 +561,6 @@ namespace System.Globalization
         // if this calendar does not have leap month, or this year is not a leap year.
         //
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override int GetLeapMonth(int year, int era)
         {
             CheckYearRange(year, era);
index f39457b..3d3292e 100644 (file)
@@ -7,7 +7,7 @@ using System.Runtime.InteropServices;
 
 namespace System.Globalization
 {
-    sealed partial class IdnMapping
+    public sealed partial class IdnMapping
     {
         private unsafe string GetAsciiCore(char* unicode, int count)
         {
index bbde320..a83c4fa 100644 (file)
@@ -33,7 +33,7 @@ namespace System.Globalization
             // Look in the registry key and see if we can find any ranges
             int iFoundEras = 0;
             EraInfo[] registryEraRanges = null;
-            
+
             try
             {
                 // Need to access registry
@@ -59,7 +59,7 @@ namespace System.Globalization
 
                         // Remember we found one.
                         registryEraRanges[iFoundEras] = era;
-                        iFoundEras++;                        
+                        iFoundEras++;
                     }
                 }
             }
@@ -109,7 +109,7 @@ namespace System.Globalization
                 else
                 {
                     // Rest are until the next era (remember most recent era is first in array)
-                    registryEraRanges[i].maxEraYear = registryEraRanges[i-1].yearOffset + 1 - registryEraRanges[i].yearOffset;
+                    registryEraRanges[i].maxEraYear = registryEraRanges[i - 1].yearOffset + 1 - registryEraRanges[i].yearOffset;
                 }
             }
 
@@ -147,7 +147,7 @@ namespace System.Globalization
         {
             // Need inputs
             if (value == null || data == null) return null;
-            
+
             //
             // Get Date
             //
@@ -159,9 +159,9 @@ namespace System.Globalization
             int month;
             int day;
 
-            if (!Int32.TryParse(value.Substring(0,4), NumberStyles.None, NumberFormatInfo.InvariantInfo, out year) ||
-                !Int32.TryParse(value.Substring(5,2), NumberStyles.None, NumberFormatInfo.InvariantInfo, out month) ||
-                !Int32.TryParse(value.Substring(8,2), NumberStyles.None, NumberFormatInfo.InvariantInfo, out day))
+            if (!Int32.TryParse(value.Substring(0, 4), NumberStyles.None, NumberFormatInfo.InvariantInfo, out year) ||
+                !Int32.TryParse(value.Substring(5, 2), NumberStyles.None, NumberFormatInfo.InvariantInfo, out month) ||
+                !Int32.TryParse(value.Substring(8, 2), NumberStyles.None, NumberFormatInfo.InvariantInfo, out day))
             {
                 // Couldn't convert integer, fail
                 return null;
@@ -171,7 +171,7 @@ namespace System.Globalization
             // Get Strings
             //
             // Needs to be a certain length e_a_E_A at least (7 chars, exactly 4 groups)
-            String[] names = data.Split(new char[] {'_'});
+            String[] names = data.Split('_');
 
             // Should have exactly 4 parts
             // 0 - Era Name
@@ -192,18 +192,18 @@ namespace System.Globalization
             // Note that the era # and max era year need cleaned up after sorting
             // Don't use the full English Era Name (names[2])
             //
-            return new EraInfo( 0, year, month, day, year - 1, 1, 0, 
+            return new EraInfo(0, year, month, day, year - 1, 1, 0,
                                 names[0], names[1], names[3]);
         }
 
         // PAL Layer ends here
 
-        private static string[] JapaneseErasEnglishNames = new String[] { "M", "T", "S", "H" };
+        private static string[] s_japaneseErasEnglishNames = new String[] { "M", "T", "S", "H" };
 
         private static string GetJapaneseEnglishEraName(int era)
         {
             Debug.Assert(era > 0);
-            return era <= JapaneseErasEnglishNames.Length ? JapaneseErasEnglishNames[era - 1] : " ";
+            return era <= s_japaneseErasEnglishNames.Length ? s_japaneseErasEnglishNames[era - 1] : " ";
         }
     }
 }
index 0b0fa77..f0216c8 100644 (file)
@@ -39,13 +39,11 @@ namespace System.Globalization
 
 
     [Serializable]
-    [System.Runtime.InteropServices.ComVisible(true)]
     public partial class JapaneseCalendar : Calendar
     {
         internal static readonly DateTime calendarMinValue = new DateTime(1868, 9, 8);
 
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override DateTime MinSupportedDateTime
         {
             get
@@ -54,7 +52,6 @@ namespace System.Globalization
             }
         }
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override DateTime MaxSupportedDateTime
         {
             get
@@ -63,7 +60,6 @@ namespace System.Globalization
             }
         }
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override CalendarAlgorithmType AlgorithmType
         {
             get
@@ -233,7 +229,6 @@ namespace System.Globalization
 
 
         [SuppressMessage("Microsoft.Contracts", "CC1055")]  // Skip extra error checking to avoid *potential* AppCompat problems.
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override int GetWeekOfYear(DateTime time, CalendarWeekRule rule, DayOfWeek firstDayOfWeek)
         {
             return (helper.GetWeekOfYear(time, rule, firstDayOfWeek));
@@ -281,7 +276,6 @@ namespace System.Globalization
         // if this calendar does not have leap month, or this year is not a leap year.
         //
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override int GetLeapMonth(int year, int era)
         {
             return (helper.GetLeapMonth(year, era));
index ecdaced..cc3d349 100644 (file)
@@ -206,9 +206,9 @@ namespace System.Globalization
             }
         }
 
-        internal override int GetYearInfo(int LunarYear, int Index)
+        internal override int GetYearInfo(int lunarYear, int index)
         {
-            if ((LunarYear < MIN_LUNISOLAR_YEAR) || (LunarYear > MAX_LUNISOLAR_YEAR))
+            if ((lunarYear < MIN_LUNISOLAR_YEAR) || (lunarYear > MAX_LUNISOLAR_YEAR))
             {
                 throw new ArgumentOutOfRangeException(
                             "year",
@@ -220,7 +220,7 @@ namespace System.Globalization
             }
             Contract.EndContractBlock();
 
-            return s_yinfo[LunarYear - MIN_LUNISOLAR_YEAR, Index];
+            return s_yinfo[lunarYear - MIN_LUNISOLAR_YEAR, index];
         }
 
         internal override int GetYear(int year, DateTime time)
index a4277c6..43e6ad0 100644 (file)
@@ -19,7 +19,6 @@ namespace System.Globalization
     //*      Julia       0001/01/03   9999/10/19
 
     [Serializable]
-    [System.Runtime.InteropServices.ComVisible(true)]
     public class JulianCalendar : Calendar
     {
         public static readonly int JulianEra = 1;
@@ -49,7 +48,6 @@ namespace System.Globalization
         internal int MaxYear = 9999;
 
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override DateTime MinSupportedDateTime
         {
             get
@@ -58,7 +56,6 @@ namespace System.Globalization
             }
         }
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override DateTime MaxSupportedDateTime
         {
             get
@@ -67,7 +64,6 @@ namespace System.Globalization
             }
         }
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override CalendarAlgorithmType AlgorithmType
         {
             get
@@ -346,7 +342,6 @@ namespace System.Globalization
         // if this calendar does not have leap month, or this year is not a leap year.
         //
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override int GetLeapMonth(int year, int era)
         {
             CheckYearEraRange(year, era);
index 27d0aa8..b015aa0 100644 (file)
@@ -25,7 +25,6 @@ namespace System.Globalization
 
 
     [Serializable]
-    [System.Runtime.InteropServices.ComVisible(true)]
     public class KoreanCalendar : Calendar
     {
         //
@@ -51,7 +50,6 @@ namespace System.Globalization
         internal GregorianCalendarHelper helper;
 
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override DateTime MinSupportedDateTime
         {
             get
@@ -60,7 +58,6 @@ namespace System.Globalization
             }
         }
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override DateTime MaxSupportedDateTime
         {
             get
@@ -69,7 +66,6 @@ namespace System.Globalization
             }
         }
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override CalendarAlgorithmType AlgorithmType
         {
             get
@@ -160,7 +156,6 @@ namespace System.Globalization
 
 
         [SuppressMessage("Microsoft.Contracts", "CC1055")]  // Skip extra error checking to avoid *potential* AppCompat problems.
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override int GetWeekOfYear(DateTime time, CalendarWeekRule rule, DayOfWeek firstDayOfWeek)
         {
             return (helper.GetWeekOfYear(time, rule, firstDayOfWeek));
@@ -199,7 +194,6 @@ namespace System.Globalization
         // if this calendar does not have leap month, or this year is not a leap year.
         //
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override int GetLeapMonth(int year, int era)
         {
             return (helper.GetLeapMonth(year, era));
index 07d85a4..6d09128 100644 (file)
@@ -1251,9 +1251,9 @@ namespace System.Globalization
             }
         }
 
-        internal override int GetYearInfo(int LunarYear, int Index)
+        internal override int GetYearInfo(int lunarYear, int index)
         {
-            if ((LunarYear < MIN_LUNISOLAR_YEAR) || (LunarYear > MAX_LUNISOLAR_YEAR))
+            if ((lunarYear < MIN_LUNISOLAR_YEAR) || (lunarYear > MAX_LUNISOLAR_YEAR))
             {
                 throw new ArgumentOutOfRangeException(
                             "year",
@@ -1264,7 +1264,7 @@ namespace System.Globalization
                                 MAX_LUNISOLAR_YEAR));
             }
             Contract.EndContractBlock();
-            return s_yinfo[LunarYear - MIN_LUNISOLAR_YEAR, Index];
+            return s_yinfo[lunarYear - MIN_LUNISOLAR_YEAR, index];
         }
 
         internal override int GetYear(int year, DateTime time)
index fc151fa..9e22a6f 100644 (file)
@@ -19,7 +19,6 @@ namespace System.Globalization {
     using System.Diagnostics;
     using System.Diagnostics.Contracts;
 
-    [System.Runtime.InteropServices.ComVisible(true)]
     [Serializable]
     public partial class SortKey
     {
index 72aa6d6..983179c 100644 (file)
@@ -5,7 +5,7 @@
 using System;
 using System.Diagnostics.Contracts;
 
-namespace System.Globalization 
+namespace System.Globalization
 {
     [Serializable]
     public sealed class SortVersion : IEquatable<SortVersion>
@@ -13,48 +13,48 @@ namespace System.Globalization
         private int _nlsVersion;
         private Guid _sortId;
 
-        public int FullVersion 
+        public int FullVersion
         {
-            get 
+            get
             {
                 return _nlsVersion;
             }
         }
 
-        public Guid SortId 
+        public Guid SortId
         {
-            get 
+            get
             {
                 return _sortId;
             }
         }
 
-        public SortVersion(int fullVersion, Guid sortId) 
-        {           
+        public SortVersion(int fullVersion, Guid sortId)
+        {
             _sortId = sortId;
             _nlsVersion = fullVersion;
         }
 
-        internal SortVersion(int nlsVersion, int effectiveId, Guid customVersion) 
+        internal SortVersion(int nlsVersion, int effectiveId, Guid customVersion)
         {
             _nlsVersion = nlsVersion;
 
-            if (customVersion == Guid.Empty) 
+            if (customVersion == Guid.Empty)
             {
-                byte b1 = (byte) (effectiveId >> 24);
-                byte b2 = (byte) ((effectiveId  & 0x00FF0000) >> 16);
-                byte b3 = (byte) ((effectiveId  & 0x0000FF00) >> 8);
-                byte b4 = (byte) (effectiveId  & 0xFF);
-                customVersion = new Guid(0,0,0,0,0,0,0,b1,b2,b3,b4);
+                byte b1 = (byte)(effectiveId >> 24);
+                byte b2 = (byte)((effectiveId & 0x00FF0000) >> 16);
+                byte b3 = (byte)((effectiveId & 0x0000FF00) >> 8);
+                byte b4 = (byte)(effectiveId & 0xFF);
+                customVersion = new Guid(0, 0, 0, 0, 0, 0, 0, b1, b2, b3, b4);
             }
 
             _sortId = customVersion;
         }
 
-        public override bool Equals(object obj) 
+        public override bool Equals(object obj)
         {
             SortVersion n = obj as SortVersion;
-            if (n != null) 
+            if (n != null)
             {
                 return this.Equals(n);
             }
@@ -62,9 +62,9 @@ namespace System.Globalization
             return false;
         }
 
-        public bool Equals(SortVersion other) 
+        public bool Equals(SortVersion other)
         {
-            if (other == null) 
+            if (other == null)
             {
                 return false;
             }
@@ -72,19 +72,19 @@ namespace System.Globalization
             return _nlsVersion == other._nlsVersion && _sortId == other._sortId;
         }
 
-        public override int GetHashCode() 
-        { 
-            return _nlsVersion * 7 | _sortId.GetHashCode(); 
+        public override int GetHashCode()
+        {
+            return _nlsVersion * 7 | _sortId.GetHashCode();
         }
 
-        public static bool operator ==(SortVersion left, SortVersion right) 
+        public static bool operator ==(SortVersion left, SortVersion right)
         {
-            if (((object) left) != null) 
+            if (((object)left) != null)
             {
                 return left.Equals(right);
             }
 
-            if (((object) right) != null) 
+            if (((object)right) != null)
             {
                 return right.Equals(left);
             }
@@ -93,7 +93,7 @@ namespace System.Globalization
             return true;
         }
 
-        public static bool operator !=(SortVersion left, SortVersion right) 
+        public static bool operator !=(SortVersion left, SortVersion right)
         {
             return !(left == right);
         }
index 7558002..f1dd305 100644 (file)
@@ -20,7 +20,6 @@ using System.Runtime.Serialization;
 namespace System.Globalization
 {
     [Serializable]
-    [System.Runtime.InteropServices.ComVisible(true)]
     public class StringInfo
     {
         [OptionalField(VersionAdded = 2)] 
@@ -53,7 +52,6 @@ namespace System.Globalization
             }
         }
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override bool Equals(Object value)
         {
             StringInfo that = value as StringInfo;
@@ -64,7 +62,6 @@ namespace System.Globalization
             return (false);
         }
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override int GetHashCode()
         {
             return _str.GetHashCode();
index 36edd5b..2e735e0 100644 (file)
@@ -22,7 +22,6 @@ namespace System.Globalization
     ============================================================================*/
 
     [Serializable]
-    [System.Runtime.InteropServices.ComVisible(true)]
     public class TaiwanCalendar : Calendar
     {
         //
@@ -65,7 +64,6 @@ namespace System.Globalization
         internal static readonly DateTime calendarMinValue = new DateTime(1912, 1, 1);
 
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override DateTime MinSupportedDateTime
         {
             get
@@ -74,7 +72,6 @@ namespace System.Globalization
             }
         }
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override DateTime MaxSupportedDateTime
         {
             get
@@ -83,7 +80,6 @@ namespace System.Globalization
             }
         }
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override CalendarAlgorithmType AlgorithmType
         {
             get
@@ -166,7 +162,6 @@ namespace System.Globalization
 
 
         [SuppressMessage("Microsoft.Contracts", "CC1055")]  // Skip extra error checking to avoid *potential* AppCompat problems.
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override int GetWeekOfYear(DateTime time, CalendarWeekRule rule, DayOfWeek firstDayOfWeek)
         {
             return (helper.GetWeekOfYear(time, rule, firstDayOfWeek));
@@ -205,7 +200,6 @@ namespace System.Globalization
         // if this calendar does not have leap month, or this year is not a leap year.
         //
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override int GetLeapMonth(int year, int era)
         {
             return (helper.GetLeapMonth(year, era));
index 42b7f24..1f75ac9 100644 (file)
@@ -264,9 +264,9 @@ namespace System.Globalization
             }
         }
 
-        internal override int GetYearInfo(int LunarYear, int Index)
+        internal override int GetYearInfo(int lunarYear, int index)
         {
-            if ((LunarYear < MIN_LUNISOLAR_YEAR) || (LunarYear > MAX_LUNISOLAR_YEAR))
+            if ((lunarYear < MIN_LUNISOLAR_YEAR) || (lunarYear > MAX_LUNISOLAR_YEAR))
             {
                 throw new ArgumentOutOfRangeException(
                             "year",
@@ -278,7 +278,7 @@ namespace System.Globalization
             }
             Contract.EndContractBlock();
 
-            return s_yinfo[LunarYear - MIN_LUNISOLAR_YEAR, Index];
+            return s_yinfo[lunarYear - MIN_LUNISOLAR_YEAR, index];
         }
 
         internal override int GetYear(int year, DateTime time)
index c0ffc65..464897b 100644 (file)
@@ -21,7 +21,6 @@ namespace System.Globalization
     //
 
     [Serializable]
-    [System.Runtime.InteropServices.ComVisible(true)]
     public class TextElementEnumerator : IEnumerator
     {
         private String _str;
index 5bb376f..172bbd2 100644 (file)
@@ -188,7 +188,6 @@ namespace System.Globalization
             }
         }
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public int LCID 
         {
             get 
@@ -220,7 +219,6 @@ namespace System.Globalization
         //  Detect if the object is readonly.
         //
         ////////////////////////////////////////////////////////////////////////
-        [System.Runtime.InteropServices.ComVisible(false)]
         public bool IsReadOnly
         {
             get { return (_isReadOnly); }
@@ -248,7 +246,6 @@ namespace System.Globalization
         //  readonly.
         //
         ////////////////////////////////////////////////////////////////////////
-        [System.Runtime.InteropServices.ComVisible(false)]
         public static TextInfo ReadOnly(TextInfo textInfo)
         {
             if (textInfo == null) { throw new ArgumentNullException(nameof(textInfo)); }
index 8ebbfa0..9e6e304 100644 (file)
@@ -21,7 +21,6 @@ namespace System.Globalization
     ============================================================================*/
 
     [Serializable]
-    [System.Runtime.InteropServices.ComVisible(true)]
     public class ThaiBuddhistCalendar : Calendar
     {
         // Initialize our era info.
@@ -38,7 +37,6 @@ namespace System.Globalization
         internal GregorianCalendarHelper helper;
 
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override DateTime MinSupportedDateTime
         {
             get
@@ -47,7 +45,6 @@ namespace System.Globalization
             }
         }
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override DateTime MaxSupportedDateTime
         {
             get
@@ -56,7 +53,6 @@ namespace System.Globalization
             }
         }
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override CalendarAlgorithmType AlgorithmType
         {
             get
@@ -128,7 +124,6 @@ namespace System.Globalization
 
 
         [SuppressMessage("Microsoft.Contracts", "CC1055")]  // Skip extra error checking to avoid *potential* AppCompat problems.
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override int GetWeekOfYear(DateTime time, CalendarWeekRule rule, DayOfWeek firstDayOfWeek)
         {
             return (helper.GetWeekOfYear(time, rule, firstDayOfWeek));
@@ -167,7 +162,6 @@ namespace System.Globalization
         // if this calendar does not have leap month, or this year is not a leap year.
         //
 
-        [System.Runtime.InteropServices.ComVisible(false)]
         public override int GetLeapMonth(int year, int era)
         {
             return (helper.GetLeapMonth(year, era));
index 997c5f2..7b47d9c 100644 (file)
@@ -41,7 +41,7 @@ namespace System.Globalization
 
         private static DateMapping[] InitDateMapping()
         {
-            short[] rawData = new short[] 
+            short[] rawData = new short[]
             {
                 //These data is taken from Tables/Excel/UmAlQura.xls please make sure that the two places are in sync
                 /*  DaysPerM     GY      GM     GD     D1   D2   D3   D4   D5   D6   D7   D8   D9   D10  D11  D12    
diff --git a/src/mscorlib/corefx/System/IO/FileStream.NetStandard17.cs b/src/mscorlib/corefx/System/IO/FileStream.NetStandard17.cs
deleted file mode 100644 (file)
index dc1385f..0000000
+++ /dev/null
@@ -1,76 +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.
-
-using Microsoft.Win32.SafeHandles;
-using System.Threading.Tasks;
-using System.Diagnostics;
-using System.Threading;
-
-namespace System.IO
-{
-    public partial class FileStream : Stream
-    {
-        public override IAsyncResult BeginRead(byte[] array, int offset, int numBytes, AsyncCallback callback, object state)
-        {
-            if (array == null)
-                throw new ArgumentNullException(nameof(array));
-            if (offset < 0)
-                throw new ArgumentOutOfRangeException(nameof(offset), SR.ArgumentOutOfRange_NeedNonNegNum);
-            if (numBytes < 0)
-                throw new ArgumentOutOfRangeException(nameof(numBytes), SR.ArgumentOutOfRange_NeedNonNegNum);
-            if (array.Length - offset < numBytes)
-                throw new ArgumentException(SR.Argument_InvalidOffLen);
-
-            if (IsClosed) throw new ObjectDisposedException(SR.ObjectDisposed_FileClosed);
-            if (!CanRead) throw new NotSupportedException(SR.NotSupported_UnreadableStream);
-
-            if (!IsAsync)
-                return base.BeginRead(array, offset, numBytes, callback, state);
-            else
-                return TaskToApm.Begin(ReadAsyncInternal(array, offset, numBytes, CancellationToken.None), callback, state);
-        }
-
-        public override IAsyncResult BeginWrite(byte[] array, int offset, int numBytes, AsyncCallback callback, object state)
-        {
-            if (array == null)
-                throw new ArgumentNullException(nameof(array));
-            if (offset < 0)
-                throw new ArgumentOutOfRangeException(nameof(offset), SR.ArgumentOutOfRange_NeedNonNegNum);
-            if (numBytes < 0)
-                throw new ArgumentOutOfRangeException(nameof(numBytes), SR.ArgumentOutOfRange_NeedNonNegNum);
-            if (array.Length - offset < numBytes)
-                throw new ArgumentException(SR.Argument_InvalidOffLen);
-
-            if (IsClosed) throw new ObjectDisposedException(SR.ObjectDisposed_FileClosed);
-            if (!CanWrite) throw new NotSupportedException(SR.NotSupported_UnwritableStream);
-
-            if (!IsAsync)
-                return base.BeginWrite(array, offset, numBytes, callback, state);
-            else
-                return TaskToApm.Begin(WriteAsyncInternal(array, offset, numBytes, CancellationToken.None), callback, state);
-        }
-
-        public override int EndRead(IAsyncResult asyncResult)
-        {
-            if (asyncResult == null)
-                throw new ArgumentNullException(nameof(asyncResult));
-
-            if (!IsAsync)
-                return base.EndRead(asyncResult);
-            else
-                return TaskToApm.End<int>(asyncResult);
-        }
-
-        public override void EndWrite(IAsyncResult asyncResult)
-        {
-            if (asyncResult == null)
-                throw new ArgumentNullException(nameof(asyncResult));
-
-            if (!IsAsync)
-                base.EndWrite(asyncResult);
-            else
-                TaskToApm.End(asyncResult);
-        }
-    }
-}
index 398f5a6..7db8518 100644 (file)
@@ -139,20 +139,6 @@ namespace System.IO
             this(path, mode, access, share, bufferSize, useAsync ? FileOptions.Asynchronous : FileOptions.None)
         { }
 
-        internal FileStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options, string msgPath, bool bFromProxy)
-            : this(path, mode, access, share, bufferSize, options, msgPath, bFromProxy, useLongPath: false)
-        {
-        }
-
-        internal FileStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options, string msgPath, bool bFromProxy, bool useLongPath)
-            : this(path, mode, access, share, bufferSize, options)
-        {
-            // msgPath is the path that is handed back to untrusted code, CoreCLR is always full trust
-            // bFromProxy is also related to asserting rights for limited trust and also can be ignored
-            // useLongPath was used to get around the legacy MaxPath check, this is no longer applicable as everything supports long paths
-            // checkHost is also related to limited trust scenarios
-        }
-
         public FileStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options)
         {
             if (path == null)
@@ -225,24 +211,6 @@ namespace System.IO
             return handle.IsAsync.HasValue ? handle.IsAsync.Value : false;
         }
 
-        // InternalOpen, InternalCreate, and InternalAppend:
-        // Factory methods for FileStream used by File, FileInfo, and ReadLinesIterator
-        // Specifies default access and sharing options for FileStreams created by those classes
-        internal static FileStream InternalOpen(string path, int bufferSize = DefaultBufferSize, bool useAsync = DefaultIsAsync)
-        {
-            return new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize, useAsync);
-        }
-
-        internal static FileStream InternalCreate(string path, int bufferSize = DefaultBufferSize, bool useAsync = DefaultIsAsync)
-        {
-            return new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read, bufferSize, useAsync);
-        }
-
-        internal static FileStream InternalAppend(string path, int bufferSize = DefaultBufferSize, bool useAsync = DefaultIsAsync)
-        {
-            return new FileStream(path, FileMode.Append, FileAccess.Write, FileShare.Read, bufferSize, useAsync);
-        }
-
         [Obsolete("This property has been deprecated.  Please use FileStream's SafeFileHandle property instead.  http://go.microsoft.com/fwlink/?linkid=14202")]
         public virtual IntPtr Handle { get { return SafeFileHandle.DangerousGetHandle(); } }
 
@@ -650,5 +618,67 @@ namespace System.IO
             // on Dispose(false) call.
             Dispose(false);
         }
+
+        public override IAsyncResult BeginRead(byte[] array, int offset, int numBytes, AsyncCallback callback, object state)
+        {
+            if (array == null)
+                throw new ArgumentNullException(nameof(array));
+            if (offset < 0)
+                throw new ArgumentOutOfRangeException(nameof(offset), SR.ArgumentOutOfRange_NeedNonNegNum);
+            if (numBytes < 0)
+                throw new ArgumentOutOfRangeException(nameof(numBytes), SR.ArgumentOutOfRange_NeedNonNegNum);
+            if (array.Length - offset < numBytes)
+                throw new ArgumentException(SR.Argument_InvalidOffLen);
+
+            if (IsClosed) throw new ObjectDisposedException(SR.ObjectDisposed_FileClosed);
+            if (!CanRead) throw new NotSupportedException(SR.NotSupported_UnreadableStream);
+
+            if (!IsAsync)
+                return base.BeginRead(array, offset, numBytes, callback, state);
+            else
+                return TaskToApm.Begin(ReadAsyncInternal(array, offset, numBytes, CancellationToken.None), callback, state);
+        }
+
+        public override IAsyncResult BeginWrite(byte[] array, int offset, int numBytes, AsyncCallback callback, object state)
+        {
+            if (array == null)
+                throw new ArgumentNullException(nameof(array));
+            if (offset < 0)
+                throw new ArgumentOutOfRangeException(nameof(offset), SR.ArgumentOutOfRange_NeedNonNegNum);
+            if (numBytes < 0)
+                throw new ArgumentOutOfRangeException(nameof(numBytes), SR.ArgumentOutOfRange_NeedNonNegNum);
+            if (array.Length - offset < numBytes)
+                throw new ArgumentException(SR.Argument_InvalidOffLen);
+
+            if (IsClosed) throw new ObjectDisposedException(SR.ObjectDisposed_FileClosed);
+            if (!CanWrite) throw new NotSupportedException(SR.NotSupported_UnwritableStream);
+
+            if (!IsAsync)
+                return base.BeginWrite(array, offset, numBytes, callback, state);
+            else
+                return TaskToApm.Begin(WriteAsyncInternal(array, offset, numBytes, CancellationToken.None), callback, state);
+        }
+
+        public override int EndRead(IAsyncResult asyncResult)
+        {
+            if (asyncResult == null)
+                throw new ArgumentNullException(nameof(asyncResult));
+
+            if (!IsAsync)
+                return base.EndRead(asyncResult);
+            else
+                return TaskToApm.End<int>(asyncResult);
+        }
+
+        public override void EndWrite(IAsyncResult asyncResult)
+        {
+            if (asyncResult == null)
+                throw new ArgumentNullException(nameof(asyncResult));
+
+            if (!IsAsync)
+                base.EndWrite(asyncResult);
+            else
+                TaskToApm.End(asyncResult);
+        }
     }
 }
index 324c8b5..a45ac46 100644 (file)
       <Member Name="CreateInstanceFrom(System.String,System.String)" />
       <Member Name="CreateInstanceFrom(System.String,System.String,System.Boolean,System.Reflection.BindingFlags,System.Reflection.Binder,System.Object[],System.Globalization.CultureInfo,System.Object[])" />
       <Member Name="CreateInstanceFrom(System.String,System.String,System.Object[])" />
-      <Member Status="ImplRoot" Name="System.Runtime.InteropServices._Activator.GetIDsOfNames(System.Guid@,System.IntPtr,System.UInt32,System.UInt32,System.IntPtr)" />
-      <Member Status="ImplRoot" Name="System.Runtime.InteropServices._Activator.GetTypeInfo(System.UInt32,System.UInt32,System.IntPtr)" />
-      <Member Status="ImplRoot" Name="System.Runtime.InteropServices._Activator.GetTypeInfoCount(System.UInt32@)" />
-      <Member Status="ImplRoot" Name="System.Runtime.InteropServices._Activator.Invoke(System.UInt32,System.Guid@,System.UInt32,System.Int16,System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr)" />
     </Type>
     <Type Status="ImplRoot" Name="System.AppDomain">
       <Member Status="ImplRoot" Name="get_CurrentDomain" />
       <Member Name="get_Value"/>
       <Member Status="ImplRoot" Name="OnSerializing(System.Runtime.Serialization.StreamingContext)" />
     </Type>
-    <Type Name="System.LocalDataStoreSlot">
-      <Member Status="ImplRoot" Name="Finalize" />
-    </Type>
     <Type Name="System.MarshalByRefObject">
       <Member Name="#ctor" />
       <Member Name="GetLifetimeService" />
       <Member Name="GetFieldFromHandle(System.RuntimeFieldHandle)" />
       <Member Name="GetFieldFromHandle(System.RuntimeFieldHandle,System.RuntimeTypeHandle)" />
       <Member Name="GetValue(System.Object)" />
+      <Member Name="GetValueDirect(System.TypedReference)" />
       <Member Name="GetOptionalCustomModifiers" />
       <Member Name="GetRequiredCustomModifiers" />
       <Member Name="GetRawConstantValue" />
       <Member Name="GetHashCode" />
       <Member Name="SetValue(System.Object,System.Object)" />
       <Member Name="SetValue(System.Object,System.Object,System.Reflection.BindingFlags,System.Reflection.Binder,System.Globalization.CultureInfo)" />
+      <Member Name="SetValueDirect(System.TypedReference,System.Object)" />
       <Member MemberType="Property" Name="Attributes" />
       <Member MemberType="Property" Name="FieldHandle" />
       <Member MemberType="Property" Name="FieldType" />
       <Member Name="Concat(System.Object)" />
       <Member Name="Concat(System.Object,System.Object)" />
       <Member Name="Concat(System.Object,System.Object,System.Object)" />
+      <Member Name="Concat(System.Object,System.Object,System.Object,System.Object,__arglist)" />
       <Member Name="Concat(System.Object[])" />
       <Member Name="Concat(System.String,System.String)" />
       <Member Name="Concat(System.String,System.String,System.String)" />
     </Type>
     <Type Name="System.Threading.IOCompletionCallback">
     </Type>
+    <Type Name="System.Threading.PreAllocatedOverlapped">
+      <Member Name="#ctor(System.Threading.IOCompletionCallback,System.Object,System.Object)" />
+      <Member Name="Dispose" />
+    </Type>
+    <Type Name="System.Threading.ThreadPoolBoundHandle">
+      <Member Name="get_Handle" />
+      <Member Name="AllocateNativeOverlapped(System.Threading.IOCompletionCallback,System.Object,System.Object)" />
+      <Member Name="AllocateNativeOverlapped(System.Threading.PreAllocatedOverlapped)" />
+      <Member Name="BindHandle(System.Runtime.InteropServices.SafeHandle)" />
+      <Member Name="Dispose" />
+      <Member Name="FreeNativeOverlapped(System.Threading.NativeOverlapped*)" />
+      <Member Name="GetNativeOverlappedState(System.Threading.NativeOverlapped*)" />
+    </Type>
     <Type Name="System.Threading.RegisteredWaitHandle">
       <Member Name="Unregister(System.Threading.WaitHandle)" />
       <Member Status="ImplRoot" Name="SetHandle(System.IntPtr)" />
       <Member Name="get_TypeName" />
       <Member MemberType="Property" Name="TypeName" />
     </Type>
-    <Type Name="System.TypedReference" />
+    <Type Name="System.TypedReference">
+      <Member Name="Equals(System.Object)" />
+      <Member Name="GetHashCode" />
+      <Member Name="GetTargetType(System.TypedReference)" />
+      <Member Name="MakeTypedReference(System.Object,System.Reflection.FieldInfo[])" />
+      <Member Name="SetTypedReference(System.TypedReference,System.Object)" />
+      <Member Name="TargetTypeToken(System.TypedReference)" />
+      <Member Name="ToObject(System.TypedReference)" />
+    </Type>
     <Type Name="System.TypeLoadException">
       <Member Name="#ctor" />
       <Member Name="#ctor(System.String)" />
     </Type>
     <Type Status="ImplRoot" Name="System.Runtime.InteropServices.PInvokeMap" />
     <Type Name="System.ArgIterator">  <!-- for MC++ -->
-      <Member Status="ImplRoot" Name="#ctor(System.RuntimeArgumentHandle,System.Void*)" /> <!-- EE - il stubs -->
+      <Member Name="#ctor(System.RuntimeArgumentHandle)" />
+      <Member Name="#ctor(System.RuntimeArgumentHandle,System.Void*)" />
+      <Member Name="End" />
+      <Member Name="Equals(System.Object)" />
+      <Member Name="GetHashCode" />
+      <Member Name="GetNextArg" />
+      <Member Name="GetNextArg(System.RuntimeTypeHandle)" />
+      <Member Name="GetNextArgType" />
+      <Member Name="GetRemainingCount" />
     </Type>
         <Type Name="System.Runtime.InteropServices.BestFitMappingAttribute">
       <Member MemberType="Field" Name="ThrowOnUnmappableChar" />
       <Member Name="DangerousCreate(System.Object,T@,System.Int32)" />
       <Member Name="Clear" />
       <Member Name="Fill(T)" />
+      <Member Name="GetItem(System.Int32)" /> 
       <Member Name="GetHashCode" />
       <Member Name="CopyTo(System.Span&lt;T&gt;)" />
       <Member Name="TryCopyTo(System.Span&lt;T&gt;)" />
       <Member Name="TryCopyTo(System.Span&lt;T&gt;)" />
       <Member Name="CopyTo(System.Span&lt;T&gt;)" />
     </Type>
-    <Type Name="System.SpanExtensions">
+    <Type Name="System.Span">
       <Member Name="AsBytes&lt;T&gt;(System.Span&lt;T&gt;)" />
       <Member Name="AsBytes&lt;T&gt;(System.ReadOnlySpan&lt;T&gt;)" />
       <Member Name="NonPortableCast&lt;TFrom,TTo&gt;(System.Span&lt;TFrom&gt;)" />
       <Member Name="NonPortableCast&lt;TFrom,TTo&gt;(System.ReadOnlySpan&lt;TFrom&gt;)" />
-    </Type>
-    <Type Name="System.ReadOnlySpanExtensions">
       <Member Name="Slice(System.String)" />
       <Member Name="Slice(System.String,System.Int32)" />
       <Member Name="Slice(System.String,System.Int32,System.Int32)" />
index 9688e28..5c51e47 100644 (file)
     <SystemSources Include="$(BclSourcesRoot)\System\AppDomainSetup.cs" />
     <SystemSources Include="$(BclSourcesRoot)\System\AppDomainManager.cs" />
     <SystemSources Include="$(BclSourcesRoot)\System\IAppDomainPauseManager.cs" />
-    <SystemSources Include="$(BclSourcesRoot)\System\IAppDomain.cs" />
     <SystemSources Include="$(BclSourcesRoot)\System\AppDomainAttributes.cs" />
     <SystemSources Include="$(BclSourcesRoot)\System\AppDomainUnloadedException.cs" />
     <SystemSources Include="$(BclSourcesRoot)\System\ApplicationId.cs" />
     <SystemSources Include="$(BclSourcesRoot)\System\CfgParser.cs" />
     <SystemSources Include="$(BclSourcesRoot)\System\CLSCompliantAttribute.cs" />
     <SystemSources Include="$(BclSourcesRoot)\System\TypeUnloadedException.cs" />
-    <SystemSources Include="$(BclSourcesRoot)\System\cominterfaces.cs" />
     <SystemSources Include="$(BclSourcesRoot)\System\CompatibilitySwitches.cs" />
     <SystemSources Include="$(BclSourcesRoot)\System\LowLevelConsole.cs" />
     <SystemSources Include="$(BclSourcesRoot)\System\ContextMarshalException.cs" />
     <SystemSources Include="$(BclSourcesRoot)\System\InvalidTimeZoneException.cs" />
     <SystemSources Include="$(BclSourcesRoot)\System\IConvertible.cs" />
     <SystemSources Include="$(BclSourcesRoot)\System\IServiceObjectProvider.cs" />
-    <SystemSources Include="$(BclSourcesRoot)\System\_LocalDataStore.cs" />
-    <SystemSources Include="$(BclSourcesRoot)\System\_LocalDataStoreMgr.cs" />
     <SystemSources Include="$(BclSourcesRoot)\System\MarshalByRefObject.cs" />
     <SystemSources Include="$(BclSourcesRoot)\System\Math.cs" />
     <SystemSources Include="$(BclSourcesRoot)\System\MathF.cs" />
     <ReflectionSources Include="$(BclSourcesRoot)\System\Reflection\Binder.cs" />
     <ReflectionSources Include="$(BclSourcesRoot)\System\Reflection\BindingFlags.cs" />
     <ReflectionSources Include="$(BclSourcesRoot)\System\Reflection\CallingConventions.cs" />
-    <ReflectionSources Include="$(BclSourcesRoot)\System\Reflection\ComInterfaces.cs" />
     <ReflectionSources Include="$(BclSourcesRoot)\System\Reflection\ConstructorInfo.cs" />
     <ReflectionSources Include="$(BclSourcesRoot)\System\Reflection\CustomAttribute.cs" />
     <ReflectionSources Include="$(BclSourcesRoot)\System\Reflection\DefaultMemberAttribute.cs" />
     <ReflectionEmitSources Include="$(BclSourcesRoot)\System\Reflection\Emit\AssemblyBuilderData.cs" />
     <ReflectionEmitSources Include="$(BclSourcesRoot)\System\Reflection\Emit\AssemblyBuilderAccess.cs" />
     <ReflectionEmitSources Include="$(BclSourcesRoot)\System\Reflection\Emit\AQNBuilder.cs" />
-    <ReflectionEmitSources Include="$(BclSourcesRoot)\System\Reflection\Emit\ComInterfaces.cs" />
     <ReflectionEmitSources Include="$(BclSourcesRoot)\System\Reflection\Emit\ConstructorBuilder.cs" />
     <ReflectionEmitSources Include="$(BclSourcesRoot)\System\Reflection\Emit\DynamicILGenerator.cs" />
     <ReflectionEmitSources Include="$(BclSourcesRoot)\System\Reflection\Emit\DynamicMethod.cs" />
   </ItemGroup>
   <ItemGroup>
     <FileStreamSources Include="$(CoreFxSourcesRoot)\System\IO\FileStream.cs" />
-    <FileStreamSources Include="$(CoreFxSourcesRoot)\System\IO\FileStream.NetStandard17.cs" />
     <FileStreamSources Include="$(CoreFxSourcesRoot)\System\IO\Error.cs" />
   </ItemGroup>
   <ItemGroup Condition="'$(TargetsUnix)' == 'true'">
index 3a8ca2d..2ef242a 100644 (file)
@@ -2414,12 +2414,6 @@ namespace System
         public override string ToString() { throw null; }
     }
     [System.Runtime.InteropServices.ComVisibleAttribute(true)]
-    public sealed partial class LocalDataStoreSlot
-    {
-        internal LocalDataStoreSlot() { }
-        ~LocalDataStoreSlot() { }
-    }
-    [System.Runtime.InteropServices.ComVisibleAttribute(true)]
     public abstract partial class MarshalByRefObject
     {
         protected MarshalByRefObject() { }
index 43d9a74..5fad0bd 100644 (file)
@@ -1389,6 +1389,8 @@ NotSupported_AssemblyLoadCodeBase = Assembly.Load with a Codebase is not support
 NotSupported_AssemblyLoadFromHash = Assembly.LoadFrom with hashValue is not supported.
 NotSupported_CannotCallEqualsOnSpan = Equals() on Span and ReadOnlySpan is not supported. Use operator== instead.
 NotSupported_CannotCallGetHashCodeOnSpan = GetHashCode() on Span and ReadOnlySpan is not supported.
+NotSupported_ReflectionOnlyLoad = Assembly.ReflectionOnlyLoad is not supported.
+NotSupported_ReflectionOnlyGetType = Type.ReflectionOnlyGetType is not supported.
 
 ; TypeLoadException
 TypeLoad_ResolveType = Could not resolve type '{0}'.
index 308d52e..12911c1 100644 (file)
 **
 =============================================================================*/
 
-namespace System 
-{   
-    
-    using System;
-    using System.Runtime.Serialization;
-    [System.Runtime.InteropServices.ComVisible(true)]
+using System;
+using System.Runtime.Serialization;
+
+namespace System
+{
     [Serializable]
-    public class AccessViolationException : SystemException 
+    public class AccessViolationException : SystemException
     {
-        public AccessViolationException() 
-            : base(Environment.GetResourceString("Arg_AccessViolationException")) 
+        public AccessViolationException()
+            : base(SR.Arg_AccessViolationException)
         {
-            SetErrorCode(__HResults.E_POINTER);
+            HResult = __HResults.E_POINTER;
         }
-    
-        public AccessViolationException(String message) 
-            : base(message) 
+
+        public AccessViolationException(String message)
+            : base(message)
         {
-            SetErrorCode(__HResults.E_POINTER);
+            HResult = __HResults.E_POINTER;
         }
-        
-        public AccessViolationException(String message, Exception innerException) 
-            : base(message, innerException) 
+
+        public AccessViolationException(String message, Exception innerException)
+            : base(message, innerException)
         {
-            SetErrorCode(__HResults.E_POINTER);
+            HResult = __HResults.E_POINTER;
         }
 
-        protected AccessViolationException(SerializationInfo info, StreamingContext context) : base(info, context) {}
+        protected AccessViolationException(SerializationInfo info, StreamingContext context) : base(info, context) { }
 
 #pragma warning disable 169  // Field is not used from managed.
         private IntPtr _ip;             // Address of faulting instruction.
         private IntPtr _target;         // Address that could not be accessed.
         private int _accessType;        // 0:read, 1:write
 #pragma warning restore 169
-
     }
-
 }
index 27f7faf..23c7e93 100644 (file)
@@ -6,8 +6,6 @@ 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
     public delegate void Action();
     public delegate void Action<in T1,in T2>(T1 arg1, T2 arg2);
     public delegate void Action<in T1,in T2,in T3>(T1 arg1, T2 arg2, T3 arg3);
@@ -32,8 +30,6 @@ namespace System
     public delegate int Comparison<in T>(T x, T y);
 
     public delegate TOutput Converter<in TInput, out TOutput>(TInput input); 
-    
-    public delegate bool Predicate<in T>(T obj); 
 
+    public delegate bool Predicate<in T>(T obj); 
 }
-
index 6fad8f3..769e4cb 100644 (file)
@@ -28,10 +28,7 @@ namespace System {
     using System.Diagnostics.Contracts;
 
     // Only statics, does not need to be marked with the serializable attribute
-    [ClassInterface(ClassInterfaceType.None)]
-    [ComDefaultInterface(typeof(_Activator))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public sealed class Activator : _Activator
+    public sealed class Activator
     {
         internal const int LookupMask                 = 0x000000FF;
         internal const BindingFlags ConLookup         = (BindingFlags) (BindingFlags.Instance | BindingFlags.Public);
@@ -553,28 +550,6 @@ namespace System {
         private static void Log(bool test, string title, string success, string failure)
         {
         }
-
-        void _Activator.GetTypeInfoCount(out uint pcTInfo)
-        {
-            throw new NotImplementedException();
-        }
-
-        void _Activator.GetTypeInfo(uint iTInfo, uint lcid, IntPtr ppTInfo)
-        {
-            throw new NotImplementedException();
-        }
-
-        void _Activator.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 _Activator.Invoke in VM\DangerousAPIs.h and
-        // include _Activator in SystemDomain::IsReflectionInvocationMethod in AppDomain.cpp.
-        void _Activator.Invoke(uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
-        {
-            throw new NotImplementedException();
-        }
     }
 }
 
index 8410456..3aeb465 100644 (file)
@@ -176,11 +176,7 @@ namespace System
     }
 
 
-    [ClassInterface(ClassInterfaceType.None)]
-    [ComDefaultInterface(typeof(System._AppDomain))]
-    [ComVisible(true)]
-    public sealed class AppDomain :
-        _AppDomain, IEvidenceFactory
+    public sealed class AppDomain : IEvidenceFactory
     {
         // Domain security information
         // These fields initialized from the other side only. (NOTE: order 
index c56746f..900feb5 100644 (file)
 **
 =============================================================================*/
 
-namespace System {
-    
-    using System.Runtime.Serialization;
+using System.Runtime.Serialization;
+
+namespace System
+{
     // The ApplicationException is the base class for nonfatal, 
     // application errors that occur.  These exceptions are generated 
     // (i.e., thrown) by an application, not the Runtime. Applications that need 
@@ -22,35 +23,34 @@ namespace System {
     // ApplicationException extends but adds no new functionality to 
     // RecoverableException.
     // 
-    [System.Runtime.InteropServices.ComVisible(true)]
     [Serializable]
-    public class ApplicationException : Exception {
-        
+    public class ApplicationException : Exception
+    {
         // Creates a new ApplicationException with its message string set to
         // the empty string, its HRESULT set to COR_E_APPLICATION, 
         // and its ExceptionInfo reference set to null. 
-        public ApplicationException() 
-            : base(Environment.GetResourceString("Arg_ApplicationException")) {
-            SetErrorCode(__HResults.COR_E_APPLICATION);
+        public ApplicationException()
+            : base(SR.Arg_ApplicationException)
+        {
+            HResult = __HResults.COR_E_APPLICATION;
         }
-        
+
         // Creates a new ApplicationException with its message string set to
         // message, its HRESULT set to COR_E_APPLICATION, 
         // and its ExceptionInfo reference set to null. 
         // 
-        public ApplicationException(String message) 
-            : base(message) {
-            SetErrorCode(__HResults.COR_E_APPLICATION);
-        }
-        
-        public ApplicationException(String message, Exception innerException) 
-            : base(message, innerException) {
-            SetErrorCode(__HResults.COR_E_APPLICATION);
+        public ApplicationException(String message)
+            : base(message)
+        {
+            HResult = __HResults.COR_E_APPLICATION;
         }
 
-        protected ApplicationException(SerializationInfo info, StreamingContext context) : base(info, context) {
+        public ApplicationException(String message, Exception innerException)
+            : base(message, innerException)
+        {
+            HResult = __HResults.COR_E_APPLICATION;
         }
 
+        protected ApplicationException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
-
 }
index c5bc379..83a60b9 100644 (file)
@@ -16,6 +16,19 @@ namespace System {
     [StructLayout(LayoutKind.Sequential)]
     public struct ArgIterator
     {
+        private IntPtr ArgCookie;               // Cookie from the EE.
+
+        // The SigPointer structure consists of the following members.  (Note: this is an inline native SigPointer data type)
+        private IntPtr sigPtr;                  // Pointer to remaining signature.
+        private IntPtr sigPtrLen;               // Remaining length of the pointer
+
+        // Note, sigPtrLen is actually a DWORD, but on 64bit systems this structure becomes
+        // 8-byte aligned, which requires us to pad it.
+            
+        private IntPtr ArgPtr;                  // Pointer to remaining args.
+        private int    RemainingArgs;           // # of remaining args.
+        
+#if VARARGS_ENABLED //The JIT doesn't support Varargs calling convention.
         [MethodImplAttribute(MethodImplOptions.InternalCall)]
         private extern ArgIterator(IntPtr arglist);
 
@@ -34,7 +47,6 @@ namespace System {
         // This is much like the C va_start macro
 
         [CLSCompliant(false)]
-
         public unsafe ArgIterator(RuntimeArgumentHandle arglist, void* ptr) : this(arglist.Value, ptr)
         {
         }
@@ -121,17 +133,54 @@ namespace System {
         {
             throw new NotSupportedException(Environment.GetResourceString("NotSupported_NYI"));
         }
+#else
+        public ArgIterator(RuntimeArgumentHandle arglist)
+        {
+            throw new PlatformNotSupportedException(); //The JIT requires work to enable ArgIterator see: https://github.com/dotnet/coreclr/issues/9204.
+        }
 
-        private IntPtr ArgCookie;               // Cookie from the EE.
+        [CLSCompliant(false)]
+        public unsafe ArgIterator(RuntimeArgumentHandle arglist, void* ptr)
+        {
+            throw new PlatformNotSupportedException(); //The JIT requires work to enable ArgIterator see: https://github.com/dotnet/coreclr/issues/9204.
+        }
 
-        // The SigPointer structure consists of the following members.  (Note: this is an inline native SigPointer data type)
-        private IntPtr sigPtr;                  // Pointer to remaining signature.
-        private IntPtr sigPtrLen;               // Remaining length of the pointer
+        public void End() 
+        { 
+            throw new PlatformNotSupportedException(); //The JIT requires work to enable ArgIterator see: https://github.com/dotnet/coreclr/issues/9204.
+        }
 
-        // Note, sigPtrLen is actually a DWORD, but on 64bit systems this structure becomes
-        // 8-byte aligned, which requires us to pad it.
-            
-        private IntPtr ArgPtr;                  // Pointer to remaining args.
-        private int    RemainingArgs;           // # of remaining args.
+        public override bool Equals(Object o) 
+        {  
+            throw new PlatformNotSupportedException(); //The JIT requires work to enable ArgIterator see: https://github.com/dotnet/coreclr/issues/9204.
+        }
+
+        public override int GetHashCode()
+        { 
+            throw new PlatformNotSupportedException(); //The JIT requires work to enable ArgIterator see: https://github.com/dotnet/coreclr/issues/9204.
+        }
+
+        [System.CLSCompliantAttribute(false)]
+        public System.TypedReference GetNextArg()
+        {
+            throw new PlatformNotSupportedException(); //The JIT requires work to enable ArgIterator see: https://github.com/dotnet/coreclr/issues/9204.
+        }
+
+        [System.CLSCompliantAttribute(false)]
+        public System.TypedReference GetNextArg(System.RuntimeTypeHandle rth)
+        {
+            throw new PlatformNotSupportedException(); //The JIT requires work to enable ArgIterator see: https://github.com/dotnet/coreclr/issues/9204.
+        }
+
+        public unsafe System.RuntimeTypeHandle GetNextArgType()
+        {
+            throw new PlatformNotSupportedException(); //The JIT requires work to enable ArgIterator see: https://github.com/dotnet/coreclr/issues/9204.
+        }
+
+        public int GetRemainingCount()
+        {  
+            throw new PlatformNotSupportedException(); //The JIT requires work to enable ArgIterator see: https://github.com/dotnet/coreclr/issues/9204.
+        }
+#endif //VARARGS_ENABLED
     }
 }
index f37b769..fe054a9 100644 (file)
 **
 =============================================================================*/
 
-namespace System {
-    
-    using System;
-    using System.Runtime.Remoting;
-    using System.Runtime.Serialization;
-    using System.Globalization;
-    using System.Security.Permissions;
-    using System.Diagnostics.Contracts;
+using System.Globalization;
+using System.Runtime.Serialization;
+
+namespace System
+{
     // The ArgumentException is thrown when an argument does not meet 
     // the contract of the method.  Ideally it should give a meaningful error
     // message describing what was wrong and which parameter is incorrect.
     // 
-    [System.Runtime.InteropServices.ComVisible(true)]
     [Serializable]
-    public class ArgumentException : SystemException, ISerializable {
-        private String m_paramName;
-        
+    public class ArgumentException : SystemException, ISerializable
+    {
+        private String _paramName;
+
         // Creates a new ArgumentException with its message 
         // string set to the empty string. 
-        public ArgumentException() 
-            : base(Environment.GetResourceString("Arg_ArgumentException")) {
-            SetErrorCode(__HResults.COR_E_ARGUMENT);
+        public ArgumentException()
+            : base(SR.Arg_ArgumentException)
+        {
+            HResult = __HResults.COR_E_ARGUMENT;
         }
-        
+
         // Creates a new ArgumentException with its message 
         // string set to message. 
         // 
-        public ArgumentException(String message) 
-            : base(message) {
-            SetErrorCode(__HResults.COR_E_ARGUMENT);
+        public ArgumentException(String message)
+            : base(message)
+        {
+            HResult = __HResults.COR_E_ARGUMENT;
         }
-        
-        public ArgumentException(String message, Exception innerException) 
-            : base(message, innerException) {
-            SetErrorCode(__HResults.COR_E_ARGUMENT);
+
+        public ArgumentException(String message, Exception innerException)
+            : base(message, innerException)
+        {
+            HResult = __HResults.COR_E_ARGUMENT;
         }
 
-        public ArgumentException(String message, String paramName, Exception innerException) 
-            : base(message, innerException) {
-            m_paramName = paramName;
-            SetErrorCode(__HResults.COR_E_ARGUMENT);
+        public ArgumentException(String message, String paramName, Exception innerException)
+            : base(message, innerException)
+        {
+            _paramName = paramName;
+            HResult = __HResults.COR_E_ARGUMENT;
         }
-        
-        public ArgumentException (String message, String paramName)
-        
-            : base (message) {
-            m_paramName = paramName;
-            SetErrorCode(__HResults.COR_E_ARGUMENT);
+
+        public ArgumentException(String message, String paramName)
+            : base(message)
+        {
+            _paramName = paramName;
+            HResult = __HResults.COR_E_ARGUMENT;
         }
 
-        protected ArgumentException(SerializationInfo info, StreamingContext context) : base(info, context) {
-            m_paramName = info.GetString("ParamName");
+        protected ArgumentException(SerializationInfo info, StreamingContext context)
+            : base(info, context)
+        {
+            _paramName = info.GetString("ParamName");
         }
-        
+
+        public override void GetObjectData(SerializationInfo info, StreamingContext context)
+        {
+            base.GetObjectData(info, context);
+            info.AddValue("ParamName", _paramName, typeof(String));
+        }
+
         public override String Message
         {
-            get {
+            get
+            {
                 String s = base.Message;
-                if (!String.IsNullOrEmpty(m_paramName)) {
-                    String resourceString = Environment.GetResourceString("Arg_ParamName_Name", m_paramName);
+                if (!String.IsNullOrEmpty(_paramName))
+                {
+                    String resourceString = SR.Format(SR.Arg_ParamName_Name, _paramName);
                     return s + Environment.NewLine + resourceString;
                 }
                 else
                     return s;
             }
         }
-                
-        public virtual String ParamName {
-            get { return m_paramName; }
-        }
-    
-        public override void GetObjectData(SerializationInfo info, StreamingContext context) {
-            if (info==null) {
-                throw new ArgumentNullException(nameof(info));
-            }
-            Contract.EndContractBlock();
-            base.GetObjectData(info, context);
-            info.AddValue("ParamName", m_paramName, typeof(String));
+
+        public virtual String ParamName
+        {
+            get { return _paramName; }
         }
     }
 }
index 661ebd2..3a86223 100644 (file)
 **
 =============================================================================*/
 
-namespace System {
-    
-    using System;
-    using System.Runtime.Serialization;
-    using System.Runtime.Remoting;
-    using System.Security.Permissions;
-    
+using System.Runtime.Serialization;
+
+namespace System
+{
     // The ArgumentException is thrown when an argument 
     // is null when it shouldn't be.
     // 
-    [System.Runtime.InteropServices.ComVisible(true)]
     [Serializable]
     public class ArgumentNullException : ArgumentException
     {
         // Creates a new ArgumentNullException with its message 
         // string set to a default message explaining an argument was null.
-       public ArgumentNullException() 
-            : base(Environment.GetResourceString("ArgumentNull_Generic")) {
-                // Use E_POINTER - COM used that for null pointers.  Description is "invalid pointer"
-                SetErrorCode(__HResults.E_POINTER);
+        public ArgumentNullException()
+             : base(SR.ArgumentNull_Generic)
+        {
+            // Use E_POINTER - COM used that for null pointers.  Description is "invalid pointer"
+            HResult = __HResults.E_POINTER;
         }
 
-        public ArgumentNullException(String paramName) 
-            : base(Environment.GetResourceString("ArgumentNull_Generic"), paramName) {
-            SetErrorCode(__HResults.E_POINTER);
+        public ArgumentNullException(String paramName)
+            : base(SR.ArgumentNull_Generic, paramName)
+        {
+            HResult = __HResults.E_POINTER;
         }
 
-        public ArgumentNullException(String message, Exception innerException) 
-            : base(message, innerException) {
-            SetErrorCode(__HResults.E_POINTER);
-        }
-            
-        public ArgumentNullException(String paramName, String message) 
-            : base(message, paramName) {
-            SetErrorCode(__HResults.E_POINTER);   
+        public ArgumentNullException(String message, Exception innerException)
+            : base(message, innerException)
+        {
+            HResult = __HResults.E_POINTER;
         }
 
-        protected ArgumentNullException(SerializationInfo info, StreamingContext context) : base(info, context) {
+        public ArgumentNullException(String paramName, String message)
+            : base(message, paramName)
+        {
+            HResult = __HResults.E_POINTER;
         }
+
+        protected ArgumentNullException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
 }
index f536093..081ba45 100644 (file)
 **
 =============================================================================*/
 
-namespace System {
-    
-    using System;
-    using System.Runtime.Serialization;
+using System.Runtime.Serialization;
+
+namespace System
+{
     // The ArithmeticException is thrown when overflow or underflow
     // occurs.
     // 
-    [System.Runtime.InteropServices.ComVisible(true)]
     [Serializable]
     public class ArithmeticException : SystemException
-    {        
+    {
         // Creates a new ArithmeticException with its message string set to
         // the empty string, its HRESULT set to COR_E_ARITHMETIC, 
         // and its ExceptionInfo reference set to null. 
-        public ArithmeticException() 
-            : base(Environment.GetResourceString("Arg_ArithmeticException")) {
-            SetErrorCode(__HResults.COR_E_ARITHMETIC);
+        public ArithmeticException()
+            : base(SR.Arg_ArithmeticException)
+        {
+            HResult = __HResults.COR_E_ARITHMETIC;
         }
-        
+
         // Creates a new ArithmeticException with its message string set to
         // message, its HRESULT set to COR_E_ARITHMETIC, 
         // and its ExceptionInfo reference set to null. 
         // 
-        public ArithmeticException(String message) 
-            : base(message) {
-            SetErrorCode(__HResults.COR_E_ARITHMETIC);
-        }
-        
-        public ArithmeticException(String message, Exception innerException) 
-            : base(message, innerException) {
-            SetErrorCode(__HResults.COR_E_ARITHMETIC);
+        public ArithmeticException(String message)
+            : base(message)
+        {
+            HResult = __HResults.COR_E_ARITHMETIC;
         }
 
-        protected ArithmeticException(SerializationInfo info, StreamingContext context) : base(info, context) {
+        public ArithmeticException(String message, Exception innerException)
+            : base(message, innerException)
+        {
+            HResult = __HResults.COR_E_ARITHMETIC;
         }
 
+        protected ArithmeticException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
-
 }
index 4f24b9d..3e941fd 100644 (file)
 **
 =============================================================================*/
 
-namespace System {
-    
-    using System;
-    using System.Runtime.Serialization;
+using System.Runtime.Serialization;
+
+namespace System
+{
     // The ArrayMismatchException is thrown when an attempt to store
     // an object of the wrong type within an array occurs.
     // 
-    [System.Runtime.InteropServices.ComVisible(true)]
     [Serializable]
-    public class ArrayTypeMismatchException : SystemException {
-        
+    public class ArrayTypeMismatchException : SystemException
+    {
         // Creates a new ArrayMismatchException with its message string set to
         // the empty string, its HRESULT set to COR_E_ARRAYTYPEMISMATCH, 
         // and its ExceptionInfo reference set to null. 
-        public ArrayTypeMismatchException() 
-            : base(Environment.GetResourceString("Arg_ArrayTypeMismatchException")) {
-            SetErrorCode(__HResults.COR_E_ARRAYTYPEMISMATCH);
+        public ArrayTypeMismatchException()
+            : base(SR.Arg_ArrayTypeMismatchException)
+        {
+            HResult = __HResults.COR_E_ARRAYTYPEMISMATCH;
         }
-        
+
         // Creates a new ArrayMismatchException with its message string set to
         // message, its HRESULT set to COR_E_ARRAYTYPEMISMATCH, 
         // and its ExceptionInfo reference set to null. 
         // 
-        public ArrayTypeMismatchException(String message) 
-            : base(message) {
-            SetErrorCode(__HResults.COR_E_ARRAYTYPEMISMATCH);
-        }
-        
-        public ArrayTypeMismatchException(String message, Exception innerException) 
-            : base(message, innerException) {
-            SetErrorCode(__HResults.COR_E_ARRAYTYPEMISMATCH);
+        public ArrayTypeMismatchException(String message)
+            : base(message)
+        {
+            HResult = __HResults.COR_E_ARRAYTYPEMISMATCH;
         }
 
-        protected ArrayTypeMismatchException(SerializationInfo info, StreamingContext context) : base(info, context) {
+        public ArrayTypeMismatchException(String message, Exception innerException)
+            : base(message, innerException)
+        {
+            HResult = __HResults.COR_E_ARRAYTYPEMISMATCH;
         }
 
+        protected ArrayTypeMismatchException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
-
 }
index 69a0381..5c49535 100644 (file)
@@ -9,9 +9,9 @@
 ** Purpose: Type of callback for async operations
 **
 ===========================================================*/
-namespace System {
+
+namespace System
+{
     [Serializable]
-    [System.Runtime.InteropServices.ComVisible(true)]
     public delegate void AsyncCallback(IAsyncResult ar);
-
 }
index e77450e..796608a 100644 (file)
@@ -17,10 +17,7 @@ namespace System {
 
     [Serializable]
     [AttributeUsageAttribute(AttributeTargets.All, Inherited = true, AllowMultiple=false)] 
-    [ClassInterface(ClassInterfaceType.None)]
-    [ComDefaultInterface(typeof(_Attribute))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public abstract class Attribute : _Attribute
+    public abstract class Attribute
     {
         #region Private Statics
 
index 33617e9..fdfa4ab 100644 (file)
@@ -4,37 +4,33 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////////
-namespace System {
-    
-    using System;
-    
+
+namespace System
+{
     // Enum used to indicate all the elements of the
     // VOS it is valid to attach this element to.
-[Serializable]
     [Flags]
-[System.Runtime.InteropServices.ComVisible(true)]
+    [Serializable]
     public enum AttributeTargets
     {
-        Assembly      = 0x0001,
-        Module        = 0x0002,
-        Class         = 0x0004,
-        Struct        = 0x0008,
-        Enum          = 0x0010,
-        Constructor   = 0x0020,
-        Method        = 0x0040,
-        Property      = 0x0080,
-        Field         = 0x0100,
-        Event         = 0x0200,
-        Interface     = 0x0400,
-        Parameter     = 0x0800,
-        Delegate      = 0x1000,
-        ReturnValue   = 0x2000,
-        //@todo GENERICS: document GenericParameter
+        Assembly = 0x0001,
+        Module = 0x0002,
+        Class = 0x0004,
+        Struct = 0x0008,
+        Enum = 0x0010,
+        Constructor = 0x0020,
+        Method = 0x0040,
+        Property = 0x0080,
+        Field = 0x0100,
+        Event = 0x0200,
+        Interface = 0x0400,
+        Parameter = 0x0800,
+        Delegate = 0x1000,
+        ReturnValue = 0x2000,
         GenericParameter = 0x4000,
-        
-        
-        All           = Assembly | Module   | Class | Struct | Enum      | Constructor | 
-                        Method   | Property | Field | Event  | Interface | Parameter   | 
-                        Delegate | ReturnValue | GenericParameter,
+
+        All = Assembly | Module | Class | Struct | Enum | Constructor |
+                        Method | Property | Field | Event | Interface | Parameter |
+                        Delegate | ReturnValue | GenericParameter
     }
 }
index e902049..e03600d 100644 (file)
 **
 =============================================================================*/
 
-namespace System {
-[Serializable]
-    [AttributeUsage (AttributeTargets.All, Inherited=true, AllowMultiple=false)]
-[System.Runtime.InteropServices.ComVisible(true)]
-    public sealed class CLSCompliantAttribute : Attribute 
+namespace System
+{
+    [Serializable]
+    [AttributeUsage(AttributeTargets.All, Inherited = true, AllowMultiple = false)]
+    public sealed class CLSCompliantAttribute : Attribute
     {
-        private bool m_compliant;
+        private bool _compliant;
 
-        public CLSCompliantAttribute (bool isCompliant)
+        public CLSCompliantAttribute(bool isCompliant)
         {
-            m_compliant = isCompliant;
+            _compliant = isCompliant;
         }
-        public bool IsCompliant 
+        public bool IsCompliant
         {
-            get 
+            get
             {
-                return m_compliant;
+                return _compliant;
             }
         }
     }
index d25294c..689ed7e 100644 (file)
 **
 **
 ============================================================*/
-namespace System {
 
-    using System.Collections;
-    using System.Collections.Generic;
-    using System.Diagnostics.Contracts;
+using System.Collections;
+using System.Collections.Generic;
 
-[System.Runtime.InteropServices.ComVisible(true)]
-    [Serializable] 
-    public sealed class CharEnumerator : IEnumerator, ICloneable, IEnumerator<char>, IDisposable {
-        private String str;
-        private int index;
-        private char currentElement;
+namespace System
+{
+    public sealed class CharEnumerator : IEnumerator, IEnumerator<char>, IDisposable, ICloneable
+    {
+        private String _str;
+        private int _index;
+        private char _currentElement;
 
-        internal CharEnumerator(String str) {
-            Contract.Requires(str != null);
-            this.str = str;
-            this.index = -1;
+        internal CharEnumerator(String str)
+        {
+            _str = str;
+            _index = -1;
         }
 
-        public Object Clone() {
+        public object Clone()
+        {
             return MemberwiseClone();
         }
-    
-        public bool MoveNext() {
-            if (index < (str.Length-1)) {
-                index++;
-                currentElement = str[index];
+
+        public bool MoveNext()
+        {
+            if (_index < (_str.Length - 1))
+            {
+                _index++;
+                _currentElement = _str[_index];
                 return true;
             }
             else
-                index = str.Length;
+                _index = _str.Length;
             return false;
-
         }
 
-        public void Dispose() {
-            if (str != null)
-                index = str.Length;
-            str = null;
+        public void Dispose()
+        {
+            if (_str != null)
+                _index = _str.Length;
+            _str = null;
         }
-    
+
         /// <internalonly/>
-        Object IEnumerator.Current {
+        Object IEnumerator.Current
+        {
             get { return Current; }
         }
-    
-        public char Current {
-            get {
-                if (index == -1)
-                    throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumNotStarted));
-                if (index >= str.Length)
-                    throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumEnded));                                            
-                return currentElement;
+
+        public char Current
+        {
+            get
+            {
+                if (_index == -1)
+                    throw new InvalidOperationException(SR.InvalidOperation_EnumNotStarted);
+                if (_index >= _str.Length)
+                    throw new InvalidOperationException(SR.InvalidOperation_EnumEnded);
+                return _currentElement;
             }
         }
 
-        public void Reset() {
-            currentElement = (char)0;
-            index = -1;
+        public void Reset()
+        {
+            _currentElement = (char)0;
+            _index = -1;
         }
     }
 }
index 7aa5971..5828369 100644 (file)
 // 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.
-#pragma warning disable 0420
 
-
-// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
-//
-//
-//
-// A lock-free, concurrent queue primitive, and its associated debugger view type.
-//
-// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-
-using System;
-using System.Collections;
 using System.Collections.Generic;
 using System.Diagnostics;
-using System.Diagnostics.Contracts;
-using System.Runtime.ConstrainedExecution;
 using System.Runtime.InteropServices;
 using System.Runtime.Serialization;
-using System.Security;
-using System.Security.Permissions;
 using System.Threading;
 
 namespace System.Collections.Concurrent
 {
-
     /// <summary>
     /// Represents a thread-safe first-in, first-out collection of objects.
     /// </summary>
     /// <typeparam name="T">Specifies the type of elements in the queue.</typeparam>
     /// <remarks>
-    /// All public  and protected members of <see cref="ConcurrentQueue{T}"/> are thread-safe and may be used
+    /// All public and protected members of <see cref="ConcurrentQueue{T}"/> are thread-safe and may be used
     /// concurrently from multiple threads.
     /// </remarks>
-    [ComVisible(false)]
     [DebuggerDisplay("Count = {Count}")]
     [DebuggerTypeProxy(typeof(SystemCollectionsConcurrent_ProducerConsumerCollectionDebugView<>))]
     [Serializable]
     public class ConcurrentQueue<T> : IProducerConsumerCollection<T>, IReadOnlyCollection<T>
     {
-        //fields of ConcurrentQueue
-        [NonSerialized]
-        private volatile Segment m_head;
+        // This implementation provides an unbounded, multi-producer multi-consumer queue
+        // that supports the standard Enqueue/TryDequeue operations, as well as support for
+        // snapshot enumeration (GetEnumerator, ToArray, CopyTo), peeking, and Count/IsEmpty.
+        // It is composed of a linked list of bounded ring buffers, each of which has a head
+        // and a tail index, isolated from each other to minimize false sharing.  As long as
+        // the number of elements in the queue remains less than the size of the current
+        // buffer (Segment), no additional allocations are required for enqueued items.  When
+        // the number of items exceeds the size of the current segment, the current segment is
+        // "frozen" to prevent further enqueues, and a new segment is linked from it and set
+        // as the new tail segment for subsequent enqueues.  As old segments are consumed by
+        // dequeues, the head reference is updated to point to the segment that dequeuers should
+        // try next.  To support snapshot enumeration, segments also support the notion of
+        // preserving for observation, whereby they avoid overwriting state as part of dequeues.
+        // Any operation that requires a snapshot results in all current segments being
+        // both frozen for enqueues and preserved for observation: any new enqueues will go
+        // to new segments, and dequeuers will consume from the existing segments but without
+        // overwriting the existing data.
+
+        /// <summary>Initial length of the segments used in the queue.</summary>
+        private const int InitialSegmentLength = 32;
+        /// <summary>
+        /// Maximum length of the segments used in the queue.  This is a somewhat arbitrary limit:
+        /// larger means that as long as we don't exceed the size, we avoid allocating more segments,
+        /// but if we do exceed it, then the segment becomes garbage.
+        /// </summary>
+        private const int MaxSegmentLength = 1024 * 1024;
 
+        /// <summary>
+        /// Lock used to protect cross-segment operations, including any updates to <see cref="_tail"/> or <see cref="_head"/>
+        /// and any operations that need to get a consistent view of them.
+        /// </summary>
         [NonSerialized]
-        private volatile Segment m_tail;
-
-        private T[] m_serializationArray; // Used for custom serialization.
-
-        private const int SEGMENT_SIZE = 32;
-
-        //number of snapshot takers, GetEnumerator(), ToList() and ToArray() operations take snapshot.
+        private object _crossSegmentLock;
+        /// <summary>The current tail segment.</summary>
         [NonSerialized]
-        internal volatile int m_numSnapshotTakers = 0;
+        private volatile Segment _tail;
+        /// <summary>The current head segment.</summary>
+        [NonSerialized]
+        private volatile Segment _head;
+        /// <summary>Field used to temporarily store the contents of the queue for serialization.</summary>
+        private T[] _serializationArray;
 
         /// <summary>
         /// Initializes a new instance of the <see cref="ConcurrentQueue{T}"/> class.
         /// </summary>
         public ConcurrentQueue()
         {
-            m_head = m_tail = new Segment(0, this);
+            _crossSegmentLock = new object();
+            _tail = _head = new Segment(InitialSegmentLength);
+        }
+
+        /// <summary>Set the data array to be serialized.</summary>
+        [OnSerializing]
+        private void OnSerializing(StreamingContext context)
+        {
+            _serializationArray = ToArray();
+        }
+
+        /// <summary>Clear the data array that was serialized.</summary>
+        [OnSerialized]
+        private void OnSerialized(StreamingContext context)
+        {
+            _serializationArray = null;
+        }
+
+        /// <summary>Construct the queue from the deserialized <see cref="_serializationArray"/>.</summary>
+        [OnDeserialized]
+        private void OnDeserialized(StreamingContext context)
+        {
+            Debug.Assert(_serializationArray != null);
+            InitializeFromCollection(_serializationArray);
+            _serializationArray = null;
         }
 
         /// <summary>
@@ -70,34 +103,39 @@ namespace System.Collections.Concurrent
         /// <param name="collection">A collection from which to copy elements.</param>
         private void InitializeFromCollection(IEnumerable<T> collection)
         {
-            Segment localTail = new Segment(0, this);//use this local variable to avoid the extra volatile read/write. this is safe because it is only called from ctor
-            m_head = localTail; 
-
-            int index = 0;
-            foreach (T element in collection)
+            _crossSegmentLock = new object();
+
+            // Determine the initial segment size.  We'll use the default,
+            // unless the collection is known to be larger than than, in which
+            // case we round its length up to a power of 2, as all segments must
+            // be a power of 2 in length.
+            int length = InitialSegmentLength;
+            var c = collection as ICollection<T>;
+            if (c != null)
             {
-                Debug.Assert(index >= 0 && index < SEGMENT_SIZE);
-                localTail.UnsafeAdd(element);
-                index++;
-
-                if (index >= SEGMENT_SIZE)
+                int count = c.Count;
+                if (count > length)
                 {
-                    localTail = localTail.UnsafeGrow();
-                    index = 0;
+                    length = RoundUpToPowerOf2(count);
                 }
             }
 
-            m_tail = localTail;
+            // Initialize the segment and add all of the data to it.
+            _tail = _head = new Segment(length);
+            foreach (T item in collection)
+            {
+                Enqueue(item);
+            }
         }
 
         /// <summary>
-        /// Initializes a new instance of the <see cref="ConcurrentQueue{T}"/>
-        /// class that contains elements copied from the specified collection
+        /// Initializes a new instance of the <see cref="ConcurrentQueue{T}"/> class that contains elements copied
+        /// from the specified collection.
         /// </summary>
-        /// <param name="collection">The collection whose elements are copied to the new <see
-        /// cref="ConcurrentQueue{T}"/>.</param>
-        /// <exception cref="T:System.ArgumentNullException">The <paramref name="collection"/> argument is
-        /// null.</exception>
+        /// <param name="collection">
+        /// The collection whose elements are copied to the new <see cref="ConcurrentQueue{T}"/>.
+        /// </param>
+        /// <exception cref="System.ArgumentNullException">The <paramref name="collection"/> argument is null.</exception>
         public ConcurrentQueue(IEnumerable<T> collection)
         {
             if (collection == null)
@@ -109,37 +147,15 @@ namespace System.Collections.Concurrent
         }
 
         /// <summary>
-        /// Get the data array to be serialized
+        /// Copies the elements of the <see cref="ICollection"/> to an <see
+        /// cref="Array"/>, starting at a particular <see cref="Array"/> index.
         /// </summary>
-        [OnSerializing]
-        private void OnSerializing(StreamingContext context)
-        {
-            // save the data into the serialization array to be saved
-            m_serializationArray = ToArray();
-        }
-
-        /// <summary>
-        /// Construct the queue from a previously seiralized one
-        /// </summary>
-        [OnDeserialized]
-        private void OnDeserialized(StreamingContext context)
-        {
-            Debug.Assert(m_serializationArray != null);
-            InitializeFromCollection(m_serializationArray);
-            m_serializationArray = null;
-        }
-
-        /// <summary>
-        /// Copies the elements of the <see cref="T:System.Collections.ICollection"/> to an <see
-        /// cref="T:System.Array"/>, starting at a particular
-        /// <see cref="T:System.Array"/> index.
-        /// </summary>
-        /// <param name="array">The one-dimensional <see cref="T:System.Array">Array</see> that is the
-        /// destination of the elements copied from the
-        /// <see cref="T:System.Collections.Concurrent.ConcurrentBag"/>. The <see
-        /// cref="T:System.Array">Array</see> must have zero-based indexing.</param>
-        /// <param name="index">The zero-based index in <paramref name="array"/> at which copying
-        /// begins.</param>
+        /// <param name="array">
+        /// The one-dimensional <see cref="Array">Array</see> that is the destination of the
+        /// elements copied from the <see cref="ConcurrentQueue{T}"/>. <paramref name="array"/> must have
+        /// zero-based indexing.
+        /// </param>
+        /// <param name="index">The zero-based index in <paramref name="array"/> at which copying begins.</param>
         /// <exception cref="ArgumentNullException"><paramref name="array"/> is a null reference (Nothing in
         /// Visual Basic).</exception>
         /// <exception cref="ArgumentOutOfRangeException"><paramref name="index"/> is less than
@@ -148,72 +164,58 @@ namespace System.Collections.Concurrent
         /// <paramref name="array"/> is multidimensional. -or-
         /// <paramref name="array"/> does not have zero-based indexing. -or-
         /// <paramref name="index"/> is equal to or greater than the length of the <paramref name="array"/>
-        /// -or- The number of elements in the source <see cref="T:System.Collections.ICollection"/> is
+        /// -or- The number of elements in the source <see cref="ICollection"/> is
         /// greater than the available space from <paramref name="index"/> to the end of the destination
         /// <paramref name="array"/>. -or- The type of the source <see
-        /// cref="T:System.Collections.ICollection"/> cannot be cast automatically to the type of the
+        /// cref="ICollection"/> cannot be cast automatically to the type of the
         /// destination <paramref name="array"/>.
         /// </exception>
         void ICollection.CopyTo(Array array, int index)
         {
+            // Special-case when the Array is actually a T[], taking a faster path
+            T[] szArray = array as T[];
+            if (szArray != null)
+            {
+                CopyTo(szArray, index);
+                return;
+            }
+
             // Validate arguments.
             if (array == null)
             {
                 throw new ArgumentNullException(nameof(array));
             }
 
-            // We must be careful not to corrupt the array, so we will first accumulate an
-            // internal list of elements that we will then copy to the array. This requires
-            // some extra allocation, but is necessary since we don't know up front whether
-            // the array is sufficiently large to hold the stack's contents.
-            ((ICollection)ToList()).CopyTo(array, index);
+            // Otherwise, fall back to the slower path that first copies the contents
+            // to an array, and then uses that array's non-generic CopyTo to do the copy.
+            ToArray().CopyTo(array, index);
         }
 
         /// <summary>
-        /// Gets a value indicating whether access to the <see cref="T:System.Collections.ICollection"/> is
+        /// Gets a value indicating whether access to the <see cref="ICollection"/> is
         /// synchronized with the SyncRoot.
         /// </summary>
-        /// <value>true if access to the <see cref="T:System.Collections.ICollection"/> is synchronized
+        /// <value>true if access to the <see cref="ICollection"/> is synchronized
         /// with the SyncRoot; otherwise, false. For <see cref="ConcurrentQueue{T}"/>, this property always
         /// returns false.</value>
-        bool ICollection.IsSynchronized
-        {
-            // Gets a value indicating whether access to this collection is synchronized. Always returns
-            // false. The reason is subtle. While access is in face thread safe, it's not the case that
-            // locking on the SyncRoot would have prevented concurrent pushes and pops, as this property
-            // would typically indicate; that's because we internally use CAS operations vs. true locks.
-            get { return false; }
-        }
-
+        bool ICollection.IsSynchronized => false; // always false, as true implies synchronization via SyncRoot
 
         /// <summary>
         /// Gets an object that can be used to synchronize access to the <see
-        /// cref="T:System.Collections.ICollection"/>. This property is not supported.
+        /// cref="ICollection"/>. This property is not supported.
         /// </summary>
-        /// <exception cref="T:System.NotSupportedException">The SyncRoot property is not supported.</exception>
-        object ICollection.SyncRoot
-        {
-            get
-            {
-                throw new NotSupportedException(Environment.GetResourceString("ConcurrentCollection_SyncRoot_NotSupported"));
-            }
-        }
+        /// <exception cref="NotSupportedException">The SyncRoot property is not supported.</exception>
+        object ICollection.SyncRoot { get { throw new NotSupportedException(Environment.GetResourceString("ConcurrentCollection_SyncRoot_NotSupported")); } }
 
-        /// <summary>
-        /// Returns an enumerator that iterates through a collection.
-        /// </summary>
-        /// <returns>An <see cref="T:System.Collections.IEnumerator"/> that can be used to iterate through the collection.</returns>
-        IEnumerator IEnumerable.GetEnumerator()
-        {
-            return ((IEnumerable<T>)this).GetEnumerator();
-        }
+        /// <summary>Returns an enumerator that iterates through a collection.</summary>
+        /// <returns>An <see cref="IEnumerator"/> that can be used to iterate through the collection.</returns>
+        IEnumerator IEnumerable.GetEnumerator() => ((IEnumerable<T>)this).GetEnumerator();
 
         /// <summary>
-        /// Attempts to add an object to the <see
-        /// cref="T:System.Collections.Concurrent.IProducerConsumerCollection{T}"/>.
+        /// Attempts to add an object to the <see cref="Concurrent.IProducerConsumerCollection{T}"/>.
         /// </summary>
         /// <param name="item">The object to add to the <see
-        /// cref="T:System.Collections.Concurrent.IProducerConsumerCollection{T}"/>. The value can be a null
+        /// cref="Concurrent.IProducerConsumerCollection{T}"/>. The value can be a null
         /// reference (Nothing in Visual Basic) for reference types.
         /// </param>
         /// <returns>true if the object was added successfully; otherwise, false.</returns>
@@ -227,21 +229,17 @@ namespace System.Collections.Concurrent
         }
 
         /// <summary>
-        /// Attempts to remove and return an object from the <see
-        /// cref="T:System.Collections.Concurrent.IProducerConsumerCollection{T}"/>.
+        /// Attempts to remove and return an object from the <see cref="Concurrent.IProducerConsumerCollection{T}"/>.
         /// </summary>
         /// <param name="item">
         /// When this method returns, if the operation was successful, <paramref name="item"/> contains the
         /// object removed. If no object was available to be removed, the value is unspecified.
         /// </param>
-        /// <returns>true if an element was removed and returned succesfully; otherwise, false.</returns>
+        /// <returns>true if an element was removed and returned successfully; otherwise, false.</returns>
         /// <remarks>For <see cref="ConcurrentQueue{T}"/>, this operation will attempt to remove the object
         /// from the beginning of the <see cref="ConcurrentQueue{T}"/>.
         /// </remarks>
-        bool IProducerConsumerCollection<T>.TryTake(out T item)
-        {
-            return TryDequeue(out item);
-        }
+        bool IProducerConsumerCollection<T>.TryTake(out T item) => TryDequeue(out item);
 
         /// <summary>
         /// Gets a value that indicates whether the <see cref="ConcurrentQueue{T}"/> is empty.
@@ -258,126 +256,43 @@ namespace System.Collections.Concurrent
         {
             get
             {
-                Segment head = m_head;
-                if (!head.IsEmpty)
-                    //fast route 1:
-                    //if current head is not empty, then queue is not empty
-                    return false;
-                else if (head.Next == null)
-                    //fast route 2:
-                    //if current head is empty and it's the last segment
-                    //then queue is empty
-                    return true;
-                else
-                //slow route:
-                //current head is empty and it is NOT the last segment,
-                //it means another thread is growing new segment 
-                {
-                    SpinWait spin = new SpinWait();
-                    while (head.IsEmpty)
-                    {
-                        if (head.Next == null)
-                            return true;
-
-                        spin.SpinOnce();
-                        head = m_head;
-                    }
-                    return false;
-                }
+                // IsEmpty == !TryPeek. We use a "resultUsed:false" peek in order to avoid marking
+                // segments as preserved for observation, making IsEmpty a cheaper way than either
+                // TryPeek(out T) or Count == 0 to check whether any elements are in the queue.
+                T ignoredResult;
+                return !TryPeek(out ignoredResult, resultUsed: false);
             }
         }
 
-        /// <summary>
-        /// Copies the elements stored in the <see cref="ConcurrentQueue{T}"/> to a new array.
-        /// </summary>
-        /// <returns>A new array containing a snapshot of elements copied from the <see
-        /// cref="ConcurrentQueue{T}"/>.</returns>
+        /// <summary>Copies the elements stored in the <see cref="ConcurrentQueue{T}"/> to a new array.</summary>
+        /// <returns>A new array containing a snapshot of elements copied from the <see cref="ConcurrentQueue{T}"/>.</returns>
         public T[] ToArray()
         {
-            return ToList().ToArray();
-        }
+            // Snap the current contents for enumeration.
+            Segment head, tail;
+            int headHead, tailTail;
+            SnapForObservation(out head, out headHead, out tail, out tailTail);
 
-        /// <summary>
-        /// Copies the <see cref="ConcurrentQueue{T}"/> elements to a new <see
-        /// cref="T:System.Collections.Generic.List{T}"/>.
-        /// </summary>
-        /// <returns>A new <see cref="T:System.Collections.Generic.List{T}"/> containing a snapshot of
-        /// elements copied from the <see cref="ConcurrentQueue{T}"/>.</returns>
-        private List<T> ToList()
-        {
-            // Increments the number of active snapshot takers. This increment must happen before the snapshot is 
-            // taken. At the same time, Decrement must happen after list copying is over. Only in this way, can it
-            // eliminate race condition when Segment.TryRemove() checks whether m_numSnapshotTakers == 0. 
-            Interlocked.Increment(ref m_numSnapshotTakers);
+            // Count the number of items in that snapped set, and use it to allocate an
+            // array of the right size.
+            long count = GetCount(head, headHead, tail, tailTail);
+            T[] arr = new T[count];
 
-            List<T> list = new List<T>();
-            try
+            // Now enumerate the contents, copying each element into the array.
+            using (IEnumerator<T> e = Enumerate(head, headHead, tail, tailTail))
             {
-                //store head and tail positions in buffer, 
-                Segment head, tail;
-                int headLow, tailHigh;
-                GetHeadTailPositions(out head, out tail, out headLow, out tailHigh);
-
-                if (head == tail)
+                int i = 0;
+                while (e.MoveNext())
                 {
-                    head.AddToList(list, headLow, tailHigh);
-                }
-                else
-                {
-                    head.AddToList(list, headLow, SEGMENT_SIZE - 1);
-                    Segment curr = head.Next;
-                    while (curr != tail)
-                    {
-                        curr.AddToList(list, 0, SEGMENT_SIZE - 1);
-                        curr = curr.Next;
-                    }
-                    //Add tail segment
-                    tail.AddToList(list, 0, tailHigh);
+                    arr[i++] = e.Current;
                 }
+                Debug.Assert(count == i);
             }
-            finally
-            {
-                // This Decrement must happen after copying is over. 
-                Interlocked.Decrement(ref m_numSnapshotTakers);
-            }
-            return list;
-        }
 
-        /// <summary>
-        /// Store the position of the current head and tail positions.
-        /// </summary>
-        /// <param name="head">return the head segment</param>
-        /// <param name="tail">return the tail segment</param>
-        /// <param name="headLow">return the head offset, value range [0, SEGMENT_SIZE]</param>
-        /// <param name="tailHigh">return the tail offset, value range [-1, SEGMENT_SIZE-1]</param>
-        private void GetHeadTailPositions(out Segment head, out Segment tail,
-            out int headLow, out int tailHigh)
-        {
-            head = m_head;
-            tail = m_tail;
-            headLow = head.Low;
-            tailHigh = tail.High;
-            SpinWait spin = new SpinWait();
-
-            //we loop until the observed values are stable and sensible.  
-            //This ensures that any update order by other methods can be tolerated.
-            while (
-                //if head and tail changed, retry
-                head != m_head || tail != m_tail
-                //if low and high pointers, retry
-                || headLow != head.Low || tailHigh != tail.High
-                //if head jumps ahead of tail because of concurrent grow and dequeue, retry
-                || head.m_index > tail.m_index)
-            {
-                spin.SpinOnce();
-                head = m_head;
-                tail = m_tail;
-                headLow = head.Low;
-                tailHigh = tail.High;
-            }
+            // And return it.
+            return arr;
         }
 
-
         /// <summary>
         /// Gets the number of elements contained in the <see cref="ConcurrentQueue{T}"/>.
         /// </summary>
@@ -391,38 +306,140 @@ namespace System.Collections.Concurrent
         {
             get
             {
-                //store head and tail positions in buffer, 
                 Segment head, tail;
-                int headLow, tailHigh;
-                GetHeadTailPositions(out head, out tail, out headLow, out tailHigh);
-
-                if (head == tail)
+                int headHead, headTail, tailHead, tailTail;
+                var spinner = new SpinWait();
+                while (true)
                 {
-                    return tailHigh - headLow + 1;
+                    // Capture the head and tail, as well as the head's head and tail.
+                    head = _head;
+                    tail = _tail;
+                    headHead = Volatile.Read(ref head._headAndTail.Head);
+                    headTail = Volatile.Read(ref head._headAndTail.Tail);
+
+                    if (head == tail)
+                    {
+                        // There was a single segment in the queue.  If the captured
+                        // values still (or again) represent reality, return the segment's
+                        // count. A single segment should be the most common case once the
+                        // queue's size has stabilized after segments have grown to
+                        // the point where growing is no longer needed.
+                        if (head == _head &&
+                            head == _tail &&
+                            headHead == Volatile.Read(ref head._headAndTail.Head) &&
+                            headTail == Volatile.Read(ref head._headAndTail.Tail))
+                        {
+                            return GetCount(head, headHead, headTail);
+                        }
+                    }
+                    else if (head._nextSegment == tail)
+                    {
+                        // There were two segments in the queue.  Get the positions
+                        // from the tail, and if the captured values still (or again) match
+                        // reality, return the sum of the counts from both segments.
+                        tailHead = Volatile.Read(ref tail._headAndTail.Head);
+                        tailTail = Volatile.Read(ref tail._headAndTail.Tail);
+                        if (head == _head &&
+                            tail == _tail &&
+                            headHead == Volatile.Read(ref head._headAndTail.Head) &&
+                            headTail == Volatile.Read(ref head._headAndTail.Tail) &&
+                            tailHead == Volatile.Read(ref tail._headAndTail.Head) &&
+                            tailTail == Volatile.Read(ref tail._headAndTail.Tail))
+                        {
+                            // We got stable values, so we can just compute the sizes based on those
+                            // values and return the sum of the counts of the segments.
+                            return GetCount(head, headHead, headTail) + GetCount(tail, tailHead, tailTail);
+                        }
+                    }
+                    else
+                    {
+                        // There were more than two segments.  Take the slower path, where we freeze the
+                        // queue and then count the now stable segments.
+                        SnapForObservation(out head, out headHead, out tail, out tailTail);
+                        return unchecked((int)GetCount(head, headHead, tail, tailTail));
+                    }
+
+                    // We raced with enqueues/dequeues and captured an inconsistent picture of the queue.
+                    // Spin and try again.
+                    spinner.SpinOnce();
                 }
+            }
+        }
 
-                //head segment
-                int count = SEGMENT_SIZE - headLow;
+        /// <summary>Computes the number of items in a segment based on a fixed head and tail in that segment.</summary>
+        private static int GetCount(Segment s, int head, int tail)
+        {
+            if (head != tail && head != tail - s.FreezeOffset)
+            {
+                head &= s._slotsMask;
+                tail &= s._slotsMask;
+                return head < tail ? tail - head : s._slots.Length - head + tail;
+            }
+            return 0;
+        }
 
-                //middle segment(s), if any, are full.
-                //We don't deal with overflow to be consistent with the behavior of generic types in CLR.
-                count += SEGMENT_SIZE * ((int)(tail.m_index - head.m_index - 1));
+        /// <summary>Gets the number of items in snapped region.</summary>
+        private static long GetCount(Segment head, int headHead, Segment tail, int tailTail)
+        {
+            // All of the segments should have been both frozen for enqueues and preserved for observation.
+            // Validate that here for head and tail; we'll validate it for intermediate segments later.
+            Debug.Assert(head._preservedForObservation);
+            Debug.Assert(head._frozenForEnqueues);
+            Debug.Assert(tail._preservedForObservation);
+            Debug.Assert(tail._frozenForEnqueues);
+
+            long count = 0;
+
+            // Head segment.  We've already marked it as frozen for enqueues, so its tail position is fixed,
+            // and we've already marked it as preserved for observation (before we grabbed the head), so we
+            // can safely enumerate from its head to its tail and access its elements.
+            int headTail = (head == tail ? tailTail : Volatile.Read(ref head._headAndTail.Tail)) - head.FreezeOffset;
+            if (headHead < headTail)
+            {
+                // Mask the head and tail for the head segment
+                headHead &= head._slotsMask;
+                headTail &= head._slotsMask;
+
+                // Increase the count by either the one or two regions, based on whether tail
+                // has wrapped to be less than head.
+                count += headHead < headTail ?
+                    headTail - headHead :
+                    head._slots.Length - headHead + headTail;
+            }
 
-                //tail segment
-                count += tailHigh + 1;
+            // We've enumerated the head.  If the tail is different from the head, we need to
+            // enumerate the remaining segments.
+            if (head != tail)
+            {
+                // Count the contents of each segment between head and tail, not including head and tail.
+                // Since there were segments before these, for our purposes we consider them to start at
+                // the 0th element, and since there is at least one segment after each, each was frozen
+                // by the time we snapped it, so we can iterate until each's frozen tail.
+                for (Segment s = head._nextSegment; s != tail; s = s._nextSegment)
+                {
+                    Debug.Assert(s._preservedForObservation);
+                    Debug.Assert(s._frozenForEnqueues);
+                    count += s._headAndTail.Tail - s.FreezeOffset;
+                }
 
-                return count;
+                // Finally, enumerate the tail.  As with the intermediate segments, there were segments
+                // before this in the snapped region, so we can start counting from the beginning. Unlike
+                // the intermediate segments, we can't just go until the Tail, as that could still be changing;
+                // instead we need to go until the tail we snapped for observation.
+                count += tailTail - tail.FreezeOffset;
             }
-        }
 
+            // Return the computed count.
+            return count;
+        }
 
         /// <summary>
         /// Copies the <see cref="ConcurrentQueue{T}"/> elements to an existing one-dimensional <see
-        /// cref="T:System.Array">Array</see>, starting at the specified array index.
+        /// cref="Array">Array</see>, starting at the specified array index.
         /// </summary>
-        /// <param name="array">The one-dimensional <see cref="T:System.Array">Array</see> that is the
+        /// <param name="array">The one-dimensional <see cref="Array">Array</see> that is the
         /// destination of the elements copied from the
-        /// <see cref="ConcurrentQueue{T}"/>. The <see cref="T:System.Array">Array</see> must have zero-based
+        /// <see cref="ConcurrentQueue{T}"/>. The <see cref="Array">Array</see> must have zero-based
         /// indexing.</param>
         /// <param name="index">The zero-based index in <paramref name="array"/> at which copying
         /// begins.</param>
@@ -442,19 +459,36 @@ namespace System.Collections.Concurrent
             {
                 throw new ArgumentNullException(nameof(array));
             }
+            if (index < 0)
+            {
+                throw new ArgumentOutOfRangeException(nameof(index));
+            }
 
-            // We must be careful not to corrupt the array, so we will first accumulate an
-            // internal list of elements that we will then copy to the array. This requires
-            // some extra allocation, but is necessary since we don't know up front whether
-            // the array is sufficiently large to hold the stack's contents.
-            ToList().CopyTo(array, index);
-        }
+            // Snap for enumeration
+            Segment head, tail;
+            int headHead, tailTail;
+            SnapForObservation(out head, out headHead, out tail, out tailTail);
 
+            // Get the number of items to be enumerated
+            long count = GetCount(head, headHead, tail, tailTail);
+            if (index > array.Length - count)
+            {
+                throw new ArgumentException(); // TODO: finish this
+            }
 
-        /// <summary>
-        /// Returns an enumerator that iterates through the <see
-        /// cref="ConcurrentQueue{T}"/>.
-        /// </summary>
+            // Copy the items to the target array
+            int i = index;
+            using (IEnumerator<T> e = Enumerate(head, headHead, tail, tailTail))
+            {
+                while (e.MoveNext())
+                {
+                    array[i++] = e.Current;
+                }
+            }
+            Debug.Assert(count == i - index);
+        }
+
+        /// <summary>Returns an enumerator that iterates through the <see cref="ConcurrentQueue{T}"/>.</summary>
         /// <returns>An enumerator for the contents of the <see
         /// cref="ConcurrentQueue{T}"/>.</returns>
         /// <remarks>
@@ -465,124 +499,195 @@ namespace System.Collections.Concurrent
         /// </remarks>
         public IEnumerator<T> GetEnumerator()
         {
-            // Increments the number of active snapshot takers. This increment must happen before the snapshot is 
-            // taken. At the same time, Decrement must happen after the enumeration is over. Only in this way, can it
-            // eliminate race condition when Segment.TryRemove() checks whether m_numSnapshotTakers == 0. 
-            Interlocked.Increment(ref m_numSnapshotTakers);
-
-            // Takes a snapshot of the queue. 
-            // A design flaw here: if a Thread.Abort() happens, we cannot decrement m_numSnapshotTakers. But we cannot 
-            // wrap the following with a try/finally block, otherwise the decrement will happen before the yield return 
-            // statements in the GetEnumerator (head, tail, headLow, tailHigh) method.           
             Segment head, tail;
-            int headLow, tailHigh;
-            GetHeadTailPositions(out head, out tail, out headLow, out tailHigh);
-
-            //If we put yield-return here, the iterator will be lazily evaluated. As a result a snapshot of
-            // the queue is not taken when GetEnumerator is initialized but when MoveNext() is first called.
-            // This is inconsistent with existing generic collections. In order to prevent it, we capture the 
-            // value of m_head in a buffer and call out to a helper method.
-            //The old way of doing this was to return the ToList().GetEnumerator(), but ToList() was an 
-            // unnecessary perfomance hit.
-            return GetEnumerator(head, tail, headLow, tailHigh);
+            int headHead, tailTail;
+            SnapForObservation(out head, out headHead, out tail, out tailTail);
+            return Enumerate(head, headHead, tail, tailTail);
         }
 
         /// <summary>
-        /// Helper method of GetEnumerator to seperate out yield return statement, and prevent lazy evaluation. 
+        /// Gets the head and tail information of the current contents of the queue.
+        /// After this call returns, the specified region can be enumerated any number
+        /// of times and will not change.
         /// </summary>
-        private IEnumerator<T> GetEnumerator(Segment head, Segment tail, int headLow, int tailHigh)
+        private void SnapForObservation(out Segment head, out int headHead, out Segment tail, out int tailTail)
+        {
+            lock (_crossSegmentLock) // _head and _tail may only change while the lock is held.
+            {
+                // Snap the head and tail
+                head = _head;
+                tail = _tail;
+                Debug.Assert(head != null);
+                Debug.Assert(tail != null);
+                Debug.Assert(tail._nextSegment == null);
+
+                // Mark them and all segments in between as preserving, and ensure no additional items
+                // can be added to the tail.
+                for (Segment s = head; ; s = s._nextSegment)
+                {
+                    s._preservedForObservation = true;
+                    if (s == tail) break;
+                    Debug.Assert(s._frozenForEnqueues); // any non-tail should already be marked
+                }
+                tail.EnsureFrozenForEnqueues(); // we want to prevent the tailTail from moving
+
+                // At this point, any dequeues from any segment won't overwrite the value, and
+                // none of the existing segments can have new items enqueued.
+
+                headHead = Volatile.Read(ref head._headAndTail.Head);
+                tailTail = Volatile.Read(ref tail._headAndTail.Tail);
+            }
+        }
+
+        /// <summary>Gets the item stored in the <paramref name="i"/>th entry in <paramref name="segment"/>.</summary>
+        private T GetItemWhenAvailable(Segment segment, int i)
         {
-            try
+            Debug.Assert(segment._preservedForObservation);
+
+            // Get the expected value for the sequence number
+            int expectedSequenceNumberAndMask = (i + 1) & segment._slotsMask;
+
+            // If the expected sequence number is not yet written, we're still waiting for
+            // an enqueuer to finish storing it.  Spin until it's there.
+            if ((segment._slots[i].SequenceNumber & segment._slotsMask) != expectedSequenceNumberAndMask)
             {
-                SpinWait spin = new SpinWait();
+                var spinner = new SpinWait();
+                while ((Volatile.Read(ref segment._slots[i].SequenceNumber) & segment._slotsMask) != expectedSequenceNumberAndMask)
+                {
+                    spinner.SpinOnce();
+                }
+            }
 
-                if (head == tail)
+            // Return the value from the slot.
+            return segment._slots[i].Item;
+        }
+
+        private IEnumerator<T> Enumerate(Segment head, int headHead, Segment tail, int tailTail)
+        {
+            Debug.Assert(head._preservedForObservation);
+            Debug.Assert(head._frozenForEnqueues);
+            Debug.Assert(tail._preservedForObservation);
+            Debug.Assert(tail._frozenForEnqueues);
+
+            // Head segment.  We've already marked it as not accepting any more enqueues,
+            // so its tail position is fixed, and we've already marked it as preserved for
+            // enumeration (before we grabbed its head), so we can safely enumerate from
+            // its head to its tail.
+            int headTail = (head == tail ? tailTail : Volatile.Read(ref head._headAndTail.Tail)) - head.FreezeOffset;
+            if (headHead < headTail)
+            {
+                headHead &= head._slotsMask;
+                headTail &= head._slotsMask;
+
+                if (headHead < headTail)
                 {
-                    for (int i = headLow; i <= tailHigh; i++)
-                    {
-                        // If the position is reserved by an Enqueue operation, but the value is not written into,
-                        // spin until the value is available.
-                        spin.Reset();
-                        while (!head.m_state[i].m_value)
-                        {
-                            spin.SpinOnce();
-                        }
-                        yield return head.m_array[i];
-                    }
+                    for (int i = headHead; i < headTail; i++) yield return GetItemWhenAvailable(head, i);
                 }
                 else
                 {
-                    //iterate on head segment
-                    for (int i = headLow; i < SEGMENT_SIZE; i++)
-                    {
-                        // If the position is reserved by an Enqueue operation, but the value is not written into,
-                        // spin until the value is available.
-                        spin.Reset();
-                        while (!head.m_state[i].m_value)
-                        {
-                            spin.SpinOnce();
-                        }
-                        yield return head.m_array[i];
-                    }
-                    //iterate on middle segments
-                    Segment curr = head.Next;
-                    while (curr != tail)
-                    {
-                        for (int i = 0; i < SEGMENT_SIZE; i++)
-                        {
-                            // If the position is reserved by an Enqueue operation, but the value is not written into,
-                            // spin until the value is available.
-                            spin.Reset();
-                            while (!curr.m_state[i].m_value)
-                            {
-                                spin.SpinOnce();
-                            }
-                            yield return curr.m_array[i];
-                        }
-                        curr = curr.Next;
-                    }
+                    for (int i = headHead; i < head._slots.Length; i++) yield return GetItemWhenAvailable(head, i);
+                    for (int i = 0; i < headTail; i++) yield return GetItemWhenAvailable(head, i);
+                }
+            }
+
+            // We've enumerated the head.  If the tail is the same, we're done.
+            if (head != tail)
+            {
+                // Each segment between head and tail, not including head and tail.  Since there were
+                // segments before these, for our purposes we consider it to start at the 0th element.
+                for (Segment s = head._nextSegment; s != tail; s = s._nextSegment)
+                {
+                    Debug.Assert(s._preservedForObservation, "Would have had to been preserved as a segment part of enumeration");
+                    Debug.Assert(s._frozenForEnqueues, "Would have had to be frozen for enqueues as it's intermediate");
 
-                    //iterate on tail segment
-                    for (int i = 0; i <= tailHigh; i++)
+                    int sTail = s._headAndTail.Tail - s.FreezeOffset;
+                    for (int i = 0; i < sTail; i++)
                     {
-                        // If the position is reserved by an Enqueue operation, but the value is not written into,
-                        // spin until the value is available.
-                        spin.Reset();
-                        while (!tail.m_state[i].m_value)
-                        {
-                            spin.SpinOnce();
-                        }
-                        yield return tail.m_array[i];
+                        yield return GetItemWhenAvailable(s, i);
                     }
                 }
-            }
-            finally
-            {
-                // This Decrement must happen after the enumeration is over. 
-                Interlocked.Decrement(ref m_numSnapshotTakers);
+
+                // Enumerate the tail.  Since there were segments before this, we can just start at
+                // its beginning, and iterate until the tail we already grabbed.
+                tailTail -= tail.FreezeOffset;
+                for (int i = 0; i < tailTail; i++)
+                {
+                    yield return GetItemWhenAvailable(tail, i);
+                }
             }
         }
 
-        /// <summary>
-        /// Adds an object to the end of the <see cref="ConcurrentQueue{T}"/>.
-        /// </summary>
-        /// <param name="item">The object to add to the end of the <see
-        /// cref="ConcurrentQueue{T}"/>. The value can be a null reference
-        /// (Nothing in Visual Basic) for reference types.
+        /// <summary>Round the specified value up to the next power of 2, if it isn't one already.</summary>
+        private static int RoundUpToPowerOf2(int i)
+        {
+            --i;
+            i |= i >> 1;
+            i |= i >> 2;
+            i |= i >> 4;
+            i |= i >> 8;
+            i |= i >> 16;
+            return i + 1;
+        }
+
+        /// <summary>Adds an object to the end of the <see cref="ConcurrentQueue{T}"/>.</summary>
+        /// <param name="item">
+        /// The object to add to the end of the <see cref="ConcurrentQueue{T}"/>.
+        /// The value can be a null reference (Nothing in Visual Basic) for reference types.
         /// </param>
         public void Enqueue(T item)
         {
-            SpinWait spin = new SpinWait();
+            // Try to enqueue to the current tail.
+            if (!_tail.TryEnqueue(item))
+            {
+                // If we're unable to, we need to take a slow path that will
+                // try to add a new tail segment.
+                EnqueueSlow(item);
+            }
+        }
+
+        /// <summary>Adds to the end of the queue, adding a new segment if necessary.</summary>
+        private void EnqueueSlow(T item)
+        {
             while (true)
             {
-                Segment tail = m_tail;
-                if (tail.TryAppend(item))
+                Segment tail = _tail;
+
+                // Try to append to the existing tail.
+                if (tail.TryEnqueue(item))
+                {
                     return;
-                spin.SpinOnce();
+                }
+
+                // If we were unsuccessful, take the lock so that we can compare and manipulate
+                // the tail.  Assuming another enqueuer hasn't already added a new segment,
+                // do so, then loop around to try enqueueing again.
+                lock (_crossSegmentLock)
+                {
+                    if (tail == _tail)
+                    {
+                        // Make sure no one else can enqueue to this segment.
+                        tail.EnsureFrozenForEnqueues();
+
+                        // We determine the new segment's length based on the old length.
+                        // In general, we double the size of the segment, to make it less likely
+                        // that we'll need to grow again.  However, if the tail segment is marked
+                        // as preserved for observation, something caused us to avoid reusing this
+                        // segment, and if that happens a lot and we grow, we'll end up allocating
+                        // lots of wasted space.  As such, in such situations we reset back to the
+                        // initial segment length; if these observations are happening frequently,
+                        // this will help to avoid wasted memory, and if they're not, we'll
+                        // relatively quickly grow again to a larger size.
+                        int nextSize = tail._preservedForObservation ? InitialSegmentLength : tail.Capacity * 2;
+                        var newTail = new Segment(nextSize);
+
+                        // Hook up the new tail.
+                        tail._nextSegment = newTail;
+                        _tail = newTail;
+                    }
+                }
             }
         }
 
-
         /// <summary>
         /// Attempts to remove and return the object at the beginning of the <see
         /// cref="ConcurrentQueue{T}"/>.
@@ -591,369 +696,453 @@ namespace System.Collections.Concurrent
         /// When this method returns, if the operation was successful, <paramref name="result"/> contains the
         /// object removed. If no object was available to be removed, the value is unspecified.
         /// </param>
-        /// <returns>true if an element was removed and returned from the beggining of the <see
-        /// cref="ConcurrentQueue{T}"/>
-        /// succesfully; otherwise, false.</returns>
-        public bool TryDequeue(out T result)
+        /// <returns>
+        /// true if an element was removed and returned from the beginning of the
+        /// <see cref="ConcurrentQueue{T}"/> successfully; otherwise, false.
+        /// </returns>
+        public bool TryDequeue(out T result) =>
+            _head.TryDequeue(out result) || // fast-path that operates just on the head segment
+            TryDequeueSlow(out result); // slow path that needs to fix up segments
+
+        /// <summary>Tries to dequeue an item, removing empty segments as needed.</summary>
+        private bool TryDequeueSlow(out T item)
         {
-            while (!IsEmpty)
+            while (true)
             {
-                Segment head = m_head;
-                if (head.TryRemove(out result))
+                // Get the current head
+                Segment head = _head;
+
+                // Try to take.  If we're successful, we're done.
+                if (head.TryDequeue(out item))
+                {
+                    return true;
+                }
+
+                // Check to see whether this segment is the last. If it is, we can consider
+                // this to be a moment-in-time empty condition (even though between the TryDequeue
+                // check and this check, another item could have arrived).
+                if (head._nextSegment == null)
+                {
+                    item = default(T);
+                    return false;
+                }
+
+                // At this point we know that head.Next != null, which means
+                // this segment has been frozen for additional enqueues. But between
+                // the time that we ran TryDequeue and checked for a next segment,
+                // another item could have been added.  Try to dequeue one more time
+                // to confirm that the segment is indeed empty.
+                Debug.Assert(head._frozenForEnqueues);
+                if (head.TryDequeue(out item))
+                {
                     return true;
-                //since method IsEmpty spins, we don't need to spin in the while loop
+                }
+
+                // This segment is frozen (nothing more can be added) and empty (nothing is in it).
+                // Update head to point to the next segment in the list, assuming no one's beat us to it.
+                lock (_crossSegmentLock)
+                {
+                    if (head == _head)
+                    {
+                        _head = head._nextSegment;
+                    }
+                }
             }
-            result = default(T);
-            return false;
         }
 
         /// <summary>
         /// Attempts to return an object from the beginning of the <see cref="ConcurrentQueue{T}"/>
         /// without removing it.
         /// </summary>
-        /// <param name="result">When this method returns, <paramref name="result"/> contains an object from
-        /// the beginning of the <see cref="T:System.Collections.Concurrent.ConccurrentQueue{T}"/> or an
-        /// unspecified value if the operation failed.</param>
+        /// <param name="result">
+        /// When this method returns, <paramref name="result"/> contains an object from
+        /// the beginning of the <see cref="Concurrent.ConcurrentQueue{T}"/> or default(T)
+        /// if the operation failed.
+        /// </param>
         /// <returns>true if and object was returned successfully; otherwise, false.</returns>
-        public bool TryPeek(out T result)
-        {
-            Interlocked.Increment(ref m_numSnapshotTakers);
+        /// <remarks>
+        /// For determining whether the collection contains any items, use of the <see cref="IsEmpty"/>
+        /// property is recommended rather than peeking.
+        /// </remarks>
+        public bool TryPeek(out T result) => TryPeek(out result, resultUsed: true);
 
-            while (!IsEmpty)
+        /// <summary>Attempts to retrieve the value for the first element in the queue.</summary>
+        /// <param name="result">The value of the first element, if found.</param>
+        /// <param name="resultUsed">true if the result is neede; otherwise false if only the true/false outcome is needed.</param>
+        /// <returns>true if an element was found; otherwise, false.</returns>
+        private bool TryPeek(out T result, bool resultUsed)
+        {
+            // Starting with the head segment, look through all of the segments
+            // for the first one we can find that's not empty.
+            Segment s = _head;
+            while (true)
             {
-                Segment head = m_head;
-                if (head.TryPeek(out result))
+                // Grab the next segment from this one, before we peek.
+                // This is to be able to see whether the value has changed
+                // during the peek operation.
+                Segment next = Volatile.Read(ref s._nextSegment);
+
+                // Peek at the segment.  If we find an element, we're done.
+                if (s.TryPeek(out result, resultUsed))
                 {
-                    Interlocked.Decrement(ref m_numSnapshotTakers);
                     return true;
                 }
-                //since method IsEmpty spins, we don't need to spin in the while loop
+
+                // The current segment was empty at the moment we checked.
+
+                if (next != null)
+                {
+                    // If prior to the peek there was already a next segment, then
+                    // during the peek no additional items could have been enqueued
+                    // to it and we can just move on to check the next segment.
+                    Debug.Assert(next == s._nextSegment);
+                    s = next;
+                }
+                else if (Volatile.Read(ref s._nextSegment) == null)
+                {
+                    // The next segment is null.  Nothing more to peek at.
+                    break;
+                }
+
+                // The next segment was null before we peeked but non-null after.
+                // That means either when we peeked the first segment had
+                // already been frozen but the new segment not yet added,
+                // or that the first segment was empty and between the time
+                // that we peeked and then checked _nextSegment, so many items
+                // were enqueued that we filled the first segment and went
+                // into the next.  Since we need to peek in order, we simply
+                // loop around again to peek on the same segment.  The next
+                // time around on this segment we'll then either successfully
+                // peek or we'll find that next was non-null before peeking,
+                // and we'll traverse to that segment.
             }
+
             result = default(T);
-            Interlocked.Decrement(ref m_numSnapshotTakers);
             return false;
         }
 
-
         /// <summary>
-        /// private class for ConcurrentQueue. 
-        /// a queue is a linked list of small arrays, each node is called a segment.
-        /// A segment contains an array, a pointer to the next segment, and m_low, m_high indices recording
-        /// the first and last valid elements of the array.
+        /// Removes all objects from the <see cref="ConcurrentQueue{T}"/>.
         /// </summary>
-        private class Segment
+        public void Clear()
         {
-            //we define two volatile arrays: m_array and m_state. Note that the accesses to the array items 
-            //do not get volatile treatment. But we don't need to worry about loading adjacent elements or 
-            //store/load on adjacent elements would suffer reordering. 
-            // - Two stores:  these are at risk, but CLRv2 memory model guarantees store-release hence we are safe.
-            // - Two loads: because one item from two volatile arrays are accessed, the loads of the array references
-            //          are sufficient to prevent reordering of the loads of the elements.
-            internal volatile T[] m_array;
-
-            // For each entry in m_array, the corresponding entry in m_state indicates whether this position contains 
-            // a valid value. m_state is initially all false. 
-            internal volatile VolatileBool[] m_state;
-
-            //pointer to the next segment. null if the current segment is the last segment
-            private volatile Segment m_next;
-
-            //We use this zero based index to track how many segments have been created for the queue, and
-            //to compute how many active segments are there currently. 
-            // * The number of currently active segments is : m_tail.m_index - m_head.m_index + 1;
-            // * m_index is incremented with every Segment.Grow operation. We use Int64 type, and we can safely 
-            //   assume that it never overflows. To overflow, we need to do 2^63 increments, even at a rate of 4 
-            //   billion (2^32) increments per second, it takes 2^31 seconds, which is about 64 years.
-            internal readonly long m_index;
-
-            //indices of where the first and last valid values
-            // - m_low points to the position of the next element to pop from this segment, range [0, infinity)
-            //      m_low >= SEGMENT_SIZE implies the segment is disposable
-            // - m_high points to the position of the latest pushed element, range [-1, infinity)
-            //      m_high == -1 implies the segment is new and empty
-            //      m_high >= SEGMENT_SIZE-1 means this segment is ready to grow. 
-            //        and the thread who sets m_high to SEGMENT_SIZE-1 is responsible to grow the segment
-            // - Math.Min(m_low, SEGMENT_SIZE) > Math.Min(m_high, SEGMENT_SIZE-1) implies segment is empty
-            // - initially m_low =0 and m_high=-1;
-            private volatile int m_low;
-            private volatile int m_high;
-
-            private volatile ConcurrentQueue<T> m_source;
-
-            /// <summary>
-            /// Create and initialize a segment with the specified index.
-            /// </summary>
-            internal Segment(long index, ConcurrentQueue<T> source)
-            {
-                m_array = new T[SEGMENT_SIZE];
-                m_state = new VolatileBool[SEGMENT_SIZE]; //all initialized to false
-                m_high = -1;
-                Debug.Assert(index >= 0);
-                m_index = index;
-                m_source = source;
-            }
-
-            /// <summary>
-            /// return the next segment
-            /// </summary>
-            internal Segment Next
-            {
-                get { return m_next; }
-            }
-
-
-            /// <summary>
-            /// return true if the current segment is empty (doesn't have any element available to dequeue, 
-            /// false otherwise
-            /// </summary>
-            internal bool IsEmpty
+            lock (_crossSegmentLock)
             {
-                get { return (Low > High); }
-            }
-
-            /// <summary>
-            /// Add an element to the tail of the current segment
-            /// exclusively called by ConcurrentQueue.InitializedFromCollection
-            /// InitializeFromCollection is responsible to guaratee that there is no index overflow,
-            /// and there is no contention
-            /// </summary>
-            /// <param name="value"></param>
-            internal void UnsafeAdd(T value)
-            {
-                Debug.Assert(m_high < SEGMENT_SIZE - 1);
-                m_high++;
-                m_array[m_high] = value;
-                m_state[m_high].m_value = true;
+                // Simply substitute a new segment for the existing head/tail,
+                // as is done in the constructor.  Operations currently in flight
+                // may still read from or write to an existing segment that's
+                // getting dropped, meaning that in flight operations may not be
+                // linear with regards to this clear operation.  To help mitigate
+                // in-flight operations enqueuing onto the tail that's about to
+                // be dropped, we first freeze it; that'll force enqueuers to take
+                // this lock to synchronize and see the new tail.
+                _tail.EnsureFrozenForEnqueues();
+                _tail = _head = new Segment(InitialSegmentLength);
             }
+        }
 
-            /// <summary>
-            /// Create a new segment and append to the current one
-            /// Does not update the m_tail pointer
-            /// exclusively called by ConcurrentQueue.InitializedFromCollection
-            /// InitializeFromCollection is responsible to guaratee that there is no index overflow,
-            /// and there is no contention
-            /// </summary>
-            /// <returns>the reference to the new Segment</returns>
-            internal Segment UnsafeGrow()
+        /// <summary>
+        /// Provides a multi-producer, multi-consumer thread-safe bounded segment.  When the queue is full,
+        /// enqueues fail and return false.  When the queue is empty, dequeues fail and return null.
+        /// These segments are linked together to form the unbounded <see cref="ConcurrentQueue{T}"/>. 
+        /// </summary>
+        [DebuggerDisplay("Capacity = {Capacity}")]
+        private sealed class Segment
+        {
+            // Segment design is inspired by the algorithm outlined at:
+            // http://www.1024cores.net/home/lock-free-algorithms/queues/bounded-mpmc-queue
+
+            /// <summary>The array of items in this queue.  Each slot contains the item in that slot and its "sequence number".</summary>
+            internal readonly Slot[] _slots;
+            /// <summary>Mask for quickly accessing a position within the queue's array.</summary>
+            internal readonly int _slotsMask;
+            /// <summary>The head and tail positions, with padding to help avoid false sharing contention.</summary>
+            /// <remarks>Dequeueing happens from the head, enqueueing happens at the tail.</remarks>
+            internal PaddedHeadAndTail _headAndTail; // mutable struct: do not make this readonly
+
+            /// <summary>Indicates whether the segment has been marked such that dequeues don't overwrite the removed data.</summary>
+            internal bool _preservedForObservation;
+            /// <summary>Indicates whether the segment has been marked such that no additional items may be enqueued.</summary>
+            internal bool _frozenForEnqueues;
+            /// <summary>The segment following this one in the queue, or null if this segment is the last in the queue.</summary>
+            internal Segment _nextSegment;
+
+            /// <summary>Creates the segment.</summary>
+            /// <param name="boundedLength">
+            /// The maximum number of elements the segment can contain.  Must be a power of 2.
+            /// </param>
+            public Segment(int boundedLength)
             {
-                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;
+                // Validate the length
+                Debug.Assert(boundedLength >= 2, $"Must be >= 2, got {boundedLength}");
+                Debug.Assert((boundedLength & (boundedLength - 1)) == 0, $"Must be a power of 2, got {boundedLength}");
+
+                // Initialize the slots and the mask.  The mask is used as a way of quickly doing "% _slots.Length",
+                // instead letting us do "& _slotsMask".
+                _slots = new Slot[boundedLength];
+                _slotsMask = boundedLength - 1;
+
+                // Initialize the sequence number for each slot.  The sequence number provides a ticket that
+                // allows dequeuers to know whether they can dequeue and enqueuers to know whether they can
+                // enqueue.  An enqueuer at position N can enqueue when the sequence number is N, and a dequeuer
+                // for position N can dequeue when the sequence number is N + 1.  When an enqueuer is done writing
+                // at position N, it sets the sequence number to N so that a dequeuer will be able to dequeue,
+                // and when a dequeuer is done dequeueing at position N, it sets the sequence number to N + _slots.Length,
+                // so that when an enqueuer loops around the slots, it'll find that the sequence number at
+                // position N is N.  This also means that when an enqueuer finds that at position N the sequence
+                // number is < N, there is still a value in that slot, i.e. the segment is full, and when a
+                // dequeuer finds that the value in a slot is < N + 1, there is nothing currently available to
+                // dequeue. (It is possible for multiple enqueuers to enqueue concurrently, writing into
+                // subsequent slots, and to have the first enqueuer take longer, so that the slots for 1, 2, 3, etc.
+                // may have values, but the 0th slot may still be being filled... in that case, TryDequeue will
+                // return false.)
+                for (int i = 0; i < _slots.Length; i++)
+                {
+                    _slots[i].SequenceNumber = i;
+                }
             }
 
-            /// <summary>
-            /// Create a new segment and append to the current one
-            /// Update the m_tail pointer
-            /// This method is called when there is no contention
-            /// </summary>
-            internal void Grow()
-            {
-                //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;
-                Debug.Assert(m_source.m_tail == this);
-                m_source.m_tail = m_next;
-            }
+            /// <summary>Gets the number of elements this segment can store.</summary>
+            internal int Capacity => _slots.Length;
 
+            /// <summary>Gets the "freeze offset" for this segment.</summary>
+            internal int FreezeOffset => _slots.Length * 2;
 
             /// <summary>
-            /// Try to append an element at the end of this segment.
+            /// Ensures that the segment will not accept any subsequent enqueues that aren't already underway.
             /// </summary>
-            /// <param name="value">the element to append</param>
-            /// <param name="tail">The tail.</param>
-            /// <returns>true if the element is appended, false if the current segment is full</returns>
-            /// <remarks>if appending the specified element succeeds, and after which the segment is full, 
-            /// then grow the segment</remarks>
-            internal bool TryAppend(T value)
+            /// <remarks>
+            /// When we mark a segment as being frozen for additional enqueues,
+            /// we set the <see cref="_frozenForEnqueues"/> bool, but that's mostly
+            /// as a small helper to avoid marking it twice.  The real marking comes
+            /// by modifying the Tail for the segment, increasing it by this
+            /// <see cref="FreezeOffset"/>.  This effectively knocks it off the
+            /// sequence expected by future enqueuers, such that any additional enqueuer
+            /// will be unable to enqueue due to it not lining up with the expected
+            /// sequence numbers.  This value is chosen specially so that Tail will grow
+            /// to a value that maps to the same slot but that won't be confused with
+            /// any other enqueue/dequeue sequence number.
+            /// </remarks>
+            internal void EnsureFrozenForEnqueues() // must only be called while queue's segment lock is held
             {
-                //quickly check if m_high is already over the boundary, if so, bail out
-                if (m_high >= SEGMENT_SIZE - 1)
+                if (!_frozenForEnqueues) // flag used to ensure we don't increase the Tail more than once if frozen more than once
                 {
-                    return false;
-                }
+                    _frozenForEnqueues = true;
 
-                //Now we will use a CAS to increment m_high, and store the result in newhigh.
-                //Depending on how many free spots left in this segment and how many threads are doing this Increment
-                //at this time, the returning "newhigh" can be 
-                // 1) < SEGMENT_SIZE - 1 : we took a spot in this segment, and not the last one, just insert the value
-                // 2) == SEGMENT_SIZE - 1 : we took the last spot, insert the value AND grow the segment
-                // 3) > SEGMENT_SIZE - 1 : we failed to reserve a spot in this segment, we return false to 
-                //    Queue.Enqueue method, telling it to try again in the next segment.
-
-                int newhigh = SEGMENT_SIZE; //initial value set to be over the boundary
-
-                //We need do Interlocked.Increment and value/state update in a finally block to ensure that they run
-                //without interuption. This is to prevent anything from happening between them, and another dequeue
-                //thread maybe spinning forever to wait for m_state[] to be true;
-                try
-                { }
-                finally
-                {
-                    newhigh = Interlocked.Increment(ref m_high);
-                    if (newhigh <= SEGMENT_SIZE - 1)
+                    // Increase the tail by FreezeOffset, spinning until we're successful in doing so.
+                    var spinner = new SpinWait();
+                    while (true)
                     {
-                        m_array[newhigh] = value;
-                        m_state[newhigh].m_value = true;
-                    }
-
-                    //if this thread takes up the last slot in the segment, then this thread is responsible
-                    //to grow a new segment. Calling Grow must be in the finally block too for reliability reason:
-                    //if thread abort during Grow, other threads will be left busy spinning forever.
-                    if (newhigh == SEGMENT_SIZE - 1)
-                    {
-                        Grow();
+                        int tail = Volatile.Read(ref _headAndTail.Tail);
+                        if (Interlocked.CompareExchange(ref _headAndTail.Tail, tail + FreezeOffset, tail) == tail)
+                        {
+                            break;
+                        }
+                        spinner.SpinOnce();
                     }
                 }
-
-                //if newhigh <= SEGMENT_SIZE-1, it means the current thread successfully takes up a spot
-                return newhigh <= SEGMENT_SIZE - 1;
             }
 
-
-            /// <summary>
-            /// try to remove an element from the head of current segment
-            /// </summary>
-            /// <param name="result">The result.</param>
-            /// <param name="head">The head.</param>
-            /// <returns>return false only if the current segment is empty</returns>
-            internal bool TryRemove(out T result)
+            /// <summary>Tries to dequeue an element from the queue.</summary>
+            public bool TryDequeue(out T item)
             {
-                SpinWait spin = new SpinWait();
-                int lowLocal = Low, highLocal = High;
-                while (lowLocal <= highLocal)
+                // Loop in case of contention...
+                var spinner = new SpinWait();
+                while (true)
                 {
-                    //try to update m_low
-                    if (Interlocked.CompareExchange(ref m_low, lowLocal + 1, lowLocal) == lowLocal)
-                    {
-                        //if the specified value is not available (this spot is taken by a push operation,
-                        // but the value is not written into yet), then spin
-                        SpinWait spinLocal = new SpinWait();
-                        while (!m_state[lowLocal].m_value)
-                        {
-                            spinLocal.SpinOnce();
-                        }
-                        result = m_array[lowLocal];
+                    // Get the head at which to try to dequeue.
+                    int currentHead = Volatile.Read(ref _headAndTail.Head);
+                    int slotsIndex = currentHead & _slotsMask;
 
-                        // If there is no other thread taking snapshot (GetEnumerator(), ToList(), etc), reset the deleted entry to null.
-                        // It is ok if after this conditional check m_numSnapshotTakers becomes > 0, because new snapshots won't include 
-                        // the deleted entry at m_array[lowLocal]. 
-                        if (m_source.m_numSnapshotTakers <= 0)
-                        {
-                            m_array[lowLocal] = default(T); //release the reference to the object. 
-                        }
+                    // Read the sequence number for the head position.
+                    int sequenceNumber = Volatile.Read(ref _slots[slotsIndex].SequenceNumber);
 
-                        //if the current thread sets m_low to SEGMENT_SIZE, which means the current segment becomes
-                        //disposable, then this thread is responsible to dispose this segment, and reset m_head 
-                        if (lowLocal + 1 >= SEGMENT_SIZE)
+                    // We can dequeue from this slot if it's been filled by an enqueuer, which
+                    // would have left the sequence number at pos+1.
+                    if (sequenceNumber == currentHead + 1)
+                    {
+                        // We may be racing with other dequeuers.  Try to reserve the slot by incrementing
+                        // the head.  Once we've done that, no one else will be able to read from this slot,
+                        // and no enqueuer will be able to read from this slot until we've written the new
+                        // sequence number. WARNING: The next few lines are not reliable on a runtime that
+                        // supports thread aborts. If a thread abort were to sneak in after the CompareExchange
+                        // but before the Volatile.Write, enqueuers trying to enqueue into this slot would
+                        // spin indefinitely.  If this implementation is ever used on such a platform, this
+                        // if block should be wrapped in a finally / prepared region.
+                        if (Interlocked.CompareExchange(ref _headAndTail.Head, currentHead + 1, currentHead) == currentHead)
                         {
-                            //  Invariant: we only dispose the current m_head, not any other segment
-                            //  In usual situation, disposing a segment is simply seting m_head to m_head.m_next
-                            //  But there is one special case, where m_head and m_tail points to the same and ONLY
-                            //segment of the queue: Another thread A is doing Enqueue and finds that it needs to grow,
-                            //while the *current* thread is doing *this* Dequeue operation, and finds that it needs to 
-                            //dispose the current (and ONLY) segment. Then we need to wait till thread A finishes its 
-                            //Grow operation, this is the reason of having the following while loop
-                            spinLocal = new SpinWait();
-                            while (m_next == null)
+                            // Successfully reserved the slot.  Note that after the above CompareExchange, other threads
+                            // trying to dequeue from this slot will end up spinning until we do the subsequent Write.
+                            item = _slots[slotsIndex].Item;
+                            if (!Volatile.Read(ref _preservedForObservation))
                             {
-                                spinLocal.SpinOnce();
+                                // If we're preserving, though, we don't zero out the slot, as we need it for
+                                // enumerations, peeking, ToArray, etc.  And we don't update the sequence number,
+                                // so that an enqueuer will see it as full and be forced to move to a new segment.
+                                _slots[slotsIndex].Item = default(T);
+                                Volatile.Write(ref _slots[slotsIndex].SequenceNumber, currentHead + _slots.Length);
                             }
-                            Debug.Assert(m_source.m_head == this);
-                            m_source.m_head = m_next;
+                            return true;
                         }
-                        return true;
                     }
-                    else
+                    else if (sequenceNumber < currentHead + 1)
                     {
-                        //CAS failed due to contention: spin briefly and retry
-                        spin.SpinOnce();
-                        lowLocal = Low; highLocal = High;
+                        // The sequence number was less than what we needed, which means this slot doesn't
+                        // yet contain a value we can dequeue, i.e. the segment is empty.  Technically it's
+                        // possible that multiple enqueuers could have written concurrently, with those
+                        // getting later slots actually finishing first, so there could be elements after
+                        // this one that are available, but we need to dequeue in order.  So before declaring
+                        // failure and that the segment is empty, we check the tail to see if we're actually
+                        // empty or if we're just waiting for items in flight or after this one to become available.
+                        bool frozen = _frozenForEnqueues;
+                        int currentTail = Volatile.Read(ref _headAndTail.Tail);
+                        if (currentTail - currentHead <= 0 || (frozen && (currentTail - FreezeOffset - currentHead <= 0)))
+                        {
+                            item = default(T);
+                            return false;
+                        }
+
+                        // It's possible it could have become frozen after we checked _frozenForEnqueues
+                        // and before reading the tail.  That's ok: in that rare race condition, we just
+                        // loop around again.
                     }
-                }//end of while
-                result = default(T);
-                return false;
+
+                    // Lost a race. Spin a bit, then try again.
+                    spinner.SpinOnce();
+                }
             }
 
-            /// <summary>
-            /// try to peek the current segment
-            /// </summary>
-            /// <param name="result">holds the return value of the element at the head position, 
-            /// value set to default(T) if there is no such an element</param>
-            /// <returns>true if there are elements in the current segment, false otherwise</returns>
-            internal bool TryPeek(out T result)
+            /// <summary>Tries to peek at an element from the queue, without removing it.</summary>
+            public bool TryPeek(out T result, bool resultUsed)
             {
-                result = default(T);
-                int lowLocal = Low;
-                if (lowLocal > High)
-                    return false;
-                SpinWait spin = new SpinWait();
-                while (!m_state[lowLocal].m_value)
+                if (resultUsed)
                 {
-                    spin.SpinOnce();
+                    // In order to ensure we don't get a torn read on the value, we mark the segment
+                    // as preserving for observation.  Additional items can still be enqueued to this
+                    // segment, but no space will be freed during dequeues, such that the segment will
+                    // no longer be reusable.
+                    _preservedForObservation = true;
+                    Interlocked.MemoryBarrier();
                 }
-                result = m_array[lowLocal];
-                return true;
-            }
 
-            /// <summary>
-            /// Adds part or all of the current segment into a List.
-            /// </summary>
-            /// <param name="list">the list to which to add</param>
-            /// <param name="start">the start position</param>
-            /// <param name="end">the end position</param>
-            internal void AddToList(List<T> list, int start, int end)
-            {
-                for (int i = start; i <= end; i++)
+                // Loop in case of contention...
+                var spinner = new SpinWait();
+                while (true)
                 {
-                    SpinWait spin = new SpinWait();
-                    while (!m_state[i].m_value)
+                    // Get the head at which to try to peek.
+                    int currentHead = Volatile.Read(ref _headAndTail.Head);
+                    int slotsIndex = currentHead & _slotsMask;
+
+                    // Read the sequence number for the head position.
+                    int sequenceNumber = Volatile.Read(ref _slots[slotsIndex].SequenceNumber);
+
+                    // We can peek from this slot if it's been filled by an enqueuer, which
+                    // would have left the sequence number at pos+1.
+                    if (sequenceNumber == currentHead + 1)
+                    {
+                        result = resultUsed ? _slots[slotsIndex].Item : default(T);
+                        return true;
+                    }
+                    else if (sequenceNumber < currentHead + 1)
                     {
-                        spin.SpinOnce();
+                        // The sequence number was less than what we needed, which means this slot doesn't
+                        // yet contain a value we can peek, i.e. the segment is empty.  Technically it's
+                        // possible that multiple enqueuers could have written concurrently, with those
+                        // getting later slots actually finishing first, so there could be elements after
+                        // this one that are available, but we need to peek in order.  So before declaring
+                        // failure and that the segment is empty, we check the tail to see if we're actually
+                        // empty or if we're just waiting for items in flight or after this one to become available.
+                        bool frozen = _frozenForEnqueues;
+                        int currentTail = Volatile.Read(ref _headAndTail.Tail);
+                        if (currentTail - currentHead <= 0 || (frozen && (currentTail - FreezeOffset - currentHead <= 0)))
+                        {
+                            result = default(T);
+                            return false;
+                        }
+
+                        // It's possible it could have become frozen after we checked _frozenForEnqueues
+                        // and before reading the tail.  That's ok: in that rare race condition, we just
+                        // loop around again.
                     }
-                    list.Add(m_array[i]);
+
+                    // Lost a race. Spin a bit, then try again.
+                    spinner.SpinOnce();
                 }
             }
 
             /// <summary>
-            /// return the position of the head of the current segment
-            /// Value range [0, SEGMENT_SIZE], if it's SEGMENT_SIZE, it means this segment is exhausted and thus empty
+            /// Attempts to enqueue the item.  If successful, the item will be stored
+            /// in the queue and true will be returned; otherwise, the item won't be stored, and false
+            /// will be returned.
             /// </summary>
-            internal int Low
+            public bool TryEnqueue(T item)
             {
-                get
+                // Loop in case of contention...
+                var spinner = new SpinWait();
+                while (true)
                 {
-                    return Math.Min(m_low, SEGMENT_SIZE);
+                    // Get the tail at which to try to return.
+                    int currentTail = Volatile.Read(ref _headAndTail.Tail);
+                    int slotsIndex = currentTail & _slotsMask;
+
+                    // Read the sequence number for the tail position.
+                    int sequenceNumber = Volatile.Read(ref _slots[slotsIndex].SequenceNumber);
+
+                    // The slot is empty and ready for us to enqueue into it if its sequence
+                    // number matches the slot.
+                    if (sequenceNumber == currentTail)
+                    {
+                        // We may be racing with other enqueuers.  Try to reserve the slot by incrementing
+                        // the tail.  Once we've done that, no one else will be able to write to this slot,
+                        // and no dequeuer will be able to read from this slot until we've written the new
+                        // sequence number. WARNING: The next few lines are not reliable on a runtime that
+                        // supports thread aborts. If a thread abort were to sneak in after the CompareExchange
+                        // but before the Volatile.Write, other threads will spin trying to access this slot.
+                        // If this implementation is ever used on such a platform, this if block should be
+                        // wrapped in a finally / prepared region.
+                        if (Interlocked.CompareExchange(ref _headAndTail.Tail, currentTail + 1, currentTail) == currentTail)
+                        {
+                            // Successfully reserved the slot.  Note that after the above CompareExchange, other threads
+                            // trying to return will end up spinning until we do the subsequent Write.
+                            _slots[slotsIndex].Item = item;
+                            Volatile.Write(ref _slots[slotsIndex].SequenceNumber, currentTail + 1);
+                            return true;
+                        }
+                    }
+                    else if (sequenceNumber < currentTail)
+                    {
+                        // The sequence number was less than what we needed, which means this slot still
+                        // contains a value, i.e. the segment is full.  Technically it's possible that multiple
+                        // dequeuers could have read concurrently, with those getting later slots actually
+                        // finishing first, so there could be spaces after this one that are available, but
+                        // we need to enqueue in order.
+                        return false;
+                    }
+
+                    // Lost a race. Spin a bit, then try again.
+                    spinner.SpinOnce();
                 }
             }
 
-            /// <summary>
-            /// return the logical position of the tail of the current segment      
-            /// Value range [-1, SEGMENT_SIZE-1]. When it's -1, it means this is a new segment and has no elemnet yet
-            /// </summary>
-            internal int High
+            /// <summary>Represents a slot in the queue.</summary>
+            [StructLayout(LayoutKind.Auto)]
+            [DebuggerDisplay("Item = {Item}, SequenceNumber = {SequenceNumber}")]
+            internal struct Slot
             {
-                get
-                {
-                    //if m_high > SEGMENT_SIZE, it means it's out of range, we should return
-                    //SEGMENT_SIZE-1 as the logical position
-                    return Math.Min(m_high, SEGMENT_SIZE - 1);
-                }
+                /// <summary>The item.</summary>
+                public T Item;
+                /// <summary>The sequence number for this slot, used to synchronize between enqueuers and dequeuers.</summary>
+                public int SequenceNumber;
             }
-
         }
-    }//end of class Segment
+    }
 
-    /// <summary>
-    /// A wrapper struct for volatile bool, please note the copy of the struct it self will not be volatile
-    /// for example this statement will not include in volatilness operation volatileBool1 = volatileBool2 the jit will copy the struct and will ignore the volatile
-    /// </summary>
-    struct VolatileBool
+    /// <summary>Padded head and tail indices, to avoid false sharing between producers and consumers.</summary>
+    [DebuggerDisplay("Head = {Head}, Tail = {Tail}")]
+    [StructLayout(LayoutKind.Explicit, Size = 192)] // padding before/between/after fields based on typical cache line size of 64
+    internal struct PaddedHeadAndTail
     {
-        public VolatileBool(bool value)
-        {
-            m_value = value;
-        }
-        public volatile bool m_value;
+        [FieldOffset(64)]  public int Head;
+        [FieldOffset(128)] public int Tail;
     }
 }
index e5332bb..a3653e7 100644 (file)
@@ -9,37 +9,31 @@
 **
 =============================================================================*/
 
-namespace System 
-{
-    using System;
-    using System.Runtime.Serialization;
+using System.Runtime.Serialization;
 
+namespace System
+{
     [Serializable]
-    [System.Runtime.InteropServices.ComVisible(true)]
     public sealed class DataMisalignedException : SystemException 
     {
-        public DataMisalignedException() 
-            : base(Environment.GetResourceString("Arg_DataMisalignedException")) 
-        {
-            SetErrorCode(__HResults.COR_E_DATAMISALIGNED);
-        }
-    
-        public DataMisalignedException(String message) 
-            : base(message) 
+        public DataMisalignedException()
+            : base(SR.Arg_DataMisalignedException)
         {
-            SetErrorCode(__HResults.COR_E_DATAMISALIGNED);
+            HResult = __HResults.COR_E_DATAMISALIGNED;
         }
 
-        public DataMisalignedException(String message, Exception innerException) 
-            : base(message, innerException) 
+        public DataMisalignedException(String message)
+            : base(message)
         {
-            SetErrorCode(__HResults.COR_E_DATAMISALIGNED);
+            HResult = __HResults.COR_E_DATAMISALIGNED;
         }
 
-        internal DataMisalignedException(SerializationInfo info, StreamingContext context) 
-            : base (info, context) 
+        public DataMisalignedException(String message, Exception innerException)
+            : base(message, innerException)
         {
+            HResult = __HResults.COR_E_DATAMISALIGNED;
         }
-    }
 
+        internal DataMisalignedException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+    }
 }
index 1a8a4ff..6b5e690 100644 (file)
@@ -2,14 +2,12 @@
 // 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 {
-
+namespace System
+{
     // This enum is used to indentify DateTime instances in cases when they are known to be in local time, 
     // UTC time or if this information has not been specified or is not applicable.
 
     [Serializable]
-[System.Runtime.InteropServices.ComVisible(true)]
     public enum DateTimeKind
     {
         Unspecified = 0,
index 37b8f89..5d84257 100644 (file)
 **
 **
 ============================================================*/
-namespace System {
 
+namespace System
+{
     [Serializable]
-[System.Runtime.InteropServices.ComVisible(true)]
-    public enum DayOfWeek {
+    public enum DayOfWeek
+    {
         Sunday = 0,
         Monday = 1,
         Tuesday = 2,
index b975e81..4abd43a 100644 (file)
 **
 =============================================================================*/
 
-namespace System {
-    
-    using System;
-    using System.Runtime.Serialization;
-[System.Runtime.InteropServices.ComVisible(true)]
+using System.Runtime.Serialization;
+
+namespace System
+{
     [Serializable]
-    public class DivideByZeroException : ArithmeticException {
-        public DivideByZeroException() 
-            : base(Environment.GetResourceString("Arg_DivideByZero")) {
-            SetErrorCode(__HResults.COR_E_DIVIDEBYZERO);
-        }
-    
-        public DivideByZeroException(String message) 
-            : base(message) {
-            SetErrorCode(__HResults.COR_E_DIVIDEBYZERO);
+    public class DivideByZeroException : ArithmeticException
+    {
+        public DivideByZeroException()
+            : base(SR.Arg_DivideByZero)
+        {
+            HResult = __HResults.COR_E_DIVIDEBYZERO;
         }
-    
-        public DivideByZeroException(String message, Exception innerException) 
-            : base(message, innerException) {
-            SetErrorCode(__HResults.COR_E_DIVIDEBYZERO);
+
+        public DivideByZeroException(String message)
+            : base(message)
+        {
+            HResult = __HResults.COR_E_DIVIDEBYZERO;
         }
 
-        protected DivideByZeroException(SerializationInfo info, StreamingContext context) : base(info, context) {
+        public DivideByZeroException(String message, Exception innerException)
+            : base(message, innerException)
+        {
+            HResult = __HResults.COR_E_DIVIDEBYZERO;
         }
+
+        protected DivideByZeroException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
 }
index d358d96..da29e2a 100644 (file)
 **
 =============================================================================*/
 
-namespace System {
-    
-    using System;
-    using System.Runtime.Remoting;
-    using System.Runtime.Serialization;
+using System.Runtime.Serialization;
 
+namespace System
+{
     // The DuplicateWaitObjectException is thrown when an object 
     // appears more than once in the list of objects to WaitAll or WaitAny.
     // 
-    [System.Runtime.InteropServices.ComVisible(true)]
     [Serializable]
-    public class DuplicateWaitObjectException : ArgumentException {
+    public class DuplicateWaitObjectException : ArgumentException
+    {
+        private static volatile String s_duplicateWaitObjectMessage = null;
 
-        private static volatile String _duplicateWaitObjectMessage = null;
-
-        private static String DuplicateWaitObjectMessage {
-            get {
-                if (_duplicateWaitObjectMessage == null)
-                    _duplicateWaitObjectMessage = Environment.GetResourceString("Arg_DuplicateWaitObjectException");
-                return _duplicateWaitObjectMessage;
+        private static String DuplicateWaitObjectMessage
+        {
+            get
+            {
+                if (s_duplicateWaitObjectMessage == null)
+                    s_duplicateWaitObjectMessage = SR.Arg_DuplicateWaitObjectException;
+                return s_duplicateWaitObjectMessage;
             }
         }
 
         // Creates a new DuplicateWaitObjectException with its message 
         // string set to a default message.
-        public DuplicateWaitObjectException() 
-            : base(DuplicateWaitObjectMessage) {
-            SetErrorCode(__HResults.COR_E_DUPLICATEWAITOBJECT);
+        public DuplicateWaitObjectException()
+            : base(DuplicateWaitObjectMessage)
+        {
+            HResult = __HResults.COR_E_DUPLICATEWAITOBJECT;
         }
 
-        public DuplicateWaitObjectException(String parameterName) 
-            : base(DuplicateWaitObjectMessage, parameterName) {
-            SetErrorCode(__HResults.COR_E_DUPLICATEWAITOBJECT);
+        public DuplicateWaitObjectException(String parameterName)
+            : base(DuplicateWaitObjectMessage, parameterName)
+        {
+            HResult = __HResults.COR_E_DUPLICATEWAITOBJECT;
         }
 
-        public DuplicateWaitObjectException(String parameterName, String message) 
-            : base(message, parameterName) {
-            SetErrorCode(__HResults.COR_E_DUPLICATEWAITOBJECT);
+        public DuplicateWaitObjectException(String parameterName, String message)
+            : base(message, parameterName)
+        {
+            HResult = __HResults.COR_E_DUPLICATEWAITOBJECT;
         }
 
-        public DuplicateWaitObjectException(String message, Exception innerException) 
-            : base(message, innerException) {
-            SetErrorCode(__HResults.COR_E_DUPLICATEWAITOBJECT);
+        public DuplicateWaitObjectException(String message, Exception innerException)
+            : base(message, innerException)
+        {
+            HResult = __HResults.COR_E_DUPLICATEWAITOBJECT;
         }
 
         // This constructor is required for serialization
-        protected DuplicateWaitObjectException(SerializationInfo info, StreamingContext context) : base (info, context) {
-        }
+        protected DuplicateWaitObjectException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
 }
index a65d800..835d334 100644 (file)
 **
 =============================================================================*/
 
-namespace System {
-    
-    using System;
-    using System.Runtime.Serialization;
-    [System.Runtime.InteropServices.ComVisible(true)]
+using System;
+using System.Runtime.Serialization;
+
+namespace System
+{
     [Serializable]
-    public class EntryPointNotFoundException : TypeLoadException {
-        public EntryPointNotFoundException() 
-            : base(Environment.GetResourceString("Arg_EntryPointNotFoundException")) {
-            SetErrorCode(__HResults.COR_E_ENTRYPOINTNOTFOUND);
-        }
-    
-        public EntryPointNotFoundException(String message) 
-            : base(message) {
-            SetErrorCode(__HResults.COR_E_ENTRYPOINTNOTFOUND);
+    public class EntryPointNotFoundException : TypeLoadException
+    {
+        public EntryPointNotFoundException()
+            : base(SR.Arg_EntryPointNotFoundException)
+        {
+            HResult = __HResults.COR_E_ENTRYPOINTNOTFOUND;
         }
-    
-        public EntryPointNotFoundException(String message, Exception inner) 
-            : base(message, inner) {
-            SetErrorCode(__HResults.COR_E_ENTRYPOINTNOTFOUND);
+
+        public EntryPointNotFoundException(String message)
+            : base(message)
+        {
+            HResult = __HResults.COR_E_ENTRYPOINTNOTFOUND;
         }
 
-        protected EntryPointNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) {
+        public EntryPointNotFoundException(String message, Exception inner)
+            : base(message, inner)
+        {
+            HResult = __HResults.COR_E_ENTRYPOINTNOTFOUND;
         }
-    
-    
-    }
 
+        protected EntryPointNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+    }
 }
index 349de85..c035661 100644 (file)
@@ -2,16 +2,17 @@
 // 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;
+using System;
+
+namespace System
+{
     // The base class for all event classes.
     [Serializable]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public class EventArgs {
+    public class EventArgs
+    {
         public static readonly EventArgs Empty = new EventArgs();
-    
-        public EventArgs() 
+
+        public EventArgs()
         {
         }
     }
index 517e1f7..e6923cf 100644 (file)
@@ -2,10 +2,11 @@
 // 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;
+
+namespace System
+{
     [Serializable]
-    [System.Runtime.InteropServices.ComVisible(true)]
     public delegate void EventHandler(Object sender, EventArgs e);
 
     [Serializable]
index 5b2592c..bebfd49 100644 (file)
 **
 =============================================================================*/
 
-namespace System {
+using System;
+using System.Runtime.Serialization;
 
-       using System;
-       using System.Runtime.Serialization;
+namespace System
+{
     [Obsolete("This type previously indicated an unspecified fatal error in the runtime. The runtime no longer raises this exception so this type is obsolete.")]
-    [System.Runtime.InteropServices.ComVisible(true)]
     [Serializable]
-    public sealed class ExecutionEngineException : SystemException {
-        public ExecutionEngineException() 
-            : base(Environment.GetResourceString("Arg_ExecutionEngineException")) {
-               SetErrorCode(__HResults.COR_E_EXECUTIONENGINE);
+    public sealed class ExecutionEngineException : SystemException
+    {
+        public ExecutionEngineException()
+            : base(SR.Arg_ExecutionEngineException)
+        {
+            HResult = __HResults.COR_E_EXECUTIONENGINE;
         }
-    
-        public ExecutionEngineException(String message) 
-            : base(message) {
-               SetErrorCode(__HResults.COR_E_EXECUTIONENGINE);
-        }
-    
-        public ExecutionEngineException(String message, Exception innerException) 
-            : base(message, innerException) {
-               SetErrorCode(__HResults.COR_E_EXECUTIONENGINE);
+
+        public ExecutionEngineException(String message)
+            : base(message)
+        {
+            HResult = __HResults.COR_E_EXECUTIONENGINE;
         }
 
-        internal ExecutionEngineException(SerializationInfo info, StreamingContext context) : base(info, context) {
+        public ExecutionEngineException(String message, Exception innerException)
+            : base(message, innerException)
+        {
+            HResult = __HResults.COR_E_EXECUTIONENGINE;
         }
+
+        internal ExecutionEngineException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
 }
index fbc3b1f..ac62c0f 100644 (file)
@@ -9,31 +9,31 @@
 **
 =============================================================================*/
 
-namespace System {
-    
-    using System;
-    using System.Runtime.Serialization;
-    [System.Runtime.InteropServices.ComVisible(true)]
+using System.Runtime.Serialization;
+
+namespace System
+{
     [Serializable]
-    public class FieldAccessException : MemberAccessException {
-        public FieldAccessException() 
-            : base(Environment.GetResourceString("Arg_FieldAccessException")) {
-            SetErrorCode(__HResults.COR_E_FIELDACCESS);
-        }
-    
-        public FieldAccessException(String message) 
-            : base(message) {
-            SetErrorCode(__HResults.COR_E_FIELDACCESS);
+    public class FieldAccessException : MemberAccessException
+    {
+        public FieldAccessException()
+            : base(SR.Arg_FieldAccessException)
+        {
+            HResult = __HResults.COR_E_FIELDACCESS;
         }
-    
-        public FieldAccessException(String message, Exception inner) 
-            : base(message, inner) {
-            SetErrorCode(__HResults.COR_E_FIELDACCESS);
+
+        public FieldAccessException(String message)
+            : base(message)
+        {
+            HResult = __HResults.COR_E_FIELDACCESS;
         }
 
-        protected FieldAccessException(SerializationInfo info, StreamingContext context) : base(info, context) {
+        public FieldAccessException(String message, Exception inner)
+            : base(message, inner)
+        {
+            HResult = __HResults.COR_E_FIELDACCESS;
         }
 
+        protected FieldAccessException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
-
 }
index cb955cf..5f8c108 100644 (file)
@@ -4,16 +4,15 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////////
-namespace System {
-    
-    using System;
+
+namespace System
+{
     // Custom attribute to indicate that the enum
     // should be treated as a bitfield (or set of flags).
     // An IDE may use this information to provide a richer
     // development experience.
     [Serializable]
     [AttributeUsage(AttributeTargets.Enum, Inherited = false)]
-    [System.Runtime.InteropServices.ComVisible(true)]
     public class FlagsAttribute : Attribute
     {
         public FlagsAttribute()
index 2e1c8a9..c5758e1 100644 (file)
 **
 ** 
 ===========================================================*/
-namespace System {
-    
-    using System.Runtime.Serialization;
-    [System.Runtime.InteropServices.ComVisible(true)]
+
+using System.Runtime.Serialization;
+
+namespace System
+{
     [Serializable]
-    public class FormatException : SystemException {
-        public FormatException() 
-            : base(Environment.GetResourceString("Arg_FormatException")) {
-            SetErrorCode(__HResults.COR_E_FORMAT);
-        }
-    
-        public FormatException(String message) 
-            : base(message) {
-            SetErrorCode(__HResults.COR_E_FORMAT);
+    public class FormatException : SystemException
+    {
+        public FormatException()
+            : base(SR.Arg_FormatException)
+        {
+            HResult = __HResults.COR_E_FORMAT;
         }
-        
-        public FormatException(String message, Exception innerException) 
-            : base(message, innerException) {
-            SetErrorCode(__HResults.COR_E_FORMAT);
+
+        public FormatException(String message)
+            : base(message)
+        {
+            HResult = __HResults.COR_E_FORMAT;
         }
 
-        protected FormatException(SerializationInfo info, StreamingContext context) : base(info, context) {
+        public FormatException(String message, Exception innerException)
+            : base(message, innerException)
+        {
+            HResult = __HResults.COR_E_FORMAT;
         }
 
+        protected FormatException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
-
 }
index 294b2c1..6369363 100644 (file)
@@ -4,13 +4,13 @@
 
 /*============================================================
 **
-** Class:  FormattableString
 **
 **
 ** Purpose: implementation of the FormattableString
 ** class.
 **
 ===========================================================*/
+
 namespace System
 {
     /// <summary>
diff --git a/src/mscorlib/src/System/IAppDomain.cs b/src/mscorlib/src/System/IAppDomain.cs
deleted file mode 100644 (file)
index cdb8316..0000000
+++ /dev/null
@@ -1,28 +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.
-
-/*============================================================
-**
-** Interface:  IAppDomain
-** 
-** 
-**
-**
-** Purpose: Properties and methods exposed to COM
-**
-** 
-===========================================================*/
-namespace System
-{
-    using System.Runtime.InteropServices;
-
-    [GuidAttribute("05F696DC-2B29-3663-AD8B-C4389CF2A713")]
-    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-    [CLSCompliant(false)]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public interface _AppDomain
-    {
-    }
-}
-
index 2591c72..0abeaca 100644 (file)
 **          operation
 **
 ===========================================================*/
-namespace System {
-    
-    using System;
-    using System.Threading;
-[System.Runtime.InteropServices.ComVisible(true)]
+
+using System;
+using System.Threading;
+
+namespace System
+{
     public interface IAsyncResult
     {
         bool IsCompleted { get; }
@@ -22,11 +23,8 @@ namespace System {
         WaitHandle AsyncWaitHandle { get; }
 
 
-        Object     AsyncState      { get; }
+        Object AsyncState { get; }
 
-        bool       CompletedSynchronously { get; }
-   
-    
+        bool CompletedSynchronously { get; }
     }
-
 }
index 111d892..72aeeb0 100644 (file)
@@ -2,18 +2,16 @@
 // 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;
+namespace System
+{
     // The IComparable interface is implemented by classes that support an
     // ordering of instances of the class. The ordering represented by
     // IComparable can be used to sort arrays and collections of objects
     // that implement the interface.
     // 
-[System.Runtime.InteropServices.ComVisible(true)]
     public interface IComparable
     {
-    // Interface does not need to be marked with the serializable attribute
+        // Interface does not need to be marked with the serializable attribute
         // Compares this object to another object, returning an integer that
         // indicates the relationship. An implementation of this method must return
         // a value less than zero if this is less than object, zero
index 174b25b..8735112 100644 (file)
@@ -2,15 +2,12 @@
 // 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.Diagnostics.Contracts;
-    using System.Threading;
-
+namespace System
+{
     // The IConvertible interface represents an object that contains a value. This
     // interface is implemented by the following types in the System namespace:
     // Boolean, Char, SByte, Byte, Int16, UInt16, Int32, UInt32, Int64, UInt64,
-    // Single, Double, Decimal, DateTime, TimeSpan, and String. The interface may
+    // Single, Double, Decimal, DateTime, and String. The interface may
     // be implemented by other types that are to be considered values. For example,
     // a library of nullable database types could implement IConvertible.
     //
@@ -23,7 +20,6 @@ namespace System {
     // IConvertible implementation should simply throw an InvalidCastException.
 
     [CLSCompliant(false)]
-    [System.Runtime.InteropServices.ComVisible(true)]
     public interface IConvertible
     {
         // Returns the type code of this object. An implementation of this method
index cbc3816..47340f3 100644 (file)
 **
 **
 ===========================================================*/
-namespace System {
-    
-    using System;
-    using System.Runtime.Serialization;
 
-    [System.Runtime.InteropServices.ComVisible(true)]
+using System;
+
+namespace System
+{
     public interface ICustomFormatter
     {
         // Interface does not need to be marked with the serializable attribute
-        String Format (String format, Object arg, IFormatProvider formatProvider);
+        String Format(String format, Object arg, IFormatProvider formatProvider);
     }
 }
index fcb65be..24f0740 100644 (file)
@@ -11,7 +11,9 @@
 **
 ** 
 ===========================================================*/
-namespace System {
+
+namespace System
+{
     // IDisposable is an attempt at helping to solve problems with deterministic
     // finalization.  The GC of course doesn't leave any way to deterministically
     // know when a finalizer will run.  This forces classes that hold onto OS
@@ -51,8 +53,8 @@ namespace System {
     // data buffered by the StreamWriter cannot be written to the Stream.  In this
     // case, it doesn't make much sense to provide a finalizer on the StreamWriter
     // since you cannot solve this problem correctly.  
-[System.Runtime.InteropServices.ComVisible(true)]
-    public interface IDisposable {
+    public interface IDisposable
+    {
         void Dispose();
     }
 }
index aa034da..1264fdd 100644 (file)
@@ -2,13 +2,13 @@
 // 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;    
+using System;
+
+namespace System
+{
     public interface IEquatable<T>
     {
         bool Equals(T other);
     }
-
 }
 
index a5cc783..0c17354 100644 (file)
 **
 **
 ============================================================*/
-namespace System {
-    
-    using System;
 
-    [System.Runtime.InteropServices.ComVisible(true)]
+using System;
+
+namespace System
+{
     public interface IFormatProvider
     {
         // Interface does not need to be marked with the serializable attribute
index 414b468..28a7d70 100644 (file)
@@ -2,12 +2,11 @@
 // 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;
-    using System.Diagnostics.Contracts;
+using System;
+using System.Diagnostics.Contracts;
 
-    [System.Runtime.InteropServices.ComVisible(true)]
+namespace System
+{
     public interface IFormattable
     {
         [Pure]
index 0adf822..b5464d7 100644 (file)
@@ -88,7 +88,7 @@ namespace System.IO
         {
             byte[] bytes;
             using(FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 
-                FileStream.DefaultBufferSize, FileOptions.None, Path.GetFileName(path), false, false)) {
+                FileStream.DefaultBufferSize, FileOptions.None)) {
                 // Do a blocking read
                 int index = 0;
                 long fileLength = fs.Length;
index 708db08..b96c9ee 100644 (file)
@@ -188,7 +188,7 @@ namespace System.IO
                 throw new ArgumentOutOfRangeException(nameof(bufferSize), Environment.GetResourceString("ArgumentOutOfRange_NeedPosNum"));
             Contract.EndContractBlock();
 
-            Stream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, DefaultFileStreamBufferSize, FileOptions.SequentialScan, Path.GetFileName(path), false, false);
+            Stream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, DefaultFileStreamBufferSize, FileOptions.SequentialScan);
             Init(stream, encoding, detectEncodingFromByteOrderMarks, bufferSize, false);
         }
         
index c231c45..aabb0b8 100644 (file)
@@ -2,23 +2,10 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-/*============================================================
-**
-** 
-** 
-**
-**
-** Purpose: Interface for exposing an Observable in the 
-** Observer pattern
-**
-**
-===========================================================*/
-
 namespace System
 {
     public interface IObservable<out T>
     {
         IDisposable Subscribe(IObserver<T> observer);
     }
-
 }
index 7f55ce0..39e123d 100644 (file)
@@ -2,20 +2,6 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-/*============================================================
-**
-** 
-** 
-**
-**
-** Purpose: Interface for exposing an Observer in the 
-** Observer pattern
-**
-**
-===========================================================*/
-
-using System;
-
 namespace System
 {
     public interface IObserver<in T>
index e104301..724c7bd 100644 (file)
@@ -2,17 +2,6 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-/*============================================================
-**
-** 
-** 
-**
-**
-** Purpose: Interface for providing progress updates.
-**
-**
-===========================================================*/
-
 namespace System
 {
     /// <summary>Defines a provider for progress updates.</summary>
index e641b5e..4969c2b 100644 (file)
 **
 =============================================================================*/
 
-namespace System {
-    
-    using System.Runtime.Serialization;
-    [System.Runtime.InteropServices.ComVisible(true)]
+using System.Runtime.Serialization;
+
+namespace System
+{
     [Serializable]
-    public sealed class IndexOutOfRangeException : SystemException {
-        public IndexOutOfRangeException() 
-            : base(Environment.GetResourceString("Arg_IndexOutOfRangeException")) {
-            SetErrorCode(__HResults.COR_E_INDEXOUTOFRANGE);
-        }
-    
-        public IndexOutOfRangeException(String message) 
-            : base(message) {
-            SetErrorCode(__HResults.COR_E_INDEXOUTOFRANGE);
+    public sealed class IndexOutOfRangeException : SystemException
+    {
+        public IndexOutOfRangeException()
+            : base(SR.Arg_IndexOutOfRangeException)
+        {
+            HResult = __HResults.COR_E_INDEXOUTOFRANGE;
         }
-        
-        public IndexOutOfRangeException(String message, Exception innerException) 
-            : base(message, innerException) {
-            SetErrorCode(__HResults.COR_E_INDEXOUTOFRANGE);
+
+        public IndexOutOfRangeException(String message)
+            : base(message)
+        {
+            HResult = __HResults.COR_E_INDEXOUTOFRANGE;
         }
 
-        internal IndexOutOfRangeException(SerializationInfo info, StreamingContext context) : base(info, context) {
+        public IndexOutOfRangeException(String message, Exception innerException)
+            : base(message, innerException)
+        {
+            HResult = __HResults.COR_E_INDEXOUTOFRANGE;
         }
 
+        internal IndexOutOfRangeException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
-
 }
index 6b02f46..b9a4a12 100644 (file)
@@ -2,46 +2,31 @@
 // 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 exception class used when there is insufficient execution stack
-**          to allow most Framework methods to execute.
-**
-**
-=============================================================================*/
-
-namespace System {
-    
-    using System;
-    using System.Runtime.Serialization;
+using System.Runtime.Serialization;
 
+namespace System
+{
     [Serializable]
-    public sealed class InsufficientExecutionStackException : SystemException 
+    public sealed class InsufficientExecutionStackException : SystemException
     {
         public InsufficientExecutionStackException()
-            : base(Environment.GetResourceString("Arg_InsufficientExecutionStackException")) 
-        {
-            SetErrorCode(__HResults.COR_E_INSUFFICIENTEXECUTIONSTACK);
-        }
-    
-        public InsufficientExecutionStackException(String message) 
-            : base(message) 
+            : base(SR.Arg_InsufficientExecutionStackException)
         {
-            SetErrorCode(__HResults.COR_E_INSUFFICIENTEXECUTIONSTACK);
+            HResult = __HResults.COR_E_INSUFFICIENTEXECUTIONSTACK;
         }
-        
-        public InsufficientExecutionStackException(String message, Exception innerException) 
-            : base(message, innerException) 
+
+        public InsufficientExecutionStackException(String message)
+            : base(message)
         {
-            SetErrorCode(__HResults.COR_E_INSUFFICIENTEXECUTIONSTACK);
+            HResult = __HResults.COR_E_INSUFFICIENTEXECUTIONSTACK;
         }
 
-        private InsufficientExecutionStackException(SerializationInfo info, StreamingContext context)
-            : base(info, context)
+        public InsufficientExecutionStackException(String message, Exception innerException)
+            : base(message, innerException)
         {
+            HResult = __HResults.COR_E_INSUFFICIENTEXECUTIONSTACK;
         }
-        
+
+        internal InsufficientExecutionStackException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
 }
index ba7b722..01d92b2 100644 (file)
@@ -4,42 +4,41 @@
 
 /*=============================================================================
 **
-**
-**
-** Purpose: Exception class for bad cast conditions!
-**
+** Purpose: Exception class for invalid cast conditions!
 **
 =============================================================================*/
 
-namespace System {
-    
-    using System.Runtime.Serialization;
-    [System.Runtime.InteropServices.ComVisible(true)]
+using System.Runtime.Serialization;
+
+namespace System
+{
     [Serializable]
-    public class InvalidCastException : SystemException {
-        public InvalidCastException() 
-            : base(Environment.GetResourceString("Arg_InvalidCastException")) {
-            SetErrorCode(__HResults.COR_E_INVALIDCAST);
-        }
-    
-        public InvalidCastException(String message) 
-            : base(message) {
-            SetErrorCode(__HResults.COR_E_INVALIDCAST);
+    public class InvalidCastException : SystemException
+    {
+        public InvalidCastException()
+            : base(SR.Arg_InvalidCastException)
+        {
+            HResult = __HResults.COR_E_INVALIDCAST;
         }
 
-        public InvalidCastException(String message, Exception innerException) 
-            : base(message, innerException) {
-            SetErrorCode(__HResults.COR_E_INVALIDCAST);
+        public InvalidCastException(String message)
+            : base(message)
+        {
+            HResult = __HResults.COR_E_INVALIDCAST;
         }
 
-        protected InvalidCastException(SerializationInfo info, StreamingContext context) : base(info, context) {
+        public InvalidCastException(String message, Exception innerException)
+            : base(message, innerException)
+        {
+            HResult = __HResults.COR_E_INVALIDCAST;
         }
 
-        public InvalidCastException(String message, int errorCode) 
-            : base(message) {
-            SetErrorCode(errorCode);
+        public InvalidCastException(String message, int errorCode)
+            : base(message)
+        {
+            HResult = errorCode;
         }
 
+        protected InvalidCastException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
-
 }
index 5f29e79..24a08c8 100644 (file)
 **
 **
 =============================================================================*/
-namespace System {
-    
-    using System.Runtime.Serialization;
-    [System.Runtime.InteropServices.ComVisible(true)]
+
+using System.Runtime.Serialization;
+
+namespace System
+{
     [Serializable]
     public class InvalidOperationException : SystemException
     {
-        public InvalidOperationException() 
-            : base(Environment.GetResourceString("Arg_InvalidOperationException")) {
-            SetErrorCode(__HResults.COR_E_INVALIDOPERATION);
-        }
-        
-        public InvalidOperationException(String message) 
-            : base(message) {
-            SetErrorCode(__HResults.COR_E_INVALIDOPERATION);
+        public InvalidOperationException()
+            : base(SR.Arg_InvalidOperationException)
+        {
+            HResult = __HResults.COR_E_INVALIDOPERATION;
         }
-    
-        public InvalidOperationException(String message, Exception innerException) 
-            : base(message, innerException) {
-            SetErrorCode(__HResults.COR_E_INVALIDOPERATION);
+
+        public InvalidOperationException(String message)
+            : base(message)
+        {
+            HResult = __HResults.COR_E_INVALIDOPERATION;
         }
 
-        protected InvalidOperationException(SerializationInfo info, StreamingContext context) : base(info, context) {
+        public InvalidOperationException(String message, Exception innerException)
+            : base(message, innerException)
+        {
+            HResult = __HResults.COR_E_INVALIDOPERATION;
         }
 
+        protected InvalidOperationException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
 }
-
index 649849a..401b3a0 100644 (file)
 **
 =============================================================================*/
 
-namespace System {
+using System.Runtime.Serialization;
 
-    using System;
-    using System.Runtime.Serialization;
+namespace System
+{
     [Serializable]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public sealed class InvalidProgramException : SystemException {
-        public InvalidProgramException() 
-            : base(Environment.GetResourceString("InvalidProgram_Default")) {
-            SetErrorCode(__HResults.COR_E_INVALIDPROGRAM);
+    public sealed class InvalidProgramException : SystemException
+    {
+        public InvalidProgramException()
+            : base(SR.InvalidProgram_Default)
+        {
+            HResult = __HResults.COR_E_INVALIDPROGRAM;
         }
-    
-        public InvalidProgramException(String message) 
-            : base(message) {
-            SetErrorCode(__HResults.COR_E_INVALIDPROGRAM);
-        }
-    
-        public InvalidProgramException(String message, Exception inner) 
-            : base(message, inner) {
-            SetErrorCode(__HResults.COR_E_INVALIDPROGRAM);
+
+        public InvalidProgramException(String message)
+            : base(message)
+        {
+            HResult = __HResults.COR_E_INVALIDPROGRAM;
         }
 
-        internal InvalidProgramException(SerializationInfo info, StreamingContext context) : base(info, context) {
+        public InvalidProgramException(String message, Exception inner)
+            : base(message, inner)
+        {
+            HResult = __HResults.COR_E_INVALIDPROGRAM;
         }
 
+        internal InvalidProgramException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
-
 }
index f334754..8f0751c 100644 (file)
@@ -6,19 +6,23 @@ using System.Runtime.Serialization;
 
 namespace System
 {
-   [Serializable]
-   [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)]
-   public class InvalidTimeZoneException : Exception
-   {
-       public InvalidTimeZoneException(String message)
-           : base(message) { }
+    [Serializable]
+    public class InvalidTimeZoneException : Exception
+    {
+        public InvalidTimeZoneException()
+        {
+        }
 
-       public InvalidTimeZoneException(String message, Exception innerException)
-           : base(message, innerException) { }
+        public InvalidTimeZoneException(String message)
+            : base(message)
+        {
+        }
 
-       protected InvalidTimeZoneException(SerializationInfo info, StreamingContext context)
-           : base(info, context) { }
+        public InvalidTimeZoneException(String message, Exception innerException)
+            : base(message, innerException)
+        {
+        }
 
-       public InvalidTimeZoneException() { }
-   }
+        protected InvalidTimeZoneException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+    }
 }
index 53ebda7..9014de0 100644 (file)
@@ -2,32 +2,25 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-/*============================================================
-**
-**
-**              
-**
-** Purpose: Defines the root type for all marshal by reference aka
-**          AppDomain bound types
-**          
-**
-**
-===========================================================*/
 namespace System
 {
     [Serializable]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public abstract class MarshalByRefObject 
+    public abstract class MarshalByRefObject
     {
-        protected MarshalByRefObject() { }
+        protected MarshalByRefObject()
+        {
+        }
+
         public object GetLifetimeService()
         {
             throw new PlatformNotSupportedException();
         }
+
         public virtual object InitializeLifetimeService()
         {
             throw new PlatformNotSupportedException();
         }
+
         protected MarshalByRefObject MemberwiseClone(bool cloneIdentity)
         {
             MarshalByRefObject mbr = (MarshalByRefObject)base.MemberwiseClone();
index bc21248..54eee67 100644 (file)
@@ -8,41 +8,41 @@
 // access, due to it being removed, private or something similar.
 ////////////////////////////////////////////////////////////////////////////////
 
-namespace System {
-    
-    using System;
-    using System.Runtime.Serialization;
+using System.Runtime.Serialization;
+
+namespace System
+{
     // The MemberAccessException is thrown when trying to access a class
     // member fails.
     // 
-    [System.Runtime.InteropServices.ComVisible(true)]
     [Serializable]
-    public class MemberAccessException : SystemException {
-        
+    public class MemberAccessException : SystemException
+    {
         // Creates a new MemberAccessException with its message string set to
         // the empty string, its HRESULT set to COR_E_MEMBERACCESS, 
         // and its ExceptionInfo reference set to null. 
-        public MemberAccessException() 
-            : base(Environment.GetResourceString("Arg_AccessException")) {
-            SetErrorCode(__HResults.COR_E_MEMBERACCESS);
+        public MemberAccessException()
+            : base(SR.Arg_AccessException)
+        {
+            HResult = __HResults.COR_E_MEMBERACCESS;
         }
-        
+
         // Creates a new MemberAccessException with its message string set to
         // message, its HRESULT set to COR_E_ACCESS, 
         // and its ExceptionInfo reference set to null. 
         // 
-        public MemberAccessException(String message) 
-            : base(message) {
-            SetErrorCode(__HResults.COR_E_MEMBERACCESS);
-        }
-        
-        public MemberAccessException(String message, Exception inner) 
-            : base(message, inner) {
-            SetErrorCode(__HResults.COR_E_MEMBERACCESS);
+        public MemberAccessException(String message)
+            : base(message)
+        {
+            HResult = __HResults.COR_E_MEMBERACCESS;
         }
 
-        protected MemberAccessException(SerializationInfo info, StreamingContext context) : base(info, context) {
+        public MemberAccessException(String message, Exception inner)
+            : base(message, inner)
+        {
+            HResult = __HResults.COR_E_MEMBERACCESS;
         }
 
+        protected MemberAccessException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
 }
index 3feaf3e..2ecbd14 100644 (file)
@@ -9,31 +9,31 @@
 **
 =============================================================================*/
 
-namespace System {
-    
-    using System;
-    using System.Runtime.Serialization;
-    [System.Runtime.InteropServices.ComVisible(true)]
+using System.Runtime.Serialization;
+
+namespace System
+{
     [Serializable]
-    public class MethodAccessException : MemberAccessException {
-        public MethodAccessException() 
-            : base(Environment.GetResourceString("Arg_MethodAccessException")) {
-            SetErrorCode(__HResults.COR_E_METHODACCESS);
-        }
-    
-        public MethodAccessException(String message) 
-            : base(message) {
-            SetErrorCode(__HResults.COR_E_METHODACCESS);
+    public class MethodAccessException : MemberAccessException
+    {
+        public MethodAccessException()
+            : base(SR.Arg_MethodAccessException)
+        {
+            HResult = __HResults.COR_E_METHODACCESS;
         }
-    
-        public MethodAccessException(String message, Exception inner) 
-            : base(message, inner) {
-            SetErrorCode(__HResults.COR_E_METHODACCESS);
+
+        public MethodAccessException(String message)
+            : base(message)
+        {
+            HResult = __HResults.COR_E_METHODACCESS;
         }
 
-        protected MethodAccessException(SerializationInfo info, StreamingContext context) : base(info, context) {
+        public MethodAccessException(String message, Exception inner)
+            : base(message, inner)
+        {
+            HResult = __HResults.COR_E_METHODACCESS;
         }
 
+        protected MethodAccessException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
-
 }
index ff70924..a75de43 100644 (file)
@@ -2,11 +2,10 @@
 // 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 {
-
-[System.Runtime.InteropServices.ComVisible(true)]
-    public enum MidpointRounding {
+namespace System
+{
+    public enum MidpointRounding
+    {
         ToEven = 0,
         AwayFromZero = 1,
     }
index ad8eeeb..4fcaa98 100644 (file)
@@ -7,31 +7,31 @@
 // This is thrown when you add multiple callbacks to a non-multicast delegate.
 ////////////////////////////////////////////////////////////////////////////////
 
-namespace System {
-    
-    using System;
-    using System.Runtime.Serialization;
-    [System.Runtime.InteropServices.ComVisible(true)]
+using System.Runtime.Serialization;
+
+namespace System
+{
     [Serializable]
-    public sealed class MulticastNotSupportedException : SystemException {
-        
-        public MulticastNotSupportedException() 
-            : base(Environment.GetResourceString("Arg_MulticastNotSupportedException")) {
-            SetErrorCode(__HResults.COR_E_MULTICASTNOTSUPPORTED);
-        }
-    
-        public MulticastNotSupportedException(String message) 
-            : base(message) {
-            SetErrorCode(__HResults.COR_E_MULTICASTNOTSUPPORTED);
+    public sealed class MulticastNotSupportedException : SystemException
+    {
+        public MulticastNotSupportedException()
+            : base(SR.Arg_MulticastNotSupportedException)
+        {
+            HResult = __HResults.COR_E_MULTICASTNOTSUPPORTED;
         }
-        
-        public MulticastNotSupportedException(String message, Exception inner) 
-            : base(message, inner) {
-            SetErrorCode(__HResults.COR_E_MULTICASTNOTSUPPORTED);
+
+        public MulticastNotSupportedException(String message)
+            : base(message)
+        {
+            HResult = __HResults.COR_E_MULTICASTNOTSUPPORTED;
         }
 
-        internal MulticastNotSupportedException(SerializationInfo info, StreamingContext context) : base(info, context) {
+        public MulticastNotSupportedException(String message, Exception inner)
+            : base(message, inner)
+        {
+            HResult = __HResults.COR_E_MULTICASTNOTSUPPORTED;
         }
 
+        internal MulticastNotSupportedException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
 }
index 3a896ce..68e8f88 100644 (file)
@@ -2,68 +2,70 @@
 // 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;
-    using System.Runtime.Serialization;
-    using System.Security.Permissions;
-    using System.Diagnostics.Contracts;
+using System.Runtime.Serialization;
 
-    [System.Runtime.InteropServices.ComVisible(true)]
+namespace System 
+{
     [Serializable]
-    public class NotFiniteNumberException : ArithmeticException {
+    public class NotFiniteNumberException : ArithmeticException 
+    {
         private double _offendingNumber;    
     
         public NotFiniteNumberException() 
-            : base(Environment.GetResourceString("Arg_NotFiniteNumberException")) {
+            : base(SR.Arg_NotFiniteNumberException) 
+        {
             _offendingNumber = 0;
-            SetErrorCode(__HResults.COR_E_NOTFINITENUMBER);
+            HResult = __HResults.COR_E_NOTFINITENUMBER;
         }
 
         public NotFiniteNumberException(double offendingNumber) 
-            : base() {
+            : base() 
+        {
             _offendingNumber = offendingNumber;
-            SetErrorCode(__HResults.COR_E_NOTFINITENUMBER);
+            HResult = __HResults.COR_E_NOTFINITENUMBER;
         }
 
         public NotFiniteNumberException(String message) 
-            : base(message) {
+            : base(message) 
+        {
             _offendingNumber = 0;
-            SetErrorCode(__HResults.COR_E_NOTFINITENUMBER);
+            HResult = __HResults.COR_E_NOTFINITENUMBER;
         }
 
         public NotFiniteNumberException(String message, double offendingNumber) 
-            : base(message) {
+            : base(message) 
+        {
             _offendingNumber = offendingNumber;
-            SetErrorCode(__HResults.COR_E_NOTFINITENUMBER);
+            HResult = __HResults.COR_E_NOTFINITENUMBER;
         }
 
         public NotFiniteNumberException(String message, Exception innerException) 
-            : base(message, innerException) {
-            SetErrorCode(__HResults.COR_E_NOTFINITENUMBER);
+            : base(message, innerException) 
+        {
+            HResult = __HResults.COR_E_NOTFINITENUMBER;
         }
         
         public NotFiniteNumberException(String message, double offendingNumber, Exception innerException) 
-            : base(message, innerException) {
+            : base(message, innerException) 
+        {
             _offendingNumber = offendingNumber;
-            SetErrorCode(__HResults.COR_E_NOTFINITENUMBER);
+            HResult = __HResults.COR_E_NOTFINITENUMBER;
         }
 
-        protected NotFiniteNumberException(SerializationInfo info, StreamingContext context) : base(info, context) {
+        protected NotFiniteNumberException(SerializationInfo info, StreamingContext context) : base(info, context) 
+        {
             _offendingNumber = info.GetInt32("OffendingNumber");
         }
 
-        public double OffendingNumber {
-            get { return _offendingNumber; }
-        }
-
-        public override void GetObjectData(SerializationInfo info, StreamingContext context) {
-            if (info==null) {
-                throw new ArgumentNullException(nameof(info));
-            }
-            Contract.EndContractBlock();
+        public override void GetObjectData(SerializationInfo info, StreamingContext context) 
+        {
             base.GetObjectData(info, context);
             info.AddValue("OffendingNumber", _offendingNumber, typeof(Int32));
         }
+
+        public double OffendingNumber 
+        {
+            get { return _offendingNumber; }
+        }
     }
 }
index d6c9668..4d141ea 100644 (file)
 **
 =============================================================================*/
 
-namespace System {
-    
-    using System;
-    using System.Runtime.Serialization;
+using System.Runtime.Serialization;
 
-    [System.Runtime.InteropServices.ComVisible(true)]
+namespace System
+{
     [Serializable]
     public class NotImplementedException : SystemException
     {
-        public NotImplementedException() 
-            : base(Environment.GetResourceString("Arg_NotImplementedException")) {
-            SetErrorCode(__HResults.E_NOTIMPL);
+        public NotImplementedException()
+            : base(SR.Arg_NotImplementedException)
+        {
+            HResult = __HResults.E_NOTIMPL;
         }
-        public NotImplementedException(String message) 
-            : base(message) {
-            SetErrorCode(__HResults.E_NOTIMPL);
+        public NotImplementedException(String message)
+            : base(message)
+        {
+            HResult = __HResults.E_NOTIMPL;
         }
-        public NotImplementedException(String message, Exception inner) 
-            : base(message, inner) {
-            SetErrorCode(__HResults.E_NOTIMPL);
+        public NotImplementedException(String message, Exception inner)
+            : base(message, inner)
+        {
+            HResult = __HResults.E_NOTIMPL;
         }
 
-        protected NotImplementedException(SerializationInfo info, StreamingContext context) : base(info, context) {
-        }
+        protected NotImplementedException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
 }
index ecef1d1..21b2d54 100644 (file)
 **
 =============================================================================*/
 
-namespace System {
-    
-    using System;
-    using System.Runtime.Serialization;
-    [System.Runtime.InteropServices.ComVisible(true)]
+using System.Runtime.Serialization;
+
+namespace System
+{
     [Serializable]
     public class NotSupportedException : SystemException
     {
-        public NotSupportedException() 
-            : base(Environment.GetResourceString("Arg_NotSupportedException")) {
-            SetErrorCode(__HResults.COR_E_NOTSUPPORTED);
-        }
-    
-        public NotSupportedException(String message) 
-            : base(message) {
-            SetErrorCode(__HResults.COR_E_NOTSUPPORTED);
+        public NotSupportedException()
+            : base(SR.Arg_NotSupportedException)
+        {
+            HResult = __HResults.COR_E_NOTSUPPORTED;
         }
-        
-        public NotSupportedException(String message, Exception innerException) 
-            : base(message, innerException) {
-            SetErrorCode(__HResults.COR_E_NOTSUPPORTED);
+
+        public NotSupportedException(String message)
+            : base(message)
+        {
+            HResult = __HResults.COR_E_NOTSUPPORTED;
         }
 
-        protected NotSupportedException(SerializationInfo info, StreamingContext context) : base(info, context) {
+        public NotSupportedException(String message, Exception innerException)
+            : base(message, innerException)
+        {
+            HResult = __HResults.COR_E_NOTSUPPORTED;
         }
 
+        protected NotSupportedException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
 }
index d66ad9c..0aa5c61 100644 (file)
 **
 =============================================================================*/
 
-namespace System {   
-    
-    using System;
-    using System.Runtime.Serialization;
-    [System.Runtime.InteropServices.ComVisible(true)]
+using System.Runtime.Serialization;
+
+namespace System
+{
     [Serializable]
-    public class NullReferenceException : SystemException {
-        public NullReferenceException() 
-            : base(Environment.GetResourceString("Arg_NullReferenceException")) {
-            SetErrorCode(__HResults.COR_E_NULLREFERENCE);
-        }
-    
-        public NullReferenceException(String message) 
-            : base(message) {
-            SetErrorCode(__HResults.COR_E_NULLREFERENCE);
+    public class NullReferenceException : SystemException
+    {
+        public NullReferenceException()
+            : base(SR.Arg_NullReferenceException)
+        {
+            HResult = __HResults.COR_E_NULLREFERENCE;
         }
-        
-        public NullReferenceException(String message, Exception innerException) 
-            : base(message, innerException) {
-            SetErrorCode(__HResults.COR_E_NULLREFERENCE);
+
+        public NullReferenceException(String message)
+            : base(message)
+        {
+            HResult = __HResults.COR_E_NULLREFERENCE;
         }
 
-        protected NullReferenceException(SerializationInfo info, StreamingContext context) : base(info, context) {}
+        public NullReferenceException(String message, Exception innerException)
+            : base(message, innerException)
+        {
+            HResult = __HResults.COR_E_NULLREFERENCE;
+        }
 
+        protected NullReferenceException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
-
 }
index d2eca37..1f77b1f 100644 (file)
@@ -2,72 +2,81 @@
 // 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;
-    using System.Runtime.Serialization;
-    using System.Globalization;
-    using System.Security.Permissions;
+using System.Globalization;
+using System.Runtime.Serialization;
 
+namespace System
+{
     /// <devdoc>
     ///    <para> The exception that is thrown when accessing an object that was
     ///       disposed.</para>
     /// </devdoc>
-    [System.Runtime.InteropServices.ComVisible(true)]
     [Serializable]
-    public class ObjectDisposedException : InvalidOperationException {
-        private String objectName;
+    public class ObjectDisposedException : InvalidOperationException
+    {
+        private String _objectName;
 
         // This constructor should only be called by the EE (COMPlusThrow)
-        private ObjectDisposedException() : 
-            this(null ,Environment.GetResourceString("ObjectDisposed_Generic")) {
+        private ObjectDisposedException() :
+            this(null, SR.ObjectDisposed_Generic)
+        {
         }
 
-        public ObjectDisposedException(String objectName) : 
-            this(objectName, Environment.GetResourceString("ObjectDisposed_Generic")) {
+        public ObjectDisposedException(String objectName) :
+            this(objectName, SR.ObjectDisposed_Generic)
+        {
         }
 
-        public ObjectDisposedException(String objectName, String message) : base(message) {
-            SetErrorCode(__HResults.COR_E_OBJECTDISPOSED);
-            this.objectName = objectName;
+        public ObjectDisposedException(String objectName, String message) : base(message)
+        {
+            HResult = __HResults.COR_E_OBJECTDISPOSED;
+            _objectName = objectName;
         }
 
-        public ObjectDisposedException(String message, Exception innerException) 
-            : base(message, innerException) {
-            SetErrorCode(__HResults.COR_E_OBJECTDISPOSED);
+        public ObjectDisposedException(String message, Exception innerException)
+            : base(message, innerException)
+        {
+            HResult = __HResults.COR_E_OBJECTDISPOSED;
+        }
+
+        protected ObjectDisposedException(SerializationInfo info, StreamingContext context)
+            : base(info, context)
+        {
+            _objectName = info.GetString("ObjectName");
+        }
+
+        public override void GetObjectData(SerializationInfo info, StreamingContext context)
+        {
+            base.GetObjectData(info, context);
+            info.AddValue("ObjectName",ObjectName,typeof(String));
         }
 
         /// <devdoc>
         ///    <para>Gets the text for the message for this exception.</para>
         /// </devdoc>
-        public override String Message {
-            get {
+        public override String Message
+        {
+            get
+            {
                 String name = ObjectName;
                 if (name == null || name.Length == 0)
                     return base.Message;
 
-                String objectDisposed = Environment.GetResourceString("ObjectDisposed_ObjectName_Name", name);
+                String objectDisposed = SR.Format(SR.ObjectDisposed_ObjectName_Name, name);
                 return base.Message + Environment.NewLine + objectDisposed;
             }
         }
 
-        public String ObjectName {
-            get {
-                if (objectName == null)
+        public String ObjectName
+        {
+            get
+            {
+                if ((_objectName == null)) // && !CompatibilitySwitches.IsAppEarlierThanWindowsPhone8)
                 {
                     return String.Empty;
                 }
-                return objectName; 
+                return _objectName;
             }
         }
-
-        protected ObjectDisposedException(SerializationInfo info, StreamingContext context) : base(info, context) {
-            objectName = info.GetString("ObjectName");
-        }
-
-        public override void GetObjectData(SerializationInfo info, StreamingContext context) {
-            base.GetObjectData(info, context);
-            info.AddValue("ObjectName",ObjectName,typeof(String));
-        }
-
     }
 }
index 679e32a..f183685 100644 (file)
 **
 ** 
 ===========================================================*/
-namespace System {
-    
-    using System;
-    using System.Runtime.Remoting;
+
+using System;
+
+namespace System
+{
     // This attribute is attached to members that are not to be used any longer.
     // Message is some human readable explanation of what to use
     // Error indicates if the compiler should treat usage of such a method as an
     //   error. (this would be used if the actual implementation of the obsolete 
     //   method's implementation had changed).
     // 
-[Serializable]
-[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum |
-        AttributeTargets.Interface | AttributeTargets.Constructor | AttributeTargets.Method| AttributeTargets.Property  | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Delegate
+    [Serializable]
+    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum |
+        AttributeTargets.Interface | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Delegate
         , Inherited = false)]
-[System.Runtime.InteropServices.ComVisible(true)]
     public sealed class ObsoleteAttribute : Attribute
     {
         private String _message;
         private bool _error;
-        
-        public ObsoleteAttribute ()
+
+        public ObsoleteAttribute()
         {
             _message = null;
             _error = false;
         }
-    
-        public ObsoleteAttribute (String message)
+
+        public ObsoleteAttribute(String message)
         {
             _message = message;
             _error = false;
         }
-    
-        public ObsoleteAttribute (String message, bool error)
+
+        public ObsoleteAttribute(String message, bool error)
         {
             _message = message;
             _error = error;
         }
-    
-        public String Message {
-            get {return _message;}
+
+        public String Message
+        {
+            get { return _message; }
         }
-        
-        public bool IsError{
-            get {return _error;}
+
+        public bool IsError
+        {
+            get { return _error; }
         }
-        
     }
 }
index ab717fb..e28c688 100644 (file)
 **
 =============================================================================*/
 
-namespace System {
-    
-    using System;
-    using System.Runtime.Serialization;
-    [System.Runtime.InteropServices.ComVisible(true)]
+using System.Runtime.Serialization;
+
+namespace System
+{
     [Serializable]
-    public class OverflowException : ArithmeticException {
-        public OverflowException() 
-            : base(Environment.GetResourceString("Arg_OverflowException")) {
-            SetErrorCode(__HResults.COR_E_OVERFLOW);
-        }
-    
-        public OverflowException(String message) 
-            : base(message) {
-            SetErrorCode(__HResults.COR_E_OVERFLOW);
+    public class OverflowException : ArithmeticException
+    {
+        public OverflowException()
+            : base(SR.Arg_OverflowException)
+        {
+            HResult = __HResults.COR_E_OVERFLOW;
         }
-        
-        public OverflowException(String message, Exception innerException) 
-            : base(message, innerException) {
-            SetErrorCode(__HResults.COR_E_OVERFLOW);
+
+        public OverflowException(String message)
+            : base(message)
+        {
+            HResult = __HResults.COR_E_OVERFLOW;
         }
 
-        protected OverflowException(SerializationInfo info, StreamingContext context) : base(info, context) {
+        public OverflowException(String message, Exception innerException)
+            : base(message, innerException)
+        {
+            HResult = __HResults.COR_E_OVERFLOW;
         }
 
+        protected OverflowException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
-
 }
index 3a8e2e8..d3c3d46 100644 (file)
 **
 **
 =============================================================================*/
+
 namespace System
 {
-//This class contains only static members and does not need to be serializable 
-   [AttributeUsage (AttributeTargets.Parameter, Inherited=true, AllowMultiple=false)]
-[System.Runtime.InteropServices.ComVisible(true)]
-   public sealed class ParamArrayAttribute : Attribute
-   {
-      public ParamArrayAttribute () {}  
-   }
+    [AttributeUsage(AttributeTargets.Parameter, Inherited = true, AllowMultiple = false)]
+    public sealed class ParamArrayAttribute : Attribute
+    {
+        public ParamArrayAttribute() { }
+    }
 }
index 75d6d1d..d2370b3 100644 (file)
 **
 =============================================================================*/
 
-namespace System {
-    
-    using System;
-    using System.Runtime.Serialization;
+using System.Runtime.Serialization;
 
-    [System.Runtime.InteropServices.ComVisible(true)]
+namespace System
+{
     [Serializable]
     public class PlatformNotSupportedException : NotSupportedException
     {
-        public PlatformNotSupportedException() 
-            : base(Environment.GetResourceString("Arg_PlatformNotSupported")) {
-            SetErrorCode(__HResults.COR_E_PLATFORMNOTSUPPORTED);
+        public PlatformNotSupportedException()
+            : base(SR.Arg_PlatformNotSupported)
+        {
+            HResult = __HResults.COR_E_PLATFORMNOTSUPPORTED;
         }
-    
-        public PlatformNotSupportedException(String message) 
-            : base(message) {
-            SetErrorCode(__HResults.COR_E_PLATFORMNOTSUPPORTED);
-        }
-        
-        public PlatformNotSupportedException(String message, Exception inner) 
-            : base(message, inner) {
-            SetErrorCode(__HResults.COR_E_PLATFORMNOTSUPPORTED);
+
+        public PlatformNotSupportedException(String message)
+            : base(message)
+        {
+            HResult = __HResults.COR_E_PLATFORMNOTSUPPORTED;
         }
 
-        protected PlatformNotSupportedException(SerializationInfo info, StreamingContext context) : base(info, context) {
+        public PlatformNotSupportedException(String message, Exception inner)
+            : base(message, inner)
+        {
+            HResult = __HResults.COR_E_PLATFORMNOTSUPPORTED;
         }
 
+        protected PlatformNotSupportedException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
 }
index 72c43c3..755e771 100644 (file)
@@ -2,21 +2,9 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-/*============================================================
-**
-** 
-** 
-**
-**
-** Purpose: Event-based implementation of IProgress<T>.
-**
-**
-===========================================================*/
-
 using System;
 using System.Threading;
 using System.Diagnostics;
-using System.Diagnostics.Contracts;
 
 namespace System
 {
@@ -34,22 +22,20 @@ namespace System
     public class Progress<T> : IProgress<T>
     {
         /// <summary>The synchronization context captured upon construction.  This will never be null.</summary>
-        private readonly SynchronizationContext m_synchronizationContext;
+        private readonly SynchronizationContext _synchronizationContext;
         /// <summary>The handler specified to the constructor.  This may be null.</summary>
-        private readonly Action<T> m_handler;
+        private readonly Action<T> _handler;
         /// <summary>A cached delegate used to post invocation to the synchronization context.</summary>
-        private readonly SendOrPostCallback m_invokeHandlers;
+        private readonly SendOrPostCallback _invokeHandlers;
 
         /// <summary>Initializes the <see cref="Progress{T}"/>.</summary>
         public Progress()
         {
-            // Capture the current synchronization context.  "current" is determined by CurrentNoFlow,
-            // which doesn't consider the sync ctx flown with an ExecutionContext, avoiding
-            // sync ctx reference identity issues where the sync ctx for one thread could be Current on another.
+            // Capture the current synchronization context.
             // If there is no current context, we use a default instance targeting the ThreadPool.
-            m_synchronizationContext = SynchronizationContext.CurrentNoFlow ?? ProgressStatics.DefaultContext;
-            Debug.Assert(m_synchronizationContext != null);
-            m_invokeHandlers = new SendOrPostCallback(InvokeHandlers);
+            _synchronizationContext = SynchronizationContext.Current ?? ProgressStatics.DefaultContext;
+            Debug.Assert(_synchronizationContext != null);
+            _invokeHandlers = new SendOrPostCallback(InvokeHandlers);
         }
 
         /// <summary>Initializes the <see cref="Progress{T}"/> with the specified callback.</summary>
@@ -64,7 +50,7 @@ namespace System
         public Progress(Action<T> handler) : this()
         {
             if (handler == null) throw new ArgumentNullException(nameof(handler));
-            m_handler = handler;
+            _handler = handler;
         }
 
         /// <summary>Raised for each reported progress value.</summary>
@@ -81,13 +67,13 @@ namespace System
             // If there's no handler, don't bother going through the sync context.
             // Inside the callback, we'll need to check again, in case 
             // an event handler is removed between now and then.
-            Action<T> handler = m_handler;
+            Action<T> handler = _handler;
             EventHandler<T> changedEvent = ProgressChanged;
             if (handler != null || changedEvent != null)
             {
                 // Post the processing to the sync context.
                 // (If T is a value type, it will get boxed here.)
-                m_synchronizationContext.Post(m_invokeHandlers, value);
+                _synchronizationContext.Post(_invokeHandlers, value);
             }
         }
 
@@ -101,7 +87,7 @@ namespace System
         {
             T value = (T)state;
 
-            Action<T> handler = m_handler;
+            Action<T> handler = _handler;
             EventHandler<T> changedEvent = ProgressChanged;
 
             if (handler != null) handler(value);
index 8639bba..612d0f0 100644 (file)
 **
 =============================================================================*/
 
-namespace System {
-    
-    using System;
-    using System.Runtime.Serialization;
-    [System.Runtime.InteropServices.ComVisible(true)]
+using System.Runtime.Serialization;
+
+namespace System
+{
     [Serializable]
     public class RankException : SystemException
     {
-        public RankException() 
-            : base(Environment.GetResourceString("Arg_RankException")) {
-            SetErrorCode(__HResults.COR_E_RANK);
-        }
-    
-        public RankException(String message) 
-            : base(message) {
-            SetErrorCode(__HResults.COR_E_RANK);
+        public RankException()
+            : base(SR.Arg_RankException)
+        {
+            HResult = __HResults.COR_E_RANK;
         }
-        
-        public RankException(String message, Exception innerException) 
-            : base(message, innerException) {
-            SetErrorCode(__HResults.COR_E_RANK);
+
+        public RankException(String message)
+            : base(message)
+        {
+            HResult = __HResults.COR_E_RANK;
         }
 
-        protected RankException(SerializationInfo info, StreamingContext context) : base(info, context) {
+        public RankException(String message, Exception innerException)
+            : base(message, innerException)
+        {
+            HResult = __HResults.COR_E_RANK;
         }
 
+        protected RankException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
 }
index c7125eb..e67cc30 100644 (file)
@@ -327,62 +327,4 @@ namespace System
         /// </summary>
         public static ReadOnlySpan<T> Empty => default(ReadOnlySpan<T>);
     }
-
-    public static class ReadOnlySpanExtensions
-    {
-        /// <summary>
-        /// Creates a new readonly span over the portion of the target string.
-        /// </summary>
-        /// <param name="text">The target string.</param>
-        /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="text"/> is a null
-        /// reference (Nothing in Visual Basic).</exception>
-        public static ReadOnlySpan<char> Slice(this string text)
-        {
-            if (text == null)
-                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.text);
-
-            return new ReadOnlySpan<char>(ref text.GetFirstCharRef(), text.Length);
-        }
-
-        /// <summary>
-        /// Creates a new readonly span over the portion of the target string, beginning at 'start'.
-        /// </summary>
-        /// <param name="text">The target string.</param>
-        /// <param name="start">The index at which to begin this slice.</param>
-        /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="text"/> is a null
-        /// reference (Nothing in Visual Basic).</exception>
-        /// <exception cref="System.ArgumentOutOfRangeException">
-        /// Thrown when the specified <paramref name="start"/> index is not in range (&lt;0 or &gt;Length).
-        /// </exception>
-        public static ReadOnlySpan<char> Slice(this string text, int start)
-        {
-            if (text == null)
-                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.text);
-            if ((uint)start > (uint)text.Length)
-                ThrowHelper.ThrowArgumentOutOfRangeException();
-
-            return new ReadOnlySpan<char>(ref Unsafe.Add(ref text.GetFirstCharRef(), start), text.Length - start);
-        }
-
-        /// <summary>
-        /// Creates a new readonly span over the portion of the target string, beginning at <paramref name="start"/>, of given <paramref name="length"/>.
-        /// </summary>
-        /// <param name="text">The target string.</param>
-        /// <param name="start">The index at which to begin this slice.</param>
-        /// <param name="length">The number of items in the span.</param>
-        /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="text"/> is a null
-        /// reference (Nothing in Visual Basic).</exception>
-        /// <exception cref="System.ArgumentOutOfRangeException">
-        /// Thrown when the specified <paramref name="start"/> or end index is not in range (&lt;0 or &gt;&eq;Length).
-        /// </exception>
-        public static ReadOnlySpan<char> Slice(this string text, int start, int length)
-        {
-            if (text == null)
-                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.text);
-            if ((uint)start > (uint)text.Length || (uint)length > (uint)(text.Length - start))
-                ThrowHelper.ThrowArgumentOutOfRangeException();
-
-            return new ReadOnlySpan<char>(ref Unsafe.Add(ref text.GetFirstCharRef(), start), length);
-        }
-    }
 }
index f8cb3b6..cfa8da1 100644 (file)
@@ -40,15 +40,11 @@ namespace System.Reflection
     using System.Runtime.Loader;
 
     [Serializable]
-    [System.Runtime.InteropServices.ComVisible(true)]
     public delegate Module ModuleResolveEventHandler(Object sender, ResolveEventArgs e);
 
 
     [Serializable]
-    [ClassInterface(ClassInterfaceType.None)]
-    [ComDefaultInterface(typeof(_Assembly))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public abstract class Assembly : _Assembly, IEvidenceFactory, ICustomAttributeProvider, ISerializable
+    public abstract class Assembly : IEvidenceFactory, ICustomAttributeProvider, ISerializable
     {
         protected Assembly() {}
 
@@ -112,18 +108,11 @@ namespace System.Reflection
         [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
         public static Assembly ReflectionOnlyLoadFrom(String assemblyFile)
         {
-            Contract.Ensures(Contract.Result<Assembly>() != null);
-
-            StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
-
-            return RuntimeAssembly.InternalLoadFrom(
-                assemblyFile,
-                null, //securityEvidence
-                null, //hashValue
-                AssemblyHashAlgorithm.None,
-                true,  //forIntrospection
-                false, //suppressSecurityChecks
-                ref stackMark);
+            if (assemblyFile == null)
+                throw new ArgumentNullException(nameof(assemblyFile));
+            if (assemblyFile.Length == 0)
+                throw new ArgumentException(Environment.GetResourceString("Format_StringZeroLength"));
+            throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReflectionOnlyLoad"));
         }
 
         // Evidence is protected in Assembly.Load()
@@ -229,10 +218,11 @@ namespace System.Reflection
         [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
         public static Assembly ReflectionOnlyLoad(String assemblyString)
         {
-            Contract.Ensures(Contract.Result<Assembly>() != null);
-
-            StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
-            return RuntimeAssembly.InternalLoad(assemblyString, null,  ref stackMark, true /*forIntrospection*/);
+            if (assemblyString == null)
+                throw new ArgumentNullException(nameof(assemblyString));
+            if (assemblyString.Length == 0)
+                throw new ArgumentException(Environment.GetResourceString("Format_StringZeroLength"));
+            throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReflectionOnlyLoad"));
         }
     
         [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
@@ -319,18 +309,9 @@ namespace System.Reflection
         [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
         public static Assembly ReflectionOnlyLoad(byte[] rawAssembly)
         {
-            Contract.Ensures(Contract.Result<Assembly>() != null);
-
-            AppDomain.CheckReflectionOnlyLoadSupported();
-
-            StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
-            return RuntimeAssembly.nLoadImage(
-                rawAssembly,
-                null, // symbol store
-                null, // evidence
-                ref stackMark,
-                true,  // fIntrospection
-                SecurityContextSource.CurrentAssembly);
+            if (rawAssembly == null)
+                throw new ArgumentNullException(nameof(rawAssembly));
+            throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReflectionOnlyLoad"));
         }
 
         // Loads the assembly with a COFF based IMAGE containing
@@ -679,9 +660,6 @@ namespace System.Reflection
             throw new NotImplementedException();
         }
 
-        // To not break compatibility with the V1 _Assembly interface we need to make this
-        // new member ComVisible(false).
-        [ComVisible(false)]
         public virtual bool ReflectionOnly
         {
             get
@@ -831,9 +809,6 @@ namespace System.Reflection
             }
         }
 
-        // To not break compatibility with the V1 _Assembly interface we need to make this
-        // new member ComVisible(false).
-        [ComVisible(false)]
         public virtual String ImageRuntimeVersion
         {
             get
@@ -1417,9 +1392,6 @@ namespace System.Reflection
         [MethodImplAttribute(MethodImplOptions.InternalCall)]
         private static extern bool IsReflectionOnly(RuntimeAssembly assembly);
 
-        // To not break compatibility with the V1 _Assembly interface we need to make this
-        // new member ComVisible(false).
-        [ComVisible(false)]
         public override bool ReflectionOnly
         {
             get
@@ -1598,9 +1570,6 @@ namespace System.Reflection
         [SuppressUnmanagedCodeSecurity]
         private extern static void GetImageRuntimeVersion(RuntimeAssembly assembly, StringHandleOnStack retString);
 
-        // To not break compatibility with the V1 _Assembly interface we need to make this
-        // new member ComVisible(false).
-        [ComVisible(false)]
         public override String ImageRuntimeVersion
         {
             get{
index 48eab33..93f8022 100644 (file)
@@ -27,10 +27,7 @@ namespace System.Reflection {
     using System.Text;
 
     [Serializable]
-    [ClassInterface(ClassInterfaceType.None)]
-    [ComDefaultInterface(typeof(_AssemblyName))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public sealed class AssemblyName : _AssemblyName, ICloneable, ISerializable, IDeserializationCallback
+    public sealed class AssemblyName : ICloneable, ISerializable, IDeserializationCallback
     {
         //
         // READ ME
diff --git a/src/mscorlib/src/System/Reflection/ComInterfaces.cs b/src/mscorlib/src/System/Reflection/ComInterfaces.cs
deleted file mode 100644 (file)
index 6e4b0cc..0000000
+++ /dev/null
@@ -1,115 +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.
-
-namespace System.Runtime.InteropServices
-{
-    [GuidAttribute("BCA8B44D-AAD6-3A86-8AB7-03349F4F2DA2")]
-    [CLSCompliant(false)]
-    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-    [TypeLibImportClassAttribute(typeof(System.Type))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public interface _Type
-    {
-    }
-
-    [GuidAttribute("17156360-2f1a-384a-bc52-fde93c215c5b")]
-    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsDual)]
-    [TypeLibImportClassAttribute(typeof(System.Reflection.Assembly))]
-    [CLSCompliant(false)]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public interface _Assembly
-    {
-    }
-
-    [GuidAttribute("f7102fa9-cabb-3a74-a6da-b4567ef1b079")]
-    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-    [TypeLibImportClassAttribute(typeof(System.Reflection.MemberInfo))]
-    [CLSCompliant(false)]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public interface _MemberInfo
-    {
-    }
-
-    [GuidAttribute("6240837A-707F-3181-8E98-A36AE086766B")]
-    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-    [CLSCompliant(false)]
-    [TypeLibImportClassAttribute(typeof(System.Reflection.MethodBase))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public interface _MethodBase
-    {
-    }
-
-    [GuidAttribute("FFCC1B5D-ECB8-38DD-9B01-3DC8ABC2AA5F")]
-    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-    [CLSCompliant(false)]
-    [TypeLibImportClassAttribute(typeof(System.Reflection.MethodInfo))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public interface _MethodInfo
-    {
-    }
-
-    [GuidAttribute("E9A19478-9646-3679-9B10-8411AE1FD57D")]
-    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-    [CLSCompliant(false)]
-    [TypeLibImportClassAttribute(typeof(System.Reflection.ConstructorInfo))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public interface _ConstructorInfo
-    {
-    }
-
-    [GuidAttribute("8A7C1442-A9FB-366B-80D8-4939FFA6DBE0")]
-    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-    [CLSCompliant(false)]
-    [TypeLibImportClassAttribute(typeof(System.Reflection.FieldInfo))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public interface _FieldInfo
-    {
-    }
-
-    [GuidAttribute("F59ED4E4-E68F-3218-BD77-061AA82824BF")]
-    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-    [CLSCompliant(false)]
-    [TypeLibImportClassAttribute(typeof(System.Reflection.PropertyInfo))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public interface _PropertyInfo
-    {
-    }
-
-    [GuidAttribute("9DE59C64-D889-35A1-B897-587D74469E5B")]
-    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-    [CLSCompliant(false)]
-    [TypeLibImportClassAttribute(typeof(System.Reflection.EventInfo))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public interface _EventInfo
-    {
-    }
-
-    [GuidAttribute("993634C4-E47A-32CC-BE08-85F567DC27D6")]
-    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-    [CLSCompliant(false)]
-    [TypeLibImportClassAttribute(typeof(System.Reflection.ParameterInfo))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public interface _ParameterInfo
-    {
-    }
-
-    [GuidAttribute("D002E9BA-D9E3-3749-B1D3-D565A08B13E7")]
-    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-    [CLSCompliant(false)]
-    [TypeLibImportClassAttribute(typeof(System.Reflection.Module))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public interface _Module
-    {
-    }
-
-    [GuidAttribute("B42B6AAC-317E-34D5-9FA9-093BB4160C50")]
-    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-    [CLSCompliant(false)]
-    [TypeLibImportClassAttribute(typeof(System.Reflection.AssemblyName))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public interface _AssemblyName
-    {
-    }
-}
-
index 3d927fc..c5549d0 100644 (file)
@@ -23,10 +23,7 @@ namespace System.Reflection
     using System.Runtime.CompilerServices;
 
     [Serializable]
-    [ClassInterface(ClassInterfaceType.None)]
-    [ComDefaultInterface(typeof(_ConstructorInfo))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public abstract class ConstructorInfo : MethodBase, _ConstructorInfo
+    public abstract class ConstructorInfo : MethodBase
     {
         #region Static Members
         [System.Runtime.InteropServices.ComVisible(true)]
index 9520015..34b657f 100644 (file)
@@ -156,10 +156,7 @@ namespace System.Reflection.Emit
 
     // AssemblyBuilder class.
     // deliberately not [serializable]
-    [ClassInterface(ClassInterfaceType.None)]
-    [ComDefaultInterface(typeof(_AssemblyBuilder))]
-    [ComVisible(true)]
-    public sealed class AssemblyBuilder : Assembly, _AssemblyBuilder
+    public sealed class AssemblyBuilder : Assembly
     {
         #region FCALL
         [MethodImplAttribute(MethodImplOptions.InternalCall)]
diff --git a/src/mscorlib/src/System/Reflection/Emit/ComInterfaces.cs b/src/mscorlib/src/System/Reflection/Emit/ComInterfaces.cs
deleted file mode 100644 (file)
index daa0e23..0000000
+++ /dev/null
@@ -1,133 +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.
-
-namespace System.Runtime.InteropServices
-{
-    [GuidAttribute("BEBB2505-8B54-3443-AEAD-142A16DD9CC7")]
-    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-    [CLSCompliant(false)]
-    [TypeLibImportClassAttribute(typeof(System.Reflection.Emit.AssemblyBuilder))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public interface _AssemblyBuilder
-    {
-    }
-
-    [GuidAttribute("ED3E4384-D7E2-3FA7-8FFD-8940D330519A")]
-    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-    [CLSCompliant(false)]
-    [TypeLibImportClassAttribute(typeof(System.Reflection.Emit.ConstructorBuilder))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public interface _ConstructorBuilder
-    {
-    }
-
-    [GuidAttribute("BE9ACCE8-AAFF-3B91-81AE-8211663F5CAD")]
-    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-    [CLSCompliant(false)]
-    [TypeLibImportClassAttribute(typeof(System.Reflection.Emit.CustomAttributeBuilder))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public interface _CustomAttributeBuilder
-    {
-    }
-
-    [GuidAttribute("C7BD73DE-9F85-3290-88EE-090B8BDFE2DF")]
-    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-    [CLSCompliant(false)]
-    [TypeLibImportClassAttribute(typeof(System.Reflection.Emit.EnumBuilder))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public interface _EnumBuilder
-    {
-    }
-
-    [GuidAttribute("AADABA99-895D-3D65-9760-B1F12621FAE8")]
-    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-    [CLSCompliant(false)]
-    [TypeLibImportClassAttribute(typeof(System.Reflection.Emit.EventBuilder))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public interface _EventBuilder
-    {
-    }
-
-    [GuidAttribute("CE1A3BF5-975E-30CC-97C9-1EF70F8F3993")]
-    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-    [CLSCompliant(false)]
-    [TypeLibImportClassAttribute(typeof(System.Reflection.Emit.FieldBuilder))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public interface _FieldBuilder
-    {
-    }
-
-    [GuidAttribute("A4924B27-6E3B-37F7-9B83-A4501955E6A7")]
-    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-    [CLSCompliant(false)]
-    [TypeLibImportClassAttribute(typeof(System.Reflection.Emit.ILGenerator))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public interface _ILGenerator
-    {
-    }
-
-    [GuidAttribute("4E6350D1-A08B-3DEC-9A3E-C465F9AEEC0C")]
-    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-    [CLSCompliant(false)]
-    [TypeLibImportClassAttribute(typeof(System.Reflection.Emit.LocalBuilder))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public interface _LocalBuilder
-    {
-    }
-
-    [GuidAttribute("007D8A14-FDF3-363E-9A0B-FEC0618260A2")]
-    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-    [CLSCompliant(false)]
-    [TypeLibImportClassAttribute(typeof(System.Reflection.Emit.MethodBuilder))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public interface _MethodBuilder
-    {
-    }
-
-
-    [GuidAttribute("D05FFA9A-04AF-3519-8EE1-8D93AD73430B")]
-    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-    [CLSCompliant(false)]
-    [TypeLibImportClassAttribute(typeof(System.Reflection.Emit.ModuleBuilder))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public interface _ModuleBuilder
-    {
-    }
-
-    [GuidAttribute("36329EBA-F97A-3565-BC07-0ED5C6EF19FC")]
-    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-    [CLSCompliant(false)]
-    [TypeLibImportClassAttribute(typeof(System.Reflection.Emit.ParameterBuilder))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public interface _ParameterBuilder
-    {
-    }
-
-    [GuidAttribute("15F9A479-9397-3A63-ACBD-F51977FB0F02")]
-    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-    [CLSCompliant(false)]
-    [TypeLibImportClassAttribute(typeof(System.Reflection.Emit.PropertyBuilder))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public interface _PropertyBuilder
-    {
-    }
-
-    [GuidAttribute("7D13DD37-5A04-393C-BBCA-A5FEA802893D")]
-    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-    [CLSCompliant(false)]
-    [TypeLibImportClassAttribute(typeof(System.Reflection.Emit.SignatureHelper))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public interface _SignatureHelper
-    {
-    }
-
-    [GuidAttribute("7E5678EE-48B3-3F83-B076-C58543498A58")]
-    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-    [CLSCompliant(false)]
-    [TypeLibImportClassAttribute(typeof(System.Reflection.Emit.TypeBuilder))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public interface _TypeBuilder
-    {
-    }
-}
index ef76adc..3e1f348 100644 (file)
@@ -16,10 +16,7 @@ namespace System.Reflection.Emit
     using System.Runtime.InteropServices;
     using System.Diagnostics.Contracts;
     
-    [ClassInterface(ClassInterfaceType.None)]
-    [ComDefaultInterface(typeof(_ConstructorBuilder))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public sealed class ConstructorBuilder : ConstructorInfo, _ConstructorBuilder
+    public sealed class ConstructorBuilder : ConstructorInfo
     { 
         private readonly MethodBuilder m_methodBuilder;
         internal bool m_isDefaultConstructor;
index 545657a..c40a31d 100644 (file)
@@ -25,10 +25,7 @@ namespace System.Reflection.Emit {
     using System.Diagnostics;
     using System.Diagnostics.Contracts;
     
-    [ClassInterface(ClassInterfaceType.None)]
-    [ComDefaultInterface(typeof(_CustomAttributeBuilder))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public class CustomAttributeBuilder : _CustomAttributeBuilder
+    public class CustomAttributeBuilder
     {
         // public constructor to form the custom attribute with constructor and constructor
         // parameters.
index 82dc282..19bcf6f 100644 (file)
@@ -22,11 +22,7 @@ namespace System.Reflection.Emit {
     using CultureInfo = System.Globalization.CultureInfo;
     using System.Security.Permissions;
 
-    
-    [ClassInterface(ClassInterfaceType.None)]
-    [ComDefaultInterface(typeof(_EnumBuilder))]
-[System.Runtime.InteropServices.ComVisible(true)]
-    sealed public class EnumBuilder : TypeInfo, _EnumBuilder
+    sealed public class EnumBuilder : TypeInfo
     {
         public override bool IsAssignableFrom(System.Reflection.TypeInfo typeInfo){
             if(typeInfo==null) return false;
index 449b208..6b81575 100644 (file)
@@ -24,10 +24,7 @@ namespace System.Reflection.Emit {
     // A EventBuilder is always associated with a TypeBuilder.  The TypeBuilder.DefineEvent
     // method will return a new EventBuilder to a client.
     // 
-    [ClassInterface(ClassInterfaceType.None)]
-    [ComDefaultInterface(typeof(_EventBuilder))]
-[System.Runtime.InteropServices.ComVisible(true)]
-    public sealed class EventBuilder : _EventBuilder
+    public sealed class EventBuilder
     { 
     
         // Make a private constructor so these cannot be constructed externally.
index 595d60a..415dc45 100644 (file)
@@ -13,10 +13,7 @@ namespace System.Reflection.Emit
     using System.Security.Permissions;
     using System.Diagnostics.Contracts;
     
-    [ClassInterface(ClassInterfaceType.None)]
-    [ComDefaultInterface(typeof(_FieldBuilder))]
-[System.Runtime.InteropServices.ComVisible(true)]
-    public sealed class FieldBuilder : FieldInfo, _FieldBuilder
+    public sealed class FieldBuilder : FieldInfo
     {
         #region Private Data Members
         private int m_fieldTok;
index b7d7e3f..284beb1 100644 (file)
@@ -15,10 +15,7 @@ namespace System.Reflection.Emit
     using System.Diagnostics;
     using System.Diagnostics.Contracts;
     
-    [ClassInterface(ClassInterfaceType.None)]
-    [ComDefaultInterface(typeof(_ILGenerator))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public class ILGenerator : _ILGenerator
+    public class ILGenerator
     {
         #region Const Members
         private const int defaultSize = 16;
index a34d5eb..2db6e51 100644 (file)
@@ -9,10 +9,7 @@ using System.Runtime.InteropServices;
 
 namespace System.Reflection.Emit 
 {
-    [ClassInterface(ClassInterfaceType.None)]
-    [ComDefaultInterface(typeof(_LocalBuilder))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public sealed class LocalBuilder : LocalVariableInfo, _LocalBuilder
+    public sealed class LocalBuilder : LocalVariableInfo
     { 
         #region Private Data Members
         private int m_localIndex;
index 654e166..74fd9aa 100644 (file)
@@ -19,10 +19,7 @@ namespace System.Reflection.Emit
     using System.Diagnostics;
     using System.Diagnostics.Contracts;
 
-    [ClassInterface(ClassInterfaceType.None)]
-    [ComDefaultInterface(typeof(_MethodBuilder))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public sealed class MethodBuilder : MethodInfo, _MethodBuilder
+    public sealed class MethodBuilder : MethodInfo
     {
         #region Private Data Members
         // Identity
index 75320a1..399ca50 100644 (file)
@@ -50,10 +50,7 @@ namespace System.Reflection.Emit
     }
 
     // deliberately not [serializable]
-    [ClassInterface(ClassInterfaceType.None)]
-    [ComDefaultInterface(typeof(_ModuleBuilder))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public class ModuleBuilder : Module, _ModuleBuilder
+    public class ModuleBuilder : Module
     {
         #region FCalls
 
index 7909562..0c10eb4 100644 (file)
@@ -19,10 +19,7 @@ namespace System.Reflection.Emit {
     using System.Security.Permissions;
     using System.Diagnostics.Contracts;
 
-    [ClassInterface(ClassInterfaceType.None)]
-    [ComDefaultInterface(typeof(_ParameterBuilder))]
-[System.Runtime.InteropServices.ComVisible(true)]
-    public class ParameterBuilder : _ParameterBuilder
+    public class ParameterBuilder
     {
         // set ParamMarshal
         [Obsolete("An alternate API is available: Emit the MarshalAs custom attribute instead. http://go.microsoft.com/fwlink/?linkid=14202")]
index e7442b4..17cc1b9 100644 (file)
@@ -25,10 +25,7 @@ namespace System.Reflection.Emit {
     // A PropertyBuilder is always associated with a TypeBuilder.  The TypeBuilder.DefineProperty
     // method will return a new PropertyBuilder to a client.
     // 
-    [ClassInterface(ClassInterfaceType.None)]
-    [ComDefaultInterface(typeof(_PropertyBuilder))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public sealed class PropertyBuilder : PropertyInfo, _PropertyBuilder
+    public sealed class PropertyBuilder : PropertyInfo
     { 
     
         // Make a private constructor so these cannot be constructed externally.
index 5128576..b939cbb 100644 (file)
@@ -16,10 +16,7 @@ namespace System.Reflection.Emit
     using System.Runtime.Versioning;
     using System.Security.Permissions;
     
-    [ClassInterface(ClassInterfaceType.None)]
-    [ComDefaultInterface(typeof(_SignatureHelper))]
-[System.Runtime.InteropServices.ComVisible(true)]
-    public sealed class SignatureHelper : _SignatureHelper
+    public sealed class SignatureHelper
     {
         #region Consts Fields
         private const int NO_SIZE_IN_SIG = -1;
index 3680900..b0d968d 100644 (file)
@@ -35,10 +35,7 @@ namespace System.Reflection.Emit {
         Size128                     = 128,
     }
 
-    [ClassInterface(ClassInterfaceType.None)]
-    [ComDefaultInterface(typeof(_TypeBuilder))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public sealed class TypeBuilder : TypeInfo, _TypeBuilder
+    public sealed class TypeBuilder : TypeInfo
     {
         public override bool IsAssignableFrom(System.Reflection.TypeInfo typeInfo){
             if(typeInfo==null) return false;            
index 0eabb9d..1790b03 100644 (file)
@@ -17,10 +17,7 @@ namespace System.Reflection
     using RuntimeTypeCache = System.RuntimeType.RuntimeTypeCache;
 
     [Serializable]
-    [ClassInterface(ClassInterfaceType.None)]
-    [ComDefaultInterface(typeof(_EventInfo))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public abstract class EventInfo : MemberInfo, _EventInfo
+    public abstract class EventInfo : MemberInfo
     {
         #region Constructor
         protected EventInfo() { }
index e61207a..2fe1537 100644 (file)
@@ -21,10 +21,7 @@ namespace System.Reflection
     using RuntimeTypeCache = System.RuntimeType.RuntimeTypeCache;
 
     [Serializable]
-    [ClassInterface(ClassInterfaceType.None)]
-    [ComDefaultInterface(typeof(_FieldInfo))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public abstract class FieldInfo : MemberInfo, _FieldInfo
+    public abstract class FieldInfo : MemberInfo
     {
         #region Static Members
         public static FieldInfo GetFieldFromHandle(RuntimeFieldHandle handle)
index 96a89ad..3466ed2 100644 (file)
@@ -14,10 +14,7 @@ namespace System.Reflection
     using System.Security.Permissions;
 
     [Serializable]
-    [ClassInterface(ClassInterfaceType.None)]
-    [ComDefaultInterface(typeof(_MemberInfo))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public abstract class MemberInfo : ICustomAttributeProvider, _MemberInfo
+    public abstract class MemberInfo : ICustomAttributeProvider
     {
         #region Constructor
         protected MemberInfo() { }
index 8c77411..fe2ab71 100644 (file)
@@ -48,10 +48,7 @@ namespace System.Reflection
     }
 
     [Serializable]
-    [ClassInterface(ClassInterfaceType.None)]
-    [ComDefaultInterface(typeof(_MethodBase))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public abstract class MethodBase : MemberInfo, _MethodBase
+    public abstract class MethodBase : MemberInfo
     {
         #region Static Members
         public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle)
index 39387b1..14c0378 100644 (file)
@@ -24,10 +24,7 @@ namespace System.Reflection
     using System.Runtime.CompilerServices;
 
     [Serializable]
-    [ClassInterface(ClassInterfaceType.None)]
-    [ComDefaultInterface(typeof(_MethodInfo))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public abstract class MethodInfo : MethodBase, _MethodInfo
+    public abstract class MethodInfo : MethodBase
     {
         #region Constructor
         protected MethodInfo() { }
index b6be38e..c8e7ccb 100644 (file)
@@ -56,10 +56,7 @@ namespace System.Reflection
     }
 
     [Serializable]
-    [ClassInterface(ClassInterfaceType.None)]
-    [ComDefaultInterface(typeof(_Module))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public abstract class Module : _Module, ISerializable, ICustomAttributeProvider
+    public abstract class Module : ISerializable, ICustomAttributeProvider
     {   
         #region Static Constructor
         static Module()
index 6592e5a..107dedc 100644 (file)
@@ -18,10 +18,7 @@ namespace System.Reflection
     using MdToken = System.Reflection.MetadataToken;
 
     [Serializable]
-    [ClassInterface(ClassInterfaceType.None)]
-    [ComDefaultInterface(typeof(_ParameterInfo))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public class ParameterInfo : _ParameterInfo, ICustomAttributeProvider, IObjectReference
+    public class ParameterInfo : ICustomAttributeProvider, IObjectReference
     {
         #region Legacy Protected Members
         protected String NameImpl; 
index e31b378..330396c 100644 (file)
@@ -20,10 +20,7 @@ namespace System.Reflection
     using RuntimeTypeCache = System.RuntimeType.RuntimeTypeCache;
 
     [Serializable]
-    [ClassInterface(ClassInterfaceType.None)]
-    [ComDefaultInterface(typeof(_PropertyInfo))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public abstract class PropertyInfo : MemberInfo, _PropertyInfo
+    public abstract class PropertyInfo : MemberInfo
     {
         #region Constructor
         protected PropertyInfo() { }
index 0bde286..a03f4d8 100644 (file)
@@ -112,7 +112,7 @@ namespace System.Resources {
         public ResourceReader(String fileName)
         {
             _resCache = new Dictionary<String, ResourceLocator>(FastResourceComparer.Default);
-            _store = new BinaryReader(new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read, DefaultFileStreamBufferSize, FileOptions.RandomAccess, Path.GetFileName(fileName), false), Encoding.UTF8);
+            _store = new BinaryReader(new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read, DefaultFileStreamBufferSize, FileOptions.RandomAccess), Encoding.UTF8);
             BCLDebug.Log("RESMGRFILEFORMAT", "ResourceReader .ctor(String).  UnmanagedMemoryStream: "+(_ums!=null));
 
             try {
index a6e46d5..5f6a7ae 100644 (file)
@@ -217,7 +217,8 @@ namespace System
         // TODO: https://github.com/dotnet/corefx/issues/13681
         //   Until we get over the hurdle of C# 7 tooling, this temporary method will simulate the intended "ref T" indexer for those
         //   who need bypass the workaround for performance.
-        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        //[MethodImpl(MethodImplOptions.AggressiveInlining)]
+        [MethodImpl(MethodImplOptions.NoOptimization)] // TODO-SPAN: Workaround for https://github.com/dotnet/coreclr/issues/7894 
         public ref T GetItem(int index)
         {
             if ((uint)index >= ((uint)_length))
@@ -396,7 +397,7 @@ namespace System
         public static Span<T> Empty => default(Span<T>);
     }
 
-    public static class SpanExtensions
+    public static class Span
     {
         /// <summary>
         /// Casts a Span of one primitive type <typeparamref name="T"/> to Span of bytes.
@@ -485,6 +486,61 @@ namespace System
                 ref Unsafe.As<TFrom, TTo>(ref source.DangerousGetPinnableReference()),
                 checked((int)((long)source.Length * Unsafe.SizeOf<TFrom>() / Unsafe.SizeOf<TTo>())));
         }
+
+        /// <summary>
+        /// Creates a new readonly span over the portion of the target string.
+        /// </summary>
+        /// <param name="text">The target string.</param>
+        /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="text"/> is a null
+        /// reference (Nothing in Visual Basic).</exception>
+        public static ReadOnlySpan<char> Slice(this string text)
+        {
+            if (text == null)
+                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.text);
+
+            return new ReadOnlySpan<char>(ref text.GetFirstCharRef(), text.Length);
+        }
+
+        /// <summary>
+        /// Creates a new readonly span over the portion of the target string, beginning at 'start'.
+        /// </summary>
+        /// <param name="text">The target string.</param>
+        /// <param name="start">The index at which to begin this slice.</param>
+        /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="text"/> is a null
+        /// reference (Nothing in Visual Basic).</exception>
+        /// <exception cref="System.ArgumentOutOfRangeException">
+        /// Thrown when the specified <paramref name="start"/> index is not in range (&lt;0 or &gt;Length).
+        /// </exception>
+        public static ReadOnlySpan<char> Slice(this string text, int start)
+        {
+            if (text == null)
+                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.text);
+            if ((uint)start > (uint)text.Length)
+                ThrowHelper.ThrowArgumentOutOfRangeException();
+
+            return new ReadOnlySpan<char>(ref Unsafe.Add(ref text.GetFirstCharRef(), start), text.Length - start);
+        }
+
+        /// <summary>
+        /// Creates a new readonly span over the portion of the target string, beginning at <paramref name="start"/>, of given <paramref name="length"/>.
+        /// </summary>
+        /// <param name="text">The target string.</param>
+        /// <param name="start">The index at which to begin this slice.</param>
+        /// <param name="length">The number of items in the span.</param>
+        /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="text"/> is a null
+        /// reference (Nothing in Visual Basic).</exception>
+        /// <exception cref="System.ArgumentOutOfRangeException">
+        /// Thrown when the specified <paramref name="start"/> or end index is not in range (&lt;0 or &gt;&eq;Length).
+        /// </exception>
+        public static ReadOnlySpan<char> Slice(this string text, int start, int length)
+        {
+            if (text == null)
+                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.text);
+            if ((uint)start > (uint)text.Length || (uint)length > (uint)(text.Length - start))
+                ThrowHelper.ThrowArgumentOutOfRangeException();
+
+            return new ReadOnlySpan<char>(ref Unsafe.Add(ref text.GetFirstCharRef(), start), length);
+        }
     }
 
     internal static class SpanHelper
index 4a20527..0a875e7 100644 (file)
 **
 =============================================================================*/
 
-namespace System {
-    
-    using System;
-    using System.Runtime.Serialization;
-    [System.Runtime.InteropServices.ComVisible(true)]
+using System.Runtime.Serialization;
+
+namespace System
+{
     [Serializable]
-    public sealed class StackOverflowException : SystemException {
-        public StackOverflowException() 
-            : base(Environment.GetResourceString("Arg_StackOverflowException")) {
-            SetErrorCode(__HResults.COR_E_STACKOVERFLOW);
-        }
-    
-        public StackOverflowException(String message) 
-            : base(message) {
-            SetErrorCode(__HResults.COR_E_STACKOVERFLOW);
+    public sealed class StackOverflowException : SystemException
+    {
+        public StackOverflowException()
+            : base(SR.Arg_StackOverflowException)
+        {
+            HResult = __HResults.COR_E_STACKOVERFLOW;
         }
-        
-        public StackOverflowException(String message, Exception innerException) 
-            : base(message, innerException) {
-            SetErrorCode(__HResults.COR_E_STACKOVERFLOW);
+
+        public StackOverflowException(String message)
+            : base(message)
+        {
+            HResult = __HResults.COR_E_STACKOVERFLOW;
         }
 
-        internal StackOverflowException(SerializationInfo info, StreamingContext context) : base (info, context) {
+        public StackOverflowException(String message, Exception innerException)
+            : base(message, innerException)
+        {
+            HResult = __HResults.COR_E_STACKOVERFLOW;
         }
-        
+
+        internal StackOverflowException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
 }
index aa83e39..c654f72 100644 (file)
 **
 ** 
 ===========================================================*/
-namespace System{
-    
+
+namespace System
+{
     [Serializable]
-[System.Runtime.InteropServices.ComVisible(true)]
-    public enum StringComparison {
+    public enum StringComparison
+    {
         CurrentCulture = 0,
         CurrentCultureIgnoreCase = 1,
         InvariantCulture = 2,
index ae95aae..43b626a 100644 (file)
@@ -2,15 +2,12 @@
 // 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.InteropServices;
-
 namespace System
 {
-    [ComVisible(false)]
     [Flags]
     public enum StringSplitOptions
     {
         None = 0,
         RemoveEmptyEntries = 1
     }
-}
+}
\ No newline at end of file
index 8a54124..f4779a2 100644 (file)
@@ -2,30 +2,31 @@
 // 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;
-    using System.Runtime.Serialization;
+using System.Runtime.Serialization;
+
+namespace System
+{
     [Serializable]
-    [System.Runtime.InteropServices.ComVisible(true)]
     public class SystemException : Exception
     {
-        public SystemException() 
-            : base(Environment.GetResourceString("Arg_SystemException")) {
-            SetErrorCode(__HResults.COR_E_SYSTEM);
-        }
-        
-        public SystemException(String message) 
-            : base(message) {
-            SetErrorCode(__HResults.COR_E_SYSTEM);
+        public SystemException()
+            : base(SR.Arg_SystemException)
+        {
+            HResult = __HResults.COR_E_SYSTEM;
         }
-        
-        public SystemException(String message, Exception innerException) 
-            : base(message, innerException) {
-            SetErrorCode(__HResults.COR_E_SYSTEM);
+
+        public SystemException(String message)
+            : base(message)
+        {
+            HResult = __HResults.COR_E_SYSTEM;
         }
 
-        protected SystemException(SerializationInfo info, StreamingContext context) : base(info, context) {
+        public SystemException(String message, Exception innerException)
+            : base(message, innerException)
+        {
+            HResult = __HResults.COR_E_SYSTEM;
         }
+
+        protected SystemException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
 }
index bbd859c..6248736 100644 (file)
@@ -4,16 +4,13 @@
 
 /*=============================================================================
 **
-**
-**
 ** Purpose: For Threads-related custom attributes.
 **
-**
 =============================================================================*/
 
-namespace System {
-    [AttributeUsage (AttributeTargets.Method)]  
-[System.Runtime.InteropServices.ComVisible(true)]
+namespace System
+{
+    [AttributeUsage(AttributeTargets.Method)]
     public sealed class STAThreadAttribute : Attribute
     {
         public STAThreadAttribute()
@@ -21,8 +18,7 @@ namespace System {
         }
     }
 
-    [AttributeUsage (AttributeTargets.Method)]  
-[System.Runtime.InteropServices.ComVisible(true)]
+    [AttributeUsage(AttributeTargets.Method)]
     public sealed class MTAThreadAttribute : Attribute
     {
         public MTAThreadAttribute()
index 58842ee..3755e65 100644 (file)
 **
 **
 ===========================================================*/
-namespace System {
-    
-    using System;
 
-[Serializable]
+using System;
+
+namespace System
+{
+    [Serializable]
     [AttributeUsage(AttributeTargets.Field, Inherited = false)]
-[System.Runtime.InteropServices.ComVisible(true)]
-    public class  ThreadStaticAttribute : Attribute
+    public class ThreadStaticAttribute : Attribute
     {
         public ThreadStaticAttribute()
         {
index aad274d..eee73ce 100644 (file)
@@ -9,19 +9,14 @@
 // repeatedly checking until the lock becomes available. As the thread remains active performing a non-useful task,
 // the use of such a lock is a kind of busy waiting and consumes CPU resources without performing real work. 
 //
-//
 // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-using System;
-using System.Security.Permissions;
+
+using System.Diagnostics;
 using System.Runtime.InteropServices;
 using System.Runtime.CompilerServices;
-using System.Runtime.ConstrainedExecution;
-using System.Diagnostics;
-using System.Diagnostics.Contracts;
 
 namespace System.Threading
 {
-
     /// <summary>
     /// Provides a mutual exclusion lock primitive where a thread trying to acquire the lock waits in a loop
     /// repeatedly checking until the lock becomes available.
@@ -54,7 +49,6 @@ namespace System.Threading
     /// concurrently.
     /// </para>
     /// </remarks>
-    [ComVisible(false)]
     [DebuggerTypeProxy(typeof(SystemThreading_SpinLockDebugView))]
     [DebuggerDisplay("IsHeld = {IsHeld}")]
     public struct SpinLock
@@ -106,6 +100,14 @@ namespace System.Threading
         // The waiters count is calculated by m_owner & WAITERS_MASK 01111....110
         private static int MAXIMUM_WAITERS = WAITERS_MASK;
 
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        private int CompareExchange(ref int location, int value, int comparand, ref bool success)
+        {
+            int result = Interlocked.CompareExchange(ref location, value, comparand);
+            success = (result == comparand);
+            return result;
+        }
+
         /// <summary>
         /// Initializes a new instance of the <see cref="T:System.Threading.SpinLock"/>
         /// structure with the option to track thread IDs to improve debugging.
@@ -158,9 +160,8 @@ namespace System.Threading
             int observedOwner = m_owner;
             if (lockTaken || //invalid parameter
                 (observedOwner & ID_DISABLED_AND_ANONYMOUS_OWNED) != LOCK_ID_DISABLE_MASK || //thread tracking is enabled or the lock is already acquired
-                Interlocked.CompareExchange(ref m_owner, observedOwner | LOCK_ANONYMOUS_OWNED, observedOwner, ref lockTaken) != observedOwner) //acquiring the lock failed
+                CompareExchange(ref m_owner, observedOwner | LOCK_ANONYMOUS_OWNED, observedOwner, ref lockTaken) != observedOwner) //acquiring the lock failed
                 ContinueTryEnter(Timeout.Infinite, ref lockTaken); // Then try the slow path if any of the above conditions is met
-
         }
 
         /// <summary>
@@ -197,7 +198,7 @@ namespace System.Threading
             else
             {
                 // Lock wasn't held; try to acquire it.
-                Interlocked.CompareExchange(ref m_owner, observedOwner | LOCK_ANONYMOUS_OWNED, observedOwner, ref lockTaken);
+                CompareExchange(ref m_owner, observedOwner | LOCK_ANONYMOUS_OWNED, observedOwner, ref lockTaken);
             }
         }
 
@@ -234,7 +235,7 @@ namespace System.Threading
             if (totalMilliseconds < -1 || totalMilliseconds > int.MaxValue)
             {
                 throw new System.ArgumentOutOfRangeException(
-                    nameof(timeout), timeout, Environment.GetResourceString("SpinLock_TryEnter_ArgumentOutOfRange"));
+                    nameof(timeout), timeout, SR.SpinLock_TryEnter_ArgumentOutOfRange);
             }
 
             // Call reliable enter with the int-based timeout milliseconds
@@ -269,7 +270,7 @@ namespace System.Threading
             if (millisecondsTimeout < -1 || //invalid parameter
                 lockTaken || //invalid parameter
                 (observedOwner & ID_DISABLED_AND_ANONYMOUS_OWNED) != LOCK_ID_DISABLE_MASK ||  //thread tracking is enabled or the lock is already acquired
-                Interlocked.CompareExchange(ref m_owner, observedOwner | LOCK_ANONYMOUS_OWNED, observedOwner, ref lockTaken) != observedOwner) // acquiring the lock failed
+                CompareExchange(ref m_owner, observedOwner | LOCK_ANONYMOUS_OWNED, observedOwner, ref lockTaken) != observedOwner) // acquiring the lock failed
                 ContinueTryEnter(millisecondsTimeout, ref lockTaken); // The call the slow pth
         }
 
@@ -286,13 +287,13 @@ namespace System.Threading
             if (lockTaken)
             {
                 lockTaken = false;
-                throw new System.ArgumentException(Environment.GetResourceString("SpinLock_TryReliableEnter_ArgumentException"));
+                throw new System.ArgumentException(SR.SpinLock_TryReliableEnter_ArgumentException);
             }
 
             if (millisecondsTimeout < -1)
             {
                 throw new ArgumentOutOfRangeException(
-                    nameof(millisecondsTimeout), millisecondsTimeout, Environment.GetResourceString("SpinLock_TryEnter_ArgumentOutOfRange"));
+                    nameof(millisecondsTimeout), millisecondsTimeout, SR.SpinLock_TryEnter_ArgumentOutOfRange);
             }
 
             uint startTime = 0;
@@ -326,7 +327,7 @@ namespace System.Threading
             observedOwner = m_owner;
             if ((observedOwner & LOCK_ANONYMOUS_OWNED) == LOCK_UNOWNED)
             {
-                if (Interlocked.CompareExchange(ref m_owner, observedOwner | 1, observedOwner, ref lockTaken) == observedOwner)
+                if (CompareExchange(ref m_owner, observedOwner | 1, observedOwner, ref lockTaken) == observedOwner)
                 {
                     // Aquired lock
                     return;
@@ -346,7 +347,7 @@ namespace System.Threading
             else //failed to acquire the lock,then try to update the waiters. If the waiters count reached the maximum, jsut break the loop to avoid overflow
             {
                 if ((observedOwner & WAITERS_MASK) != MAXIMUM_WAITERS)
-                    turn = (Interlocked.Add(ref m_owner, 2) & WAITERS_MASK) >> 1 ;
+                    turn = (Interlocked.Add(ref m_owner, 2) & WAITERS_MASK) >> 1;
             }
 
             //***Step 2. Spinning
@@ -368,7 +369,7 @@ namespace System.Threading
                             : (observedOwner - 2) | 1; // otherwise decrement the waiters and set the lock bit
                         Debug.Assert((newOwner & WAITERS_MASK) >= 0);
 
-                        if (Interlocked.CompareExchange(ref m_owner, newOwner, observedOwner, ref lockTaken) == observedOwner)
+                        if (CompareExchange(ref m_owner, newOwner, observedOwner, ref lockTaken) == observedOwner)
                         {
                             return;
                         }
@@ -396,7 +397,7 @@ namespace System.Threading
                            : (observedOwner - 2) | 1; // otherwise decrement the waiters and set the lock bit
                     Debug.Assert((newOwner & WAITERS_MASK) >= 0);
 
-                    if (Interlocked.CompareExchange(ref m_owner, newOwner, observedOwner, ref lockTaken) == observedOwner)
+                    if (CompareExchange(ref m_owner, newOwner, observedOwner, ref lockTaken) == observedOwner)
                     {
                         return;
                     }
@@ -446,7 +447,6 @@ namespace System.Threading
                 }
                 spinner.SpinOnce();
             }
-
         }
 
         /// <summary>
@@ -459,11 +459,11 @@ namespace System.Threading
             int lockUnowned = 0;
             // We are using thread IDs to mark ownership. Snap the thread ID and check for recursion.
             // We also must or the ID enablement bit, to ensure we propagate when we CAS it in.
-            int m_newOwner = Thread.CurrentThread.ManagedThreadId;
+            int m_newOwner = Environment.CurrentManagedThreadId;
             if (m_owner == m_newOwner)
             {
                 // We don't allow lock recursion.
-                throw new LockRecursionException(Environment.GetResourceString("SpinLock_TryEnter_LockRecursionException"));
+                throw new LockRecursionException(SR.SpinLock_TryEnter_LockRecursionException);
             }
 
 
@@ -472,7 +472,6 @@ namespace System.Threading
             // Loop until the lock has been successfully acquired or, if specified, the timeout expires.
             do
             {
-
                 // We failed to get the lock, either from the fast route or the last iteration
                 // and the timeout hasn't expired; spin once and try again.
                 spinner.SpinOnce();
@@ -481,7 +480,7 @@ namespace System.Threading
 
                 if (m_owner == lockUnowned)
                 {
-                    if (Interlocked.CompareExchange(ref m_owner, m_newOwner, lockUnowned, ref lockTaken) == lockUnowned)
+                    if (CompareExchange(ref m_owner, m_newOwner, lockUnowned, ref lockTaken) == lockUnowned)
                     {
                         return;
                     }
@@ -506,7 +505,6 @@ namespace System.Threading
         /// <exception cref="SynchronizationLockException">
         /// Thread ownership tracking is enabled, and the current thread is not the owner of this lock.
         /// </exception>
-        [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
         public void Exit()
         {
             //This is the fast path for the thread tracking is disabled, otherwise go to the slow path
@@ -532,7 +530,6 @@ namespace System.Threading
         /// <exception cref="SynchronizationLockException">
         /// Thread ownership tracking is enabled, and the current thread is not the owner of this lock.
         /// </exception>
-        [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
         public void Exit(bool useMemoryBarrier)
         {
             // This is the fast path for the thread tracking is diabled and not to use memory barrier, otherwise go to the slow path
@@ -560,7 +557,7 @@ namespace System.Threading
             if (threadTrackingEnabled && !IsHeldByCurrentThread)
             {
                 throw new System.Threading.SynchronizationLockException(
-                    Environment.GetResourceString("SpinLock_Exit_SynchronizationLockException"));
+                    SR.SpinLock_Exit_SynchronizationLockException);
             }
 
             if (useMemoryBarrier)
@@ -569,7 +566,6 @@ namespace System.Threading
                     Interlocked.Exchange(ref m_owner, LOCK_UNOWNED);
                 else
                     Interlocked.Decrement(ref m_owner);
-
             }
             else
             {
@@ -580,9 +576,7 @@ namespace System.Threading
                     int tmpOwner = m_owner;
                     m_owner = tmpOwner & (~LOCK_ANONYMOUS_OWNED);
                 }
-
             }
-
         }
 
         /// <summary>
@@ -590,7 +584,6 @@ namespace System.Threading
         /// </summary>
         public bool IsHeld
         {
-            [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
             get
             {
                 if (IsThreadOwnerTrackingEnabled)
@@ -616,21 +609,19 @@ namespace System.Threading
         /// </exception>
         public bool IsHeldByCurrentThread
         {
-            [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
             get
             {
                 if (!IsThreadOwnerTrackingEnabled)
                 {
-                    throw new InvalidOperationException(Environment.GetResourceString("SpinLock_IsHeldByCurrentThread"));
+                    throw new InvalidOperationException(SR.SpinLock_IsHeldByCurrentThread);
                 }
-                return ((m_owner & (~LOCK_ID_DISABLE_MASK)) == Thread.CurrentThread.ManagedThreadId);
+                return ((m_owner & (~LOCK_ID_DISABLE_MASK)) == Environment.CurrentManagedThreadId);
             }
         }
 
         /// <summary>Gets whether thread ownership tracking is enabled for this instance.</summary>
         public bool IsThreadOwnerTrackingEnabled
         {
-            [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
             get { return (m_owner & LOCK_ID_DISABLE_MASK) == 0; }
         }
 
index ead7a5e..8a50f46 100644 (file)
@@ -103,11 +103,7 @@ namespace System.Threading {
         }
     }
 
-    // deliberately not [serializable]
-    [ClassInterface(ClassInterfaceType.None)]
-    [ComDefaultInterface(typeof(_Thread))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public sealed class Thread : RuntimeThread, _Thread
+    public sealed class Thread : RuntimeThread
     {
         /*=========================================================================
         ** Data accessed from managed code that needs to be defined in
@@ -145,18 +141,6 @@ namespace System.Threading {
         private bool m_ForbidExecutionContextMutation;
 #endif
 
-        /*=========================================================================
-        ** This manager is responsible for storing the global data that is
-        ** shared amongst all the thread local stores.
-        =========================================================================*/
-        static private LocalDataStoreMgr s_LocalDataStoreMgr;
-
-        /*=========================================================================
-        ** Thread-local data store
-        =========================================================================*/
-        [ThreadStatic]
-        static private LocalDataStoreHolder s_LocalDataStore;
-
         // Do not move! Order of above fields needs to be preserved for alignment
         // with native code
         // See code:#threadCultureInfo
@@ -498,78 +482,6 @@ namespace System.Threading {
         private extern void StartupSetApartmentStateInternal();
 #endif // FEATURE_COMINTEROP_APARTMENT_SUPPORT
 
-        /*=========================================================================
-        ** Allocates an un-named data slot. The slot is allocated on ALL the
-        ** threads.
-        =========================================================================*/
-        public static LocalDataStoreSlot AllocateDataSlot()
-        {
-            return LocalDataStoreManager.AllocateDataSlot();
-        }
-
-        /*=========================================================================
-        ** Allocates a named data slot. The slot is allocated on ALL the
-        ** threads.  Named data slots are "public" and can be manipulated by
-        ** anyone.
-        =========================================================================*/
-        public static LocalDataStoreSlot AllocateNamedDataSlot(String name)
-        {
-            return LocalDataStoreManager.AllocateNamedDataSlot(name);
-        }
-
-        /*=========================================================================
-        ** Looks up a named data slot. If the name has not been used, a new slot is
-        ** allocated.  Named data slots are "public" and can be manipulated by
-        ** anyone.
-        =========================================================================*/
-        public static LocalDataStoreSlot GetNamedDataSlot(String name)
-        {
-            return LocalDataStoreManager.GetNamedDataSlot(name);
-        }
-
-        /*=========================================================================
-        ** Frees a named data slot. The slot is allocated on ALL the
-        ** threads.  Named data slots are "public" and can be manipulated by
-        ** anyone.
-        =========================================================================*/
-        public static void FreeNamedDataSlot(String name)
-        {
-            LocalDataStoreManager.FreeNamedDataSlot(name);
-        }
-
-        /*=========================================================================
-        ** Retrieves the value from the specified slot on the current thread, for that thread's current domain.
-        =========================================================================*/
-        public static Object GetData(LocalDataStoreSlot slot)
-        {
-            LocalDataStoreHolder dls = s_LocalDataStore;
-            if (dls == null)
-            {
-                // Make sure to validate the slot even if we take the quick path
-                LocalDataStoreManager.ValidateSlot(slot);
-                return null;
-            }
-
-            return dls.Store.GetData(slot);
-        }
-
-        /*=========================================================================
-        ** Sets the data in the specified slot on the currently running thread, for that thread's current domain.
-        =========================================================================*/
-        public static void SetData(LocalDataStoreSlot slot, Object data)
-        {
-            LocalDataStoreHolder dls = s_LocalDataStore;
-
-            // Create new DLS if one hasn't been created for this domain for this thread
-            if (dls == null) {
-                dls = LocalDataStoreManager.CreateLocalDataStore();
-                s_LocalDataStore = dls;
-            }
-
-            dls.Store.SetData(slot, data);
-        }
-
-
         // #threadCultureInfo
         //
         // Background:
@@ -821,19 +733,6 @@ namespace System.Threading {
         [MethodImplAttribute(MethodImplOptions.InternalCall)]
         public static extern void MemoryBarrier();
 
-        private static LocalDataStoreMgr LocalDataStoreManager
-        {
-            get 
-            {
-                if (s_LocalDataStoreMgr == null)
-                {
-                    Interlocked.CompareExchange(ref s_LocalDataStoreMgr, new LocalDataStoreMgr(), null);    
-                }
-
-                return s_LocalDataStoreMgr;
-            }
-        }
-
         // Helper function to set the AbortReason for a thread abort.
         //  Checks that they're not alredy set, and then atomically updates
         //  the reason info (object + ADID).
index 451b15d..8bcdb9b 100644 (file)
 **
 =============================================================================*/
 
-#pragma warning disable 0420
-
-/*
- * Below you'll notice two sets of APIs that are separated by the
- * use of 'Unsafe' in their names.  The unsafe versions are called
- * that because they do not propagate the calling stack onto the
- * worker thread.  This allows code to lose the calling stack and 
- * thereby elevate its security privileges.  Note that this operation
- * is much akin to the combined ability to control security policy
- * and control security evidence.  With these privileges, a person 
- * can gain the right to load assemblies that are fully trusted which
- * then assert full trust and can call any code they want regardless
- * of the previous stack information.
- */
+using System.Security;
+using System.Security.Permissions;
+using System;
+using Microsoft.Win32;
+using System.Runtime.CompilerServices;
+using System.Runtime.ConstrainedExecution;
+using System.Runtime.InteropServices;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Diagnostics.Contracts;
+using System.Diagnostics.CodeAnalysis;
+using System.Diagnostics.Tracing;
 
 namespace System.Threading
 {
-    using System.Security;
-    using System.Security.Permissions;
-    using System;
-    using Microsoft.Win32;
-    using System.Runtime.CompilerServices;
-    using System.Runtime.ConstrainedExecution;
-    using System.Runtime.InteropServices;
-    using System.Collections.Generic;
-    using System.Diagnostics;
-    using System.Diagnostics.Contracts;
-    using System.Diagnostics.CodeAnalysis;
-    using System.Diagnostics.Tracing;
-
     internal static class ThreadPoolGlobals
     {
         //Per-appDomain quantum (in ms) for which the thread keeps processing
@@ -55,16 +41,12 @@ namespace System.Threading
         public static bool enableWorkerTracking;
 
         public static readonly ThreadPoolWorkQueue workQueue = new ThreadPoolWorkQueue();
-
-        static ThreadPoolGlobals()
-        {
-        }
     }
 
     internal sealed class ThreadPoolWorkQueue
     {
         // Simple sparsely populated array to allow lock-free reading.
-        internal class SparseArray<T> where T : class
+        internal sealed class SparseArray<T> where T : class
         {
             private volatile T[] m_array;
 
@@ -73,10 +55,7 @@ namespace System.Threading
                 m_array = new T[initialSize];
             }
 
-            internal T[] Current
-            {
-                get { return m_array; }
-            }
+            internal T[] Current => m_array;
 
             internal int Add(T e)
             {
@@ -99,7 +78,7 @@ namespace System.Threading
                                     continue;
 
                                 T[] newArray = new T[array.Length * 2];
-                                Array.Copy(array, newArray, i + 1);
+                                Array.Copy(array, 0, newArray, 0, i + 1);
                                 newArray[i + 1] = e;
                                 m_array = newArray;
                                 return i + 1;
@@ -126,7 +105,7 @@ namespace System.Threading
             }
         }
 
-        internal class WorkStealingQueue
+        internal sealed class WorkStealingQueue
         {
             private const int INITIAL_SIZE = 32;
             internal volatile IThreadPoolWorkItem[] m_array = new IThreadPoolWorkItem[INITIAL_SIZE];
@@ -142,7 +121,7 @@ namespace System.Threading
             private volatile int m_headIndex = START_INDEX;
             private volatile int m_tailIndex = START_INDEX;
 
-            private SpinLock m_foreignLock = new SpinLock(false);
+            private SpinLock m_foreignLock = new SpinLock(enableThreadOwnerTracking:false);
 
             public void LocalPush(IThreadPoolWorkItem obj)
             {
@@ -176,7 +155,7 @@ namespace System.Threading
                     finally
                     {
                         if (lockTaken)
-                            m_foreignLock.Exit(true);
+                            m_foreignLock.Exit(useMemoryBarrier:true);
                     }
                 }
 
@@ -201,7 +180,7 @@ namespace System.Threading
                         if (count >= m_mask)
                         {
                             // We're full; expand the queue by doubling its size.
-                            IThreadPoolWorkItem[] newArray = new IThreadPoolWorkItem[m_array.Length << 1];
+                            var newArray = new IThreadPoolWorkItem[m_array.Length << 1];
                             for (int i = 0; i < m_array.Length; i++)
                                 newArray[i] = m_array[(i + head) & m_mask];
 
@@ -218,7 +197,7 @@ namespace System.Threading
                     finally
                     {
                         if (lockTaken)
-                            m_foreignLock.Exit(false);
+                            m_foreignLock.Exit(useMemoryBarrier:false);
                     }
                 }
             }
@@ -276,7 +255,7 @@ namespace System.Threading
                         finally
                         {
                             if (lockTaken)
-                                m_foreignLock.Exit(false);
+                                m_foreignLock.Exit(useMemoryBarrier:false);
                         }
                     }
                 }
@@ -343,30 +322,23 @@ namespace System.Threading
                         finally
                         {
                             if (lockTaken)
-                                m_foreignLock.Exit(false);
+                                m_foreignLock.Exit(useMemoryBarrier:false);
                         }
                     }
                 }
             }
 
-            public bool TrySteal(out IThreadPoolWorkItem obj, ref bool missedSteal)
+            public IThreadPoolWorkItem TrySteal(ref bool missedSteal)
             {
-                return TrySteal(out obj, ref missedSteal, 0); // no blocking by default.
-            }
-
-            private bool TrySteal(out IThreadPoolWorkItem obj, ref bool missedSteal, int millisecondsTimeout)
-            {
-                obj = null;
-
                 while (true)
                 {
                     if (m_headIndex >= m_tailIndex)
-                        return false;
+                        return null;
 
                     bool taken = false;
                     try
                     {
-                        m_foreignLock.TryEnter(millisecondsTimeout, ref taken);
+                        m_foreignLock.TryEnter(ref taken);
                         if (taken)
                         {
                             // Increment head, and ensure read of tail doesn't move before it (fence).
@@ -376,172 +348,35 @@ namespace System.Threading
                             if (head < m_tailIndex)
                             {
                                 int idx = head & m_mask;
-                                obj = Volatile.Read(ref m_array[idx]);
+                                IThreadPoolWorkItem obj = Volatile.Read(ref m_array[idx]);
 
                                 // Check for nulls in the array.
                                 if (obj == null) continue;
 
                                 m_array[idx] = null;
-                                return true;
+                                return obj;
                             }
                             else
                             {
                                 // Failed, restore head.
                                 m_headIndex = head;
-                                obj = null;
-                                missedSteal = true;
                             }
                         }
-                        else
-                        {
-                            missedSteal = true;
-                        }
                     }
                     finally
                     {
                         if (taken)
-                            m_foreignLock.Exit(false);
-                    }
-
-                    return false;
-                }
-            }
-        }
-
-        internal class QueueSegment
-        {
-            // Holds a segment of the queue.  Enqueues/Dequeues start at element 0, and work their way up.
-            internal readonly IThreadPoolWorkItem[] nodes;
-            private const int QueueSegmentLength = 256;
-
-            // Holds the indexes of the lowest and highest valid elements of the nodes array.
-            // The low index is in the lower 16 bits, high index is in the upper 16 bits.
-            // Use GetIndexes and CompareExchangeIndexes to manipulate this.
-            private volatile int indexes;
-
-            // The next segment in the queue.
-            public volatile QueueSegment Next;
-
-
-            const int SixteenBits = 0xffff;
-
-            void GetIndexes(out int upper, out int lower)
-            {
-                int i = indexes;
-                upper = (i >> 16) & SixteenBits;
-                lower = i & SixteenBits;
-
-                Debug.Assert(upper >= lower);
-                Debug.Assert(upper <= nodes.Length);
-                Debug.Assert(lower <= nodes.Length);
-                Debug.Assert(upper >= 0);
-                Debug.Assert(lower >= 0);
-            }
-
-            bool CompareExchangeIndexes(ref int prevUpper, int newUpper, ref int prevLower, int newLower)
-            {
-                Debug.Assert(newUpper >= newLower);
-                Debug.Assert(newUpper <= nodes.Length);
-                Debug.Assert(newLower <= nodes.Length);
-                Debug.Assert(newUpper >= 0);
-                Debug.Assert(newLower >= 0);
-                Debug.Assert(newUpper >= prevUpper);
-                Debug.Assert(newLower >= prevLower);
-                Debug.Assert(newUpper == prevUpper ^ newLower == prevLower);
-
-                int oldIndexes = (prevUpper << 16) | (prevLower & SixteenBits);
-                int newIndexes = (newUpper << 16) | (newLower & SixteenBits);
-                int prevIndexes = Interlocked.CompareExchange(ref indexes, newIndexes, oldIndexes);
-                prevUpper = (prevIndexes >> 16) & SixteenBits;
-                prevLower = prevIndexes & SixteenBits;
-                return prevIndexes == oldIndexes;
-            }
-
-            [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
-            public QueueSegment()
-            {
-                Debug.Assert(QueueSegmentLength <= SixteenBits);
-                nodes = new IThreadPoolWorkItem[QueueSegmentLength];
-            }
-
-
-            public bool IsUsedUp()
-            {
-                int upper, lower;
-                GetIndexes(out upper, out lower);
-                return (upper == nodes.Length) && 
-                       (lower == nodes.Length);
-            }
-
-            public bool TryEnqueue(IThreadPoolWorkItem node)
-            {
-                //
-                // If there's room in this segment, atomically increment the upper count (to reserve
-                // space for this node), then store the node.
-                // Note that this leaves a window where it will look like there is data in that
-                // array slot, but it hasn't been written yet.  This is taken care of in TryDequeue
-                // with a busy-wait loop, waiting for the element to become non-null.  This implies
-                // that we can never store null nodes in this data structure.
-                //
-                Debug.Assert(null != node);
-
-                int upper, lower;
-                GetIndexes(out upper, out lower);
-
-                while (true)
-                {
-                    if (upper == nodes.Length)
-                        return false;
-
-                    if (CompareExchangeIndexes(ref upper, upper + 1, ref lower, lower))
-                    {
-                        Debug.Assert(Volatile.Read(ref nodes[upper]) == null);
-                        Volatile.Write(ref nodes[upper], node);
-                        return true;
-                    }
-                }
-            }
-
-            [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "Reviewed for thread safety")]
-            public bool TryDequeue(out IThreadPoolWorkItem node)
-            {
-                //
-                // If there are nodes in this segment, increment the lower count, then take the
-                // element we find there.
-                //
-                int upper, lower;
-                GetIndexes(out upper, out lower);
-
-                while(true)
-                {
-                    if (lower == upper)
-                    {
-                        node = null;
-                        return false;
+                            m_foreignLock.Exit(useMemoryBarrier:false);
                     }
 
-                    if (CompareExchangeIndexes(ref upper, upper, ref lower, lower + 1))
-                    {
-                        // It's possible that a concurrent call to Enqueue hasn't yet
-                        // written the node reference to the array.  We need to spin until
-                        // it shows up.
-                        SpinWait spinner = new SpinWait();
-                        while ((node = Volatile.Read(ref nodes[lower])) == null)
-                            spinner.SpinOnce();
-
-                        // Null-out the reference so the object can be GC'd earlier.
-                        nodes[lower] = null;
-
-                        return true;
-                    }
+                    missedSteal = true;
+                    return null;
                 }
             }
         }
 
-        // The head and tail of the queue.  We enqueue to the head, and dequeue from the tail.
-        internal volatile QueueSegment queueHead;
-        internal volatile QueueSegment queueTail;
         internal bool loggingEnabled;
+        internal readonly ConcurrentQueue<IThreadPoolWorkItem> workItems = new ConcurrentQueue<IThreadPoolWorkItem>();
 
         internal static readonly SparseArray<WorkStealingQueue> allThreadQueues = new SparseArray<WorkStealingQueue>(16);
 
@@ -549,16 +384,12 @@ namespace System.Threading
       
         public ThreadPoolWorkQueue()
         {
-            queueTail = queueHead = new QueueSegment();
             loggingEnabled = FrameworkEventSource.Log.IsEnabled(EventLevel.Verbose, FrameworkEventSource.Keywords.ThreadPool|FrameworkEventSource.Keywords.ThreadTransfer);
         }
 
-        public ThreadPoolWorkQueueThreadLocals EnsureCurrentThreadHasQueue()
-        {
-            if (null == ThreadPoolWorkQueueThreadLocals.threadLocals)
-                ThreadPoolWorkQueueThreadLocals.threadLocals = new ThreadPoolWorkQueueThreadLocals(this);
-            return ThreadPoolWorkQueueThreadLocals.threadLocals;
-        }
+        public ThreadPoolWorkQueueThreadLocals EnsureCurrentThreadHasQueue() =>
+            ThreadPoolWorkQueueThreadLocals.threadLocals ??
+            (ThreadPoolWorkQueueThreadLocals.threadLocals = new ThreadPoolWorkQueueThreadLocals(this));
 
         internal void EnsureThreadRequested()
         {
@@ -602,12 +433,12 @@ namespace System.Threading
 
         public void Enqueue(IThreadPoolWorkItem callback, bool forceGlobal)
         {
+            if (loggingEnabled)
+                System.Diagnostics.Tracing.FrameworkEventSource.Log.ThreadPoolEnqueueWorkObject(callback);
+
             ThreadPoolWorkQueueThreadLocals tl = null;
             if (!forceGlobal)
                 tl = ThreadPoolWorkQueueThreadLocals.threadLocals;
-
-            if (loggingEnabled)
-                System.Diagnostics.Tracing.FrameworkEventSource.Log.ThreadPoolEnqueueWorkObject(callback);
             
             if (null != tl)
             {
@@ -615,18 +446,7 @@ namespace System.Threading
             }
             else
             {
-                QueueSegment head = queueHead;
-
-                while (!head.TryEnqueue(callback))
-                {
-                    Interlocked.CompareExchange(ref head.Next, new QueueSegment(), null);
-
-                    while (head.Next != null)
-                    {
-                        Interlocked.CompareExchange(ref queueHead, head.Next, head);
-                        head = queueHead;
-                    }
-                }
+                workItems.Enqueue(callback);
             }
 
             EnsureThreadRequested();
@@ -635,46 +455,18 @@ namespace System.Threading
         internal bool LocalFindAndPop(IThreadPoolWorkItem callback)
         {
             ThreadPoolWorkQueueThreadLocals tl = ThreadPoolWorkQueueThreadLocals.threadLocals;
-            if (null == tl)
-                return false;
-
-            return tl.workStealingQueue.LocalFindAndPop(callback);
+            return tl != null && tl.workStealingQueue.LocalFindAndPop(callback);
         }
 
-        public void Dequeue(ThreadPoolWorkQueueThreadLocals tl, out IThreadPoolWorkItem callback, out bool missedSteal)
+        public IThreadPoolWorkItem Dequeue(ThreadPoolWorkQueueThreadLocals tl, ref bool missedSteal)
         {
-            callback = null;
-            missedSteal = false;
             WorkStealingQueue wsq = tl.workStealingQueue;
+            IThreadPoolWorkItem callback;
 
-            if (wsq.LocalPop(out callback))
-                Debug.Assert(null != callback);
-
-            if (null == callback)
-            {
-                QueueSegment tail = queueTail;
-                while (true)
-                {
-                    if (tail.TryDequeue(out callback))
-                    {
-                        Debug.Assert(null != callback);
-                        break;
-                    }
-
-                    if (null == tail.Next || !tail.IsUsedUp())
-                    {
-                        break;
-                    }
-                    else
-                    {
-                        Interlocked.CompareExchange(ref queueTail, tail.Next, tail);
-                        tail = queueTail;
-                    }
-                }
-            }
-
-            if (null == callback)
+            if (!wsq.LocalPop(out callback) && // first try the local queue
+                !workItems.TryDequeue(out callback)) // then try the global queue
             {
+                // finally try to steal from another thread's local queue
                 WorkStealingQueue[] otherQueues = allThreadQueues.Current;
                 int c = otherQueues.Length;
                 int maxIndex = c - 1;
@@ -683,19 +475,22 @@ namespace System.Threading
                 {
                     i = (i < maxIndex) ? i + 1 : 0;
                     WorkStealingQueue otherQueue = Volatile.Read(ref otherQueues[i]);
-                    if (otherQueue != null &&
-                        otherQueue != wsq &&
-                        otherQueue.TrySteal(out callback, ref missedSteal))
+                    if (otherQueue != null && otherQueue != wsq)
                     {
-                        Debug.Assert(null != callback);
-                        break;
+                        callback = otherQueue.TrySteal(ref missedSteal);
+                        if (callback != null)
+                        {
+                            break;
+                        }
                     }
                     c--;
                 }
             }
+
+            return callback;
         }
 
-        static internal bool Dispatch()
+        internal static bool Dispatch()
         {
             var workQueue = ThreadPoolGlobals.workQueue;
             //
@@ -743,7 +538,7 @@ namespace System.Threading
                     finally
                     {
                         bool missedSteal = false;
-                        workQueue.Dequeue(tl, out workItem, out missedSteal);
+                        workItem = workQueue.Dequeue(tl, ref missedSteal);
 
                         if (workItem == null)
                         {
@@ -788,7 +583,7 @@ namespace System.Threading
                                 try { }
                                 finally
                                 {
-                                    ThreadPool.ReportThreadStatus(true);
+                                    ThreadPool.ReportThreadStatus(isWorking:true);
                                     reportedStatus = true;
                                 }
                                 workItem.ExecuteWorkItem();
@@ -797,7 +592,7 @@ namespace System.Threading
                             finally
                             {
                                 if (reportedStatus)
-                                    ThreadPool.ReportThreadStatus(false);
+                                    ThreadPool.ReportThreadStatus(isWorking:false);
                             }
                         }
                         else
@@ -825,8 +620,7 @@ namespace System.Threading
                 // it was executed or not (in debug builds only).  Task uses this to communicate the ThreadAbortException to anyone
                 // who waits for the task to complete.
                 //
-                if (workItem != null)
-                    workItem.MarkAborted(tae);
+                workItem?.MarkAborted(tae);
                 
                 //
                 // In this case, the VM is going to request another thread on our behalf.  No need to do it twice.
@@ -845,7 +639,7 @@ namespace System.Threading
             }
 
             // we can never reach this point, but the C# compiler doesn't know that, because it doesn't know the ThreadAbortException will be reraised above.
-            Debug.Assert(false);
+            Debug.Fail("Should never reach this point");
             return true;
         }
     }
@@ -880,11 +674,11 @@ namespace System.Threading
                         try { }
                         finally
                         {
-                            IThreadPoolWorkItem cb = null;
+                            IThreadPoolWorkItem cb;
                             if (workStealingQueue.LocalPop(out cb))
                             {
                                 Debug.Assert(null != cb);
-                                workQueue.Enqueue(cb, true);
+                                workQueue.Enqueue(cb, forceGlobal:true);
                             }
                             else
                             {
@@ -912,27 +706,13 @@ namespace System.Threading
 
     internal sealed class RegisteredWaitHandleSafe : CriticalFinalizerObject
     {
-        private static IntPtr InvalidHandle
-        {
-            get
-            {
-                return Win32Native.INVALID_HANDLE_VALUE;
-            }
-        }
-        private IntPtr registeredWaitHandle;
+        private static IntPtr InvalidHandle => Win32Native.INVALID_HANDLE_VALUE;
+        private IntPtr registeredWaitHandle = InvalidHandle;
         private WaitHandle m_internalWaitObject;
         private bool bReleaseNeeded = false;
         private volatile int m_lock = 0;
 
-        internal RegisteredWaitHandleSafe()
-        {
-            registeredWaitHandle = InvalidHandle;
-        }
-
-        internal IntPtr GetHandle()
-        {
-           return registeredWaitHandle;
-        }
+        internal IntPtr GetHandle() => registeredWaitHandle;
     
         internal void SetHandle(IntPtr handle)
         {
@@ -1009,10 +789,8 @@ namespace System.Threading
             return result;
         }
 
-        private bool ValidHandle()
-        {
-            return (registeredWaitHandle != InvalidHandle && registeredWaitHandle != IntPtr.Zero);
-        }
+        private bool ValidHandle() =>
+            registeredWaitHandle != InvalidHandle && registeredWaitHandle != IntPtr.Zero;
 
         ~RegisteredWaitHandleSafe()
         {
@@ -1071,9 +849,9 @@ namespace System.Threading
         private static extern bool UnregisterWaitNative(IntPtr handle, SafeHandle waitObject);
     }
 
-[System.Runtime.InteropServices.ComVisible(true)]
+    [System.Runtime.InteropServices.ComVisible(true)]
     public sealed class RegisteredWaitHandle : MarshalByRefObject {
-        private RegisteredWaitHandleSafe internalRegisteredWait;
+        private readonly RegisteredWaitHandleSafe internalRegisteredWait;
     
         internal RegisteredWaitHandle()
         {
@@ -1090,8 +868,7 @@ namespace System.Threading
            internalRegisteredWait.SetWaitObject(waitObject);
         }
 
-    
-[System.Runtime.InteropServices.ComVisible(true)]
+        [System.Runtime.InteropServices.ComVisible(true)]
         // This is the only public method on this class
         public bool Unregister(
              WaitHandle     waitObject          // object to be notified when all callbacks to delegates have completed
@@ -1115,10 +892,7 @@ namespace System.Threading
     //
     internal static class _ThreadPoolWaitCallback
     {
-        static internal bool PerformWaitCallback()
-        {
-            return ThreadPoolWorkQueue.Dispatch();
-        }
+        internal static bool PerformWaitCallback() => ThreadPoolWorkQueue.Dispatch();
     }
 
     //
@@ -1138,11 +912,9 @@ namespace System.Threading
 
     internal sealed class QueueUserWorkItemCallback : IThreadPoolWorkItem
     {
-        static QueueUserWorkItemCallback() {}
-
         private WaitCallback callback;
-        private ExecutionContext context;
-        private Object state;
+        private readonly ExecutionContext context;
+        private readonly Object state;
 
 #if DEBUG
         volatile int executed;
@@ -1173,7 +945,7 @@ namespace System.Threading
         void IThreadPoolWorkItem.ExecuteWorkItem()
         {
 #if DEBUG
-            MarkExecuted(false);
+            MarkExecuted(aborted:false);
 #endif
             // call directly if it is an unsafe call OR EC flow is suppressed
             if (context == null)
@@ -1184,7 +956,7 @@ namespace System.Threading
             }
             else
             {
-                ExecutionContext.Run(context, ccb, this, true);
+                ExecutionContext.Run(context, ccb, this, preserveSyncCtx:true);
             }
         }
 
@@ -1193,16 +965,16 @@ namespace System.Threading
 #if DEBUG
             // this workitem didn't execute because we got a ThreadAbortException prior to the call to ExecuteWorkItem.  
             // This counts as being executed for our purposes.
-            MarkExecuted(true);
+            MarkExecuted(aborted:true);
 #endif
         }
 
-        static internal ContextCallback ccb = new ContextCallback(WaitCallback_Context);
+        internal static readonly ContextCallback ccb = new ContextCallback(WaitCallback_Context);
 
-        static private void WaitCallback_Context(Object state)
+        private static void WaitCallback_Context(Object state)
         {
             QueueUserWorkItemCallback obj = (QueueUserWorkItemCallback)state;
-            WaitCallback wc = obj.callback as WaitCallback;
+            WaitCallback wc = obj.callback;
             Debug.Assert(null != wc);
             wc(obj.state);
         }
@@ -1210,10 +982,8 @@ namespace System.Threading
 
     internal sealed class QueueUserWorkItemCallbackDefaultContext : IThreadPoolWorkItem
     {
-        static QueueUserWorkItemCallbackDefaultContext() { }
-
         private WaitCallback callback;
-        private Object state;
+        private readonly Object state;
 
 #if DEBUG
         private volatile int executed;
@@ -1243,9 +1013,9 @@ namespace System.Threading
         void IThreadPoolWorkItem.ExecuteWorkItem()
         {
 #if DEBUG
-            MarkExecuted(false);
+            MarkExecuted(aborted:false);
 #endif
-            ExecutionContext.Run(ExecutionContext.PreAllocatedDefault, ccb, this, true);
+            ExecutionContext.Run(ExecutionContext.PreAllocatedDefault, ccb, this, preserveSyncCtx:true);
         }
 
         void IThreadPoolWorkItem.MarkAborted(ThreadAbortException tae)
@@ -1253,16 +1023,16 @@ namespace System.Threading
 #if DEBUG
             // this workitem didn't execute because we got a ThreadAbortException prior to the call to ExecuteWorkItem.  
             // This counts as being executed for our purposes.
-            MarkExecuted(true);
+            MarkExecuted(aborted:true);
 #endif
         }
 
-        static internal ContextCallback ccb = new ContextCallback(WaitCallback_Context);
+        internal static readonly ContextCallback ccb = new ContextCallback(WaitCallback_Context);
 
-        static private void WaitCallback_Context(Object state)
+        private static void WaitCallback_Context(Object state)
         {
             QueueUserWorkItemCallbackDefaultContext obj = (QueueUserWorkItemCallbackDefaultContext)state;
-            WaitCallback wc = obj.callback as WaitCallback;
+            WaitCallback wc = obj.callback;
             Debug.Assert(null != wc);
             obj.callback = null;
             wc(obj.state);
@@ -1271,13 +1041,11 @@ namespace System.Threading
 
     internal class _ThreadPoolWaitOrTimerCallback
     {
-        static _ThreadPoolWaitOrTimerCallback() {}
-
         WaitOrTimerCallback _waitOrTimerCallback;
         ExecutionContext _executionContext;
         Object _state;
-        static private ContextCallback _ccbt = new ContextCallback(WaitOrTimerCallback_Context_t);
-        static private ContextCallback _ccbf = new ContextCallback(WaitOrTimerCallback_Context_f);
+        private static readonly ContextCallback _ccbt = new ContextCallback(WaitOrTimerCallback_Context_t);
+        private static readonly ContextCallback _ccbf = new ContextCallback(WaitOrTimerCallback_Context_f);
 
         internal _ThreadPoolWaitOrTimerCallback(WaitOrTimerCallback waitOrTimerCallback, Object state, bool compressStack, ref StackCrawlMark stackMark)
         {
@@ -1293,24 +1061,20 @@ namespace System.Threading
             }
         }
         
-        static private void WaitOrTimerCallback_Context_t(Object state)
-        {
-            WaitOrTimerCallback_Context(state, true);
-        }
+        private static void WaitOrTimerCallback_Context_t(Object state) =>
+            WaitOrTimerCallback_Context(state, timedOut:true);
 
-        static private void WaitOrTimerCallback_Context_f(Object state)
-        {
-            WaitOrTimerCallback_Context(state, false);
-        }
+        private static void WaitOrTimerCallback_Context_f(Object state) =>
+            WaitOrTimerCallback_Context(state, timedOut:false);
 
-        static private void WaitOrTimerCallback_Context(Object state, bool timedOut)
+        private static void WaitOrTimerCallback_Context(Object state, bool timedOut)
         {
             _ThreadPoolWaitOrTimerCallback helper = (_ThreadPoolWaitOrTimerCallback)state;
             helper._waitOrTimerCallback(helper._state, timedOut);
         }
             
         // call back helper
-        static internal void PerformWaitOrTimerCallback(Object state, bool timedOut)
+        internal static void PerformWaitOrTimerCallback(Object state, bool timedOut)
         {
             _ThreadPoolWaitOrTimerCallback helper = (_ThreadPoolWaitOrTimerCallback)state; 
             Debug.Assert(helper != null, "Null state passed to PerformWaitOrTimerCallback!");
@@ -1324,10 +1088,7 @@ namespace System.Threading
             {
                 using (ExecutionContext executionContext = helper._executionContext.CreateCopy())
                 {
-                if (timedOut)
-                        ExecutionContext.Run(executionContext, _ccbt, helper, true);
-                else
-                        ExecutionContext.Run(executionContext, _ccbf, helper, true);
+                    ExecutionContext.Run(executionContext, timedOut ? _ccbt : _ccbf, helper, preserveSyncCtx:true);
                 }
             }
         }    
@@ -1343,7 +1104,6 @@ namespace System.Threading
 
     public static class ThreadPool
     {
-
         public static bool SetMaxThreads(int workerThreads, int completionPortThreads)
         {
             return SetMaxThreadsNative(workerThreads, completionPortThreads);
@@ -1566,43 +1326,38 @@ namespace System.Threading
         //ThreadPool has per-appdomain managed queue of work-items. The VM is
         //responsible for just scheduling threads into appdomains. After that
         //work-items are dispatched from the managed queue.
-        private static bool QueueUserWorkItemHelper(WaitCallback callBack, Object state, ref StackCrawlMark stackMark, bool compressStack )
+        private static bool QueueUserWorkItemHelper(WaitCallback callBack, Object state, ref StackCrawlMark stackMark, bool compressStack)
         {
-            bool success =  true;
-
-            if (callBack != null)
+            if (callBack == null)
             {
-                        //The thread pool maintains a per-appdomain managed work queue.
-                //New thread pool entries are added in the managed queue.
-                //The VM is responsible for the actual growing/shrinking of 
-                //threads. 
-
-                EnsureVMInitialized();
+                throw new ArgumentNullException(nameof(callBack));
+            }
 
-                //
-                // If we are able to create the workitem, we need to get it in the queue without being interrupted
-                // by a ThreadAbortException.
-                //
-                try { }
-                finally
-                {
-                    ExecutionContext context = compressStack && !ExecutionContext.IsFlowSuppressed() ?
-                        ExecutionContext.Capture(ref stackMark, ExecutionContext.CaptureOptions.IgnoreSyncCtx | ExecutionContext.CaptureOptions.OptimizeDefaultCase) :
-                        null;
+            //The thread pool maintains a per-appdomain managed work queue.
+            //New thread pool entries are added in the managed queue.
+            //The VM is responsible for the actual growing/shrinking of 
+            //threads. 
 
-                    IThreadPoolWorkItem tpcallBack = context == ExecutionContext.PreAllocatedDefault ?
-                                 new QueueUserWorkItemCallbackDefaultContext(callBack, state) :
-                                 (IThreadPoolWorkItem)new QueueUserWorkItemCallback(callBack, state, context);
+            EnsureVMInitialized();
 
-                    ThreadPoolGlobals.workQueue.Enqueue(tpcallBack, true);
-                    success = true;
-                }
-            }
-            else
+            //
+            // If we are able to create the workitem, we need to get it in the queue without being interrupted
+            // by a ThreadAbortException.
+            //
+            try { }
+            finally
             {
-                throw new ArgumentNullException(nameof(WaitCallback));
+                ExecutionContext context = compressStack && !ExecutionContext.IsFlowSuppressed() ?
+                    ExecutionContext.Capture(ref stackMark, ExecutionContext.CaptureOptions.IgnoreSyncCtx | ExecutionContext.CaptureOptions.OptimizeDefaultCase) :
+                    null;
+
+                IThreadPoolWorkItem tpcallBack = context == ExecutionContext.PreAllocatedDefault ?
+                             new QueueUserWorkItemCallbackDefaultContext(callBack, state) :
+                             (IThreadPoolWorkItem)new QueueUserWorkItemCallback(callBack, state, context);
+
+                ThreadPoolGlobals.workQueue.Enqueue(tpcallBack, forceGlobal:true);
             }
-            return success;
+            return true;
         }
 
         internal static void UnsafeQueueCustomWorkItem(IThreadPoolWorkItem workItem, bool forceGlobal)
@@ -1624,50 +1379,33 @@ namespace System.Threading
         internal static bool TryPopCustomWorkItem(IThreadPoolWorkItem workItem)
         {
             Debug.Assert(null != workItem);
-            if (!ThreadPoolGlobals.vmTpInitialized)
-                return false; //Not initialized, so there's no way this workitem was ever queued.
-            return ThreadPoolGlobals.workQueue.LocalFindAndPop(workItem);
+            return
+                ThreadPoolGlobals.vmTpInitialized && // if not initialized, so there's no way this workitem was ever queued.
+                ThreadPoolGlobals.workQueue.LocalFindAndPop(workItem);
         }
 
         // Get all workitems.  Called by TaskScheduler in its debugger hooks.
         internal static IEnumerable<IThreadPoolWorkItem> GetQueuedWorkItems()
         {
-            return EnumerateQueuedWorkItems(ThreadPoolWorkQueue.allThreadQueues.Current, ThreadPoolGlobals.workQueue.queueTail);
-        }
-
-        internal static IEnumerable<IThreadPoolWorkItem> EnumerateQueuedWorkItems(ThreadPoolWorkQueue.WorkStealingQueue[] wsQueues, ThreadPoolWorkQueue.QueueSegment globalQueueTail)
-        {
-            if (wsQueues != null)
+            // Enumerate global queue
+            foreach (IThreadPoolWorkItem workItem in ThreadPoolGlobals.workQueue.workItems)
             {
-                // First, enumerate all workitems in thread-local queues.
-                foreach (ThreadPoolWorkQueue.WorkStealingQueue wsq in wsQueues)
-                {
-                    if (wsq != null && wsq.m_array != null)
-                    {
-                        IThreadPoolWorkItem[] items = wsq.m_array;
-                        for (int i = 0; i < items.Length; i++)
-                        {
-                            IThreadPoolWorkItem item = items[i];
-                            if (item != null)
-                                yield return item;
-                        }
-                    }
-                }
+                yield return workItem;
             }
 
-            if (globalQueueTail != null)
+            // Enumerate each local queue
+            foreach (ThreadPoolWorkQueue.WorkStealingQueue wsq in ThreadPoolWorkQueue.allThreadQueues.Current)
             {
-                // Now the global queue
-                for (ThreadPoolWorkQueue.QueueSegment segment = globalQueueTail;
-                    segment != null;
-                    segment = segment.Next)
+                if (wsq != null && wsq.m_array != null)
                 {
-                    IThreadPoolWorkItem[] items = segment.nodes;
+                    IThreadPoolWorkItem[] items = wsq.m_array;
                     for (int i = 0; i < items.Length; i++)
                     {
                         IThreadPoolWorkItem item = items[i];
                         if (item != null)
+                        {
                             yield return item;
+                        }
                     }
                 }
             }
@@ -1675,13 +1413,20 @@ namespace System.Threading
 
         internal static IEnumerable<IThreadPoolWorkItem> GetLocallyQueuedWorkItems()
         {
-            return EnumerateQueuedWorkItems(new ThreadPoolWorkQueue.WorkStealingQueue[] { ThreadPoolWorkQueueThreadLocals.threadLocals.workStealingQueue }, null);
+            ThreadPoolWorkQueue.WorkStealingQueue wsq = ThreadPoolWorkQueueThreadLocals.threadLocals.workStealingQueue;
+            if (wsq != null && wsq.m_array != null)
+            {
+                IThreadPoolWorkItem[] items = wsq.m_array;
+                for (int i = 0; i < items.Length; i++)
+                {
+                    IThreadPoolWorkItem item = items[i];
+                    if (item != null)
+                        yield return item;
+                }
+            }
         }
 
-        internal static IEnumerable<IThreadPoolWorkItem> GetGloballyQueuedWorkItems()
-        {
-            return EnumerateQueuedWorkItems(null, ThreadPoolGlobals.workQueue.queueTail);
-        }
+        internal static IEnumerable<IThreadPoolWorkItem> GetGloballyQueuedWorkItems() => ThreadPoolGlobals.workQueue.workItems;
 
         private static object[] ToObjectArray(IEnumerable<IThreadPoolWorkItem> workitems)
         {
@@ -1705,20 +1450,14 @@ namespace System.Threading
 
         // This is the method the debugger will actually call, if it ends up calling
         // into ThreadPool directly.  Tests can use this to simulate a debugger, as well.
-        internal static object[] GetQueuedWorkItemsForDebugger()
-        {
-            return ToObjectArray(GetQueuedWorkItems());
-        }
+        internal static object[] GetQueuedWorkItemsForDebugger() =>
+            ToObjectArray(GetQueuedWorkItems());
 
-        internal static object[] GetGloballyQueuedWorkItemsForDebugger()
-        {
-            return ToObjectArray(GetGloballyQueuedWorkItems());
-        }
+        internal static object[] GetGloballyQueuedWorkItemsForDebugger() =>
+            ToObjectArray(GetGloballyQueuedWorkItems());
 
-        internal static object[] GetLocallyQueuedWorkItemsForDebugger()
-        {
-            return ToObjectArray(GetLocallyQueuedWorkItems());
-        }
+        internal static object[] GetLocallyQueuedWorkItemsForDebugger() =>
+            ToObjectArray(GetLocallyQueuedWorkItems());
 
         [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
         [SuppressUnmanagedCodeSecurity]
@@ -1728,10 +1467,8 @@ namespace System.Threading
         unsafe private static extern bool PostQueuedCompletionStatus(NativeOverlapped* overlapped);
 
         [CLSCompliant(false)]
-        unsafe public static bool UnsafeQueueNativeOverlapped(NativeOverlapped* overlapped)
-        {
-            return PostQueuedCompletionStatus(overlapped);
-        }
+        unsafe public static bool UnsafeQueueNativeOverlapped(NativeOverlapped* overlapped) =>
+            PostQueuedCompletionStatus(overlapped);
 
         private static void EnsureVMInitialized()
         {
@@ -1795,9 +1532,7 @@ namespace System.Threading
 
 
         [Obsolete("ThreadPool.BindHandle(IntPtr) has been deprecated.  Please use ThreadPool.BindHandle(SafeHandle) instead.", false)]
-        public static bool BindHandle(
-             IntPtr osHandle
-             )
+        public static bool BindHandle(IntPtr osHandle)
         {
             return BindIOCompletionCallbackNative(osHandle);
         }
index cabcc15..ee21c25 100644 (file)
@@ -2,22 +2,27 @@
 // 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.Serialization;
-   using  System.Runtime.CompilerServices;
+using System.Runtime.Serialization;
 
-   [Serializable]
-   [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)]
-   public class TimeZoneNotFoundException : Exception {
-       public TimeZoneNotFoundException(String message)
-           : base(message) { }
+namespace System
+{
+    [Serializable]
+    public class TimeZoneNotFoundException : Exception
+    {
+        public TimeZoneNotFoundException()
+        {
+        }
 
-       public TimeZoneNotFoundException(String message, Exception innerException)
-           : base(message, innerException) { }
+        public TimeZoneNotFoundException(String message)
+            : base(message)
+        {
+        }
 
-       protected TimeZoneNotFoundException(SerializationInfo info, StreamingContext context)
-           : base(info, context) { }
+        public TimeZoneNotFoundException(String message, Exception innerException)
+            : base(message, innerException)
+        {
+        }
 
-       public TimeZoneNotFoundException() { }
-   }
+        protected TimeZoneNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+    }
 }
index 0b45f62..32775a1 100644 (file)
 **
 =============================================================================*/
 
-namespace System 
-{
-    using System.Runtime.Serialization;
+using System.Runtime.Serialization;
 
+namespace System
+{
     [Serializable]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public class TimeoutException : SystemException {
-        
-        public TimeoutException() 
-            : base(Environment.GetResourceString("Arg_TimeoutException")) {
-            SetErrorCode(__HResults.COR_E_TIMEOUT);
+    public class TimeoutException : SystemException
+    {
+        public TimeoutException()
+            : base(SR.Arg_TimeoutException)
+        {
+            HResult = __HResults.COR_E_TIMEOUT;
         }
-    
-        public TimeoutException(String message) 
-            : base(message) {
-            SetErrorCode(__HResults.COR_E_TIMEOUT);
+
+        public TimeoutException(String message)
+            : base(message)
+        {
+            HResult = __HResults.COR_E_TIMEOUT;
         }
-        
+
         public TimeoutException(String message, Exception innerException)
-            : base(message, innerException) {
-            SetErrorCode(__HResults.COR_E_TIMEOUT);
-        }
-    
-        //
-        //This constructor is required for serialization.
-        //
-        protected TimeoutException(SerializationInfo info, StreamingContext context) 
-            : base(info, context) {
+            : base(message, innerException)
+        {
+            HResult = __HResults.COR_E_TIMEOUT;
         }
+
+        protected TimeoutException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
 }
-
index 27a8760..b63cb41 100644 (file)
@@ -3,7 +3,6 @@
 // See the LICENSE file in the project root for more information.
 
 using System.ComponentModel;
-
 using System.Runtime.CompilerServices;
 
 namespace System
index 2d30c4c..bced4d0 100644 (file)
@@ -29,10 +29,7 @@ namespace System
     using DebuggerStepThroughAttribute = System.Diagnostics.DebuggerStepThroughAttribute;
 
     [Serializable]
-    [ClassInterface(ClassInterfaceType.None)]
-    [ComDefaultInterface(typeof(_Type))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public abstract class Type : MemberInfo, _Type, IReflect
+    public abstract class Type : MemberInfo, IReflect
     {
         //
         // System.Type is appdomain agile type. Appdomain agile types cannot have precise static constructors. Make
@@ -135,8 +132,11 @@ namespace System
         [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
         public static Type ReflectionOnlyGetType(String typeName, bool throwIfNotFound, bool ignoreCase) 
         {
-            StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
-            return RuntimeType.GetType(typeName, throwIfNotFound, ignoreCase, true /*reflectionOnly*/, ref stackMark);
+            if (typeName == null)
+                throw new ArgumentNullException(nameof(typeName));
+            if (typeName.Length == 0 && throwIfNotFound)
+                throw new TypeLoadException(Environment.GetResourceString("Arg_TypeLoadNullStr"));
+            throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReflectionOnlyGetType"));
         }
 
         public virtual Type MakePointerType() { throw new NotSupportedException(); }
@@ -297,7 +297,6 @@ namespace System
 
 
         // Module Property associated with a class.
-        // _Type.Module
         public new abstract Module Module { get; }
 
         // Assembly Property associated with a class.
@@ -1746,7 +1745,6 @@ namespace System
             return Equals(o as Type);
         }
 
-        // _Type.Equals(Type)
         [Pure]
         public virtual bool Equals(Type o)
         {
@@ -1784,7 +1782,6 @@ namespace System
         }
 
         // this method is required so Object.GetType is not made virtual by the compiler 
-        // _Type.GetType()
         public new Type GetType()
         {
             return base.GetType();
index 5ddc9a7..32afbdf 100644 (file)
@@ -2,9 +2,7 @@
 // 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.Serialization;
-using System.Security;
 
 namespace System
 {
@@ -14,27 +12,23 @@ namespace System
     public class TypeAccessException : TypeLoadException
     {
         public TypeAccessException()
-            : base(Environment.GetResourceString("Arg_TypeAccessException"))
+            : base(SR.Arg_TypeAccessException)
         {
-            SetErrorCode(__HResults.COR_E_TYPEACCESS);
+            HResult = __HResults.COR_E_TYPEACCESS;
         }
 
-        public TypeAccessException(string message) 
+        public TypeAccessException(string message)
             : base(message)
         {
-            SetErrorCode(__HResults.COR_E_TYPEACCESS);
+            HResult = __HResults.COR_E_TYPEACCESS;
         }
-    
-        public TypeAccessException(string message, Exception inner) 
+
+        public TypeAccessException(string message, Exception inner)
             : base(message, inner)
         {
-            SetErrorCode(__HResults.COR_E_TYPEACCESS);
+            HResult = __HResults.COR_E_TYPEACCESS;
         }
-    
-        protected TypeAccessException(SerializationInfo info, StreamingContext context)
-            : base(info, context)
-        {
-            SetErrorCode(__HResults.COR_E_TYPEACCESS);
-        }    
+
+        protected TypeAccessException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
 }
index bf71c2f..293eb1f 100644 (file)
 // These types of values are instead represented as classes. When the type code
 // of an object is TypeCode.Object, a further instance-of check can be used to
 // determine if the object is one of these values.
-namespace System {
+
+namespace System
+{
     [Serializable]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public enum TypeCode {
+    public enum TypeCode
+    {
         Empty = 0,          // Null reference
         Object = 1,         // Instance that isn't a value
         DBNull = 2,         // Database null value
@@ -44,5 +46,3 @@ namespace System {
         String = 18,        // Unicode character string
     }
 }
-
-
index bcc1c3e..9191028 100644 (file)
 **
 **
 =============================================================================*/
-using System;
-using System.Runtime.Serialization;
+
 using System.Globalization;
-using System.Security.Permissions;
+using System.Runtime.Serialization;
 
-namespace System {
+namespace System
+{
     [Serializable]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public sealed class TypeInitializationException : SystemException {
+    public sealed class TypeInitializationException : SystemException
+    {
         private String _typeName;
 
         // This exception is not creatable without specifying the
         //    inner exception.
         private TypeInitializationException()
-            : base(Environment.GetResourceString("TypeInitialization_Default")) {
-            SetErrorCode(__HResults.COR_E_TYPEINITIALIZATION);
+            : base(SR.TypeInitialization_Default)
+        {
+            HResult = __HResults.COR_E_TYPEINITIALIZATION;
+        }
+
+
+        public TypeInitializationException(String fullTypeName, Exception innerException)
+            : this(fullTypeName, SR.Format(SR.TypeInitialization_Type, fullTypeName), innerException)
+        {
         }
 
         // This is called from within the runtime.  I believe this is necessary
         // for Interop only, though it's not particularly useful.
-        private TypeInitializationException(String message) : base(message) {
-            SetErrorCode(__HResults.COR_E_TYPEINITIALIZATION);
+        internal TypeInitializationException(String message) : base(message)
+        {
+            HResult = __HResults.COR_E_TYPEINITIALIZATION;
         }
-        
-        public TypeInitializationException(String fullTypeName, Exception innerException) : base(Environment.GetResourceString("TypeInitialization_Type", fullTypeName), innerException) {
+
+        internal TypeInitializationException(String fullTypeName, String message, Exception innerException)
+            : base(message, innerException)
+        {
             _typeName = fullTypeName;
-            SetErrorCode(__HResults.COR_E_TYPEINITIALIZATION);
+            HResult = __HResults.COR_E_TYPEINITIALIZATION;
         }
 
-        internal TypeInitializationException(SerializationInfo info, StreamingContext context) : base(info, context) {
+        internal TypeInitializationException(SerializationInfo info, StreamingContext context)
+            : base(info, context)
+        {
             _typeName = info.GetString("TypeName");
         }
 
+        public override void GetObjectData(SerializationInfo info, StreamingContext context)
+        {
+            base.GetObjectData(info, context);
+            info.AddValue("TypeName", TypeName, typeof(String));
+        }
+
         public String TypeName
         {
-            get {
-                if (_typeName == null) {
+            get
+            {
+                if (_typeName == null)
+                {
                     return String.Empty;
                 }
                 return _typeName;
             }
         }
-
-        public override void GetObjectData(SerializationInfo info, StreamingContext context) {
-            base.GetObjectData(info, context);
-            info.AddValue("TypeName",TypeName,typeof(String));
-        }
-
     }
 }
index 07e95d5..9973588 100644 (file)
 ** 
 ===========================================================*/
 
-using System;
 using System.Runtime.Serialization;
 
-namespace System {
+namespace System
+{
     // The UnauthorizedAccessException is thrown when access errors 
     // occur from IO or other OS methods.  
     [Serializable]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public class UnauthorizedAccessException : SystemException {
-        public UnauthorizedAccessException() 
-            : base(Environment.GetResourceString("Arg_UnauthorizedAccessException")) {
-            SetErrorCode(__HResults.COR_E_UNAUTHORIZEDACCESS);
+    public class UnauthorizedAccessException : SystemException
+    {
+        public UnauthorizedAccessException()
+            : base(SR.Arg_UnauthorizedAccessException)
+        {
+            HResult = __HResults.COR_E_UNAUTHORIZEDACCESS;
         }
-        
-        public UnauthorizedAccessException(String message) 
-            : base(message) {
-            SetErrorCode(__HResults.COR_E_UNAUTHORIZEDACCESS);
-        }
-        
-        public UnauthorizedAccessException(String message, Exception inner) 
-            : base(message, inner) {
-            SetErrorCode(__HResults.COR_E_UNAUTHORIZEDACCESS);
+
+        public UnauthorizedAccessException(String message)
+            : base(message)
+        {
+            HResult = __HResults.COR_E_UNAUTHORIZEDACCESS;
         }
 
-        protected UnauthorizedAccessException(SerializationInfo info, StreamingContext context) : base(info, context) {
+        public UnauthorizedAccessException(String message, Exception inner)
+            : base(message, inner)
+        {
+            HResult = __HResults.COR_E_UNAUTHORIZEDACCESS;
         }
+
+        protected UnauthorizedAccessException(SerializationInfo info, StreamingContext context) : base(info, context) { }
     }
 }
index e155ffc..d338301 100644 (file)
@@ -2,28 +2,28 @@
 // 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;
-    using System.Runtime.ConstrainedExecution;
-    
+namespace System
+{
     [Serializable]
-[System.Runtime.InteropServices.ComVisible(true)]
-    public class UnhandledExceptionEventArgs : EventArgs {
-        private Object _Exception;
-        private bool _IsTerminating;
+    public class UnhandledExceptionEventArgs : EventArgs
+    {
+        private Object _exception;
+        private bool _isTerminating;
 
-        public UnhandledExceptionEventArgs(Object exception, bool isTerminating) {
-            _Exception = exception;
-            _IsTerminating = isTerminating;
+        public UnhandledExceptionEventArgs(Object exception, bool isTerminating)
+        {
+            _exception = exception;
+            _isTerminating = isTerminating;
         }
-        public Object ExceptionObject { 
-            [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
-            get { return _Exception; }
+
+        public Object ExceptionObject
+        {
+            get { return _exception; }
         }
-        public bool IsTerminating {
-            [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
-            get { return _IsTerminating; }
+
+        public bool IsTerminating
+        {
+            get { return _isTerminating; }
         }
     }
 }
index 8c27982..b99414c 100644 (file)
@@ -2,10 +2,8 @@
 // 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;
+namespace System
+{
     [Serializable]
-    [System.Runtime.InteropServices.ComVisible(true)]
     public delegate void UnhandledExceptionEventHandler(Object sender, UnhandledExceptionEventArgs e);
 }
index 8476122..0f0863a 100644 (file)
@@ -28,6 +28,7 @@ namespace System
     /// - they are mutable rather than readonly, and
     /// - their members (such as Item1, Item2, etc) are fields rather than properties.
     /// </summary>
+    [Serializable]
     public struct ValueTuple
         : IEquatable<ValueTuple>, IStructuralEquatable, IStructuralComparable, IComparable, IComparable<ValueTuple>, IValueTupleInternal, ITuple
     {
@@ -296,6 +297,7 @@ namespace System
 
     /// <summary>Represents a 1-tuple, or singleton, as a value type.</summary>
     /// <typeparam name="T1">The type of the tuple's only component.</typeparam>
+    [Serializable]
     public struct ValueTuple<T1>
         : IEquatable<ValueTuple<T1>>, IStructuralEquatable, IStructuralComparable, IComparable, IComparable<ValueTuple<T1>>, IValueTupleInternal, ITuple
     {
@@ -460,6 +462,7 @@ namespace System
     /// </summary>
     /// <typeparam name="T1">The type of the tuple's first component.</typeparam>
     /// <typeparam name="T2">The type of the tuple's second component.</typeparam>
+    [Serializable]
     [StructLayout(LayoutKind.Auto)]
     public struct ValueTuple<T1, T2>
         : IEquatable<ValueTuple<T1, T2>>, IStructuralEquatable, IStructuralComparable, IComparable, IComparable<ValueTuple<T1, T2>>, IValueTupleInternal, ITuple
@@ -669,6 +672,7 @@ namespace System
     /// <typeparam name="T1">The type of the tuple's first component.</typeparam>
     /// <typeparam name="T2">The type of the tuple's second component.</typeparam>
     /// <typeparam name="T3">The type of the tuple's third component.</typeparam>
+    [Serializable]
     [StructLayout(LayoutKind.Auto)]
     public struct ValueTuple<T1, T2, T3>
         : IEquatable<ValueTuple<T1, T2, T3>>, IStructuralEquatable, IStructuralComparable, IComparable, IComparable<ValueTuple<T1, T2, T3>>, IValueTupleInternal, ITuple
@@ -876,6 +880,7 @@ namespace System
     /// <typeparam name="T2">The type of the tuple's second component.</typeparam>
     /// <typeparam name="T3">The type of the tuple's third component.</typeparam>
     /// <typeparam name="T4">The type of the tuple's fourth component.</typeparam>
+    [Serializable]
     [StructLayout(LayoutKind.Auto)]
     public struct ValueTuple<T1, T2, T3, T4>
         : IEquatable<ValueTuple<T1, T2, T3, T4>>, IStructuralEquatable, IStructuralComparable, IComparable, IComparable<ValueTuple<T1, T2, T3, T4>>, IValueTupleInternal, ITuple
@@ -1102,6 +1107,7 @@ namespace System
     /// <typeparam name="T3">The type of the tuple's third component.</typeparam>
     /// <typeparam name="T4">The type of the tuple's fourth component.</typeparam>
     /// <typeparam name="T5">The type of the tuple's fifth component.</typeparam>
+    [Serializable]
     [StructLayout(LayoutKind.Auto)]
     public struct ValueTuple<T1, T2, T3, T4, T5>
         : IEquatable<ValueTuple<T1, T2, T3, T4, T5>>, IStructuralEquatable, IStructuralComparable, IComparable, IComparable<ValueTuple<T1, T2, T3, T4, T5>>, IValueTupleInternal, ITuple
@@ -1347,6 +1353,7 @@ namespace System
     /// <typeparam name="T4">The type of the tuple's fourth component.</typeparam>
     /// <typeparam name="T5">The type of the tuple's fifth component.</typeparam>
     /// <typeparam name="T6">The type of the tuple's sixth component.</typeparam>
+    [Serializable]
     [StructLayout(LayoutKind.Auto)]
     public struct ValueTuple<T1, T2, T3, T4, T5, T6>
         : IEquatable<ValueTuple<T1, T2, T3, T4, T5, T6>>, IStructuralEquatable, IStructuralComparable, IComparable, IComparable<ValueTuple<T1, T2, T3, T4, T5, T6>>, IValueTupleInternal, ITuple
@@ -1611,6 +1618,7 @@ namespace System
     /// <typeparam name="T5">The type of the tuple's fifth component.</typeparam>
     /// <typeparam name="T6">The type of the tuple's sixth component.</typeparam>
     /// <typeparam name="T7">The type of the tuple's seventh component.</typeparam>
+    [Serializable]
     [StructLayout(LayoutKind.Auto)]
     public struct ValueTuple<T1, T2, T3, T4, T5, T6, T7>
         : IEquatable<ValueTuple<T1, T2, T3, T4, T5, T6, T7>>, IStructuralEquatable, IStructuralComparable, IComparable, IComparable<ValueTuple<T1, T2, T3, T4, T5, T6, T7>>, IValueTupleInternal, ITuple
@@ -1894,6 +1902,7 @@ namespace System
     /// <typeparam name="T6">The type of the tuple's sixth component.</typeparam>
     /// <typeparam name="T7">The type of the tuple's seventh component.</typeparam>
     /// <typeparam name="TRest">The type of the tuple's eighth component.</typeparam>
+    [Serializable]
     [StructLayout(LayoutKind.Auto)]
     public struct ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>
     : IEquatable<ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>>, IStructuralEquatable, IStructuralComparable, IComparable, IComparable<ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>>, IValueTupleInternal, ITuple
index 51df878..5c20f63 100644 (file)
@@ -7,12 +7,11 @@
 //    This class represents the void return type
 ////////////////////////////////////////////////////////////////////////////////
 
-namespace System {
-   
-    using System;
+namespace System
+{
+    // This class represents the void return type
     [Serializable]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public struct Void 
+    public struct Void
     {
     }
 }
diff --git a/src/mscorlib/src/System/_LocalDataStore.cs b/src/mscorlib/src/System/_LocalDataStore.cs
deleted file mode 100644 (file)
index a1fa488..0000000
+++ /dev/null
@@ -1,244 +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: Class that stores local data. This class is used in cooperation
-**          with the _LocalDataStoreMgr class.
-**
-**
-=============================================================================*/
-
-namespace System {
-    
-    using System;
-    using System.Threading;
-    using System.Runtime.CompilerServices;
-    using System.Diagnostics;
-    using System.Diagnostics.Contracts;
-
-    // Helper class to aid removal of LocalDataStore from the LocalDataStoreMgr
-    // LocalDataStoreMgr does not holds references to LocalDataStoreHolder. It holds
-    // references to LocalDataStore only. LocalDataStoreHolder finalizer will run once
-    // the only outstanding reference to the store is in LocalDataStoreMgr.
-    sealed internal class LocalDataStoreHolder
-    {
-        private LocalDataStore m_Store;
-
-        public LocalDataStoreHolder(LocalDataStore store)
-        {
-            m_Store = store;
-        }
-
-        ~LocalDataStoreHolder()
-        {
-            LocalDataStore store = m_Store;
-            if (store == null)
-                return;
-
-            store.Dispose();
-        }
-
-        public LocalDataStore Store
-        {
-            get
-            {
-                return m_Store;
-            }
-        }
-    }
-
-    sealed internal class LocalDataStoreElement
-    {
-        private Object m_value;
-        private long m_cookie;  // This is immutable cookie of the slot used to verify that 
-                                // the value is indeed indeed owned by the slot. Necessary 
-                                // to avoid resurection holes.
-
-        public LocalDataStoreElement(long cookie)
-        {
-            m_cookie = cookie;
-        }
-
-        public Object Value
-        {
-            get
-            {
-                return m_value;
-            }
-            set
-            {
-                m_value = value;
-            }
-        }
-
-        public long Cookie
-        {
-            get
-            {
-                return m_cookie;
-            }
-        }
-    }
-
-    // This class will not be marked serializable
-    sealed internal class LocalDataStore
-    {
-        private LocalDataStoreElement[] m_DataTable;
-        private LocalDataStoreMgr m_Manager;
-
-        /*=========================================================================
-        ** Initialize the data store.
-        =========================================================================*/
-        public LocalDataStore(LocalDataStoreMgr mgr, int InitialCapacity)
-        {
-            // Store the manager of the local data store.       
-            m_Manager = mgr;
-
-            // Allocate the array that will contain the data.
-            m_DataTable = new LocalDataStoreElement[InitialCapacity];
-        }
-
-        /*=========================================================================
-        ** Delete this store from its manager
-        =========================================================================*/
-        internal void Dispose()
-        {
-            m_Manager.DeleteLocalDataStore(this);
-        }
-
-        /*=========================================================================
-        ** Retrieves the value from the specified slot.
-        =========================================================================*/
-        public Object GetData(LocalDataStoreSlot slot)
-        {
-            // Validate the slot.
-            m_Manager.ValidateSlot(slot);
-
-            // Cache the slot index to avoid synchronization issues.
-            int slotIdx = slot.Slot;
-
-            if (slotIdx >= 0)
-            {
-                // Delay expansion of m_DataTable if we can
-                if (slotIdx >= m_DataTable.Length)
-                    return null;         
-                
-                // Retrieve the data from the given slot.
-                LocalDataStoreElement element = m_DataTable[slotIdx];
-
-          //Initially we prepopulate the elements to be null.     
-          if (element == null)
-              return null;
-
-                // Check that the element is owned by this slot by comparing cookies.
-                // This is necesary to avoid resurection race conditions.
-                if (element.Cookie == slot.Cookie)
-                    return element.Value;
-
-                // Fall thru and throw exception
-            }
-                
-            throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SlotHasBeenFreed"));
-        }
-    
-        /*=========================================================================
-        ** Sets the data in the specified slot.
-        =========================================================================*/
-        public void SetData(LocalDataStoreSlot slot, Object data)
-        {
-            // Validate the slot.
-            m_Manager.ValidateSlot(slot);
-
-            // Cache the slot index to avoid synchronization issues.
-            int slotIdx = slot.Slot;
-
-            if (slotIdx >= 0)
-            {
-                LocalDataStoreElement element = (slotIdx < m_DataTable.Length) ? m_DataTable[slotIdx] : null;
-                if (element == null)
-                {
-                    element = PopulateElement(slot);
-                }
-
-                // Check that the element is owned by this slot by comparing cookies.
-                // This is necesary to avoid resurection race conditions.
-                if (element.Cookie == slot.Cookie)
-                {
-                    // Set the data on the given slot.
-                    element.Value = data;
-                    return;
-                }
-
-                // Fall thru and throw exception
-            }
-
-            throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SlotHasBeenFreed"));
-        }
-
-        /*=========================================================================
-        ** This method does clears the unused slot.
-         * Assumes lock on m_Manager is taken
-        =========================================================================*/
-        internal void FreeData(int slot, long cookie)
-        {
-            // We try to delay allocate the dataTable (in cases like the manager clearing a
-            // just-freed slot in all stores
-            if (slot >= m_DataTable.Length)
-                return;
-
-            LocalDataStoreElement element = m_DataTable[slot];
-            if (element != null && element.Cookie == cookie)
-                m_DataTable[slot] = null;
-        }
-
-        /*=========================================================================
-        ** Method used to expand the capacity of the local data store.
-        =========================================================================*/
-        private LocalDataStoreElement PopulateElement(LocalDataStoreSlot slot)
-        {
-            bool tookLock = false;
-            RuntimeHelpers.PrepareConstrainedRegions();
-            try {
-                Monitor.Enter(m_Manager, ref tookLock);
-
-                // Make sure that the slot was not freed in the meantime
-                int slotIdx = slot.Slot;
-                if (slotIdx < 0)
-                    throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SlotHasBeenFreed"));
-
-                if (slotIdx >= m_DataTable.Length)
-                {
-                    int capacity = m_Manager.GetSlotTableLength();
-
-                    // Validate that the specified capacity is larger than the current one.
-                    Debug.Assert(capacity >= m_DataTable.Length, "LocalDataStore corrupted: capacity >= m_DataTable.Length");
-
-                    // Allocate the new data table.
-                    LocalDataStoreElement[] NewDataTable = new LocalDataStoreElement[capacity];
-
-                    // Copy all the objects into the new table.
-                    Array.Copy(m_DataTable, NewDataTable, m_DataTable.Length);
-
-                    // Save the new table.
-                    m_DataTable = NewDataTable;
-                }
-
-                // Validate that there is enough space in the local data store now
-                Debug.Assert(slotIdx < m_DataTable.Length, "LocalDataStore corrupted: slotIdx < m_DataTable.Length");
-
-                if (m_DataTable[slotIdx] == null)
-                    m_DataTable[slotIdx] = new LocalDataStoreElement(slot.Cookie);
-
-                return m_DataTable[slotIdx];
-            }
-            finally {
-                if (tookLock)
-                    Monitor.Exit(m_Manager);
-            }
-        }
-    }
-}
diff --git a/src/mscorlib/src/System/_LocalDataStoreMgr.cs b/src/mscorlib/src/System/_LocalDataStoreMgr.cs
deleted file mode 100644 (file)
index 8f60d6f..0000000
+++ /dev/null
@@ -1,332 +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: Class that manages stores of local data. This class is used in 
-**          cooperation with the LocalDataStore class.
-**
-**
-=============================================================================*/
-namespace System {
-    
-    using System;
-    using System.Collections.Generic;
-    using System.Threading;
-    using System.Runtime.CompilerServices;
-    using System.Diagnostics.Contracts;
-
-    // This class is an encapsulation of a slot so that it is managed in a secure fashion.
-    // It is constructed by the LocalDataStoreManager, holds the slot and the manager
-    // and cleans up when it is finalized.
-    // This class will not be marked serializable
-[System.Runtime.InteropServices.ComVisible(true)]
-    public sealed class LocalDataStoreSlot
-    {
-        private LocalDataStoreMgr m_mgr;
-        private int m_slot;
-        private long m_cookie;
-
-        // Construct the object to encapsulate the slot.
-        internal LocalDataStoreSlot(LocalDataStoreMgr mgr, int slot, long cookie)
-        {
-            m_mgr = mgr;
-            m_slot = slot;
-            m_cookie = cookie;
-        }
-
-        // Accessors for the two fields of this class.
-        internal LocalDataStoreMgr Manager
-        {
-            get
-            {
-                return m_mgr;
-            }
-        }
-        internal int Slot
-        {
-            get
-            {
-                return m_slot;
-            }
-        }
-        internal long Cookie
-        {
-            get
-            {
-                return m_cookie;
-            }
-        }
-
-        // Release the slot reserved by this object when this object goes away.
-        ~LocalDataStoreSlot()
-        {
-            LocalDataStoreMgr mgr = m_mgr;
-            if (mgr == null)
-                return;
-
-            int slot = m_slot;
-
-            // Mark the slot as free.
-            m_slot = -1;
-
-            mgr.FreeDataSlot(slot, m_cookie);
-        }
-    }
-
-    // This class will not be marked serializable
-    sealed internal class LocalDataStoreMgr
-    {
-        private const int InitialSlotTableSize            = 64;
-        private const int SlotTableDoubleThreshold        = 512;
-        private const int LargeSlotTableSizeIncrease    = 128;
-    
-        /*=========================================================================
-        ** Create a data store to be managed by this manager and add it to the
-        ** list. The initial size of the new store matches the number of slots
-        ** allocated in this manager.
-        =========================================================================*/
-        public LocalDataStoreHolder CreateLocalDataStore()
-        {
-            // Create a new local data store.
-            LocalDataStore store = new LocalDataStore(this, m_SlotInfoTable.Length);
-            LocalDataStoreHolder holder = new LocalDataStoreHolder(store);
-
-            bool tookLock = false;
-            RuntimeHelpers.PrepareConstrainedRegions();
-            try
-            {
-                Monitor.Enter(this, ref tookLock);
-                // Add the store to the array list and return it.
-                m_ManagedLocalDataStores.Add(store);
-            }
-            finally
-            {
-                if (tookLock)
-                    Monitor.Exit(this);
-            }
-            return holder;
-        }
-
-        /*=========================================================================
-         * Remove the specified store from the list of managed stores..
-        =========================================================================*/
-        public void DeleteLocalDataStore(LocalDataStore store)
-        {
-            bool tookLock = false;
-            RuntimeHelpers.PrepareConstrainedRegions();
-            try
-            {
-                Monitor.Enter(this, ref tookLock);
-                // Remove the store to the array list and return it.
-                m_ManagedLocalDataStores.Remove(store);
-            }
-            finally
-            {
-                if (tookLock)
-                    Monitor.Exit(this);
-            }
-        }
-
-        /*=========================================================================
-        ** Allocates a data slot by finding an available index and wrapping it
-        ** an object to prevent clients from manipulating it directly, allowing us
-        ** to make assumptions its integrity.
-        =========================================================================*/
-        public LocalDataStoreSlot AllocateDataSlot()
-        {
-            bool tookLock = false;
-            RuntimeHelpers.PrepareConstrainedRegions();
-            try
-            {
-                Monitor.Enter(this, ref tookLock);
-                LocalDataStoreSlot slot;
-
-                int slotTableSize = m_SlotInfoTable.Length;
-
-                // In case FreeDataSlot has moved the pointer back, the next slot may not be available.
-                // Find the first actually available slot.
-                int availableSlot = m_FirstAvailableSlot;
-                while (availableSlot < slotTableSize)
-                {
-                    if (!m_SlotInfoTable[availableSlot])
-                        break;
-                    availableSlot++;
-                }
-
-                // Check if there are any slots left.
-                if (availableSlot >= slotTableSize)
-                {
-                    // The table is full so we need to increase its size.
-                    int newSlotTableSize;
-                    if (slotTableSize < SlotTableDoubleThreshold)
-                    {
-                        // The table is still relatively small so double it.
-                        newSlotTableSize = slotTableSize * 2;
-                    }
-                    else
-                    {
-                        // The table is relatively large so simply increase its size by a given amount.
-                        newSlotTableSize = slotTableSize + LargeSlotTableSizeIncrease;
-                    }
-
-                    // Allocate the new slot info table.
-                    bool[] newSlotInfoTable = new bool[newSlotTableSize];
-
-                    // Copy the old array into the new one.
-                    Array.Copy(m_SlotInfoTable, newSlotInfoTable, slotTableSize);
-                    m_SlotInfoTable = newSlotInfoTable;
-                }
-
-                // availableSlot is the index of the empty slot.
-                m_SlotInfoTable[availableSlot] = true;
-
-                // We do not need to worry about overflowing m_CookieGenerator. It would take centuries
-                // of intensive slot allocations on current machines to get the 2^64 counter to overflow.
-                // We will perform the increment with overflow check just to play it on the safe side.
-                slot = new LocalDataStoreSlot(this, availableSlot, checked(m_CookieGenerator++));
-
-                // Save the new "first available slot".hint
-                m_FirstAvailableSlot = availableSlot + 1;
-
-                // Return the selected slot
-                return slot;
-            }
-            finally
-            {
-                if (tookLock)
-                    Monitor.Exit(this);
-            }
-        }
-        
-        /*=========================================================================
-        ** Allocate a slot and associate a name with it.
-        =========================================================================*/
-        public LocalDataStoreSlot AllocateNamedDataSlot(String name)
-        {
-            bool tookLock = false;
-            RuntimeHelpers.PrepareConstrainedRegions();
-            try
-            {
-                Monitor.Enter(this, ref tookLock);
-                // Allocate a normal data slot.
-                LocalDataStoreSlot slot = AllocateDataSlot();
-
-                // Insert the association between the name and the data slot number
-                // in the hash table.
-                m_KeyToSlotMap.Add(name, slot);
-                return slot;
-            }
-            finally
-            {
-                if (tookLock)
-                    Monitor.Exit(this);
-            }
-        }
-
-        /*=========================================================================
-        ** Retrieve the slot associated with a name, allocating it if no such
-        ** association has been defined.
-        =========================================================================*/
-        public LocalDataStoreSlot GetNamedDataSlot(String name)
-        {
-            bool tookLock = false;
-            RuntimeHelpers.PrepareConstrainedRegions();
-            try
-            {
-                Monitor.Enter(this, ref tookLock);
-                // Lookup in the hashtable to try find a slot for the name.
-                LocalDataStoreSlot slot = m_KeyToSlotMap.GetValueOrDefault(name);
-
-                // If the name is not yet in the hashtable then add it.
-                if (null == slot)
-                    return AllocateNamedDataSlot(name);
-
-                // The name was in the hashtable so return the associated slot.
-                return slot;
-            }
-            finally
-            {
-                if (tookLock)
-                    Monitor.Exit(this);
-            }
-        }
-
-        /*=========================================================================
-        ** Eliminate the association of a name with a slot.  The actual slot will
-        ** be reclaimed when the finalizer for the slot object runs.
-        =========================================================================*/
-        public void FreeNamedDataSlot(String name)
-        {
-            bool tookLock = false;
-            RuntimeHelpers.PrepareConstrainedRegions();
-            try
-            {
-                Monitor.Enter(this, ref tookLock);
-                // Remove the name slot association from the hashtable.
-                m_KeyToSlotMap.Remove(name);
-            }
-            finally
-            {
-                if (tookLock)
-                    Monitor.Exit(this);
-            }
-        }
-
-        /*=========================================================================
-        ** Free's a previously allocated data slot on ALL the managed data stores.
-        =========================================================================*/
-        internal void FreeDataSlot(int slot, long cookie)
-        {
-            bool tookLock = false;
-            RuntimeHelpers.PrepareConstrainedRegions();
-            try
-            {
-                Monitor.Enter(this, ref tookLock);
-                // Go thru all the managed stores and set the data on the specified slot to 0.
-                for (int i = 0; i < m_ManagedLocalDataStores.Count; i++)
-                {
-                    ((LocalDataStore)m_ManagedLocalDataStores[i]).FreeData(slot, cookie);
-                }
-
-                // Mark the slot as being no longer occupied. 
-                m_SlotInfoTable[slot] = false;
-                if (slot < m_FirstAvailableSlot)
-                    m_FirstAvailableSlot = slot;
-            }
-            finally
-            {
-                if (tookLock)
-                    Monitor.Exit(this);
-            }
-        }
-
-        /*=========================================================================
-        ** Check that this is a valid slot for this store
-        =========================================================================*/
-        public void ValidateSlot(LocalDataStoreSlot slot)
-        {
-            // Make sure the slot was allocated for this store.
-            if (slot == null || slot.Manager != this)
-                throw new ArgumentException(Environment.GetResourceString("Argument_ALSInvalidSlot"));
-            Contract.EndContractBlock();
-        }
-
-        /*=========================================================================
-        ** Return the number of allocated slots in this manager.
-        =========================================================================*/
-        internal int GetSlotTableLength()
-        {
-            return m_SlotInfoTable.Length;
-        }
-
-        private bool[] m_SlotInfoTable = new bool[InitialSlotTableSize];
-        private int m_FirstAvailableSlot;
-        private List<LocalDataStore> m_ManagedLocalDataStores = new List<LocalDataStore>();
-        private Dictionary<String, LocalDataStoreSlot> m_KeyToSlotMap = new Dictionary<String, LocalDataStoreSlot>();
-        private long m_CookieGenerator;
-    }
-}
diff --git a/src/mscorlib/src/System/cominterfaces.cs b/src/mscorlib/src/System/cominterfaces.cs
deleted file mode 100644 (file)
index a83943d..0000000
+++ /dev/null
@@ -1,40 +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.
-
-namespace System.Runtime.InteropServices
-{
-    [GuidAttribute("03973551-57A1-3900-A2B5-9083E3FF2943")]
-    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-    [CLSCompliant(false)]
-    [TypeLibImportClassAttribute(typeof(System.Activator))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public interface _Activator
-    {
-        void GetTypeInfoCount(out uint pcTInfo);
-
-        void GetTypeInfo(uint iTInfo, uint lcid, IntPtr ppTInfo);
-
-        void GetIDsOfNames([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId);
-
-        void Invoke(uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr);
-    }
-
-    [GuidAttribute("917B14D0-2D9E-38B8-92A9-381ACF52F7C0")]
-    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-    [CLSCompliant(false)]
-    [TypeLibImportClassAttribute(typeof(System.Attribute))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public interface _Attribute
-    {
-    }
-
-    [GuidAttribute("C281C7F1-4AA9-3517-961A-463CFED57E75")]
-    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
-    [CLSCompliant(false)]
-    [TypeLibImportClassAttribute(typeof(System.Threading.Thread))]
-    [System.Runtime.InteropServices.ComVisible(true)]
-    public interface _Thread
-    {
-    }
-}
index 46f4688..d0b78e9 100644 (file)
@@ -1795,10 +1795,17 @@ typedef struct _CONTEXT {
 
 typedef struct _KNONVOLATILE_CONTEXT_POINTERS {
 
-    // TODO WIP x86/Linux, need to fix this.
-    PDWORD Ebx;
-    PDWORD Esi;
+    // The ordering of these fields should be aligned with that
+    // of corresponding fields in CONTEXT
+    //
+    // (See FillRegDisplay in inc/regdisp.h for details)
     PDWORD Edi;
+    PDWORD Esi;
+    PDWORD Ebx;
+    PDWORD Edx;
+    PDWORD Ecx;
+    PDWORD Eax;
+
     PDWORD Ebp;
 
 } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
diff --git a/src/pal/tools/clang-compiler-override-arm.txt b/src/pal/tools/clang-compiler-override-arm.txt
new file mode 100644 (file)
index 0000000..da25715
--- /dev/null
@@ -0,0 +1,20 @@
+SET (CMAKE_C_FLAGS_INIT                "-Wall -std=c11")
+SET (CMAKE_C_FLAGS_DEBUG_INIT          "-g -O0")
+SET (CLR_C_FLAGS_CHECKED_INIT          "-g -O1")
+# Refer to the below instruction to support __thread with -O2/-O3 on Linux/ARM
+# https://github.com/dotnet/coreclr/blob/master/Documentation/building/linux-instructions.md
+SET (CMAKE_C_FLAGS_RELEASE_INIT        "-g -O1")
+SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-g -O1")
+
+SET (CMAKE_CXX_FLAGS_INIT                "-Wall -Wno-null-conversion -std=c++11")
+SET (CMAKE_CXX_FLAGS_DEBUG_INIT          "-g -O0")
+SET (CLR_CXX_FLAGS_CHECKED_INIT          "-g -O1")
+SET (CMAKE_CXX_FLAGS_RELEASE_INIT        "-g -O1")
+SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-g -O1")
+
+SET (CLR_DEFINES_DEBUG_INIT              DEBUG _DEBUG _DBG URTBLDENV_FRIENDLY=Checked BUILDENV_CHECKED=1)
+SET (CLR_DEFINES_CHECKED_INIT            DEBUG _DEBUG _DBG URTBLDENV_FRIENDLY=Checked BUILDENV_CHECKED=1)
+SET (CLR_DEFINES_RELEASE_INIT            NDEBUG URTBLDENV_FRIENDLY=Retail)
+SET (CLR_DEFINES_RELWITHDEBINFO_INIT     NDEBUG URTBLDENV_FRIENDLY=Retail)
+
+SET (CMAKE_INSTALL_PREFIX                $ENV{__CMakeBinDir})
index 5d4d4c8..db342eb 100755 (executable)
@@ -144,9 +144,15 @@ if [ "$build_arch" == "armel" ]; then
     cmake_extra_defines="$cmake_extra_defines -DARM_SOFTFP=1"
 fi
 
+if [ "$build_arch" == "arm" -o "$build_arch" == "armel" ]; then
+    overridefile=clang-compiler-override-arm.txt  
+else
+    overridefile=clang-compiler-override.txt  
+fi
+
 cmake \
   -G "$generator" \
-  "-DCMAKE_USER_MAKE_RULES_OVERRIDE=$1/src/pal/tools/clang-compiler-override.txt" \
+  "-DCMAKE_USER_MAKE_RULES_OVERRIDE=$1/src/pal/tools/$overridefile" \
   "-DCMAKE_AR=$llvm_ar" \
   "-DCMAKE_LINKER=$llvm_link" \
   "-DCMAKE_NM=$llvm_nm" \
index f4490ac..ca9e28e 100644 (file)
@@ -67,7 +67,6 @@ OOPStackUnwinderX86::VirtualUnwind(
     __deref_opt_out_opt PEXCEPTION_ROUTINE *HandlerRoutine
     )
 {
-    *EstablisherFrame = ContextRecord->Esp;
     if (HandlerRoutine != NULL)
     {
         *HandlerRoutine = NULL;
@@ -75,26 +74,14 @@ OOPStackUnwinderX86::VirtualUnwind(
 
     REGDISPLAY rd;
 
-    if (ContextPointers != NULL)
-    {
-#define CALLEE_SAVED_REGISTER(reg) rd.p##reg = ContextPointers->reg;
-        ENUM_CALLEE_SAVED_REGISTERS();
-#undef CALLEE_SAVED_REGISTER
-    }
-    else
-    {
-#define CALLEE_SAVED_REGISTER(reg) rd.p##reg = NULL;
-        ENUM_CALLEE_SAVED_REGISTERS();
-#undef CALLEE_SAVED_REGISTER
-    }
+    FillRegDisplay(&rd, ContextRecord);
 
-    if (rd.pEbp == NULL)
+    rd.PCTAddr = (UINT_PTR)&(ContextRecord->Eip);
+
+    if (ContextPointers)
     {
-        rd.pEbp = &(ContextRecord->Ebp);
+        rd.pCurrentContextPointers = ContextPointers;
     }
-    rd.SP = ContextRecord->Esp;
-    rd.ControlPC = (PCODE)(ContextRecord->Eip);
-    rd.PCTAddr = (UINT_PTR)&(ContextRecord->Eip);
 
     CodeManState codeManState;
     codeManState.dwIsSet = 0;
@@ -107,23 +94,23 @@ OOPStackUnwinderX86::VirtualUnwind(
         return HRESULT_FROM_WIN32(ERROR_READ_FAULT);
     }
 
-#define CALLEE_SAVED_REGISTER(reg) if (rd.p##reg != NULL) { ContextRecord->reg = *rd.p##reg; }
+    ContextRecord->ContextFlags |= CONTEXT_UNWOUND_TO_CALL;
+
+#define ARGUMENT_AND_SCRATCH_REGISTER(reg) if (rd.pCurrentContextPointers->reg) ContextRecord->reg = *rd.pCurrentContextPointers->reg;
+    ENUM_ARGUMENT_AND_SCRATCH_REGISTERS();
+#undef ARGUMENT_AND_SCRATCH_REGISTER
+
+#define CALLEE_SAVED_REGISTER(reg) if (rd.pCurrentContextPointers->reg) ContextRecord->reg = *rd.pCurrentContextPointers->reg;
     ENUM_CALLEE_SAVED_REGISTERS();
 #undef CALLEE_SAVED_REGISTER
-    
-    if (ContextPointers != NULL) 
-    {
-#define CALLEE_SAVED_REGISTER(reg) if (rd.p##reg != &(ContextRecord->reg)) { ContextPointers->reg = rd.p##reg; }
-        ENUM_CALLEE_SAVED_REGISTERS();
-#undef CALLEE_SAVED_REGISTER
-    }
-
-    ContextRecord->ContextFlags |= CONTEXT_UNWOUND_TO_CALL;
 
     ContextRecord->Esp = rd.SP;
     ContextRecord->Eip = rd.ControlPC;
-    ContextRecord->Ebp = *rd.pEbp;
 
+    // For x86, the value of Establisher Frame Pointer is Caller SP
+    //
+    // (Please refers to CLR ABI for details)
+    *EstablisherFrame = ContextRecord->Esp;
     return S_OK;
 }
 
index ab51eb5..8be965b 100644 (file)
@@ -2874,6 +2874,9 @@ void SystemDomain::LoadBaseSystemClasses()
 
 #ifdef FEATURE_SPAN_OF_T
     // Load ByReference class
+    //
+    // NOTE: ByReference<T> must be the first by-ref-like system type to be loaded,
+    //       because MethodTable::ClassifyEightBytesWithManagedLayout depends on it.
     g_pByReferenceClass = MscorlibBinder::GetClass(CLASS__BYREFERENCE);
 #endif
 
index e90217f..8a3fb4f 100644 (file)
@@ -201,7 +201,8 @@ public:
                     _ASSERTE(eightByteSize == 8);
                     _ASSERTE(IS_ALIGNED((SIZE_T)genRegDest, 8));
 
-                    (*fn)(dac_cast<PTR_PTR_Object>(genRegDest), sc, 0);
+                    uint32_t flags = eightByteClassification == SystemVClassificationTypeIntegerByRef ? GC_CALL_INTERIOR : 0;
+                    (*fn)(dac_cast<PTR_PTR_Object>(genRegDest), sc, flags);
                 }
 
                 genRegDest += eightByteSize;
index 50f0189..25e29e0 100644 (file)
@@ -373,10 +373,8 @@ FCFuncEnd()
 
 FCFuncStart(gTypedReferenceFuncs)
     FCFuncElement("InternalToObject", ReflectionInvocation::TypedReferenceToObject)
-#ifndef FEATURE_CORECLR
     FCFuncElement("InternalSetTypedReference", ReflectionInvocation::SetTypedReference)
     FCFuncElement("InternalMakeTypedReference", ReflectionInvocation::MakeTypedReference)
-#endif
 FCFuncEnd()
 
 FCFuncStart(gSystem_Type)
@@ -568,12 +566,8 @@ FCFuncEnd()
 FCFuncStart(gCOMFieldHandleNewFuncs)
     FCFuncElement("GetValue", RuntimeFieldHandle::GetValue)
     FCFuncElement("SetValue", RuntimeFieldHandle::SetValue)
-#ifndef FEATURE_CORECLR
     FCFuncElement("GetValueDirect", RuntimeFieldHandle::GetValueDirect)
-#endif
-#ifdef FEATURE_SERIALIZATION
     FCFuncElement("SetValueDirect", RuntimeFieldHandle::SetValueDirect)
-#endif
     FCFuncElement("GetName", RuntimeFieldHandle::GetName)
     FCFuncElement("_GetUtf8Name", RuntimeFieldHandle::GetUtf8Name)
     FCFuncElement("MatchesNameHash", RuntimeFieldHandle::MatchesNameHash)
@@ -1812,13 +1806,11 @@ FCFuncEnd()
 
 FCFuncStart(gVarArgFuncs)
     FCFuncElementSig(COR_CTOR_METHOD_NAME, &gsig_IM_IntPtr_PtrVoid_RetVoid, VarArgsNative::Init2)
-#ifndef FEATURE_CORECLR
     FCFuncElementSig(COR_CTOR_METHOD_NAME, &gsig_IM_IntPtr_RetVoid, VarArgsNative::Init)
     FCFuncElement("GetRemainingCount", VarArgsNative::GetRemainingCount)
     FCFuncElement("_GetNextArgType", VarArgsNative::GetNextArgType)
     FCFuncElement("FCallGetNextArg", VarArgsNative::DoGetNextArg)
     FCFuncElement("InternalGetNextArg", VarArgsNative::GetNextArg2)
-#endif // FEATURE_CORECLR
 FCFuncEnd()
 
 FCFuncStart(gMonitorFuncs)
index 11a4590..8db5396 100644 (file)
@@ -1642,10 +1642,10 @@ void *      getCalleeSavedReg(PREGDISPLAY pContext, regNum reg)
 
     switch (reg)
     {
-        case REGI_EBP: return pContext->pEbp;
-        case REGI_EBX: return pContext->pEbx;
-        case REGI_ESI: return pContext->pEsi;
-        case REGI_EDI: return pContext->pEdi;
+        case REGI_EBP: return pContext->GetEbpLocation();
+        case REGI_EBX: return pContext->GetEbxLocation();
+        case REGI_ESI: return pContext->GetEsiLocation();
+        case REGI_EDI: return pContext->GetEdiLocation();
 
         default: _ASSERTE(!"bad info.thisPtrResult"); return NULL;
     }
@@ -2840,7 +2840,9 @@ void    TRASH_CALLEE_UNSAVED_REGS(PREGDISPLAY pContext)
     /* This is not completely correct as we lose the current value, but
        it should not really be useful to anyone. */
     static DWORD s_badData = 0xDEADBEEF;
-    pContext->pEax = pContext->pEcx = pContext->pEdx = &s_badData;
+    pContext->SetEaxLocation(&s_badData);
+    pContext->SetEcxLocation(&s_badData);
+    pContext->SetEdxLocation(&s_badData);
 #endif //_DEBUG
 }
 
@@ -3126,9 +3128,11 @@ void EECodeManager::QuickUnwindStackFrame(PREGDISPLAY pRD, StackwalkCacheEntry *
     if (pCacheEntry->fUseEbpAsFrameReg)
     {
         _ASSERTE(pCacheEntry->fUseEbp);
+        TADDR curEBP = (TADDR)*pRD->GetEbpLocation();
+
         // EBP frame, update ESP through EBP, since ESPOffset may vary
-        pRD->pEbp = PTR_DWORD((TADDR)*pRD->pEbp);
-        pRD->SP = (TADDR)pRD->pEbp + sizeof(void*);
+        pRD->SetEbpLocation(PTR_DWORD(curEBP));
+        pRD->SP = curEBP + sizeof(void*);
     }
     else
     {
@@ -3203,13 +3207,32 @@ const RegMask CALLEE_SAVED_REGISTERS_MASK[] =
     RM_EBP  // last register to be pushed
 };
 
-const SIZE_T REGDISPLAY_OFFSET_OF_CALLEE_SAVED_REGISTERS[] =
+static void SetLocation(PREGDISPLAY pRD, int ind, PDWORD loc)
 {
-    offsetof(REGDISPLAY, pEdi), // first register to be pushed
-    offsetof(REGDISPLAY, pEsi),
-    offsetof(REGDISPLAY, pEbx),
-    offsetof(REGDISPLAY, pEbp)  // last register to be pushed
-};
+#ifdef WIN64EXCEPTIONS
+    static const SIZE_T OFFSET_OF_CALLEE_SAVED_REGISTERS[] =
+    {
+        offsetof(T_KNONVOLATILE_CONTEXT_POINTERS, Edi), // first register to be pushed
+        offsetof(T_KNONVOLATILE_CONTEXT_POINTERS, Esi),
+        offsetof(T_KNONVOLATILE_CONTEXT_POINTERS, Ebx),
+        offsetof(T_KNONVOLATILE_CONTEXT_POINTERS, Ebp), // last register to be pushed
+    };
+
+    SIZE_T offsetOfRegPtr = OFFSET_OF_CALLEE_SAVED_REGISTERS[ind];
+    *(LPVOID*)(PBYTE(pRD->pCurrentContextPointers) + offsetOfRegPtr) = loc;
+#else
+    static const SIZE_T OFFSET_OF_CALLEE_SAVED_REGISTERS[] =
+    {
+        offsetof(REGDISPLAY, pEdi), // first register to be pushed
+        offsetof(REGDISPLAY, pEsi),
+        offsetof(REGDISPLAY, pEbx),
+        offsetof(REGDISPLAY, pEbp), // last register to be pushed
+    };
+
+    SIZE_T offsetOfRegPtr = OFFSET_OF_CALLEE_SAVED_REGISTERS[ind];
+    *(LPVOID*)(PBYTE(pRD) + offsetOfRegPtr) = loc;
+#endif
+}
 
 /*****************************************************************************/
 
@@ -3275,8 +3298,7 @@ void UnwindEspFrameEpilog(
                Get the value from the stack if needed */
             if ((flags & UpdateAllRegs) || (regMask == RM_EBP))
             {
-                SIZE_T offsetOfRegPtr = REGDISPLAY_OFFSET_OF_CALLEE_SAVED_REGISTERS[i - 1];
-                *(LPVOID*)(PBYTE(pContext) + offsetOfRegPtr) = PTR_DWORD((TADDR)ESP);
+                SetLocation(pContext, i - 1, PTR_DWORD((TADDR)ESP));
             }
 
             /* Adjust ESP */
@@ -3381,7 +3403,7 @@ void UnwindEbpDoubleAlignFrameEpilog(
             unsigned calleeSavedRegsSize = info->savedRegsCountExclFP * sizeof(void*); 
 
             if (!InstructionAlreadyExecuted(offset, info->epilogOffs))
-                ESP = (*pContext->pEbp) - calleeSavedRegsSize;
+                ESP = *pContext->GetEbpLocation() - calleeSavedRegsSize;
             
             offset = SKIP_LEA_ESP_EBP(-int(calleeSavedRegsSize), epilogBase, offset);
         }
@@ -3399,8 +3421,7 @@ void UnwindEbpDoubleAlignFrameEpilog(
         {
             if (flags & UpdateAllRegs)
             {
-                SIZE_T offsetOfRegPtr = REGDISPLAY_OFFSET_OF_CALLEE_SAVED_REGISTERS[i - 1];
-                *(LPVOID*)(PBYTE(pContext) + offsetOfRegPtr) = PTR_DWORD((TADDR)ESP);
+                SetLocation(pContext, i - 1, PTR_DWORD((TADDR)ESP));
             }
             ESP += sizeof(void*);
         }
@@ -3411,7 +3432,7 @@ void UnwindEbpDoubleAlignFrameEpilog(
     if (needMovEspEbp)
     {
         if (!InstructionAlreadyExecuted(offset, info->epilogOffs))
-            ESP = *pContext->pEbp;
+            ESP = *pContext->GetEbpLocation();
             
         offset = SKIP_MOV_REG_REG(epilogBase, offset);
     }
@@ -3419,7 +3440,7 @@ void UnwindEbpDoubleAlignFrameEpilog(
     // Have we executed the pop EBP?
     if (!InstructionAlreadyExecuted(offset, info->epilogOffs))
     {
-        pContext->pEbp = PTR_DWORD(TADDR(ESP));
+        pContext->SetEbpLocation(PTR_DWORD(TADDR(ESP)));
         ESP += sizeof(void*);
     }
     offset = SKIP_POP_REG(epilogBase, offset);
@@ -3552,16 +3573,16 @@ void UnwindEspFrameProlog(
 
     // Always restore EBP
     if (regsMask & RM_EBP)
-        pContext->pEbp = savedRegPtr++;
+        pContext->SetEbpLocation(savedRegPtr++);
 
     if (flags & UpdateAllRegs)
     {
         if (regsMask & RM_EBX)
-            pContext->pEbx = savedRegPtr++;
+            pContext->SetEbxLocation(savedRegPtr++);
         if (regsMask & RM_ESI)
-            pContext->pEsi = savedRegPtr++;
+            pContext->SetEsiLocation(savedRegPtr++);
         if (regsMask & RM_EDI)
-            pContext->pEdi = savedRegPtr++;
+            pContext->SetEdiLocation(savedRegPtr++);
 
         TRASH_CALLEE_UNSAVED_REGS(pContext);
     }
@@ -3627,8 +3648,7 @@ void UnwindEspFrame(
             if ((regMask & regsMask) == 0)
                 continue;
             
-            SIZE_T offsetOfRegPtr = REGDISPLAY_OFFSET_OF_CALLEE_SAVED_REGISTERS[i - 1];
-            *(LPVOID*)(PBYTE(pContext) + offsetOfRegPtr) = PTR_DWORD((TADDR)ESP);
+            SetLocation(pContext, i - 1, PTR_DWORD((TADDR)ESP));
 
             ESP += sizeof(unsigned);
         }
@@ -3706,7 +3726,7 @@ void UnwindEbpDoubleAlignFrameProlog(
        can be determined using EBP. Since we are still in the prolog,
        we need to know our exact location to determine the callee-saved registers */
        
-    const unsigned curEBP = *pContext->pEbp;
+    const unsigned curEBP = *pContext->GetEbpLocation();
     
     if (flags & UpdateAllRegs)
     {        
@@ -3739,8 +3759,7 @@ void UnwindEbpDoubleAlignFrameProlog(
             
             if (InstructionAlreadyExecuted(offset, curOffs))
             {
-                SIZE_T offsetOfRegPtr = REGDISPLAY_OFFSET_OF_CALLEE_SAVED_REGISTERS[i];
-                *(LPVOID*)(PBYTE(pContext) + offsetOfRegPtr) = --pSavedRegs;
+                SetLocation(pContext, i, PTR_DWORD(--pSavedRegs));
             }
 
             // "push reg"
@@ -3752,7 +3771,7 @@ void UnwindEbpDoubleAlignFrameProlog(
     
     /* The caller's saved EBP is pointed to by our EBP */
 
-    pContext->pEbp = PTR_DWORD((TADDR)curEBP);
+    pContext->SetEbpLocation(PTR_DWORD((TADDR)curEBP));
     pContext->SP = DWORD((TADDR)(curEBP + sizeof(void *)));
     
     /* Stack pointer points to return address */
@@ -3776,7 +3795,7 @@ bool UnwindEbpDoubleAlignFrame(
     _ASSERTE(info->ebpFrame || info->doubleAlign);
 
     const unsigned curESP =  pContext->SP;
-    const unsigned curEBP = *pContext->pEbp;
+    const unsigned curEBP = *pContext->GetEbpLocation();
 
     /* First check if we are in a filter (which is obviously after the prolog) */
 
@@ -3819,8 +3838,13 @@ bool UnwindEbpDoubleAlignFrame(
             {
                 static DWORD s_badData = 0xDEADBEEF;
 
-                pContext->pEax = pContext->pEbx = pContext->pEcx =
-                pContext->pEdx = pContext->pEsi = pContext->pEdi = &s_badData;
+                pContext->SetEaxLocation(&s_badData);
+                pContext->SetEcxLocation(&s_badData);
+                pContext->SetEdxLocation(&s_badData);
+
+                pContext->SetEbxLocation(&s_badData);
+                pContext->SetEsiLocation(&s_badData);
+                pContext->SetEdiLocation(&s_badData);
             }
 #endif
 
@@ -3863,8 +3887,7 @@ bool UnwindEbpDoubleAlignFrame(
             if ((info->savedRegMask & regMask) == 0)
                 continue;
             
-            SIZE_T offsetOfRegPtr = REGDISPLAY_OFFSET_OF_CALLEE_SAVED_REGISTERS[i];
-            *(LPVOID*)(PBYTE(pContext) + offsetOfRegPtr) = --pSavedRegs;
+            SetLocation(pContext, i, --pSavedRegs);
         }
     }
 
@@ -3879,7 +3902,7 @@ bool UnwindEbpDoubleAlignFrame(
 
     /* The caller's saved EBP is pointed to by our EBP */
 
-    pContext->pEbp = PTR_DWORD((TADDR)curEBP);
+    pContext->SetEbpLocation(PTR_DWORD((TADDR)curEBP));
 
     return true;
 }
@@ -4118,7 +4141,7 @@ bool EECodeManager::EnumGcRefs( PREGDISPLAY     pContext,
     GCInfoToken gcInfoToken = pCodeInfo->GetGCInfoToken();
     unsigned  curOffs = pCodeInfo->GetRelOffset();
 
-    unsigned  EBP     = *pContext->pEbp;
+    unsigned  EBP     = *pContext->GetEbpLocation();
     unsigned  ESP     =  pContext->SP;
 
     unsigned  ptrOffs;
@@ -4185,7 +4208,7 @@ bool EECodeManager::EnumGcRefs( PREGDISPLAY     pContext,
             if (dspPtr)                                                 \
                 printf("    Live pointer register %s: ", #regName);     \
                 pCallBack(hCallBack,                                    \
-                          (OBJECTREF*)(pContext->p##regName),           \
+                          (OBJECTREF*)(pContext->Get##regName##Location()), \
                           (iptr ? GC_CALL_INTERIOR : 0)                 \
                           | CHECK_APP_DOMAIN                            \
                           DAC_ARG(DacSlotLocation(reg, 0, false)));     \
@@ -4194,7 +4217,7 @@ bool EECodeManager::EnumGcRefs( PREGDISPLAY     pContext,
 #define CHK_AND_REPORT_REG(reg, doIt, iptr, regName)                    \
         if  (doIt)                                                      \
                 pCallBack(hCallBack,                                    \
-                          (OBJECTREF*)(pContext->p##regName),           \
+                          (OBJECTREF*)(pContext->Get##regName##Location()), \
                           (iptr ? GC_CALL_INTERIOR : 0)                 \
                           | CHECK_APP_DOMAIN                            \
                           DAC_ARG(DacSlotLocation(reg, 0, false)));
@@ -5019,7 +5042,7 @@ OBJECTREF* EECodeManager::GetAddrOfSecurityObjectFromCachedInfo(PREGDISPLAY pRD,
     // We pretend that filters are ESP-based methods in UnwindEbpDoubleAlignFrame().
     // Hence we cannot enforce this assert.
     // _ASSERTE(stackwalkCacheUnwindInfo->fUseEbpAsFrameReg);
-    return (OBJECTREF *) (size_t) (DWORD(*pRD->pEbp) - (securityObjectOffset * sizeof(void*)));
+    return (OBJECTREF *) (size_t) (*pRD->GetEbpLocation() - (securityObjectOffset * sizeof(void*)));
 #else
     PORTABILITY_ASSERT("EECodeManager::GetAddrOfSecurityObjectFromContext is not implemented on this platform.");
     return NULL;
@@ -5059,7 +5082,7 @@ OBJECTREF* EECodeManager::GetAddrOfSecurityObject(CrawlFrame *pCF)
         if(stateBuf->hdrInfoBody.prologOffs == hdrInfo::NOT_IN_PROLOG &&
                 stateBuf->hdrInfoBody.epilogOffs == hdrInfo::NOT_IN_EPILOG)
         {
-            return (OBJECTREF *)(size_t)(((DWORD)*pRD->pEbp) - GetSecurityObjectOffset(&stateBuf->hdrInfoBody));
+            return (OBJECTREF *)(size_t)(*pRD->GetEbpLocation() - GetSecurityObjectOffset(&stateBuf->hdrInfoBody));
         }
     }
 #elif defined(USE_GC_INFO_DECODER) && !defined(CROSSGEN_COMPILE)
@@ -5161,7 +5184,7 @@ OBJECTREF EECodeManager::GetInstance( PREGDISPLAY    pContext,
     if (info.ebpFrame)
     {
         _ASSERTE(stackDepth == 0);
-        taArgBase = *pContext->pEbp;
+        taArgBase = *pContext->GetEbpLocation();
     }
     else
     {
index 04a1815..ae3cfdb 100644 (file)
@@ -2006,8 +2006,8 @@ BOOL MulticastFrame::TraceFrame(Thread *thread, BOOL fromPatch,
 
 #if defined(_TARGET_X86_)
     // At this point the counter hasn't been incremented yet.
-    delegateCount = *regs->pEdi + 1;
-    pbDel = *(BYTE **)( (size_t)*(regs->pEsi) + GetOffsetOfTransitionBlock() + ArgIterator::GetThisOffset());
+    delegateCount = *regs->GetEdiLocation() + 1;
+    pbDel = *(BYTE **)( (size_t)*regs->GetEsiLocation() + GetOffsetOfTransitionBlock() + ArgIterator::GetThisOffset());
 #elif defined(_TARGET_AMD64_)
     // At this point the counter hasn't been incremented yet.
     delegateCount = (int)regs->pCurrentContext->Rdi + 1;
index d5e7b60..02bb0de 100644 (file)
@@ -1565,10 +1565,10 @@ void DoGcStress (PCONTEXT regs, MethodDesc *pMD)
             
             _ASSERTE(pThread->PreemptiveGCDisabled());    // Epilogs should be in cooperative mode, no GC can happen right now. 
             bool gcHappened = gcCover->gcCount != GCHeapUtilities::GetGCHeap()->GetGcCount();
-            checkAndUpdateReg(gcCover->callerRegs.Edi, *regDisp.pEdi, gcHappened);
-            checkAndUpdateReg(gcCover->callerRegs.Esi, *regDisp.pEsi, gcHappened);
-            checkAndUpdateReg(gcCover->callerRegs.Ebx, *regDisp.pEbx, gcHappened);
-            checkAndUpdateReg(gcCover->callerRegs.Ebp, *regDisp.pEbp, gcHappened);
+            checkAndUpdateReg(gcCover->callerRegs.Edi, *regDisp.GetEdiLocation(), gcHappened);
+            checkAndUpdateReg(gcCover->callerRegs.Esi, *regDisp.GetEsiLocation(), gcHappened);
+            checkAndUpdateReg(gcCover->callerRegs.Ebx, *regDisp.GetEbxLocation(), gcHappened);
+            checkAndUpdateReg(gcCover->callerRegs.Ebp, *regDisp.GetEbpLocation(), gcHappened);
             
             gcCover->gcCount = GCHeapUtilities::GetGCHeap()->GetGcCount();
 
index 2c29d27..8a437f7 100644 (file)
@@ -154,6 +154,11 @@ typedef INT32 StackElemType;
 // This represents some of the FramedMethodFrame fields that are
 // stored at negative offsets.
 //--------------------------------------------------------------------
+#define ENUM_ARGUMENT_AND_SCRATCH_REGISTERS() \
+    ARGUMENT_AND_SCRATCH_REGISTER(Eax) \
+    ARGUMENT_AND_SCRATCH_REGISTER(Ecx) \
+    ARGUMENT_AND_SCRATCH_REGISTER(Edx)
+
 #define ENUM_CALLEE_SAVED_REGISTERS() \
     CALLEE_SAVED_REGISTER(Edi) \
     CALLEE_SAVED_REGISTER(Esi) \
index 85db84a..2bf2fb3 100644 (file)
@@ -60,6 +60,32 @@ extern "C" DWORD STDCALL GetSpecificCpuFeaturesAsm(DWORD *pInfo);
 
 void generate_noref_copy (unsigned nbytes, StubLinkerCPU* sl);
 
+#ifdef WIN64EXCEPTIONS
+void UpdateRegDisplayFromCalleeSavedRegisters(REGDISPLAY * pRD, CalleeSavedRegisters * regs)
+{
+    LIMITED_METHOD_CONTRACT;
+
+    T_CONTEXT * pContext = pRD->pCurrentContext;
+#define CALLEE_SAVED_REGISTER(regname) pContext->regname = regs->regname;
+    ENUM_CALLEE_SAVED_REGISTERS();
+#undef CALLEE_SAVED_REGISTER
+
+    KNONVOLATILE_CONTEXT_POINTERS * pContextPointers = pRD->pCurrentContextPointers;
+#define CALLEE_SAVED_REGISTER(regname) pContextPointers->regname = (DWORD*)&regs->regname;
+    ENUM_CALLEE_SAVED_REGISTERS();
+#undef CALLEE_SAVED_REGISTER
+}
+
+void ClearRegDisplayArgumentAndScratchRegisters(REGDISPLAY * pRD)
+{
+    LIMITED_METHOD_CONTRACT;
+
+#define ARGUMENT_AND_SCRATCH_REGISTER(regname) pRD->pCurrentContextPointers->regname = NULL;
+    ENUM_ARGUMENT_AND_SCRATCH_REGISTERS();
+#undef ARGUMENT_AND_SCRATCH_REGISTER
+}
+#endif // WIN64EXCEPTIONS
+
 #ifndef DACCESS_COMPILE
 
 //=============================================================================
@@ -214,10 +240,10 @@ void EHContext::Setup(PCODE resumePC, PREGDISPLAY regs)
 
     // EAX ECX EDX are scratch
     this->Esp  = regs->SP;
-    this->Ebx = *regs->pEbx;
-    this->Esi = *regs->pEsi;
-    this->Edi = *regs->pEdi;
-    this->Ebp = *regs->pEbp;
+    this->Ebx = *regs->GetEbxLocation();
+    this->Esi = *regs->GetEsiLocation();
+    this->Edi = *regs->GetEdiLocation();
+    this->Ebp = *regs->GetEbpLocation();
 
     this->Eip = (ULONG)(size_t)resumePC;
 }
@@ -246,15 +272,15 @@ void EHContext::UpdateFrame(PREGDISPLAY regs)
     // EAX ECX EDX are scratch. 
     // No need to update ESP as unwinder takes care of that for us
 
-    LOG((LF_EH, LL_INFO1000, "Updating saved EBX: *%p= %p\n", regs->pEbx, this->Ebx));
-    LOG((LF_EH, LL_INFO1000, "Updating saved ESI: *%p= %p\n", regs->pEsi, this->Esi));
-    LOG((LF_EH, LL_INFO1000, "Updating saved EDI: *%p= %p\n", regs->pEdi, this->Edi));
-    LOG((LF_EH, LL_INFO1000, "Updating saved EBP: *%p= %p\n", regs->pEbp, this->Ebp));
+    LOG((LF_EH, LL_INFO1000, "Updating saved EBX: *%p= %p\n", regs->GetEbxLocation(), this->Ebx));
+    LOG((LF_EH, LL_INFO1000, "Updating saved ESI: *%p= %p\n", regs->GetEsiLocation(), this->Esi));
+    LOG((LF_EH, LL_INFO1000, "Updating saved EDI: *%p= %p\n", regs->GetEdiLocation(), this->Edi));
+    LOG((LF_EH, LL_INFO1000, "Updating saved EBP: *%p= %p\n", regs->GetEbpLocation(), this->Ebp));
     
-    *regs->pEbx = this->Ebx;
-    *regs->pEsi = this->Esi;
-    *regs->pEdi = this->Edi;
-    *regs->pEbp = this->Ebp;
+    *regs->GetEbxLocation() = this->Ebx;
+    *regs->GetEsiLocation() = this->Esi;
+    *regs->GetEdiLocation() = this->Edi;
+    *regs->GetEbpLocation() = this->Ebp;
 }
 
 void TransitionFrame::UpdateRegDisplay(const PREGDISPLAY pRD)
@@ -294,13 +320,6 @@ void TransitionFrame::UpdateRegDisplayHelper(const PREGDISPLAY pRD, UINT cbStack
 
     CalleeSavedRegisters* regs = GetCalleeSavedRegisters();
 
-    // reset pContext; it's only valid for active (top-most) frame
-
-    pRD->pContext = NULL;
-
-#define CALLEE_SAVED_REGISTER(regname) pRD->p##regname = (DWORD*) &regs->regname;
-    ENUM_CALLEE_SAVED_REGISTERS();
-#undef CALLEE_SAVED_REGISTER
     pRD->PCTAddr = GetReturnAddressPtr();
 
 #ifdef WIN64EXCEPTIONS
@@ -311,20 +330,20 @@ void TransitionFrame::UpdateRegDisplayHelper(const PREGDISPLAY pRD, UINT cbStack
     pRD->pCurrentContext->Eip = *PTR_PCODE(pRD->PCTAddr);;
     pRD->pCurrentContext->Esp = GetSP();
 
-    T_CONTEXT * pContext = pRD->pCurrentContext;
-#define CALLEE_SAVED_REGISTER(regname) pContext->regname = regs->regname;
-    ENUM_CALLEE_SAVED_REGISTERS();
-#undef CALLEE_SAVED_REGISTER
-
-    KNONVOLATILE_CONTEXT_POINTERS * pContextPointers = pRD->pCurrentContextPointers;
-#define CALLEE_SAVED_REGISTER(regname) pContextPointers->regname = (DWORD*)&regs->regname;
-    ENUM_CALLEE_SAVED_REGISTERS();
-#undef CALLEE_SAVED_REGISTER
+    UpdateRegDisplayFromCalleeSavedRegisters(pRD, regs);
+    ClearRegDisplayArgumentAndScratchRegisters(pRD);
 
     SyncRegDisplayToCurrentContext(pRD);
 
 #else // WIN64EXCEPTIONS
 
+    // reset pContext; it's only valid for active (top-most) frame
+    pRD->pContext = NULL;
+
+#define CALLEE_SAVED_REGISTER(regname) pRD->p##regname = (DWORD*) &regs->regname;
+    ENUM_CALLEE_SAVED_REGISTERS();
+#undef CALLEE_SAVED_REGISTER
+
     pRD->ControlPC = *PTR_PCODE(pRD->PCTAddr);
     pRD->SP  = (DWORD)(pRD->PCTAddr + sizeof(TADDR) + cbStackPop);
 
@@ -350,6 +369,38 @@ void HelperMethodFrame::UpdateRegDisplay(const PREGDISPLAY pRD)
 
     LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK    HelperMethodFrame::UpdateRegDisplay cached ip:%p, sp:%p\n", m_MachState.GetRetAddr(), m_MachState.esp()));
 
+    pRD->PCTAddr = dac_cast<TADDR>(m_MachState.pRetAddr());
+
+#ifdef WIN64EXCEPTIONS
+
+    pRD->IsCallerContextValid = FALSE;
+    pRD->IsCallerSPValid      = FALSE;        // Don't add usage of this field.  This is only temporary.
+
+#ifdef DACCESS_COMPILE
+    PORTABILITY_ASSERT("HelperMethodFrame::UpdateRegDisplay");
+#endif // DACCESS_COMPILE
+
+    pRD->pCurrentContext->Eip = pRD->ControlPC = m_MachState.GetRetAddr();
+    pRD->pCurrentContext->Esp = pRD->SP = (DWORD) m_MachState.esp();
+
+#define CALLEE_SAVED_REGISTER(regname) pRD->pCurrentContext->regname = *((DWORD*) m_MachState.p##regname());
+    ENUM_CALLEE_SAVED_REGISTERS();
+#undef CALLEE_SAVED_REGISTER
+
+#define CALLEE_SAVED_REGISTER(regname) pRD->pCurrentContextPointers->regname = (DWORD*) m_MachState.p##regname();
+    ENUM_CALLEE_SAVED_REGISTERS();
+#undef CALLEE_SAVED_REGISTER
+
+    //
+    // Clear all knowledge of scratch registers.  We're skipping to any
+    // arbitrary point on the stack, and frames aren't required to preserve or
+    // keep track of these anyways.
+    //
+
+    ClearRegDisplayArgumentAndScratchRegisters(pRD);
+
+#else // WIN64EXCEPTIONS
+
     // reset pContext; it's only valid for active (top-most) frame
     pRD->pContext = NULL;
 
@@ -391,15 +442,12 @@ void HelperMethodFrame::UpdateRegDisplay(const PREGDISPLAY pRD)
         // in the real code.  I'm not sure exactly
         // what should happen in the on-the-fly case,
         // but go with what would happen from an InsureInit.
-#ifdef WIN64EXCEPTIONS
-        PORTABILITY_ASSERT("HelperMethodFrame::UpdateRegDisplay");
-#endif
 
         RETURN;
     }
 
 #endif // #ifdef DACCESS_COMPILE
-    
+
     // DACCESS: The MachState pointers are kept as PTR_TADDR so
     // the host pointers here refer to the appropriate size and
     // these casts are not a problem.
@@ -407,27 +455,10 @@ void HelperMethodFrame::UpdateRegDisplay(const PREGDISPLAY pRD)
     pRD->pEsi = (DWORD*) m_MachState.pEsi();
     pRD->pEbx = (DWORD*) m_MachState.pEbx();
     pRD->pEbp = (DWORD*) m_MachState.pEbp();
-    pRD->PCTAddr = dac_cast<TADDR>(m_MachState.pRetAddr());
+
     pRD->ControlPC = m_MachState.GetRetAddr();
     pRD->SP  = (DWORD) m_MachState.esp();
 
-#ifdef WIN64EXCEPTIONS
-    pRD->IsCallerContextValid = FALSE;
-    pRD->IsCallerSPValid      = FALSE;        // Don't add usage of this field.  This is only temporary.
-
-    //
-    // Copy the saved state from the frame to the current context.
-    //
-    pRD->pCurrentContext->Eip = pRD->ControlPC;
-    pRD->pCurrentContext->Esp = pRD->SP;
-
-#define CALLEE_SAVED_REGISTER(regname) pRD->pCurrentContext->regname = *pRD->p##regname;
-    ENUM_CALLEE_SAVED_REGISTERS();
-#undef CALLEE_SAVED_REGISTER
-
-#define CALLEE_SAVED_REGISTER(regname) pRD->pCurrentContextPointers->regname = pRD->p##regname;
-    ENUM_CALLEE_SAVED_REGISTERS();
-#undef CALLEE_SAVED_REGISTER
 #endif // WIN64EXCEPTIONS
 
     RETURN;
@@ -563,34 +594,36 @@ void FaultingExceptionFrame::UpdateRegDisplay(const PREGDISPLAY pRD)
     // reset pContext; it's only valid for active (top-most) frame
     pRD->pContext = NULL;
 
-#ifndef WIN64EXCEPTIONS
-    CalleeSavedRegisters* regs = GetCalleeSavedRegisters();
-
-#define CALLEE_SAVED_REGISTER(regname) pRD->p##regname = (DWORD*) &regs->regname;
-    ENUM_CALLEE_SAVED_REGISTERS();
-#undef CALLEE_SAVED_REGISTER
-    pRD->SP = m_Esp;
     pRD->PCTAddr = GetReturnAddressPtr();
-    pRD->ControlPC = *PTR_PCODE(pRD->PCTAddr);
-
-#else // WIN64EXCEPTIONS
 
-    pRD->IsCallerContextValid = FALSE;
-    pRD->IsCallerSPValid = FALSE;        // Don't add usage of this field.  This is only temporary.
+#ifdef WIN64EXCEPTIONS
 
     memcpy(pRD->pCurrentContext, &m_ctx, sizeof(CONTEXT));
 
+    pRD->SP = m_ctx.Esp;
+    pRD->ControlPC = m_ctx.Eip;
+
+#define ARGUMENT_AND_SCRATCH_REGISTER(regname) pRD->pCurrentContextPointers->regname = &m_ctx.regname;
+    ENUM_ARGUMENT_AND_SCRATCH_REGISTERS();
+#undef ARGUMENT_AND_SCRATCH_REGISTER
+
 #define CALLEE_SAVED_REGISTER(regname) pRD->pCurrentContextPointers->regname = &m_ctx.regname;
     ENUM_CALLEE_SAVED_REGISTERS();
 #undef CALLEE_SAVED_REGISTER
 
-#define CALLEE_SAVED_REGISTER(regname) pRD->p##regname = &m_ctx.regname;
+    pRD->IsCallerContextValid = FALSE;
+    pRD->IsCallerSPValid = FALSE;        // Don't add usage of this field.  This is only temporary.
+
+#else // WIN64EXCEPTIONS
+
+    CalleeSavedRegisters* regs = GetCalleeSavedRegisters();
+
+#define CALLEE_SAVED_REGISTER(regname) pRD->p##regname = (DWORD*) &regs->regname;
     ENUM_CALLEE_SAVED_REGISTERS();
 #undef CALLEE_SAVED_REGISTER
 
-    pRD->SP = m_ctx.Esp;
-    pRD->PCTAddr = GetReturnAddressPtr();
-    pRD->ControlPC = m_ctx.Eip;
+    pRD->SP = m_Esp;
+    pRD->ControlPC = *PTR_PCODE(pRD->PCTAddr);
 
 #endif // WIN64EXCEPTIONS
 
@@ -638,36 +671,41 @@ void InlinedCallFrame::UpdateRegDisplay(const PREGDISPLAY pRD)
         stackArgSize = pMD->GetStackArgumentSize();
     }
 
-    // reset pContext; it's only valid for active (top-most) frame
-    pRD->pContext = NULL;
-
-
-    pRD->pEbp = (DWORD*) &m_pCalleeSavedFP;
-
     /* The return address is just above the "ESP" */
     pRD->PCTAddr = PTR_HOST_MEMBER_TADDR(InlinedCallFrame, this,
                                          m_pCallerReturnAddress);
-    pRD->ControlPC = *PTR_PCODE(pRD->PCTAddr);
-
-    /* Now we need to pop off the outgoing arguments */
-    pRD->SP  = (DWORD) dac_cast<TADDR>(m_pCallSiteSP) + stackArgSize;
 
 #ifdef WIN64EXCEPTIONS
+
     pRD->IsCallerContextValid = FALSE;
     pRD->IsCallerSPValid      = FALSE;        // Don't add usage of this field.  This is only temporary.
 
-    pRD->pCurrentContext->Eip = pRD->ControlPC;
-    pRD->pCurrentContext->Esp = pRD->SP;
-    pRD->pCurrentContext->Ebp = *pRD->pEbp;
+    pRD->pCurrentContext->Eip = *PTR_PCODE(pRD->PCTAddr);
+    pRD->pCurrentContext->Esp = (DWORD) dac_cast<TADDR>(m_pCallSiteSP) + stackArgSize;
+    pRD->pCurrentContext->Ebp = (DWORD) m_pCalleeSavedFP;
+
+    ClearRegDisplayArgumentAndScratchRegisters(pRD);
 
 #define CALLEE_SAVED_REGISTER(regname) pRD->pCurrentContextPointers->regname = NULL;
     ENUM_CALLEE_SAVED_REGISTERS();
 #undef CALLEE_SAVED_REGISTER
 
-    pRD->pCurrentContextPointers->Ebp = pRD->pEbp;
+    pRD->pCurrentContextPointers->Ebp = (DWORD*) &m_pCalleeSavedFP;
 
     SyncRegDisplayToCurrentContext(pRD);
-#endif
+
+#else // WIN64EXCEPTIONS
+
+    // reset pContext; it's only valid for active (top-most) frame
+    pRD->pContext = NULL;
+
+    pRD->pEbp = (DWORD*) &m_pCalleeSavedFP;
+
+    pRD->ControlPC = *PTR_PCODE(pRD->PCTAddr);
+    /* Now we need to pop off the outgoing arguments */
+    pRD->SP  = (DWORD) dac_cast<TADDR>(m_pCallSiteSP) + stackArgSize;
+
+#endif // WIN64EXCEPTIONS
 
     LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK    InlinedCallFrame::UpdateRegDisplay(ip:%p, sp:%p)\n", pRD->ControlPC, pRD->SP));
 
@@ -696,12 +734,33 @@ void ResumableFrame::UpdateRegDisplay(const PREGDISPLAY pRD)
     }
     CONTRACT_END;
 
+    pRD->PCTAddr = dac_cast<TADDR>(m_Regs) + offsetof(CONTEXT, Eip);
+
+#ifdef WIN64EXCEPTIONS
+
+    memcpy(pRD->pCurrentContext, &m_Regs, sizeof(CONTEXT));
+
+    pRD->SP = m_Regs->Esp;
+    pRD->ControlPC = m_Regs->Eip;
+
+#define ARGUMENT_AND_SCRATCH_REGISTER(reg) pRD->pCurrentContextPointers->reg = &m_Regs->reg;
+    ENUM_ARGUMENT_AND_SCRATCH_REGISTERS();
+#undef ARGUMENT_AND_SCRATCH_REGISTER
+
+#define CALLEE_SAVED_REGISTER(reg) pRD->pCurrentContextPointers->reg = &m_Regs->reg;
+    ENUM_CALLEE_SAVED_REGISTERS();
+#undef CALLEE_SAVED_REGISTER
+
+    pRD->IsCallerContextValid = FALSE;
+    pRD->IsCallerSPValid      = FALSE;        // Don't add usage of this field.  This is only temporary.
+
+#else // WIN64EXCEPTIONS
+
     // reset pContext; it's only valid for active (top-most) frame
     pRD->pContext = NULL;
 
     CONTEXT* pUnwoundContext = m_Regs;
 
-#ifndef WIN64EXCEPTIONS
 #if !defined(DACCESS_COMPILE)
     // "pContextForUnwind" field is only used on X86 since not only is it initialized just for it,
     // but its used only under the confines of STACKWALKER_MAY_POP_FRAMES preprocessor define,
@@ -721,7 +780,6 @@ void ResumableFrame::UpdateRegDisplay(const PREGDISPLAY pRD)
         pUnwoundContext->Eip = m_Regs->Eip;
     }
 #endif // !defined(DACCESS_COMPILE)
-#endif // !WIN64EXCEPTIONS
 
     pRD->pEax = &pUnwoundContext->Eax;
     pRD->pEcx = &pUnwoundContext->Ecx;
@@ -733,10 +791,11 @@ void ResumableFrame::UpdateRegDisplay(const PREGDISPLAY pRD)
     pRD->pEbp = &pUnwoundContext->Ebp;
 
     pRD->ControlPC = pUnwoundContext->Eip;
-    pRD->PCTAddr = dac_cast<TADDR>(m_Regs) + offsetof(CONTEXT, Eip);
 
     pRD->SP  = m_Regs->Esp;
 
+#endif // !WIN64EXCEPTIONS
+
     RETURN;
 }
 
@@ -751,6 +810,34 @@ void HijackFrame::UpdateRegDisplay(const PREGDISPLAY pRD)
     }
     CONTRACTL_END;
 
+    pRD->PCTAddr = dac_cast<TADDR>(m_Args) + offsetof(HijackArgs, Eip);
+
+#ifdef WIN64EXCEPTIONS
+
+    pRD->IsCallerContextValid = FALSE;
+    pRD->IsCallerSPValid      = FALSE;        // Don't add usage of this field.  This is only temporary.
+
+    pRD->pCurrentContext->Eip = *PTR_PCODE(pRD->PCTAddr);
+    pRD->pCurrentContext->Esp = (DWORD)(pRD->PCTAddr + sizeof(TADDR));
+
+#define CALLEE_SAVED_REGISTER(reg) pRD->pCurrentContext->reg = m_Args->reg;
+    ENUM_CALLEE_SAVED_REGISTERS();
+#undef CALLEE_SAVED_REGISTER
+
+#define CALLEE_SAVED_REGISTER(reg) pRD->pCurrentContextPointers->reg = NULL;
+    ENUM_CALLEE_SAVED_REGISTERS();
+#undef CALLEE_SAVED_REGISTER
+
+#define ARGUMENT_AND_SCRATCH_REGISTER(reg) pRD->pCurrentContextPointers->reg = NULL;
+    ENUM_ARGUMENT_AND_SCRATCH_REGISTERS();
+#undef ARGUMENT_AND_SCRATCH_REGISTER
+
+    pRD->pCurrentContextPointers->Eax = (PDWORD) &m_Args->Eax;
+
+    SyncRegDisplayToCurrentContext(pRD);
+
+#else // WIN64EXCEPTIONS
+
     // This only describes the top-most frame
     pRD->pContext = NULL;
 
@@ -762,9 +849,10 @@ void HijackFrame::UpdateRegDisplay(const PREGDISPLAY pRD)
     pRD->pEax = &m_Args->Eax;
 
     pRD->pEbp = &m_Args->Ebp;
-    pRD->PCTAddr = dac_cast<TADDR>(m_Args) + offsetof(HijackArgs, Eip);
     pRD->ControlPC = *PTR_PCODE(pRD->PCTAddr);
     pRD->SP  = (DWORD)(pRD->PCTAddr + sizeof(TADDR));
+
+#endif // WIN64EXCEPTIONS
 }
 
 #endif  // FEATURE_HIJACK
@@ -801,15 +889,34 @@ void TailCallFrame::UpdateRegDisplay(const PREGDISPLAY pRD)
 
     // reset pContext; it's only valid for active (top-most) frame
     pRD->pContext = NULL;
+    pRD->PCTAddr = GetReturnAddressPtr();
+
+#ifdef WIN64EXCEPTIONS
+
+    pRD->IsCallerContextValid = FALSE;
+    pRD->IsCallerSPValid      = FALSE;        // Don't add usage of this field.  This is only temporary.
+
+    pRD->pCurrentContext->Eip = *PTR_PCODE(pRD->PCTAddr);
+    pRD->pCurrentContext->Esp = (DWORD)(pRD->PCTAddr + sizeof(TADDR));
+
+    UpdateRegDisplayFromCalleeSavedRegisters(pRD, &m_regs);
+    ClearRegDisplayArgumentAndScratchRegisters(pRD);
+
+    SyncRegDisplayToCurrentContext(pRD);
+
+#else
 
 #define CALLEE_SAVED_REGISTER(regname) pRD->p##regname = (DWORD*) &m_regs.regname;
     ENUM_CALLEE_SAVED_REGISTERS();
 #undef CALLEE_SAVED_REGISTER
 
-    pRD->PCTAddr = GetReturnAddressPtr();
     pRD->ControlPC = *PTR_PCODE(pRD->PCTAddr);
     pRD->SP  = (DWORD)(pRD->PCTAddr + sizeof(TADDR));
 
+#endif
+
+    LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK    TransitionFrame::UpdateRegDisplay(ip:%p, sp:%p)\n", pRD->ControlPC, pRD->SP));
+
     RETURN;
 }
 
index 52a2ce4..6fee50b 100644 (file)
@@ -2404,6 +2404,12 @@ bool MethodTable::ClassifyEightBytesWithManagedLayout(SystemVStructRegisterPassi
     FieldDesc *pField = GetApproxFieldDescListRaw();
     FieldDesc *pFieldEnd = pField + numIntroducedFields;
 
+    // System types are loaded before others, so ByReference<T> would be loaded before Span<T> or any other type that has a
+    // ByReference<T> field. ByReference<T> is the first by-ref-like system type to be loaded (see
+    // SystemDomain::LoadBaseSystemClasses), so if the current method table is marked as by-ref-like and g_pByReferenceClass is
+    // null, it must be the initial load of ByReference<T>.
+    bool isThisByReferenceOfT = IsByRefLike() && (g_pByReferenceClass == nullptr || HasSameTypeDefAs(g_pByReferenceClass));
+
     for (; pField < pFieldEnd; pField++)
     {
 #ifdef _DEBUG
@@ -2425,7 +2431,19 @@ bool MethodTable::ClassifyEightBytesWithManagedLayout(SystemVStructRegisterPassi
 
         CorElementType fieldType = pField->GetFieldType();
 
-        SystemVClassificationType fieldClassificationType = CorInfoType2UnixAmd64Classification(fieldType);
+        SystemVClassificationType fieldClassificationType;
+        if (isThisByReferenceOfT)
+        {
+            // ByReference<T> is a special type whose single IntPtr field holds a by-ref potentially interior pointer to GC
+            // memory, so classify its field as such
+            _ASSERTE(numIntroducedFields == 1);
+            _ASSERTE(fieldType == CorElementType::ELEMENT_TYPE_I);
+            fieldClassificationType = SystemVClassificationTypeIntegerByRef;
+        }
+        else
+        {
+            fieldClassificationType = CorInfoType2UnixAmd64Classification(fieldType);
+        }
 
 #ifdef _DEBUG
         LPCUTF8 fieldName;
index 6a50c62..da66dbd 100644 (file)
@@ -7411,7 +7411,7 @@ Loop:
                 REGDISPLAY rd;
                 ZeroMemory(&rd, sizeof(rd));
 
-                rd.pEbp = &ctxCur.Ebp;
+                rd.SetEbpLocation(&ctxCur.Ebp);
                 rd.SP = ctxCur.Esp;
                 rd.ControlPC = ctxCur.Eip;
 
@@ -7422,7 +7422,7 @@ Loop:
                     &codeManState, 
                     NULL);
 
-                ctxCur.Ebp = *(rd.pEbp);
+                ctxCur.Ebp = *rd.GetEbpLocation();
                 ctxCur.Esp = rd.SP;
                 ctxCur.Eip = rd.ControlPC;
             }
index 2c2c4f4..b9955ec 100644 (file)
@@ -5028,20 +5028,18 @@ void ReportPointersFromValueTypeArg(promote_func *fn, ScanContext *sc, PTR_Metho
 {
     WRAPPER_NO_CONTRACT;
 
-    if(pMT->ContainsPointers())
+    if (!pMT->ContainsPointers() && !pMT->IsByRefLike())
     {
-#if defined(UNIX_AMD64_ABI) && defined(FEATURE_UNIX_AMD64_STRUCT_PASSING)    
-        if (pSrc->IsStructPassedInRegs())
-        {
-            pSrc->ReportPointersFromStructInRegisters(fn, sc, pMT->GetNumInstanceFieldBytes());
-            return;
-        }
-#endif // UNIX_AMD64_ABI && FEATURE_UNIX_AMD64_STRUCT_PASSING
+        return;
     }
-    else if (!pMT->IsByRefLike())
+
+#if defined(UNIX_AMD64_ABI) && defined(FEATURE_UNIX_AMD64_STRUCT_PASSING)    
+    if (pSrc->IsStructPassedInRegs())
     {
+        pSrc->ReportPointersFromStructInRegisters(fn, sc, pMT->GetNumInstanceFieldBytes());
         return;
     }
+#endif // UNIX_AMD64_ABI && FEATURE_UNIX_AMD64_STRUCT_PASSING
 
     ReportPointersFromValueType(fn, sc, pMT, pSrc->GetDestinationAddress());
 }
index 2cac5d9..9e7f9fc 100644 (file)
 #include "interpreter.h"
 #endif // FEATURE_INTERPRETER
 
+#ifdef WIN64EXCEPTIONS
+#define PROCESS_EXPLICIT_FRAME_BEFORE_MANAGED_FRAME
+#endif
+
 #ifdef _DEBUG
 void* forceFrame;   // Variable used to force a local variable to the frame
 #endif
@@ -1343,7 +1347,7 @@ BOOL StackFrameIterator::ResetRegDisp(PREGDISPLAY pRegDisp,
     {
         TADDR curSP = GetRegdisplaySP(m_crawl.pRD);
 
-#if !defined(_TARGET_X86_)
+#ifdef PROCESS_EXPLICIT_FRAME_BEFORE_MANAGED_FRAME
         if (m_crawl.IsFrameless())
         {
             // On 64-bit and ARM, we stop at the explicit frames contained in a managed stack frame 
@@ -1351,7 +1355,7 @@ BOOL StackFrameIterator::ResetRegDisp(PREGDISPLAY pRegDisp,
             EECodeManager::EnsureCallerContextIsValid(m_crawl.pRD, NULL);
             curSP = GetSP(m_crawl.pRD->pCallerContext);
         }
-#endif // !_TARGET_X86_
+#endif // PROCESS_EXPLICIT_FRAME_BEFORE_MANAGED_FRAME
 
 #if defined(_TARGET_X86_)
         // special processing on x86; see below for more information
@@ -2368,7 +2372,7 @@ StackWalkAction StackFrameIterator::NextRaw(void)
         }
         else
         {
-#if defined(_TARGET_X86_)
+#ifndef PROCESS_EXPLICIT_FRAME_BEFORE_MANAGED_FRAME
             // On x86, we process a managed stack frame before processing any explicit frames contained in it.
             // So when we are done with the skipped explicit frame, we have already processed the managed
             // stack frame, and it is time to move onto the next stack frame.
@@ -2377,7 +2381,7 @@ StackWalkAction StackFrameIterator::NextRaw(void)
             {
                 goto Cleanup;
             }
-#else // _TARGET_X86_
+#else // !PROCESS_EXPLICIT_FRAME_BEFORE_MANAGED_FRAME
             // We are done handling the skipped explicit frame at this point.  So move on to the 
             // managed stack frame.
             m_crawl.isFrameless = true;
@@ -2387,7 +2391,7 @@ StackWalkAction StackFrameIterator::NextRaw(void)
 
             PreProcessingForManagedFrames();
             goto Cleanup;
-#endif // _TARGET_X86_
+#endif // PROCESS_EXPLICIT_FRAME_BEFORE_MANAGED_FRAME
         }
     }
     else if (m_frameState == SFITER_FRAMELESS_METHOD)
@@ -2572,14 +2576,14 @@ StackWalkAction StackFrameIterator::NextRaw(void)
         m_crawl.hasFaulted    = FALSE;
         m_crawl.isIPadjusted  = FALSE;
 
-#if defined(_TARGET_X86_)
+#ifndef PROCESS_EXPLICIT_FRAME_BEFORE_MANAGED_FRAME
         // remember, x86 handles the managed stack frame before the explicit frames contained in it
         if (CheckForSkippedFrames())
         {
             _ASSERTE(m_frameState == SFITER_SKIPPED_FRAME_FUNCTION);
             goto Cleanup;
         }
-#endif // _TARGET_X86_
+#endif // !PROCESS_EXPLICIT_FRAME_BEFORE_MANAGED_FRAME
 
         PostProcessingForManagedFrames();
         if (m_frameState == SFITER_NATIVE_MARKER_FRAME)
@@ -2966,7 +2970,7 @@ void StackFrameIterator::ProcessCurrentFrame(void)
             // Cache values which may be updated by CheckForSkippedFrames()
             m_cachedCodeInfo = m_crawl.codeInfo;
 
-#if !defined(_TARGET_X86_)
+#ifdef PROCESS_EXPLICIT_FRAME_BEFORE_MANAGED_FRAME
             // On non-X86, we want to process the skipped explicit frames before the managed stack frame
             // containing them.
             if (CheckForSkippedFrames())
@@ -2974,7 +2978,7 @@ void StackFrameIterator::ProcessCurrentFrame(void)
                 _ASSERTE(m_frameState == SFITER_SKIPPED_FRAME_FUNCTION);
             }
             else
-#endif // !_TARGET_X86_
+#endif // PROCESS_EXPLICIT_FRAME_BEFORE_MANAGED_FRAME
             {
                 PreProcessingForManagedFrames();
                 _ASSERTE(m_frameState == SFITER_FRAMELESS_METHOD);
@@ -3021,9 +3025,9 @@ BOOL StackFrameIterator::CheckForSkippedFrames(void)
     // Can the caller handle skipped frames;
     fHandleSkippedFrames = (m_flags & HANDLESKIPPEDFRAMES);
 
-#if defined(_TARGET_X86_)
+#ifndef PROCESS_EXPLICIT_FRAME_BEFORE_MANAGED_FRAME
     pvReferenceSP = GetRegdisplaySP(m_crawl.pRD);
-#else // _TARGET_X86_
+#else // !PROCESS_EXPLICIT_FRAME_BEFORE_MANAGED_FRAME
     // Order the Frames relative to the caller SP of the methods
     // this makes it so that any Frame that is in a managed call
     // frame will be reported before its containing method.
@@ -3031,7 +3035,7 @@ BOOL StackFrameIterator::CheckForSkippedFrames(void)
     // This should always succeed!  If it doesn't, it's a bug somewhere else!
     EECodeManager::EnsureCallerContextIsValid(m_crawl.pRD, m_crawl.GetStackwalkCacheEntry(), &m_cachedCodeInfo);
     pvReferenceSP = GetSP(m_crawl.pRD->pCallerContext);
-#endif // _TARGET_X86_
+#endif // PROCESS_EXPLICIT_FRAME_BEFORE_MANAGED_FRAME
 
     if ( !( (m_crawl.pFrame != FRAME_TOP) && 
             (dac_cast<TADDR>(m_crawl.pFrame) < pvReferenceSP) )
index 682ed74..655b3ea 100644 (file)
@@ -1,10 +1,10 @@
 {
   "dependencies": {
-    "Microsoft.NETCore.ILAsm": "2.0.0-beta-24930-03",
-    "Microsoft.NETCore.ILDAsm": "2.0.0-beta-24930-03",
-    "Microsoft.NETCore.Jit": "2.0.0-beta-24930-03",
-    "Microsoft.NETCore.Runtime.CoreCLR": "2.0.0-beta-24930-03",
-    "Microsoft.NETCore.TestHost": "2.0.0-beta-24930-03"
+    "Microsoft.NETCore.ILAsm": "2.0.0-beta-25002-03",
+    "Microsoft.NETCore.ILDAsm": "2.0.0-beta-25002-03",
+    "Microsoft.NETCore.Jit": "2.0.0-beta-25002-03",
+    "Microsoft.NETCore.Runtime.CoreCLR": "2.0.0-beta-25002-03",
+    "Microsoft.NETCore.TestHost": "2.0.0-beta-25002-03"
   },
   "frameworks": {
     "netcoreapp1.1": {
index 1954111..cc74ba8 100644 (file)
@@ -8,9 +8,13 @@
     "win7-x86": {},
     "win7-x64": {},
     "ubuntu.14.04-x64": {},
+    "ubuntu.16.04-x64": {},
+    "ubuntu.16.10-x64": {},
     "osx.10.10-x64": {},
     "centos.7-x64": {},
     "rhel.7-x64": {},
-    "debian.8-x64": {}
+    "debian.8-x64": {},
+    "fedora.23-x64": {},
+    "opensuse.13.2-x64": {}
   }
 }
index 5264c5c..fb63625 100644 (file)
@@ -5,7 +5,7 @@
     "emitEntryPoint": true
   },
   "dependencies": {
-    "Microsoft.NETCore.Platforms": "2.0.0-beta-24931-02",
+    "Microsoft.NETCore.Platforms": "2.0.0-beta-25001-02",
     "Microsoft.NETCore.Targets": "1.2.0-beta-24913-02",
     "System.Threading.Thread": "4.4.0-beta-24913-02",
     "System.Collections": "4.4.0-beta-24913-02",
@@ -64,7 +64,7 @@
   "frameworks": {
     "netcoreapp1.1": {
       "dependencies": {
-        "Microsoft.NETCore.Runtime.CoreCLR": "2.0.0-beta-24930-03"
+        "Microsoft.NETCore.Runtime.CoreCLR": "2.0.0-beta-25002-03"
       }
     }
   },
index 3786e51..1a15cca 100644 (file)
@@ -1,6 +1,6 @@
 {
   "dependencies": {
-    "Microsoft.TargetingPack.Private.CoreCLR": "2.0.0-beta-24930-03"
+    "Microsoft.TargetingPack.Private.CoreCLR": "2.0.0-beta-25002-03"
   },
   "frameworks": {
     "netcoreapp1.1": {
     "win7-x86": {},
     "win7-x64": {},
     "ubuntu.14.04-x64": {},
+    "ubuntu.16.04-x64": {},
+    "ubuntu.16.10-x64": {},
     "osx.10.10-x64": {},
     "centos.7-x64": {},
     "rhel.7-x64": {},
-    "debian.8-x64": {}
+    "debian.8-x64": {},
+    "fedora.23-x64": {},
+    "opensuse.13.2-x64": {}
   }
 }
index 536399e..869d518 100644 (file)
@@ -9,7 +9,7 @@
     "Microsoft.DotNet.xunit.performance.runner.Windows": "1.0.0-alpha-build0040",
     "Microsoft.Win32.Primitives": "4.4.0-beta-24913-02",
     "Newtonsoft.Json": "8.0.3",
-    "Microsoft.NETCore.Platforms": "2.0.0-beta-24931-02",
+    "Microsoft.NETCore.Platforms": "2.0.0-beta-25001-02",
     "Microsoft.NETCore.Targets": "1.2.0-beta-24913-02",
     "System.Collections.Immutable": "1.4.0-beta-24913-02",
     "System.Threading.Thread": "4.4.0-beta-24913-02",
     "win7-x86": {},
     "win7-x64": {},
     "ubuntu.14.04-x64": {},
+    "ubuntu.16.04-x64": {},
+    "ubuntu.16.10-x64": {},
     "osx.10.10-x64": {},
     "centos.7-x64": {},
     "rhel.7-x64": {},
-    "debian.8-x64": {}
+    "debian.8-x64": {},
+    "fedora.23-x64": {},
+    "opensuse.13.2-x64": {}
   }
 }
index 7c65ce1..0f50497 100644 (file)
@@ -1,5 +1,6 @@
 {
   "dependencies": {
+    "Microsoft.NETCore.Platforms": "2.0.0-beta-25001-02",
     "Microsoft.DotNet.CoreCLR.TestDependencies": "1.0.0-prerelease",
     "jit-dasm": "0.0.1.4",
     "cijobs": "0.0.1.2",
     "win7-x86": {},
     "win7-x64": {},
     "ubuntu.14.04-x64": {},
+    "ubuntu.16.04-x64": {},
+    "ubuntu.16.10-x64": {},
     "osx.10.10-x64": {},
     "centos.7-x64": {},
     "rhel.7-x64": {},
-    "debian.8-x64": {}
+    "debian.8-x64": {},
+    "fedora.23-x64": {},
+    "opensuse.13.2-x64": {}
   }
 }
index 7b98050..f3714bb 100644 (file)
@@ -4,7 +4,7 @@
     "Microsoft.DotNet.xunit.performance": "1.0.0-alpha-build0040",
     "Microsoft.DotNet.xunit.performance.analysis": "1.0.0-alpha-build0040",
     "Microsoft.DotNet.xunit.performance.runner.Windows": "1.0.0-alpha-build0040",
-    "Microsoft.NETCore.Platforms": "2.0.0-beta-24931-02",
+    "Microsoft.NETCore.Platforms": "2.0.0-beta-25001-02",
     "System.Console": "4.4.0-beta-24913-02",
     "System.Dynamic.Runtime": "4.4.0-beta-24913-02",
     "System.Linq": "4.4.0-beta-24913-02",
index 6c656e9..79449d0 100644 (file)
@@ -3,7 +3,7 @@
     "Microsoft.DotNet.xunit.performance": "1.0.0-alpha-build0040",
     "Microsoft.DotNet.xunit.performance.analysis": "1.0.0-alpha-build0040",
     "Microsoft.DotNet.xunit.performance.runner.Windows": "1.0.0-alpha-build0040",
-    "Microsoft.NETCore.Platforms": "2.0.0-beta-24931-02",
+    "Microsoft.NETCore.Platforms": "2.0.0-beta-25001-02",
     "Newtonsoft.Json": "7.0.1",
     "System.Console": "4.4.0-beta-24913-02",
     "System.IO": "4.4.0-beta-24913-02",
index bf16813..96cfc70 100644 (file)
@@ -3,7 +3,7 @@
     "Microsoft.DotNet.xunit.performance": "1.0.0-alpha-build0040",
     "Microsoft.DotNet.xunit.performance.analysis": "1.0.0-alpha-build0040",
     "Microsoft.DotNet.xunit.performance.runner.Windows": "1.0.0-alpha-build0040",
-    "Microsoft.NETCore.Platforms": "2.0.0-beta-24931-02",
+    "Microsoft.NETCore.Platforms": "2.0.0-beta-25001-02",
     "System.Collections.NonGeneric": "4.4.0-beta-24913-02",
     "System.Console": "4.4.0-beta-24913-02",
     "System.IO.FileSystem": "4.4.0-beta-24913-02",
index 262c577..931926c 100644 (file)
@@ -1,6 +1,6 @@
 {
   "dependencies": {
-    "Microsoft.NETCore.Platforms": "2.0.0-beta-24931-02",
+    "Microsoft.NETCore.Platforms": "2.0.0-beta-25001-02",
     "System.Collections": "4.4.0-beta-24913-02",
     "System.Console": "4.4.0-beta-24913-02",
     "System.Diagnostics.Debug": "4.4.0-beta-24913-02",
     "win7-x86": {},
     "win7-x64": {},
     "ubuntu.14.04-x64": {},
+    "ubuntu.16.04-x64": {},
+    "ubuntu.16.10-x64": {},
     "osx.10.10-x64": {},
     "centos.7-x64": {},
     "rhel.7-x64": {},
-    "debian.8-x64": {}
+    "debian.8-x64": {},
+    "fedora.23-x64": {},
+    "opensuse.13.2-x64": {}
   }
 }
index ea86499..cf49af5 100644 (file)
@@ -1,6 +1,6 @@
 {
   "dependencies": {
-    "Microsoft.NETCore.Platforms": "2.0.0-beta-24931-02",
+    "Microsoft.NETCore.Platforms": "2.0.0-beta-25001-02",
     "System.Console": "4.4.0-beta-24913-02",
     "System.Runtime": "4.4.0-beta-24913-02",
     "System.Runtime.Extensions": "4.4.0-beta-24913-02",
     "win7-x86": {},
     "win7-x64": {},
     "ubuntu.14.04-x64": {},
+    "ubuntu.16.04-x64": {},
+    "ubuntu.16.10-x64": {},
     "osx.10.10-x64": {},
     "centos.7-x64": {},
     "rhel.7-x64": {},
-    "debian.8-x64": {}
+    "debian.8-x64": {},
+    "fedora.23-x64": {},
+    "opensuse.13.2-x64": {}
   }
 }
index c25a307..0296783 100644 (file)
@@ -1,6 +1,6 @@
 {
   "dependencies": {
-    "Microsoft.NETCore.Platforms": "2.0.0-beta-24931-02",
+    "Microsoft.NETCore.Platforms": "2.0.0-beta-25001-02",
     "System.Console": "4.4.0-beta-24913-02",
     "System.Numerics.Vectors": "4.4.0-beta-24913-02",
     "System.Runtime": "4.4.0-beta-24913-02",
     "win7-x86": {},
     "win7-x64": {},
     "ubuntu.14.04-x64": {},
+    "ubuntu.16.04-x64": {},
+    "ubuntu.16.10-x64": {},
     "osx.10.10-x64": {},
     "centos.7-x64": {},
     "rhel.7-x64": {},
-    "debian.8-x64": {}
+    "debian.8-x64": {},
+    "fedora.23-x64": {},
+    "opensuse.13.2-x64": {}
   }
 }
index 0501f13..857de31 100644 (file)
@@ -1,6 +1,6 @@
 {
   "dependencies": {
-    "Microsoft.NETCore.Platforms": "2.0.0-beta-24931-02",
+    "Microsoft.NETCore.Platforms": "2.0.0-beta-25001-02",
     "System.Console": "4.4.0-beta-24913-02",
     "System.Runtime": "4.4.0-beta-24913-02",
     "System.Runtime.Extensions": "4.4.0-beta-24913-02",
     "win7-x86": {},
     "win7-x64": {},
     "ubuntu.14.04-x64": {},
+    "ubuntu.16.04-x64": {},
+    "ubuntu.16.10-x64": {},
     "osx.10.10-x64": {},
     "centos.7-x64": {},
     "rhel.7-x64": {},
-    "debian.8-x64": {}
+    "debian.8-x64": {},
+    "fedora.23-x64": {},
+    "opensuse.13.2-x64": {}
   }
 }
index f255e30..60f90bb 100644 (file)
@@ -1,5 +1,6 @@
 {
   "dependencies": {
+    "Microsoft.NETCore.Platforms": "2.0.0-beta-25001-02",
     "xunit": "2.2.0-beta2-build3300",
     "xunit.assert": "2.2.0-beta2-build3300",
     "xunit.core": "2.2.0-beta2-build3300",
     "win7-x86": {},
     "win7-x64": {},
     "ubuntu.14.04-x64": {},
+    "ubuntu.16.04-x64": {},
+    "ubuntu.16.10-x64": {},
     "osx.10.10-x64": {},
     "centos.7-x64": {},
     "rhel.7-x64": {},
-    "debian.8-x64": {}
+    "debian.8-x64": {},
+    "fedora.23-x64": {},
+    "opensuse.13.2-x64": {}
   }
 }
index c30ba21..d367466 100644 (file)
@@ -3,7 +3,7 @@
     "Microsoft.DotNet.xunit.performance": "1.0.0-alpha-build0040",
     "Microsoft.DotNet.xunit.performance.analysis": "1.0.0-alpha-build0040",
     "Microsoft.DotNet.xunit.performance.runner.Windows": "1.0.0-alpha-build0040",
-    "Microsoft.NETCore.Platforms": "2.0.0-beta-24931-02",
+    "Microsoft.NETCore.Platforms": "2.0.0-beta-25001-02",
     "System.Collections.NonGeneric": "4.4.0-beta-24913-02",
     "System.Console": "4.4.0-beta-24913-02",
     "System.IO.FileSystem": "4.4.0-beta-24913-02",