diff --git a/Roslyn.sln b/Roslyn.sln
index fe69d1c9957af..fcfe71c1f73cc 100644
--- a/Roslyn.sln
+++ b/Roslyn.sln
@@ -2269,6 +2269,8 @@ Global
src\Dependencies\CodeAnalysis.Debugging\Microsoft.CodeAnalysis.Debugging.projitems*{edc68a0e-c68d-4a74-91b7-bf38ec909888}*SharedItemsImports = 5
src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{fa0e905d-ec46-466d-b7b2-3b5557f9428c}*SharedItemsImports = 5
src\ExpressionEvaluator\Core\Source\ResultProvider\ResultProvider.projitems*{fa0e905d-ec46-466d-b7b2-3b5557f9428c}*SharedItemsImports = 5
+ src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{fc2ae90b-2e4b-4045-9fdd-73d4f5ed6c89}*SharedItemsImports = 5
+ src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{fc2ae90b-2e4b-4045-9fdd-73d4f5ed6c89}*SharedItemsImports = 5
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis.Utilities.projitems*{fcb56cba-fa35-46a8-86b7-bae5433197d9}*SharedItemsImports = 13
src\RoslynAnalyzers\Utilities\Compiler\Analyzer.Utilities.projitems*{fce0046b-03f8-78f6-86a1-8ddcee8f4c9f}*SharedItemsImports = 5
src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{fce88bbd-9bbd-4871-b9b0-de176d73a6b0}*SharedItemsImports = 5
diff --git a/src/Dependencies/.editorconfig b/src/Dependencies/.editorconfig
new file mode 100644
index 0000000000000..4694508c4da5a
--- /dev/null
+++ b/src/Dependencies/.editorconfig
@@ -0,0 +1,6 @@
+[*.cs]
+
+# IDE0240: Remove redundant nullable directive
+# The directive needs to be included since all sources in a source package are considered generated code
+# when referenced from a project via package reference.
+dotnet_diagnostic.IDE0240.severity = none
\ No newline at end of file
diff --git a/src/Dependencies/CodeAnalysis.Debugging/CustomDebugInfoConstants.cs b/src/Dependencies/CodeAnalysis.Debugging/CustomDebugInfoConstants.cs
index febe61ffa432f..faa494e8c239f 100644
--- a/src/Dependencies/CodeAnalysis.Debugging/CustomDebugInfoConstants.cs
+++ b/src/Dependencies/CodeAnalysis.Debugging/CustomDebugInfoConstants.cs
@@ -2,6 +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.
+#nullable enable
+
namespace Microsoft.CodeAnalysis.Debugging
{
///
diff --git a/src/Dependencies/CodeAnalysis.Debugging/CustomDebugInfoEncoder.cs b/src/Dependencies/CodeAnalysis.Debugging/CustomDebugInfoEncoder.cs
index da2f5b1c13c23..d3b81fe3b749a 100644
--- a/src/Dependencies/CodeAnalysis.Debugging/CustomDebugInfoEncoder.cs
+++ b/src/Dependencies/CodeAnalysis.Debugging/CustomDebugInfoEncoder.cs
@@ -2,7 +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.
-#nullable disable
+#nullable enable
using System;
using System.Collections.Generic;
@@ -40,7 +40,7 @@ public CustomDebugInfoEncoder(BlobBuilder builder)
public readonly int RecordCount => _recordCount;
/// More than records added.
- public readonly byte[] ToArray()
+ public readonly byte[]? ToArray()
{
if (_recordCount == 0)
{
@@ -54,8 +54,6 @@ public readonly byte[] ToArray()
public void AddStateMachineTypeName(string typeName)
{
- Debug.Assert(typeName != null);
-
AddRecord(
CustomDebugInfoKind.StateMachineTypeName,
typeName,
@@ -142,8 +140,6 @@ public void AddStateMachineHoistedLocalScopes(ImmutableArray dynamicLocals)
{
- Debug.Assert(dynamicLocals != null);
-
AddRecord(
CustomDebugInfoKind.DynamicLocals,
dynamicLocals,
@@ -168,8 +164,6 @@ public void AddDynamicLocals(IReadOnlyCollection<(string LocalName, byte[] Flags
public void AddTupleElementNames(IReadOnlyCollection<(string LocalName, int SlotIndex, int ScopeStart, int ScopeEnd, ImmutableArray Names)> tupleLocals)
{
- Debug.Assert(tupleLocals != null);
-
AddRecord(
CustomDebugInfoKind.TupleElementNames,
tupleLocals,
diff --git a/src/Dependencies/CodeAnalysis.Debugging/CustomDebugInfoKind.cs b/src/Dependencies/CodeAnalysis.Debugging/CustomDebugInfoKind.cs
index 207bdb58b56e5..320f5b0a2c9f1 100644
--- a/src/Dependencies/CodeAnalysis.Debugging/CustomDebugInfoKind.cs
+++ b/src/Dependencies/CodeAnalysis.Debugging/CustomDebugInfoKind.cs
@@ -2,7 +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.
-#nullable disable
+#nullable enable
namespace Microsoft.CodeAnalysis.Debugging
{
diff --git a/src/Dependencies/CodeAnalysis.Debugging/CustomDebugInfoReader.cs b/src/Dependencies/CodeAnalysis.Debugging/CustomDebugInfoReader.cs
index a6b5aab8dd43e..778ebc39c626f 100644
--- a/src/Dependencies/CodeAnalysis.Debugging/CustomDebugInfoReader.cs
+++ b/src/Dependencies/CodeAnalysis.Debugging/CustomDebugInfoReader.cs
@@ -2,12 +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.
-#nullable disable
+#nullable enable
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Text;
using Microsoft.CodeAnalysis.PooledObjects;
@@ -313,7 +314,7 @@ public static ImmutableArray DecodeTupleElementNamesRecor
private static TupleElementNamesInfo DecodeTupleElementNamesInfo(ImmutableArray bytes, ref int offset)
{
var n = ReadInt32(bytes, ref offset);
- var builder = ArrayBuilder.GetInstance(n);
+ var builder = ArrayBuilder.GetInstance(n);
for (var i = 0; i < n; i++)
{
var value = ReadUtf8String(bytes, ref offset);
@@ -337,7 +338,7 @@ private static TupleElementNamesInfo DecodeTupleElementNamesInfo(ImmutableArray<
public static ImmutableArray> GetCSharpGroupedImportStrings(
int methodToken,
TArg arg,
- Func getMethodCustomDebugInfo,
+ Func getMethodCustomDebugInfo,
Func> getMethodImportStrings,
out ImmutableArray externAliasStrings)
{
@@ -572,7 +573,7 @@ private static bool IsCSharpExternAliasInfo(string import)
/// "TSystem.Math" ->
/// ]]>
///
- public static bool TryParseCSharpImportString(string import, out string alias, out string externAlias, out string target, out ImportTargetKind kind)
+ public static bool TryParseCSharpImportString(string import, out string? alias, out string? externAlias, out string? target, out ImportTargetKind kind)
{
alias = null;
externAlias = null;
@@ -673,7 +674,7 @@ public static bool TryParseCSharpImportString(string import, out string alias, o
///
/// is null.
/// Format of is not valid.
- public static bool TryParseVisualBasicImportString(string import, out string alias, out string target, out ImportTargetKind kind, out VBImportScopeKind scope)
+ public static bool TryParseVisualBasicImportString(string import, out string? alias, out string? target, out ImportTargetKind kind, out VBImportScopeKind scope)
{
alias = null;
target = null;
@@ -820,7 +821,7 @@ public static bool TryParseVisualBasicImportString(string import, out string ali
}
}
- private static bool TrySplit(string input, int offset, char separator, out string before, out string after)
+ private static bool TrySplit(string input, int offset, char separator, [NotNullWhen(true)] out string? before, [NotNullWhen(true)] out string? after)
{
var separatorPos = input.IndexOf(separator, offset);
diff --git a/src/Dependencies/CodeAnalysis.Debugging/CustomDebugInfoRecord.cs b/src/Dependencies/CodeAnalysis.Debugging/CustomDebugInfoRecord.cs
index be95230e5c559..424a7f6a8fdd2 100644
--- a/src/Dependencies/CodeAnalysis.Debugging/CustomDebugInfoRecord.cs
+++ b/src/Dependencies/CodeAnalysis.Debugging/CustomDebugInfoRecord.cs
@@ -2,7 +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.
-#nullable disable
+#nullable enable
using System.Collections.Immutable;
diff --git a/src/Dependencies/CodeAnalysis.Debugging/DynamicLocalInfo.cs b/src/Dependencies/CodeAnalysis.Debugging/DynamicLocalInfo.cs
index 32220fc325193..38b648dade9d9 100644
--- a/src/Dependencies/CodeAnalysis.Debugging/DynamicLocalInfo.cs
+++ b/src/Dependencies/CodeAnalysis.Debugging/DynamicLocalInfo.cs
@@ -2,7 +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.
-#nullable disable
+#nullable enable
using System.Collections.Immutable;
diff --git a/src/Dependencies/CodeAnalysis.Debugging/ImportTargetKind.cs b/src/Dependencies/CodeAnalysis.Debugging/ImportTargetKind.cs
index eb3730f8e42d3..3442fd60cce91 100644
--- a/src/Dependencies/CodeAnalysis.Debugging/ImportTargetKind.cs
+++ b/src/Dependencies/CodeAnalysis.Debugging/ImportTargetKind.cs
@@ -2,6 +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.
+#nullable enable
+
namespace Microsoft.CodeAnalysis.Debugging
{
internal enum ImportTargetKind
diff --git a/src/Dependencies/CodeAnalysis.Debugging/Microsoft.CodeAnalysis.Debugging.Package.csproj b/src/Dependencies/CodeAnalysis.Debugging/Microsoft.CodeAnalysis.Debugging.Package.csproj
index be31526b6c3c7..b712ad770460c 100644
--- a/src/Dependencies/CodeAnalysis.Debugging/Microsoft.CodeAnalysis.Debugging.Package.csproj
+++ b/src/Dependencies/CodeAnalysis.Debugging/Microsoft.CodeAnalysis.Debugging.Package.csproj
@@ -22,6 +22,7 @@
-
+
+
diff --git a/src/Dependencies/CodeAnalysis.Debugging/PortableCustomDebugInfoKinds.cs b/src/Dependencies/CodeAnalysis.Debugging/PortableCustomDebugInfoKinds.cs
index a08e7536c6bba..33fa120d46895 100644
--- a/src/Dependencies/CodeAnalysis.Debugging/PortableCustomDebugInfoKinds.cs
+++ b/src/Dependencies/CodeAnalysis.Debugging/PortableCustomDebugInfoKinds.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
namespace Microsoft.CodeAnalysis.Debugging
diff --git a/src/Dependencies/CodeAnalysis.Debugging/StateMachineHoistedLocalScope.cs b/src/Dependencies/CodeAnalysis.Debugging/StateMachineHoistedLocalScope.cs
index e54f83293afc2..6c47b4031b026 100644
--- a/src/Dependencies/CodeAnalysis.Debugging/StateMachineHoistedLocalScope.cs
+++ b/src/Dependencies/CodeAnalysis.Debugging/StateMachineHoistedLocalScope.cs
@@ -2,7 +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.
-#nullable disable
+#nullable enable
using System.Diagnostics;
diff --git a/src/Dependencies/CodeAnalysis.Debugging/TupleElementNamesInfo.cs b/src/Dependencies/CodeAnalysis.Debugging/TupleElementNamesInfo.cs
index 28a972f008b36..161696a9ee465 100644
--- a/src/Dependencies/CodeAnalysis.Debugging/TupleElementNamesInfo.cs
+++ b/src/Dependencies/CodeAnalysis.Debugging/TupleElementNamesInfo.cs
@@ -2,7 +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.
-#nullable disable
+#nullable enable
using System.Collections.Immutable;
using System.Diagnostics;
@@ -11,13 +11,13 @@ namespace Microsoft.CodeAnalysis.Debugging
{
internal readonly struct TupleElementNamesInfo
{
- internal readonly ImmutableArray ElementNames;
+ internal readonly ImmutableArray ElementNames;
internal readonly int SlotIndex; // Locals only
internal readonly string LocalName;
internal readonly int ScopeStart; // Constants only
internal readonly int ScopeEnd; // Constants only
- internal TupleElementNamesInfo(ImmutableArray elementNames, int slotIndex, string localName, int scopeStart, int scopeEnd)
+ internal TupleElementNamesInfo(ImmutableArray elementNames, int slotIndex, string localName, int scopeStart, int scopeEnd)
{
Debug.Assert(!elementNames.IsDefault);
diff --git a/src/Dependencies/CodeAnalysis.Debugging/VBImportScopeKind.cs b/src/Dependencies/CodeAnalysis.Debugging/VBImportScopeKind.cs
index 34d85270ee7fc..e9b82318e7c49 100644
--- a/src/Dependencies/CodeAnalysis.Debugging/VBImportScopeKind.cs
+++ b/src/Dependencies/CodeAnalysis.Debugging/VBImportScopeKind.cs
@@ -2,6 +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.
+#nullable enable
+
namespace Microsoft.CodeAnalysis.Debugging
{
internal enum VBImportScopeKind
diff --git a/src/Dependencies/Collections/Extensions/ICollectionExtensions.cs b/src/Dependencies/Collections/Extensions/ICollectionExtensions.cs
index 0f88c8c6faeba..b6fd40d078d78 100644
--- a/src/Dependencies/Collections/Extensions/ICollectionExtensions.cs
+++ b/src/Dependencies/Collections/Extensions/ICollectionExtensions.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
diff --git a/src/Dependencies/Collections/Extensions/IEnumerableExtensions.cs b/src/Dependencies/Collections/Extensions/IEnumerableExtensions.cs
index 058e1e54e38e7..d06a1733a9f6f 100644
--- a/src/Dependencies/Collections/Extensions/IEnumerableExtensions.cs
+++ b/src/Dependencies/Collections/Extensions/IEnumerableExtensions.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections;
using System.Collections.Generic;
diff --git a/src/Dependencies/Collections/Extensions/ImmutableArrayExtensions.cs b/src/Dependencies/Collections/Extensions/ImmutableArrayExtensions.cs
index a57b085a28477..06227b65bc8a5 100644
--- a/src/Dependencies/Collections/Extensions/ImmutableArrayExtensions.cs
+++ b/src/Dependencies/Collections/Extensions/ImmutableArrayExtensions.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
diff --git a/src/Dependencies/Collections/Internal/ArraySortHelper.cs b/src/Dependencies/Collections/Internal/ArraySortHelper.cs
index 1817447d26878..0d60317f3ef39 100644
--- a/src/Dependencies/Collections/Internal/ArraySortHelper.cs
+++ b/src/Dependencies/Collections/Internal/ArraySortHelper.cs
@@ -2,6 +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.
+#nullable enable
+
// NOTE: This code is derived from an implementation originally in dotnet/runtime:
// https://github.com/dotnet/runtime/blob/v8.0.3/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/ArraySortHelper.cs
//
diff --git a/src/Dependencies/Collections/Internal/BitHelper.cs b/src/Dependencies/Collections/Internal/BitHelper.cs
index f7a74f4f6b806..a9238e0e47c51 100644
--- a/src/Dependencies/Collections/Internal/BitHelper.cs
+++ b/src/Dependencies/Collections/Internal/BitHelper.cs
@@ -2,6 +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.
+#nullable enable
+
// NOTE: This code is derived from an implementation originally in dotnet/runtime:
// https://github.com/dotnet/runtime/blob/v8.0.3/src/libraries/Common/src/System/Collections/Generic/BitHelper.cs
//
diff --git a/src/Dependencies/Collections/Internal/HashHelpers.cs b/src/Dependencies/Collections/Internal/HashHelpers.cs
index 2dc9e630edd63..1dfe093909404 100644
--- a/src/Dependencies/Collections/Internal/HashHelpers.cs
+++ b/src/Dependencies/Collections/Internal/HashHelpers.cs
@@ -2,6 +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.
+#nullable enable
+
// NOTE: This code is derived from an implementation originally in dotnet/runtime:
// https://github.com/dotnet/runtime/blob/v8.0.3/src/libraries/System.Private.CoreLib/src/System/Collections/HashHelpers.cs
//
diff --git a/src/Dependencies/Collections/Internal/ICollectionCalls.cs b/src/Dependencies/Collections/Internal/ICollectionCalls.cs
index 6d71ff82afb04..e45d9116104a4 100644
--- a/src/Dependencies/Collections/Internal/ICollectionCalls.cs
+++ b/src/Dependencies/Collections/Internal/ICollectionCalls.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections;
diff --git a/src/Dependencies/Collections/Internal/ICollectionCalls`1.cs b/src/Dependencies/Collections/Internal/ICollectionCalls`1.cs
index 45fa0142859da..f902f8b817b01 100644
--- a/src/Dependencies/Collections/Internal/ICollectionCalls`1.cs
+++ b/src/Dependencies/Collections/Internal/ICollectionCalls`1.cs
@@ -2,6 +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.
+#nullable enable
+
using System.Collections.Generic;
namespace Microsoft.CodeAnalysis.Collections.Internal
diff --git a/src/Dependencies/Collections/Internal/ICollectionDebugView`1.cs b/src/Dependencies/Collections/Internal/ICollectionDebugView`1.cs
index 93269df4e76e6..f59fa686a6aeb 100644
--- a/src/Dependencies/Collections/Internal/ICollectionDebugView`1.cs
+++ b/src/Dependencies/Collections/Internal/ICollectionDebugView`1.cs
@@ -2,6 +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.
+#nullable enable
+
// NOTE: This code is derived from an implementation originally in dotnet/runtime:
// https://github.com/dotnet/runtime/blob/v8.0.3/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/ICollectionDebugView.cs
//
diff --git a/src/Dependencies/Collections/Internal/IDictionaryCalls.cs b/src/Dependencies/Collections/Internal/IDictionaryCalls.cs
index 79d95fd22ef6e..a26d4425a6d71 100644
--- a/src/Dependencies/Collections/Internal/IDictionaryCalls.cs
+++ b/src/Dependencies/Collections/Internal/IDictionaryCalls.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections;
diff --git a/src/Dependencies/Collections/Internal/IDictionaryDebugView`2.cs b/src/Dependencies/Collections/Internal/IDictionaryDebugView`2.cs
index fd92c1c48a8ab..265c29b08a3f5 100644
--- a/src/Dependencies/Collections/Internal/IDictionaryDebugView`2.cs
+++ b/src/Dependencies/Collections/Internal/IDictionaryDebugView`2.cs
@@ -2,6 +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.
+#nullable enable
+
// NOTE: This code is derived from an implementation originally in dotnet/runtime:
// https://github.com/dotnet/runtime/blob/v8.0.3/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/IDictionaryDebugView.cs
//
diff --git a/src/Dependencies/Collections/Internal/IEnumerableCalls.cs b/src/Dependencies/Collections/Internal/IEnumerableCalls.cs
index ae03c4968e310..4bdd34da0e16e 100644
--- a/src/Dependencies/Collections/Internal/IEnumerableCalls.cs
+++ b/src/Dependencies/Collections/Internal/IEnumerableCalls.cs
@@ -2,6 +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.
+#nullable enable
+
using System.Collections;
namespace Microsoft.CodeAnalysis.Collections.Internal
diff --git a/src/Dependencies/Collections/Internal/IEnumerableCalls`1.cs b/src/Dependencies/Collections/Internal/IEnumerableCalls`1.cs
index 551b3f1cc14ce..000fd0d707504 100644
--- a/src/Dependencies/Collections/Internal/IEnumerableCalls`1.cs
+++ b/src/Dependencies/Collections/Internal/IEnumerableCalls`1.cs
@@ -2,6 +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.
+#nullable enable
+
using System.Collections.Generic;
namespace Microsoft.CodeAnalysis.Collections.Internal
diff --git a/src/Dependencies/Collections/Internal/IListCalls.cs b/src/Dependencies/Collections/Internal/IListCalls.cs
index d98ca9b3f13f5..f7555e2429d20 100644
--- a/src/Dependencies/Collections/Internal/IListCalls.cs
+++ b/src/Dependencies/Collections/Internal/IListCalls.cs
@@ -2,6 +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.
+#nullable enable
+
using System.Collections;
namespace Microsoft.CodeAnalysis.Collections.Internal
diff --git a/src/Dependencies/Collections/Internal/InsertionBehavior.cs b/src/Dependencies/Collections/Internal/InsertionBehavior.cs
index 1e5bcb9bf0623..40e2d12ad2ae7 100644
--- a/src/Dependencies/Collections/Internal/InsertionBehavior.cs
+++ b/src/Dependencies/Collections/Internal/InsertionBehavior.cs
@@ -2,6 +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.
+#nullable enable
+
// NOTE: This code is derived from an implementation originally in dotnet/runtime:
// https://github.com/dotnet/runtime/blob/v8.0.3/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/InsertionBehavior.cs
//
diff --git a/src/Dependencies/Collections/Internal/RoslynUnsafe.cs b/src/Dependencies/Collections/Internal/RoslynUnsafe.cs
index a02bcb73995ec..d8d40e90c5d55 100644
--- a/src/Dependencies/Collections/Internal/RoslynUnsafe.cs
+++ b/src/Dependencies/Collections/Internal/RoslynUnsafe.cs
@@ -2,6 +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.
+#nullable enable
+
using System.Runtime.CompilerServices;
namespace Microsoft.CodeAnalysis.Collections.Internal
diff --git a/src/Dependencies/Collections/Internal/SegmentedArrayHelper.cs b/src/Dependencies/Collections/Internal/SegmentedArrayHelper.cs
index 87caa4c74b574..70d87cbaea212 100644
--- a/src/Dependencies/Collections/Internal/SegmentedArrayHelper.cs
+++ b/src/Dependencies/Collections/Internal/SegmentedArrayHelper.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
diff --git a/src/Dependencies/Collections/Internal/SegmentedArraySegment`1.cs b/src/Dependencies/Collections/Internal/SegmentedArraySegment`1.cs
index c995b39f5a0b9..69d490ea85f4c 100644
--- a/src/Dependencies/Collections/Internal/SegmentedArraySegment`1.cs
+++ b/src/Dependencies/Collections/Internal/SegmentedArraySegment`1.cs
@@ -2,6 +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.
+#nullable enable
+
namespace Microsoft.CodeAnalysis.Collections.Internal
{
internal readonly struct SegmentedArraySegment
diff --git a/src/Dependencies/Collections/Internal/SegmentedHashSetEqualityComparer`1.cs b/src/Dependencies/Collections/Internal/SegmentedHashSetEqualityComparer`1.cs
index 07edb995f83a1..5946c81f76324 100644
--- a/src/Dependencies/Collections/Internal/SegmentedHashSetEqualityComparer`1.cs
+++ b/src/Dependencies/Collections/Internal/SegmentedHashSetEqualityComparer`1.cs
@@ -2,6 +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.
+#nullable enable
+
// NOTE: This code is derived from an implementation originally in dotnet/runtime:
// https://github.com/dotnet/runtime/blob/v8.0.3/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/HashSetEqualityComparer.cs
//
diff --git a/src/Dependencies/Collections/Internal/ThrowHelper.cs b/src/Dependencies/Collections/Internal/ThrowHelper.cs
index 113f80cda3a20..994a252a9cea8 100644
--- a/src/Dependencies/Collections/Internal/ThrowHelper.cs
+++ b/src/Dependencies/Collections/Internal/ThrowHelper.cs
@@ -2,6 +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.
+#nullable enable
+
// This file defines an internal class used to throw exceptions in BCL code.
// The main purpose is to reduce code size.
//
diff --git a/src/Dependencies/Collections/OneOrMany.cs b/src/Dependencies/Collections/OneOrMany.cs
index 10856414dfe81..eaad4dcf1c13d 100644
--- a/src/Dependencies/Collections/OneOrMany.cs
+++ b/src/Dependencies/Collections/OneOrMany.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
diff --git a/src/Dependencies/Collections/RoslynEnumerable.cs b/src/Dependencies/Collections/RoslynEnumerable.cs
index 18f7bc6f7b3f4..5edd13ee2e5ae 100644
--- a/src/Dependencies/Collections/RoslynEnumerable.cs
+++ b/src/Dependencies/Collections/RoslynEnumerable.cs
@@ -2,6 +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.
+#nullable enable
+
using System.Collections.Generic;
using Microsoft.CodeAnalysis.Collections;
using Microsoft.CodeAnalysis.Collections.Internal;
diff --git a/src/Dependencies/Collections/RoslynImmutableInterlocked.cs b/src/Dependencies/Collections/RoslynImmutableInterlocked.cs
index 6e5e8742d30c7..ae31779843550 100644
--- a/src/Dependencies/Collections/RoslynImmutableInterlocked.cs
+++ b/src/Dependencies/Collections/RoslynImmutableInterlocked.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
diff --git a/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary.cs b/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary.cs
index 4440fab2d7726..70ca2fa8c1782 100644
--- a/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary.cs
+++ b/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections.Generic;
using System.Linq;
diff --git a/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+Builder+KeyCollection.cs b/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+Builder+KeyCollection.cs
index 74a16225c3c10..6f406539a72ad 100644
--- a/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+Builder+KeyCollection.cs
+++ b/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+Builder+KeyCollection.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections;
using System.Collections.Generic;
diff --git a/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+Builder+PrivateMarshal.cs b/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+Builder+PrivateMarshal.cs
index 01f7a1c796de2..174a53dfc09ed 100644
--- a/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+Builder+PrivateMarshal.cs
+++ b/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+Builder+PrivateMarshal.cs
@@ -2,6 +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.
+#nullable enable
+
namespace Microsoft.CodeAnalysis.Collections;
internal readonly partial struct ImmutableSegmentedDictionary
diff --git a/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+Builder+ValueCollection.cs b/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+Builder+ValueCollection.cs
index a4a3db49a0c8c..bf68f898f0a29 100644
--- a/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+Builder+ValueCollection.cs
+++ b/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+Builder+ValueCollection.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections;
using System.Collections.Generic;
diff --git a/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+Builder.cs b/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+Builder.cs
index 6e36d573d4a10..a1e438608ac07 100644
--- a/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+Builder.cs
+++ b/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+Builder.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections;
using System.Collections.Generic;
diff --git a/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+Enumerator.cs b/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+Enumerator.cs
index 3fabd7903d827..5513c12bbc7f7 100644
--- a/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+Enumerator.cs
+++ b/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+Enumerator.cs
@@ -2,6 +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.
+#nullable enable
+
using System.Collections;
using System.Collections.Generic;
diff --git a/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+KeyCollection+Enumerator.cs b/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+KeyCollection+Enumerator.cs
index e8bc2d2e92463..d4a04d8526954 100644
--- a/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+KeyCollection+Enumerator.cs
+++ b/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+KeyCollection+Enumerator.cs
@@ -2,6 +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.
+#nullable enable
+
using System.Collections;
using System.Collections.Generic;
diff --git a/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+KeyCollection.cs b/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+KeyCollection.cs
index bd198731f0ffa..dbdbd4e515df4 100644
--- a/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+KeyCollection.cs
+++ b/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+KeyCollection.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections;
using System.Collections.Generic;
diff --git a/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+PrivateMarshal.cs b/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+PrivateMarshal.cs
index c50fc90148c7b..3b6ee1c382d68 100644
--- a/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+PrivateMarshal.cs
+++ b/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+PrivateMarshal.cs
@@ -2,6 +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.
+#nullable enable
+
using System.Runtime.CompilerServices;
using System.Threading;
diff --git a/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+ValueBuilder.cs b/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+ValueBuilder.cs
index 4c20bfdc65cbb..f57337bbd1d9e 100644
--- a/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+ValueBuilder.cs
+++ b/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+ValueBuilder.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections;
using System.Collections.Generic;
diff --git a/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+ValueCollection+Enumerator.cs b/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+ValueCollection+Enumerator.cs
index f9c24248037ac..dccb9177d8147 100644
--- a/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+ValueCollection+Enumerator.cs
+++ b/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+ValueCollection+Enumerator.cs
@@ -2,6 +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.
+#nullable enable
+
using System.Collections;
using System.Collections.Generic;
diff --git a/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+ValueCollection.cs b/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+ValueCollection.cs
index b45d6f89a8383..966328f845f9a 100644
--- a/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+ValueCollection.cs
+++ b/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2+ValueCollection.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections;
using System.Collections.Generic;
diff --git a/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2.cs b/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2.cs
index bdcdcdddcf96a..8898ed1e36756 100644
--- a/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2.cs
+++ b/src/Dependencies/Collections/Segmented/ImmutableSegmentedDictionary`2.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections;
using System.Collections.Generic;
diff --git a/src/Dependencies/Collections/Segmented/ImmutableSegmentedHashSet.cs b/src/Dependencies/Collections/Segmented/ImmutableSegmentedHashSet.cs
index 7e51c5cf4576f..63e2a1e8969df 100644
--- a/src/Dependencies/Collections/Segmented/ImmutableSegmentedHashSet.cs
+++ b/src/Dependencies/Collections/Segmented/ImmutableSegmentedHashSet.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
diff --git a/src/Dependencies/Collections/Segmented/ImmutableSegmentedHashSet`1+Builder.cs b/src/Dependencies/Collections/Segmented/ImmutableSegmentedHashSet`1+Builder.cs
index f5140e38238f5..d8273f710b8b0 100644
--- a/src/Dependencies/Collections/Segmented/ImmutableSegmentedHashSet`1+Builder.cs
+++ b/src/Dependencies/Collections/Segmented/ImmutableSegmentedHashSet`1+Builder.cs
@@ -2,6 +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.
+#nullable enable
+
using System.Collections;
using System.Collections.Generic;
using System.Collections.Immutable;
diff --git a/src/Dependencies/Collections/Segmented/ImmutableSegmentedHashSet`1+Enumerator.cs b/src/Dependencies/Collections/Segmented/ImmutableSegmentedHashSet`1+Enumerator.cs
index 59dde6ec59082..add645bb3035e 100644
--- a/src/Dependencies/Collections/Segmented/ImmutableSegmentedHashSet`1+Enumerator.cs
+++ b/src/Dependencies/Collections/Segmented/ImmutableSegmentedHashSet`1+Enumerator.cs
@@ -2,6 +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.
+#nullable enable
+
using System.Collections;
using System.Collections.Generic;
using System.Collections.Immutable;
diff --git a/src/Dependencies/Collections/Segmented/ImmutableSegmentedHashSet`1+PrivateMarshal.cs b/src/Dependencies/Collections/Segmented/ImmutableSegmentedHashSet`1+PrivateMarshal.cs
index cb8ed1656690e..282cbfb17a509 100644
--- a/src/Dependencies/Collections/Segmented/ImmutableSegmentedHashSet`1+PrivateMarshal.cs
+++ b/src/Dependencies/Collections/Segmented/ImmutableSegmentedHashSet`1+PrivateMarshal.cs
@@ -2,6 +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.
+#nullable enable
+
using System.Runtime.CompilerServices;
using System.Threading;
diff --git a/src/Dependencies/Collections/Segmented/ImmutableSegmentedHashSet`1+ValueBuilder.cs b/src/Dependencies/Collections/Segmented/ImmutableSegmentedHashSet`1+ValueBuilder.cs
index c672df7acd97f..8c8f2f8869078 100644
--- a/src/Dependencies/Collections/Segmented/ImmutableSegmentedHashSet`1+ValueBuilder.cs
+++ b/src/Dependencies/Collections/Segmented/ImmutableSegmentedHashSet`1+ValueBuilder.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections;
using System.Collections.Generic;
diff --git a/src/Dependencies/Collections/Segmented/ImmutableSegmentedHashSet`1.cs b/src/Dependencies/Collections/Segmented/ImmutableSegmentedHashSet`1.cs
index c28d85c2ae2a8..4728fa7a05b78 100644
--- a/src/Dependencies/Collections/Segmented/ImmutableSegmentedHashSet`1.cs
+++ b/src/Dependencies/Collections/Segmented/ImmutableSegmentedHashSet`1.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections;
using System.Collections.Generic;
diff --git a/src/Dependencies/Collections/Segmented/ImmutableSegmentedList.cs b/src/Dependencies/Collections/Segmented/ImmutableSegmentedList.cs
index 2c035ae1c7ce2..9272bfb597685 100644
--- a/src/Dependencies/Collections/Segmented/ImmutableSegmentedList.cs
+++ b/src/Dependencies/Collections/Segmented/ImmutableSegmentedList.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
diff --git a/src/Dependencies/Collections/Segmented/ImmutableSegmentedListExtensions.cs b/src/Dependencies/Collections/Segmented/ImmutableSegmentedListExtensions.cs
index 19ad004d99d95..a7675a069b7b3 100644
--- a/src/Dependencies/Collections/Segmented/ImmutableSegmentedListExtensions.cs
+++ b/src/Dependencies/Collections/Segmented/ImmutableSegmentedListExtensions.cs
@@ -2,6 +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.
+#nullable enable
+
using System.Collections.Generic;
using Microsoft.CodeAnalysis.Collections;
diff --git a/src/Dependencies/Collections/Segmented/ImmutableSegmentedList`1+Builder.cs b/src/Dependencies/Collections/Segmented/ImmutableSegmentedList`1+Builder.cs
index 174d53ff8904b..6ffd557d665bd 100644
--- a/src/Dependencies/Collections/Segmented/ImmutableSegmentedList`1+Builder.cs
+++ b/src/Dependencies/Collections/Segmented/ImmutableSegmentedList`1+Builder.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections;
using System.Collections.Generic;
diff --git a/src/Dependencies/Collections/Segmented/ImmutableSegmentedList`1+Enumerator.cs b/src/Dependencies/Collections/Segmented/ImmutableSegmentedList`1+Enumerator.cs
index f0ab525e968b3..6d61c3a317809 100644
--- a/src/Dependencies/Collections/Segmented/ImmutableSegmentedList`1+Enumerator.cs
+++ b/src/Dependencies/Collections/Segmented/ImmutableSegmentedList`1+Enumerator.cs
@@ -2,6 +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.
+#nullable enable
+
using System.Collections;
using System.Collections.Generic;
diff --git a/src/Dependencies/Collections/Segmented/ImmutableSegmentedList`1+PrivateMarshal.cs b/src/Dependencies/Collections/Segmented/ImmutableSegmentedList`1+PrivateMarshal.cs
index cf945b2144ce6..1b9cae87e4a9d 100644
--- a/src/Dependencies/Collections/Segmented/ImmutableSegmentedList`1+PrivateMarshal.cs
+++ b/src/Dependencies/Collections/Segmented/ImmutableSegmentedList`1+PrivateMarshal.cs
@@ -2,6 +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.
+#nullable enable
+
using System.Runtime.CompilerServices;
using System.Threading;
diff --git a/src/Dependencies/Collections/Segmented/ImmutableSegmentedList`1+ValueBuilder.cs b/src/Dependencies/Collections/Segmented/ImmutableSegmentedList`1+ValueBuilder.cs
index 456d50419de01..f71b14da7f5ce 100644
--- a/src/Dependencies/Collections/Segmented/ImmutableSegmentedList`1+ValueBuilder.cs
+++ b/src/Dependencies/Collections/Segmented/ImmutableSegmentedList`1+ValueBuilder.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections;
using System.Collections.Generic;
diff --git a/src/Dependencies/Collections/Segmented/ImmutableSegmentedList`1.cs b/src/Dependencies/Collections/Segmented/ImmutableSegmentedList`1.cs
index b8eb5c0f54524..41a5c8473f26c 100644
--- a/src/Dependencies/Collections/Segmented/ImmutableSegmentedList`1.cs
+++ b/src/Dependencies/Collections/Segmented/ImmutableSegmentedList`1.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections;
using System.Collections.Generic;
diff --git a/src/Dependencies/Collections/Segmented/SegmentedArray.cs b/src/Dependencies/Collections/Segmented/SegmentedArray.cs
index 41b2fd7b96f47..56301f0c088c1 100644
--- a/src/Dependencies/Collections/Segmented/SegmentedArray.cs
+++ b/src/Dependencies/Collections/Segmented/SegmentedArray.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections.Generic;
using System.Diagnostics;
diff --git a/src/Dependencies/Collections/Segmented/SegmentedArray`1+PrivateMarshal.cs b/src/Dependencies/Collections/Segmented/SegmentedArray`1+PrivateMarshal.cs
index 20433a3451bda..54bb94d2ffad5 100644
--- a/src/Dependencies/Collections/Segmented/SegmentedArray`1+PrivateMarshal.cs
+++ b/src/Dependencies/Collections/Segmented/SegmentedArray`1+PrivateMarshal.cs
@@ -2,6 +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.
+#nullable enable
+
namespace Microsoft.CodeAnalysis.Collections;
internal readonly partial struct SegmentedArray
diff --git a/src/Dependencies/Collections/Segmented/SegmentedArray`1.cs b/src/Dependencies/Collections/Segmented/SegmentedArray`1.cs
index ae0eb89b32c9a..c544295a66a4d 100644
--- a/src/Dependencies/Collections/Segmented/SegmentedArray`1.cs
+++ b/src/Dependencies/Collections/Segmented/SegmentedArray`1.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections;
using System.Collections.Generic;
diff --git a/src/Dependencies/Collections/Segmented/SegmentedCollectionsMarshal.cs b/src/Dependencies/Collections/Segmented/SegmentedCollectionsMarshal.cs
index d8a9ebeef1ab6..56c6f38b5e15c 100644
--- a/src/Dependencies/Collections/Segmented/SegmentedCollectionsMarshal.cs
+++ b/src/Dependencies/Collections/Segmented/SegmentedCollectionsMarshal.cs
@@ -2,6 +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.
+#nullable enable
+
using System.Diagnostics.CodeAnalysis;
namespace Microsoft.CodeAnalysis.Collections;
diff --git a/src/Dependencies/Collections/Segmented/SegmentedDictionary`2+PrivateMarshal.cs b/src/Dependencies/Collections/Segmented/SegmentedDictionary`2+PrivateMarshal.cs
index b008a411e6a1d..d29131abc2b24 100644
--- a/src/Dependencies/Collections/Segmented/SegmentedDictionary`2+PrivateMarshal.cs
+++ b/src/Dependencies/Collections/Segmented/SegmentedDictionary`2+PrivateMarshal.cs
@@ -2,6 +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.
+#nullable enable
+
namespace Microsoft.CodeAnalysis.Collections;
internal sealed partial class SegmentedDictionary
diff --git a/src/Dependencies/Collections/Segmented/SegmentedDictionary`2.cs b/src/Dependencies/Collections/Segmented/SegmentedDictionary`2.cs
index 75834b2f50781..0a9302a05e67b 100644
--- a/src/Dependencies/Collections/Segmented/SegmentedDictionary`2.cs
+++ b/src/Dependencies/Collections/Segmented/SegmentedDictionary`2.cs
@@ -2,6 +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.
+#nullable enable
+
// NOTE: This code is derived from an implementation originally in dotnet/runtime:
// https://github.com/dotnet/runtime/blob/v8.0.3/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/Dictionary.cs
//
diff --git a/src/Dependencies/Collections/Segmented/SegmentedHashSet`1.cs b/src/Dependencies/Collections/Segmented/SegmentedHashSet`1.cs
index 080048041e5ba..59d4528bc6d12 100644
--- a/src/Dependencies/Collections/Segmented/SegmentedHashSet`1.cs
+++ b/src/Dependencies/Collections/Segmented/SegmentedHashSet`1.cs
@@ -2,6 +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.
+#nullable enable
+
// NOTE: This code is derived from an implementation originally in dotnet/runtime:
// https://github.com/dotnet/runtime/blob/v8.0.3/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/HashSet.cs
//
diff --git a/src/Dependencies/Collections/Segmented/SegmentedList`1.cs b/src/Dependencies/Collections/Segmented/SegmentedList`1.cs
index 35118b06966ad..407d7925951a5 100644
--- a/src/Dependencies/Collections/Segmented/SegmentedList`1.cs
+++ b/src/Dependencies/Collections/Segmented/SegmentedList`1.cs
@@ -2,6 +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.
+#nullable enable
+
// NOTE: This code is derived from an implementation originally in dotnet/runtime:
// https://github.com/dotnet/runtime/blob/v8.0.3/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/List.cs
//
diff --git a/src/Dependencies/Collections/Specialized/SpecializedCollections.Empty.Collection.cs b/src/Dependencies/Collections/Specialized/SpecializedCollections.Empty.Collection.cs
index 99bf9198407b5..e135dcb8902c8 100644
--- a/src/Dependencies/Collections/Specialized/SpecializedCollections.Empty.Collection.cs
+++ b/src/Dependencies/Collections/Specialized/SpecializedCollections.Empty.Collection.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections.Generic;
diff --git a/src/Dependencies/Collections/Specialized/SpecializedCollections.Empty.Dictionary.cs b/src/Dependencies/Collections/Specialized/SpecializedCollections.Empty.Dictionary.cs
index b3203178f23bb..7035b5e0c0752 100644
--- a/src/Dependencies/Collections/Specialized/SpecializedCollections.Empty.Dictionary.cs
+++ b/src/Dependencies/Collections/Specialized/SpecializedCollections.Empty.Dictionary.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
diff --git a/src/Dependencies/Collections/Specialized/SpecializedCollections.Empty.Enumerable.cs b/src/Dependencies/Collections/Specialized/SpecializedCollections.Empty.Enumerable.cs
index e34c1d6b4f4ca..c0f577c7a749f 100644
--- a/src/Dependencies/Collections/Specialized/SpecializedCollections.Empty.Enumerable.cs
+++ b/src/Dependencies/Collections/Specialized/SpecializedCollections.Empty.Enumerable.cs
@@ -2,6 +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.
+#nullable enable
+
using System.Collections.Generic;
namespace Roslyn.Utilities
diff --git a/src/Dependencies/Collections/Specialized/SpecializedCollections.Empty.Enumerator.cs b/src/Dependencies/Collections/Specialized/SpecializedCollections.Empty.Enumerator.cs
index 2e4842b080e8e..fd3a41eb700ef 100644
--- a/src/Dependencies/Collections/Specialized/SpecializedCollections.Empty.Enumerator.cs
+++ b/src/Dependencies/Collections/Specialized/SpecializedCollections.Empty.Enumerator.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections;
diff --git a/src/Dependencies/Collections/Specialized/SpecializedCollections.Empty.Enumerator`1.cs b/src/Dependencies/Collections/Specialized/SpecializedCollections.Empty.Enumerator`1.cs
index e28e25ee4c3cf..70c6746438977 100644
--- a/src/Dependencies/Collections/Specialized/SpecializedCollections.Empty.Enumerator`1.cs
+++ b/src/Dependencies/Collections/Specialized/SpecializedCollections.Empty.Enumerator`1.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections.Generic;
diff --git a/src/Dependencies/Collections/Specialized/SpecializedCollections.Empty.List.cs b/src/Dependencies/Collections/Specialized/SpecializedCollections.Empty.List.cs
index 677b502c546cb..2e367fd02407e 100644
--- a/src/Dependencies/Collections/Specialized/SpecializedCollections.Empty.List.cs
+++ b/src/Dependencies/Collections/Specialized/SpecializedCollections.Empty.List.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
diff --git a/src/Dependencies/Collections/Specialized/SpecializedCollections.Empty.Set.cs b/src/Dependencies/Collections/Specialized/SpecializedCollections.Empty.Set.cs
index fd3cffe9c5636..13c41a758faa0 100644
--- a/src/Dependencies/Collections/Specialized/SpecializedCollections.Empty.Set.cs
+++ b/src/Dependencies/Collections/Specialized/SpecializedCollections.Empty.Set.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections.Generic;
diff --git a/src/Dependencies/Collections/Specialized/SpecializedCollections.Empty.cs b/src/Dependencies/Collections/Specialized/SpecializedCollections.Empty.cs
index 45c57451ded68..34ef01c22cdf2 100644
--- a/src/Dependencies/Collections/Specialized/SpecializedCollections.Empty.cs
+++ b/src/Dependencies/Collections/Specialized/SpecializedCollections.Empty.cs
@@ -2,6 +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.
+#nullable enable
+
namespace Roslyn.Utilities
{
internal partial class SpecializedCollections
diff --git a/src/Dependencies/Collections/Specialized/SpecializedCollections.ReadOnly.Collection.cs b/src/Dependencies/Collections/Specialized/SpecializedCollections.ReadOnly.Collection.cs
index 3d16afe8fd077..70c086c8cddab 100644
--- a/src/Dependencies/Collections/Specialized/SpecializedCollections.ReadOnly.Collection.cs
+++ b/src/Dependencies/Collections/Specialized/SpecializedCollections.ReadOnly.Collection.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections.Generic;
diff --git a/src/Dependencies/Collections/Specialized/SpecializedCollections.ReadOnly.Enumerable`1.cs b/src/Dependencies/Collections/Specialized/SpecializedCollections.ReadOnly.Enumerable`1.cs
index f0dc08fe29669..4b0c086b6cc1e 100644
--- a/src/Dependencies/Collections/Specialized/SpecializedCollections.ReadOnly.Enumerable`1.cs
+++ b/src/Dependencies/Collections/Specialized/SpecializedCollections.ReadOnly.Enumerable`1.cs
@@ -2,6 +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.
+#nullable enable
+
using System.Collections;
namespace Roslyn.Utilities
diff --git a/src/Dependencies/Collections/Specialized/SpecializedCollections.ReadOnly.Enumerable`2.cs b/src/Dependencies/Collections/Specialized/SpecializedCollections.ReadOnly.Enumerable`2.cs
index ae8e3d8b8e65e..5b88cbc975f74 100644
--- a/src/Dependencies/Collections/Specialized/SpecializedCollections.ReadOnly.Enumerable`2.cs
+++ b/src/Dependencies/Collections/Specialized/SpecializedCollections.ReadOnly.Enumerable`2.cs
@@ -2,6 +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.
+#nullable enable
+
using System.Collections.Generic;
namespace Roslyn.Utilities
diff --git a/src/Dependencies/Collections/Specialized/SpecializedCollections.ReadOnly.Set.cs b/src/Dependencies/Collections/Specialized/SpecializedCollections.ReadOnly.Set.cs
index 77c420b0df302..9a5781bd211df 100644
--- a/src/Dependencies/Collections/Specialized/SpecializedCollections.ReadOnly.Set.cs
+++ b/src/Dependencies/Collections/Specialized/SpecializedCollections.ReadOnly.Set.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections.Generic;
diff --git a/src/Dependencies/Collections/Specialized/SpecializedCollections.Singleton.Collection`1.cs b/src/Dependencies/Collections/Specialized/SpecializedCollections.Singleton.Collection`1.cs
index 0b34ed819367f..0b1d4b5de5f15 100644
--- a/src/Dependencies/Collections/Specialized/SpecializedCollections.Singleton.Collection`1.cs
+++ b/src/Dependencies/Collections/Specialized/SpecializedCollections.Singleton.Collection`1.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections;
using System.Collections.Generic;
diff --git a/src/Dependencies/Collections/Specialized/SpecializedCollections.Singleton.Enumerator`1.cs b/src/Dependencies/Collections/Specialized/SpecializedCollections.Singleton.Enumerator`1.cs
index 9e7bd4bde3640..160e9f272e6d3 100644
--- a/src/Dependencies/Collections/Specialized/SpecializedCollections.Singleton.Enumerator`1.cs
+++ b/src/Dependencies/Collections/Specialized/SpecializedCollections.Singleton.Enumerator`1.cs
@@ -2,6 +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.
+#nullable enable
+
using System.Collections;
using System.Collections.Generic;
diff --git a/src/Dependencies/Collections/Specialized/SpecializedCollections.cs b/src/Dependencies/Collections/Specialized/SpecializedCollections.cs
index 6c426971d6785..ac84a16712718 100644
--- a/src/Dependencies/Collections/Specialized/SpecializedCollections.cs
+++ b/src/Dependencies/Collections/Specialized/SpecializedCollections.cs
@@ -2,6 +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.
+#nullable enable
+
using System.Collections.Generic;
namespace Roslyn.Utilities
diff --git a/src/Dependencies/Collections/TemporaryArrayExtensions.cs b/src/Dependencies/Collections/TemporaryArrayExtensions.cs
index ea21e53908e6f..df57c3f899b6d 100644
--- a/src/Dependencies/Collections/TemporaryArrayExtensions.cs
+++ b/src/Dependencies/Collections/TemporaryArrayExtensions.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Linq;
using System.Runtime.CompilerServices;
diff --git a/src/Dependencies/Collections/TemporaryArray`1.cs b/src/Dependencies/Collections/TemporaryArray`1.cs
index 51571b3073b43..8f1856e4a58b4 100644
--- a/src/Dependencies/Collections/TemporaryArray`1.cs
+++ b/src/Dependencies/Collections/TemporaryArray`1.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
diff --git a/src/Dependencies/Contracts/CollectionBuilderAttribute.cs b/src/Dependencies/Contracts/CollectionBuilderAttribute.cs
index 684065ca3b927..dc4da52e89f34 100644
--- a/src/Dependencies/Contracts/CollectionBuilderAttribute.cs
+++ b/src/Dependencies/Contracts/CollectionBuilderAttribute.cs
@@ -2,6 +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.
+#nullable enable
+
#if !NET8_0_OR_GREATER
namespace System.Runtime.CompilerServices
diff --git a/src/Dependencies/Contracts/CompilerFeatureRequiredAttribute.cs b/src/Dependencies/Contracts/CompilerFeatureRequiredAttribute.cs
index 1810bdc4f64f5..18d182764b33c 100644
--- a/src/Dependencies/Contracts/CompilerFeatureRequiredAttribute.cs
+++ b/src/Dependencies/Contracts/CompilerFeatureRequiredAttribute.cs
@@ -2,6 +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.
+#nullable enable
+
// Copied from:
// https://github.com/dotnet/runtime/blob/fdd104ec5e1d0d2aa24a6723995a98d0124f724b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/CompilerFeatureRequiredAttribute.cs
diff --git a/src/Dependencies/Contracts/Contract.InterpolatedStringHandlers.cs b/src/Dependencies/Contracts/Contract.InterpolatedStringHandlers.cs
index 628aa3457f573..89b969dc5c6fc 100644
--- a/src/Dependencies/Contracts/Contract.InterpolatedStringHandlers.cs
+++ b/src/Dependencies/Contracts/Contract.InterpolatedStringHandlers.cs
@@ -2,6 +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.
+#nullable enable
+
#if !MICROSOFT_CODEANALYSIS_CONTRACTS_NO_CONTRACT
using System.Runtime.CompilerServices;
diff --git a/src/Dependencies/Contracts/Contract.cs b/src/Dependencies/Contracts/Contract.cs
index 489ffe5bea9de..28da2af8377ce 100644
--- a/src/Dependencies/Contracts/Contract.cs
+++ b/src/Dependencies/Contracts/Contract.cs
@@ -2,6 +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.
+#nullable enable
+
#if !MICROSOFT_CODEANALYSIS_CONTRACTS_NO_CONTRACT
using System;
diff --git a/src/Dependencies/Contracts/ExceptionUtilities.cs b/src/Dependencies/Contracts/ExceptionUtilities.cs
index 983341521a3c3..cfc71b0c9eaa2 100644
--- a/src/Dependencies/Contracts/ExceptionUtilities.cs
+++ b/src/Dependencies/Contracts/ExceptionUtilities.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
diff --git a/src/Dependencies/Contracts/ExperimentalAttribute.cs b/src/Dependencies/Contracts/ExperimentalAttribute.cs
index 723361aa24f85..867f4636326d2 100644
--- a/src/Dependencies/Contracts/ExperimentalAttribute.cs
+++ b/src/Dependencies/Contracts/ExperimentalAttribute.cs
@@ -2,6 +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.
+#nullable enable
+
// This was copied from https://github.com/dotnet/runtime/blob/815953a12c822847095a843d69c610a9f895ae3f/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/ExperimentalAttribute.cs
// and updated to have the scope of the attributes be internal.
diff --git a/src/Dependencies/Contracts/IReadOnlySet.cs b/src/Dependencies/Contracts/IReadOnlySet.cs
index 00d0e12056f3f..23d96d1b0c064 100644
--- a/src/Dependencies/Contracts/IReadOnlySet.cs
+++ b/src/Dependencies/Contracts/IReadOnlySet.cs
@@ -2,6 +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.
+#nullable enable
+
#if NET6_0_OR_GREATER
using System.Runtime.CompilerServices;
diff --git a/src/Dependencies/Contracts/Index.cs b/src/Dependencies/Contracts/Index.cs
index 8903fd515a3b5..214898129892d 100644
--- a/src/Dependencies/Contracts/Index.cs
+++ b/src/Dependencies/Contracts/Index.cs
@@ -2,6 +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.
+#nullable enable
+
#if NET
#pragma warning disable RS0016 // Add public types and members to the declared API (this is a supporting forwarder for an internal polyfill API)
diff --git a/src/Dependencies/Contracts/InterpolatedStringHandlerArgumentAttribute.cs b/src/Dependencies/Contracts/InterpolatedStringHandlerArgumentAttribute.cs
index 77690b8c5140c..a8df29ce9465d 100644
--- a/src/Dependencies/Contracts/InterpolatedStringHandlerArgumentAttribute.cs
+++ b/src/Dependencies/Contracts/InterpolatedStringHandlerArgumentAttribute.cs
@@ -2,6 +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.
+#nullable enable
+
#if NET6_0_OR_GREATER
using System.Runtime.CompilerServices;
@@ -12,6 +14,8 @@
#else
+#pragma warning disable CA1019 // Add a public read-only property accessor for positional argument argument of Attribute
+
namespace System.Runtime.CompilerServices
{
/// Indicates which arguments to a method involving an interpolated string handler should be passed to that handler.
diff --git a/src/Dependencies/Contracts/InterpolatedStringHandlerAttribute.cs b/src/Dependencies/Contracts/InterpolatedStringHandlerAttribute.cs
index 84f8216271823..1ac03f50faba5 100644
--- a/src/Dependencies/Contracts/InterpolatedStringHandlerAttribute.cs
+++ b/src/Dependencies/Contracts/InterpolatedStringHandlerAttribute.cs
@@ -2,6 +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.
+#nullable enable
+
#if NET6_0_OR_GREATER
using System.Runtime.CompilerServices;
diff --git a/src/Dependencies/Contracts/IsExternalInit.cs b/src/Dependencies/Contracts/IsExternalInit.cs
index 2e63533ac4099..cf6d665f0f47e 100644
--- a/src/Dependencies/Contracts/IsExternalInit.cs
+++ b/src/Dependencies/Contracts/IsExternalInit.cs
@@ -2,6 +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.
+#nullable enable
+
// Copied from:
// https://github.com/dotnet/runtime/blob/218ef0f7776c2c20f6c594e3475b80f1fe2d7d08/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/IsExternalInit.cs
diff --git a/src/Dependencies/Contracts/NonCopyableAttribute.cs b/src/Dependencies/Contracts/NonCopyableAttribute.cs
index a5efff996a18a..a83373ef6a56b 100644
--- a/src/Dependencies/Contracts/NonCopyableAttribute.cs
+++ b/src/Dependencies/Contracts/NonCopyableAttribute.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
namespace Microsoft.CodeAnalysis;
diff --git a/src/Dependencies/Contracts/NonDefaultableAttribute.cs b/src/Dependencies/Contracts/NonDefaultableAttribute.cs
index c89b6aed40f05..bddbc3f380714 100644
--- a/src/Dependencies/Contracts/NonDefaultableAttribute.cs
+++ b/src/Dependencies/Contracts/NonDefaultableAttribute.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
namespace Microsoft.CodeAnalysis;
diff --git a/src/Dependencies/Contracts/NullableAttributes.cs b/src/Dependencies/Contracts/NullableAttributes.cs
index ebe509bd420cf..b6eefd3018413 100644
--- a/src/Dependencies/Contracts/NullableAttributes.cs
+++ b/src/Dependencies/Contracts/NullableAttributes.cs
@@ -2,8 +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.
+#nullable enable
+
// This was copied from https://github.com/dotnet/runtime/blob/39b9607807f29e48cae4652cd74735182b31182e/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/NullableAttributes.cs
// and updated to have the scope of the attributes be internal.
+
namespace System.Diagnostics.CodeAnalysis
{
#if !NETCOREAPP
diff --git a/src/Dependencies/Contracts/Range.cs b/src/Dependencies/Contracts/Range.cs
index 0ee4eba72c798..1f4ac6e0bf5ea 100644
--- a/src/Dependencies/Contracts/Range.cs
+++ b/src/Dependencies/Contracts/Range.cs
@@ -2,6 +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.
+#nullable enable
+
#if NET
#pragma warning disable RS0016 // Add public types and members to the declared API (this is a supporting forwarder for an internal polyfill API)
diff --git a/src/Dependencies/Contracts/RequiredMemberAttribute.cs b/src/Dependencies/Contracts/RequiredMemberAttribute.cs
index 520a3e44cfa17..7004bd7526572 100644
--- a/src/Dependencies/Contracts/RequiredMemberAttribute.cs
+++ b/src/Dependencies/Contracts/RequiredMemberAttribute.cs
@@ -2,6 +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.
+#nullable enable
+
// Copied from:
// https://github.com/dotnet/runtime/blob/fdd104ec5e1d0d2aa24a6723995a98d0124f724b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RequiredMemberAttribute.cs
diff --git a/src/Dependencies/Contracts/SetsRequiredMembersAttribute.cs b/src/Dependencies/Contracts/SetsRequiredMembersAttribute.cs
index 05259b1e13ea5..891d50f2859d8 100644
--- a/src/Dependencies/Contracts/SetsRequiredMembersAttribute.cs
+++ b/src/Dependencies/Contracts/SetsRequiredMembersAttribute.cs
@@ -2,6 +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.
+#nullable enable
+
// Copied from:
// https://github.com/dotnet/runtime/blob/fdd104ec5e1d0d2aa24a6723995a98d0124f724b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/SetsRequiredMembersAttribute.cs
diff --git a/src/Dependencies/Directory.Build.targets b/src/Dependencies/Directory.Build.targets
new file mode 100644
index 0000000000000..db2b1748f0b33
--- /dev/null
+++ b/src/Dependencies/Directory.Build.targets
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+ $(TargetsForTfmSpecificContentInPackage);_AddEditorConfigToSourcePackage
+
+
+
+
+
+
+
+
diff --git a/src/Dependencies/PooledObjects/ArrayBuilder.Enumerator.cs b/src/Dependencies/PooledObjects/ArrayBuilder.Enumerator.cs
index de429a7d0f3aa..94bfba790f9ad 100644
--- a/src/Dependencies/PooledObjects/ArrayBuilder.Enumerator.cs
+++ b/src/Dependencies/PooledObjects/ArrayBuilder.Enumerator.cs
@@ -2,6 +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.
+#nullable enable
+
namespace Microsoft.CodeAnalysis.PooledObjects
{
internal partial class ArrayBuilder
diff --git a/src/Dependencies/PooledObjects/ArrayBuilder.cs b/src/Dependencies/PooledObjects/ArrayBuilder.cs
index 179459990b577..80ebb45f3679a 100644
--- a/src/Dependencies/PooledObjects/ArrayBuilder.cs
+++ b/src/Dependencies/PooledObjects/ArrayBuilder.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
diff --git a/src/Dependencies/PooledObjects/ArrayBuilderExtensions.cs b/src/Dependencies/PooledObjects/ArrayBuilderExtensions.cs
index 28005a924df4d..602e7df7b68f8 100644
--- a/src/Dependencies/PooledObjects/ArrayBuilderExtensions.cs
+++ b/src/Dependencies/PooledObjects/ArrayBuilderExtensions.cs
@@ -2,6 +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.
+#nullable enable
+
using System.Collections.Immutable;
namespace Microsoft.CodeAnalysis.PooledObjects;
diff --git a/src/Dependencies/PooledObjects/IPooled.cs b/src/Dependencies/PooledObjects/IPooled.cs
index 0b687f3f3e697..db9243fce9719 100644
--- a/src/Dependencies/PooledObjects/IPooled.cs
+++ b/src/Dependencies/PooledObjects/IPooled.cs
@@ -2,6 +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.
+#nullable enable
+
namespace Microsoft.CodeAnalysis.PooledObjects;
internal interface IPooled
diff --git a/src/Dependencies/PooledObjects/Microsoft.CodeAnalysis.PooledObjects.Package.csproj b/src/Dependencies/PooledObjects/Microsoft.CodeAnalysis.PooledObjects.Package.csproj
index 744452f6837d0..c760d4f28075d 100644
--- a/src/Dependencies/PooledObjects/Microsoft.CodeAnalysis.PooledObjects.Package.csproj
+++ b/src/Dependencies/PooledObjects/Microsoft.CodeAnalysis.PooledObjects.Package.csproj
@@ -21,8 +21,5 @@
-
-
-
diff --git a/src/Dependencies/PooledObjects/ObjectPool`1.cs b/src/Dependencies/PooledObjects/ObjectPool`1.cs
index 043a52b9ccc53..661523560694f 100644
--- a/src/Dependencies/PooledObjects/ObjectPool`1.cs
+++ b/src/Dependencies/PooledObjects/ObjectPool`1.cs
@@ -2,6 +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.
+#nullable enable
+
// define TRACE_LEAKS to get additional diagnostics that can lead to the leak sources. note: it will
// make everything about 2-3x slower
//
diff --git a/src/Dependencies/PooledObjects/PooledDelegates.cs b/src/Dependencies/PooledObjects/PooledDelegates.cs
index d4717535b334c..f4c62b81662c5 100644
--- a/src/Dependencies/PooledObjects/PooledDelegates.cs
+++ b/src/Dependencies/PooledObjects/PooledDelegates.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Runtime.CompilerServices;
diff --git a/src/Dependencies/PooledObjects/PooledDictionary.cs b/src/Dependencies/PooledObjects/PooledDictionary.cs
index d8347be56f51f..c62b029a2db98 100644
--- a/src/Dependencies/PooledObjects/PooledDictionary.cs
+++ b/src/Dependencies/PooledObjects/PooledDictionary.cs
@@ -2,6 +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.
+#nullable enable
+
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
diff --git a/src/Dependencies/PooledObjects/PooledDisposer.cs b/src/Dependencies/PooledObjects/PooledDisposer.cs
index e497c4dbd16e9..416eb6fc717ee 100644
--- a/src/Dependencies/PooledObjects/PooledDisposer.cs
+++ b/src/Dependencies/PooledObjects/PooledDisposer.cs
@@ -2,6 +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.
+#nullable enable
+
#if !MICROSOFT_CODEANALYSIS_POOLEDOBJECTS_NO_POOLED_DISPOSER
using System;
diff --git a/src/Dependencies/PooledObjects/PooledHashSet.cs b/src/Dependencies/PooledObjects/PooledHashSet.cs
index d3c5ca7c98104..95617c5ad407e 100644
--- a/src/Dependencies/PooledObjects/PooledHashSet.cs
+++ b/src/Dependencies/PooledObjects/PooledHashSet.cs
@@ -2,6 +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.
+#nullable enable
+
using System.Collections.Generic;
using System.Diagnostics;
diff --git a/src/Dependencies/PooledObjects/PooledStringBuilder.cs b/src/Dependencies/PooledObjects/PooledStringBuilder.cs
index 2a16fbd85f7aa..673f8ca8140ee 100644
--- a/src/Dependencies/PooledObjects/PooledStringBuilder.cs
+++ b/src/Dependencies/PooledObjects/PooledStringBuilder.cs
@@ -2,6 +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.
+#nullable enable
+
using System.Diagnostics;
using System.Text;
diff --git a/src/Dependencies/SourcePackage.editorconfig b/src/Dependencies/SourcePackage.editorconfig
new file mode 100644
index 0000000000000..f93cc9962b2f0
--- /dev/null
+++ b/src/Dependencies/SourcePackage.editorconfig
@@ -0,0 +1,2 @@
+[*.cs]
+generated_code = true
\ No newline at end of file
diff --git a/src/Dependencies/Threading/AsyncBatchingWorkQueue`0.cs b/src/Dependencies/Threading/AsyncBatchingWorkQueue`0.cs
index db94f6efbc8e7..95b46d05e6bd9 100644
--- a/src/Dependencies/Threading/AsyncBatchingWorkQueue`0.cs
+++ b/src/Dependencies/Threading/AsyncBatchingWorkQueue`0.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections.Generic;
using System.Threading;
diff --git a/src/Dependencies/Threading/AsyncBatchingWorkQueue`1.cs b/src/Dependencies/Threading/AsyncBatchingWorkQueue`1.cs
index a14aebc098cb9..0c322ba753a7f 100644
--- a/src/Dependencies/Threading/AsyncBatchingWorkQueue`1.cs
+++ b/src/Dependencies/Threading/AsyncBatchingWorkQueue`1.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections.Generic;
using System.Threading;
diff --git a/src/Dependencies/Threading/AsyncBatchingWorkQueue`2.cs b/src/Dependencies/Threading/AsyncBatchingWorkQueue`2.cs
index 4844a6f60c807..3f31f922c0425 100644
--- a/src/Dependencies/Threading/AsyncBatchingWorkQueue`2.cs
+++ b/src/Dependencies/Threading/AsyncBatchingWorkQueue`2.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -25,7 +27,7 @@ namespace Microsoft.CodeAnalysis.Threading;
/// cref="CancellationToken.IsCancellationRequested"/>.
///
///
-internal class AsyncBatchingWorkQueue
+internal class AsyncBatchingWorkQueue : IDisposable
{
///
/// Delay we wait after finishing the processing of one batch and starting up on then.
@@ -121,6 +123,11 @@ public AsyncBatchingWorkQueue(
CancelExistingWork();
}
+ public void Dispose()
+ {
+ _cancellationSeries.Dispose();
+ }
+
///
/// Cancels any outstanding work in this queue. Work that has not yet started will never run. Work that is in
/// progress will request cancellation in a standard best effort fashion.
diff --git a/src/Dependencies/Threading/CancellationSeries.cs b/src/Dependencies/Threading/CancellationSeries.cs
index 1a477841243e2..36e6a71d1ff8b 100644
--- a/src/Dependencies/Threading/CancellationSeries.cs
+++ b/src/Dependencies/Threading/CancellationSeries.cs
@@ -2,6 +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.
+#nullable enable
+
// NOTE: This code is derived from an implementation originally in dotnet/project-system:
// https://github.com/dotnet/project-system/blob/bdf69d5420ec8d894f5bf4c3d4692900b7f2479c/src/Microsoft.VisualStudio.ProjectSystem.Managed/Threading/Tasks/CancellationSeries.cs
//
diff --git a/src/Dependencies/Threading/ConfiguredYieldAwaitable.cs b/src/Dependencies/Threading/ConfiguredYieldAwaitable.cs
index 80502b3fbc1fc..c77c9f0d13dc9 100644
--- a/src/Dependencies/Threading/ConfiguredYieldAwaitable.cs
+++ b/src/Dependencies/Threading/ConfiguredYieldAwaitable.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Runtime.CompilerServices;
using System.Threading;
diff --git a/src/Dependencies/Threading/TaskExtensions.cs b/src/Dependencies/Threading/TaskExtensions.cs
index f35eb18a71e10..1ebca09b9e076 100644
--- a/src/Dependencies/Threading/TaskExtensions.cs
+++ b/src/Dependencies/Threading/TaskExtensions.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
diff --git a/src/Dependencies/Threading/TestHooks/IAsyncToken.cs b/src/Dependencies/Threading/TestHooks/IAsyncToken.cs
index c28f3d31fd157..201bbf667b1b0 100644
--- a/src/Dependencies/Threading/TestHooks/IAsyncToken.cs
+++ b/src/Dependencies/Threading/TestHooks/IAsyncToken.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
namespace Microsoft.CodeAnalysis.Shared.TestHooks;
diff --git a/src/Dependencies/Threading/TestHooks/IAsynchronousOperationListener.cs b/src/Dependencies/Threading/TestHooks/IAsynchronousOperationListener.cs
index e2093d80ad6f9..0b0e0b96948a6 100644
--- a/src/Dependencies/Threading/TestHooks/IAsynchronousOperationListener.cs
+++ b/src/Dependencies/Threading/TestHooks/IAsynchronousOperationListener.cs
@@ -2,6 +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.
+#nullable enable
+
using System.Runtime.CompilerServices;
namespace Microsoft.CodeAnalysis.Shared.TestHooks;
diff --git a/src/Dependencies/Threading/TestHooks/IAsynchronousOperationListenerProvider.cs b/src/Dependencies/Threading/TestHooks/IAsynchronousOperationListenerProvider.cs
index dde7959cf71c9..dc11fd01821c8 100644
--- a/src/Dependencies/Threading/TestHooks/IAsynchronousOperationListenerProvider.cs
+++ b/src/Dependencies/Threading/TestHooks/IAsynchronousOperationListenerProvider.cs
@@ -2,6 +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.
+#nullable enable
+
namespace Microsoft.CodeAnalysis.Shared.TestHooks;
///
diff --git a/src/Dependencies/Threading/TestHooks/IExpeditableDelaySource.cs b/src/Dependencies/Threading/TestHooks/IExpeditableDelaySource.cs
index 45398b1737ac5..c144a997db0dc 100644
--- a/src/Dependencies/Threading/TestHooks/IExpeditableDelaySource.cs
+++ b/src/Dependencies/Threading/TestHooks/IExpeditableDelaySource.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
diff --git a/src/Dependencies/Threading/ValueTaskExtensions.cs b/src/Dependencies/Threading/ValueTaskExtensions.cs
index 366c3014edcda..2d83f43f21382 100644
--- a/src/Dependencies/Threading/ValueTaskExtensions.cs
+++ b/src/Dependencies/Threading/ValueTaskExtensions.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
diff --git a/src/Dependencies/Threading/VoidResult.cs b/src/Dependencies/Threading/VoidResult.cs
index 2e626ce7209d5..6b4bce7d36141 100644
--- a/src/Dependencies/Threading/VoidResult.cs
+++ b/src/Dependencies/Threading/VoidResult.cs
@@ -2,6 +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.
+#nullable enable
+
using System;
namespace Microsoft.CodeAnalysis.Threading;
diff --git a/src/Dependencies/Threading/YieldAwaitableExtensions.cs b/src/Dependencies/Threading/YieldAwaitableExtensions.cs
index 6cd6f6db5794b..7aaf54e536331 100644
--- a/src/Dependencies/Threading/YieldAwaitableExtensions.cs
+++ b/src/Dependencies/Threading/YieldAwaitableExtensions.cs
@@ -2,6 +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.
+#nullable enable
+
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
diff --git a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/PDB/MethodDebugInfo.Native.cs b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/PDB/MethodDebugInfo.Native.cs
index 40a590376293f..1b22686f04323 100644
--- a/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/PDB/MethodDebugInfo.Native.cs
+++ b/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/PDB/MethodDebugInfo.Native.cs
@@ -358,6 +358,7 @@ private static bool TryCreateImportRecordFromCSharpImportString(EESymbolProvider
ITypeSymbolInternal? type = null;
if (targetKind == ImportTargetKind.Type)
{
+ RoslynDebug.Assert(targetString != null);
type = symbolProvider.GetTypeSymbolForSerializedType(targetString);
targetString = null;
}
@@ -599,10 +600,7 @@ private static void ReadVisualBasicImportsDebugInfo(
private static bool TryCreateImportRecordFromVisualBasicImportString(string importString, out ImportRecord record, out VBImportScopeKind scope)
{
- ImportTargetKind targetKind;
- string alias;
- string targetString;
- if (CustomDebugInfoReader.TryParseVisualBasicImportString(importString, out alias, out targetString, out targetKind, out scope))
+ if (CustomDebugInfoReader.TryParseVisualBasicImportString(importString, out var alias, out var targetString, out var targetKind, out scope))
{
record = new ImportRecord(
targetKind: targetKind,