Skip to content

Commit 5c179e8

Browse files
authored
Merge pull request #40410 from sharwell/use-index
Simplify recent code with indexing operator
2 parents d340092 + 1a58f67 commit 5c179e8

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/EditorFeatures/CSharp/Highlighting/KeywordHighlighters/AsyncAwaitHighlighter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ private static bool TryAddAsyncOrAwaitKeyword(SyntaxToken mod, List<TextSpan> sp
104104
if (spans.Count > 0)
105105
{
106106
var previousToken = mod.GetPreviousToken();
107-
var lastSpan = spans[spans.Count - 1];
107+
var lastSpan = spans[^1];
108108
if (lastSpan == previousToken.Span)
109109
{
110-
spans[spans.Count - 1] = TextSpan.FromBounds(lastSpan.Start, mod.Span.End);
110+
spans[^1] = TextSpan.FromBounds(lastSpan.Start, mod.Span.End);
111111
return true;
112112
}
113113
}

src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@
108108
<Compile Include="..\..\..\Compilers\Core\Portable\InternalUtilities\ImmutableListExtensions.cs">
109109
<Link>InternalUtilities\ImmutableListExtensions.cs</Link>
110110
</Compile>
111+
<Compile Include="..\..\..\Compilers\Core\Portable\InternalUtilities\Index.cs">
112+
<Link>InternalUtilities\Index.cs</Link>
113+
</Compile>
111114
<Compile Include="..\..\..\Compilers\Core\Portable\InternalUtilities\ISetExtensions.cs">
112115
<Link>InternalUtilities\ISetExtensions.cs</Link>
113116
</Compile>
@@ -141,6 +144,9 @@
141144
<Compile Include="..\..\..\Compilers\Core\Portable\InternalUtilities\PlatformInformation.cs">
142145
<Link>InternalUtilities\PlatformInformation.cs</Link>
143146
</Compile>
147+
<Compile Include="..\..\..\Compilers\Core\Portable\InternalUtilities\Range.cs">
148+
<Link>InternalUtilities\Range.cs</Link>
149+
</Compile>
144150
<Compile Include="..\..\..\Compilers\Core\Portable\InternalUtilities\ReaderWriterLockSlimExtensions.cs">
145151
<Link>InternalUtilities\ReaderWriterLockSlimExtensions.cs</Link>
146152
</Compile>

0 commit comments

Comments
 (0)