Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge main to features/extended-property-patterns #53903

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
ed3f297
Suppress ExecutionContext flow on SQLite hot path
sharwell May 19, 2021
f956d76
enables auto-attach to servicehub processes
jmarolf May 21, 2021
1f6d15e
have service hub debugging be its own profile
jmarolf May 21, 2021
1f902ca
Don't validate workspace invariants in release builds
jasonmalinowski May 27, 2021
6580861
Update dependencies from https://github.com/dotnet/arcade build 20210…
dotnet-maestro[bot] May 30, 2021
879ef60
Do not persist diagnostics just to purge them from memory
CyrusNajmabadi May 31, 2021
c34fa7a
Rename members for clarity
CyrusNajmabadi May 31, 2021
f944fc1
REmove unused code
CyrusNajmabadi May 31, 2021
de666d2
MOve static methods
CyrusNajmabadi May 31, 2021
4aeccc3
Remove unused field
CyrusNajmabadi May 31, 2021
0addecf
Update dependencies from https://github.com/dotnet/arcade build 20210…
dotnet-maestro[bot] Jun 1, 2021
0de95bb
Merge pull request #53723 from jasonmalinowski/check-invariants-in-de…
jasonmalinowski Jun 1, 2021
1bf0e0d
Merge pull request #53601 from jmarolf/debug-service-process
jmarolf Jun 1, 2021
87bf7c2
Inline further
CyrusNajmabadi Jun 2, 2021
cf37fb9
Merge pull request #53503 from sharwell/faster-save
sharwell Jun 2, 2021
7e06c9a
Make async again
CyrusNajmabadi Jun 2, 2021
253a00d
Make async again
CyrusNajmabadi Jun 2, 2021
5cabbd1
Cancellation tokens
CyrusNajmabadi Jun 2, 2021
97d2d16
Simplify
CyrusNajmabadi Jun 2, 2021
75d1282
Merge pull request #53792 from CyrusNajmabadi/diagnosticsPersistence
CyrusNajmabadi Jun 2, 2021
a56336b
Store more information when an exception happens when making RPC call…
CyrusNajmabadi Jun 2, 2021
31103b6
Merge pull request #53839 from CyrusNajmabadi/jsonRpcException
CyrusNajmabadi Jun 2, 2021
e126f50
Update dependencies from https://github.com/dotnet/arcade build 20210…
dotnet-maestro[bot] Jun 3, 2021
e7a1f63
Remove unused obsolete member
CyrusNajmabadi Jun 3, 2021
5bab61d
Move spans to symbol items only
CyrusNajmabadi Jun 3, 2021
d07aa08
Simplify
CyrusNajmabadi Jun 3, 2021
86e1376
Do not realize symbols in LSP for navbars
CyrusNajmabadi Jun 3, 2021
967687e
Simplify
CyrusNajmabadi Jun 3, 2021
bd1e95a
Update docs
CyrusNajmabadi Jun 3, 2021
380fdeb
Merge pull request #53869 from CyrusNajmabadi/navToFixesSafe
CyrusNajmabadi Jun 4, 2021
ce1b1b7
Fix vb event generation in navbars
CyrusNajmabadi Jun 4, 2021
4596487
Merge pull request #53876 from CyrusNajmabadi/vbNavBarEvents
CyrusNajmabadi Jun 4, 2021
4458d00
EnC: Implements support for #line mappings (#53735)
tmat Jun 4, 2021
5f49d16
Add but vb
CyrusNajmabadi Jun 4, 2021
78648af
COntinuing
CyrusNajmabadi Jun 4, 2021
af2dcdf
Finish VBside
CyrusNajmabadi Jun 4, 2021
8c21c25
Only store a single span in nav bar items
CyrusNajmabadi Jun 4, 2021
cd97cac
Update dependencies from https://github.com/dotnet/arcade build 20210…
dotnet-maestro[bot] Jun 4, 2021
6fb1e8e
Go back to spans
CyrusNajmabadi Jun 4, 2021
3c9e3d2
Simplify
CyrusNajmabadi Jun 4, 2021
95d4938
Revert
CyrusNajmabadi Jun 4, 2021
e75b807
Merge remote-tracking branch 'upstream/main' into navBarSpans
CyrusNajmabadi Jun 4, 2021
b5c0ea2
Merge branch 'singleNavBarSpan' into navBarSpans
CyrusNajmabadi Jun 4, 2021
c7491fc
Extract helper type
CyrusNajmabadi Jun 4, 2021
835a8c7
INtroduce location concept
CyrusNajmabadi Jun 4, 2021
58bc1eb
Handle tracking span
CyrusNajmabadi Jun 4, 2021
d699b84
Check nav tracking span as well
CyrusNajmabadi Jun 4, 2021
e543b83
Pass tracking span along
CyrusNajmabadi Jun 4, 2021
fdaaa15
Add but vb
CyrusNajmabadi Jun 4, 2021
c92d4ca
VBside
CyrusNajmabadi Jun 4, 2021
ce4e22f
Update LSP side
CyrusNajmabadi Jun 4, 2021
66312ff
Add datacontract
CyrusNajmabadi Jun 4, 2021
ab9740d
Restore bolding
CyrusNajmabadi Jun 4, 2021
344c91b
Before vb virtual space
CyrusNajmabadi Jun 4, 2021
7d2a7a0
Restore VBlogic
CyrusNajmabadi Jun 4, 2021
ee923e9
Move code
CyrusNajmabadi Jun 4, 2021
cb128ea
Add comments
CyrusNajmabadi Jun 4, 2021
34be751
Delete
CyrusNajmabadi Jun 4, 2021
f40f8f5
Add comments
CyrusNajmabadi Jun 4, 2021
0c64cb7
Delete
CyrusNajmabadi Jun 4, 2021
b053bc9
Relax
CyrusNajmabadi Jun 4, 2021
252f621
Merge pull request #53878 from CyrusNajmabadi/singleNavBarSpan
CyrusNajmabadi Jun 4, 2021
22a5fb6
Merge remote-tracking branch 'upstream/main' into navBarSpans
CyrusNajmabadi Jun 4, 2021
7385bd9
FOrmatting
CyrusNajmabadi Jun 4, 2021
fcf339a
Comments
CyrusNajmabadi Jun 4, 2021
8fa2647
Switch to UIthread
CyrusNajmabadi Jun 5, 2021
f172963
Merge pull request #53887 from CyrusNajmabadi/navBarSpans
CyrusNajmabadi Jun 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Roslyn.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28503.202
# Visual Studio Version 17
VisualStudioVersion = 17.0.31319.15
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RoslynDeployment", "src\Deployment\RoslynDeployment.csproj", "{600AF682-E097-407B-AD85-EE3CED37E680}"
EndProject
Expand Down
8 changes: 4 additions & 4 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="6.0.0-beta.21277.1">
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="6.0.0-beta.21303.2">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>c3e0e4070f6cd3873b775e3f4136e29f4d66cb49</Sha>
<Sha>78da7776965b428ff31da8f1ff2cb073506212b7</Sha>
<SourceBuild RepoName="arcade" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="4.0.0-2.21253.8">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>5b972bceb846f5d15f991a479e285067a75103e4</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="6.0.0-beta.21277.1">
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="6.0.0-beta.21303.2">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>c3e0e4070f6cd3873b775e3f4136e29f4d66cb49</Sha>
<Sha>78da7776965b428ff31da8f1ff2cb073506212b7</Sha>
</Dependency>
</ToolsetDependencies>
</Dependencies>
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"xcopy-msbuild": "16.8.0-preview2.1"
},
"msbuild-sdks": {
"Microsoft.DotNet.Arcade.Sdk": "6.0.0-beta.21277.1",
"Microsoft.DotNet.Helix.Sdk": "6.0.0-beta.21277.1"
"Microsoft.DotNet.Arcade.Sdk": "6.0.0-beta.21303.2",
"Microsoft.DotNet.Helix.Sdk": "6.0.0-beta.21303.2"
}
}
1 change: 1 addition & 0 deletions src/Compilers/CSharp/Portable/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ Microsoft.CodeAnalysis.CSharp.Syntax.UsingDirectiveSyntax.GlobalKeyword.get -> M
Microsoft.CodeAnalysis.CSharp.Syntax.UsingDirectiveSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken globalKeyword, Microsoft.CodeAnalysis.SyntaxToken usingKeyword, Microsoft.CodeAnalysis.SyntaxToken staticKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.NameEqualsSyntax alias, Microsoft.CodeAnalysis.CSharp.Syntax.NameSyntax name, Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.UsingDirectiveSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.UsingDirectiveSyntax.WithGlobalKeyword(Microsoft.CodeAnalysis.SyntaxToken globalKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.UsingDirectiveSyntax
*REMOVED*Microsoft.CodeAnalysis.CSharp.SyntaxKind.DataKeyword = 8441 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind
override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.GetLineMappings(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.LineMapping>
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ public override LineVisibility GetLineVisibility(SourceText sourceText, int posi
}
}

// C# does not have unknown visibility state
protected override LineVisibility GetUnknownStateVisibility(int index)
=> throw ExceptionUtilities.Unreachable;

internal override FileLinePositionSpan TranslateSpanAndVisibility(SourceText sourceText, string treeFilePath, TextSpan span, out bool isHiddenPosition)
{
var lines = sourceText.Lines;
Expand Down
67 changes: 26 additions & 41 deletions src/Compilers/CSharp/Portable/Syntax/CSharpSyntaxTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
Expand Down Expand Up @@ -607,6 +608,17 @@ public override IList<TextChange> GetChanges(SyntaxTree oldTree)

#region LinePositions and Locations

private CSharpLineDirectiveMap GetDirectiveMap()
{
if (_lazyLineDirectiveMap == null)
{
// Create the line directive map on demand.
Interlocked.CompareExchange(ref _lazyLineDirectiveMap, new CSharpLineDirectiveMap(this), null);
}

return _lazyLineDirectiveMap;
}

/// <summary>
/// Gets the location in terms of path, line and column for a given span.
/// </summary>
Expand All @@ -617,9 +629,7 @@ public override IList<TextChange> GetChanges(SyntaxTree oldTree)
/// </returns>
/// <remarks>The values are not affected by line mapping directives (<c>#line</c>).</remarks>
public override FileLinePositionSpan GetLineSpan(TextSpan span, CancellationToken cancellationToken = default)
{
return new FileLinePositionSpan(this.FilePath, GetLinePosition(span.Start), GetLinePosition(span.End));
}
=> new(FilePath, GetLinePosition(span.Start, cancellationToken), GetLinePosition(span.End, cancellationToken));

/// <summary>
/// Gets the location in terms of path, line and column after applying source line mapping directives (<c>#line</c>).
Expand All @@ -638,25 +648,18 @@ public override FileLinePositionSpan GetLineSpan(TextSpan span, CancellationToke
/// </para>
/// </returns>
public override FileLinePositionSpan GetMappedLineSpan(TextSpan span, CancellationToken cancellationToken = default)
{
if (_lazyLineDirectiveMap == null)
{
// Create the line directive map on demand.
Interlocked.CompareExchange(ref _lazyLineDirectiveMap, new CSharpLineDirectiveMap(this), null);
}

return _lazyLineDirectiveMap.TranslateSpan(this.GetText(cancellationToken), this.FilePath, span);
}
=> GetDirectiveMap().TranslateSpan(GetText(cancellationToken), this.FilePath, span);

/// <inheritdoc/>
public override LineVisibility GetLineVisibility(int position, CancellationToken cancellationToken = default)
{
if (_lazyLineDirectiveMap == null)
{
// Create the line directive map on demand.
Interlocked.CompareExchange(ref _lazyLineDirectiveMap, new CSharpLineDirectiveMap(this), null);
}
=> GetDirectiveMap().GetLineVisibility(GetText(cancellationToken), position);

return _lazyLineDirectiveMap.GetLineVisibility(this.GetText(cancellationToken), position);
/// <inheritdoc/>
public override IEnumerable<LineMapping> GetLineMappings(CancellationToken cancellationToken = default)
{
var map = GetDirectiveMap();
Debug.Assert(map.Entries.Length >= 1);
return (map.Entries.Length == 1) ? Array.Empty<LineMapping>() : map.GetLineMappings(GetText(cancellationToken).Lines);
}

/// <summary>
Expand All @@ -667,30 +670,14 @@ public override LineVisibility GetLineVisibility(int position, CancellationToken
/// <param name="isHiddenPosition">When the method returns, contains a boolean value indicating whether this span is considered hidden or not.</param>
/// <returns>A resulting <see cref="FileLinePositionSpan"/>.</returns>
internal override FileLinePositionSpan GetMappedLineSpanAndVisibility(TextSpan span, out bool isHiddenPosition)
{
if (_lazyLineDirectiveMap == null)
{
// Create the line directive map on demand.
Interlocked.CompareExchange(ref _lazyLineDirectiveMap, new CSharpLineDirectiveMap(this), null);
}

return _lazyLineDirectiveMap.TranslateSpanAndVisibility(this.GetText(), this.FilePath, span, out isHiddenPosition);
}
=> GetDirectiveMap().TranslateSpanAndVisibility(GetText(), FilePath, span, out isHiddenPosition);

/// <summary>
/// Gets a boolean value indicating whether there are any hidden regions in the tree.
/// </summary>
/// <returns>True if there is at least one hidden region.</returns>
public override bool HasHiddenRegions()
{
if (_lazyLineDirectiveMap == null)
{
// Create the line directive map on demand.
Interlocked.CompareExchange(ref _lazyLineDirectiveMap, new CSharpLineDirectiveMap(this), null);
}

return _lazyLineDirectiveMap.HasAnyHiddenRegions();
}
=> GetDirectiveMap().HasAnyHiddenRegions();

/// <summary>
/// Given the error code and the source location, get the warning state based on <c>#pragma warning</c> directives.
Expand Down Expand Up @@ -756,10 +743,8 @@ bool isGeneratedHeuristic()

private GeneratedKind _lazyIsGeneratedCode = GeneratedKind.Unknown;

private LinePosition GetLinePosition(int position)
{
return this.GetText().Lines.GetLinePosition(position);
}
private LinePosition GetLinePosition(int position, CancellationToken cancellationToken)
=> GetText(cancellationToken).Lines.GetLinePosition(position);

/// <summary>
/// Gets a <see cref="Location"/> for the specified text <paramref name="span"/>.
Expand Down
93 changes: 81 additions & 12 deletions src/Compilers/CSharp/Test/Syntax/Diagnostics/LocationsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#nullable disable

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO;
using System.Linq;
using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Test.Utilities;
using Xunit;
Expand Down Expand Up @@ -71,6 +71,12 @@ private TextSpan GetSpanIn(SyntaxTree syntaxTree, string textToFind)
return new TextSpan(index, textToFind.Length);
}

private static IEnumerable<string> InspectLineMapping(SyntaxTree tree)
{
var text = tree.GetText();
return tree.GetLineMappings().Select(mapping => $"[|{text.GetSubText(text.Lines.GetTextSpan(mapping.Span))}|] -> {(mapping.IsHidden ? "<hidden>" : mapping.MappedSpan)}");
}

[ClrOnlyFact]
public void TestGetSourceLocationInFile()
{
Expand Down Expand Up @@ -120,7 +126,7 @@ public void TestLineMapping1()
string sampleProgram = @"using System;
class X {
#line 20 ""banana.cs""
int x;
int x;
int y;
#line 44
int z;
Expand All @@ -134,7 +140,6 @@ class X {
#endif
int a;
}".NormalizeLineEndings();
var resolver = new TestSourceResolver();

SyntaxTree syntaxTree = SyntaxFactory.ParseSyntaxTree(sampleProgram, path: "goo.cs");

Expand All @@ -147,6 +152,15 @@ class X {
AssertMappedSpanEqual(syntaxTree, "w;", "goo.cs", 8, 4, 8, 6, hasMappedPath: false);
AssertMappedSpanEqual(syntaxTree, "q;\r\nin", "goo.cs", 10, 4, 11, 2, hasMappedPath: false);
AssertMappedSpanEqual(syntaxTree, "a;", "goo.cs", 15, 4, 15, 6, hasMappedPath: false);

AssertEx.Equal(new[]
{
"[|using System;\r\nclass X {\r\n|] -> : (0,0)-(1,11)",
"[|int x;\r\nint y;\r\n|] -> banana.cs: (19,0)-(20,8)",
"[|int z;\r\n|] -> banana.cs: (43,0)-(43,8)",
"[|int w;\r\n|] -> : (8,0)-(8,8)",
"[|int q;\r\nint f;\r\n#if false\r\n#line 17 \"d:\\twing.cs\"\r\n#endif\r\nint a;\r\n}|] -> <hidden>"
}, InspectLineMapping(syntaxTree));
}

[Fact]
Expand All @@ -165,8 +179,6 @@ class X {
#line 40
int v;
}";
var resolver = new TestSourceResolver();

SyntaxTree syntaxTree = SyntaxFactory.ParseSyntaxTree(sampleProgram, path: "c:\\goo.cs");

AssertMappedSpanEqual(syntaxTree, "int x;", "c:\\goo.cs", 19, 0, 19, 6, hasMappedPath: false);
Expand All @@ -183,8 +195,6 @@ public void TestLineMapping_NoSyntaxTreePath()
#line 20
class X {}
";
var resolver = new TestSourceResolver();

AssertMappedSpanEqual(SyntaxFactory.ParseSyntaxTree(sampleProgram, path: ""), "class X {}", "", 19, 0, 19, 10, hasMappedPath: false);
AssertMappedSpanEqual(SyntaxFactory.ParseSyntaxTree(sampleProgram, path: " "), "class X {}", " ", 19, 0, 19, 10, hasMappedPath: false);
}
Expand All @@ -194,32 +204,91 @@ public void TestInvalidLineMapping()
{
string sampleProgram = @"using System;
class X {
int q;
int q;
#line 0 ""firstdirective""
int r;
int r;
#line 20 ""seconddirective""
int s;
}";
int s;
}".NormalizeLineEndings();

SyntaxTree syntaxTree = SyntaxFactory.ParseSyntaxTree(sampleProgram, path: "filename.cs");

AssertMappedSpanEqual(syntaxTree, "int q", "filename.cs", 2, 4, 2, 9, hasMappedPath: false);
AssertMappedSpanEqual(syntaxTree, "int r", "filename.cs", 4, 4, 4, 9, hasMappedPath: false); // invalid #line args
AssertMappedSpanEqual(syntaxTree, "int s", "seconddirective", 19, 4, 19, 9, hasMappedPath: true);

AssertEx.Equal(new[]
{
"[|using System;\r\nclass X {\r\n int q;\r\n|] -> : (0,0)-(2,12)",
"[| int r;\r\n|] -> : (4,0)-(4,12)",
"[| int s;\r\n}|] -> seconddirective: (19,0)-(20,1)"
}, InspectLineMapping(syntaxTree));
}

[Fact]
public void TestLineMappingNoDirectives()
{
string sampleProgram = @"using System;
class X {
int x;
int x;
}";
SyntaxTree syntaxTree = SyntaxFactory.ParseSyntaxTree(sampleProgram, path: "c:\\goo.cs");

AssertMappedSpanEqual(syntaxTree, "ing Sy", "c:\\goo.cs", 0, 2, 0, 8, hasMappedPath: false);
AssertMappedSpanEqual(syntaxTree, "class X", "c:\\goo.cs", 1, 0, 1, 7, hasMappedPath: false);
AssertMappedSpanEqual(syntaxTree, $"System;{Environment.NewLine}class X", "c:\\goo.cs", 0, 6, 1, 7, hasMappedPath: false);
AssertMappedSpanEqual(syntaxTree, "x;", "c:\\goo.cs", 2, 4, 2, 6, hasMappedPath: false);

Assert.Empty(InspectLineMapping(syntaxTree));
}

[Fact]
public void TestLineMappingFirstAndLastLineDirectives()
{
string sampleProgram = @"#line 20
class X {}
#line 30".NormalizeLineEndings();
var syntaxTree = SyntaxFactory.ParseSyntaxTree(sampleProgram, path: "c:\\goo.cs");

AssertEx.Equal(new[]
{
"[|class X {}\r\n|] -> : (19,0)-(19,12)",
}, InspectLineMapping(syntaxTree));
}

[Fact]
public void TestLineMappingLastLineDirectiveFollowedByEmptyLine()
{
string sampleProgram = @"#line 30
".NormalizeLineEndings();

var syntaxTree = SyntaxFactory.ParseSyntaxTree(sampleProgram, path: "c:\\goo.cs");

AssertEx.Equal(new[]
{
"[||] -> : (29,0)-(29,0)",
}, InspectLineMapping(syntaxTree));
}

[Fact]
public void TestLineMappingConsecutiveDirectives()
{
string sampleProgram =
@"#line hidden
#line default
class C {}
#line 5
#line 10
class D {}
".NormalizeLineEndings();

var syntaxTree = SyntaxFactory.ParseSyntaxTree(sampleProgram, path: "c:\\goo.cs");

AssertEx.Equal(new[]
{
"[|class C {}\r\n|] -> : (2,0)-(2,12)",
"[|class D {}\r\n|] -> : (9,0)-(10,0)",
}, InspectLineMapping(syntaxTree));
}

[WorkItem(537005, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/537005")]
Expand Down
Loading