Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Structure;
using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.CodeAnalysis.Text;
using Xunit;

namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Structure
{
public class AccessorDeclarationTests : AbstractCSharpSyntaxNodeStructureTests<AccessorDeclarationSyntax>
public class AccessorDeclarationStructureTests : AbstractCSharpSyntaxNodeStructureTests<AccessorDeclarationSyntax>
{
internal override AbstractSyntaxStructureProvider CreateProvider() => new AccessorDeclarationStructureProvider();

Expand Down Expand Up @@ -159,22 +158,16 @@ public string Text
{
$${|hint:get{|textspan:
{
}|}
|}
}|}|}

set
{
}
}
}";

await VerifyBlockSpansAsync(code,
new BlockSpan(
isCollapsible: true,
textSpan: TextSpan.FromBounds(56, 80),
hintSpan: TextSpan.FromBounds(53, 78),
type: BlockTypes.Nonstructural,
bannerText: CSharpStructureHelpers.Ellipsis,
autoCollapse: true));
Region("textspan", "hint", CSharpStructureHelpers.Ellipsis, autoCollapse: true));
}

[Fact, Trait(Traits.Feature, Traits.Features.Outlining)]
Expand All @@ -189,8 +182,8 @@ public string Text
// Getter|}
$${|hint2:get{|textspan2:
{
}|}
|}
}|}|}

set
{
}
Expand All @@ -200,13 +193,7 @@ public string Text

await VerifyBlockSpansAsync(code,
Region("span1", "// My ...", autoCollapse: true),
new BlockSpan(
isCollapsible: true,
textSpan: TextSpan.FromBounds(90, 114),
hintSpan: TextSpan.FromBounds(87, 112),
type: BlockTypes.Nonstructural,
bannerText: CSharpStructureHelpers.Ellipsis,
autoCollapse: true));
Region("textspan2", "hint2", CSharpStructureHelpers.Ellipsis, autoCollapse: true));
}

[Fact, Trait(Traits.Feature, Traits.Features.Outlining)]
Expand All @@ -221,8 +208,8 @@ public string Text
Getter */|}
$${|hint2:get{|textspan2:
{
}|}
|}
}|}|}

set
{
}
Expand All @@ -232,13 +219,7 @@ public string Text

await VerifyBlockSpansAsync(code,
Region("span1", "/* My ...", autoCollapse: true),
new BlockSpan(
isCollapsible: true,
textSpan: TextSpan.FromBounds(93, 117),
hintSpan: TextSpan.FromBounds(90, 115),
type: BlockTypes.Nonstructural,
bannerText: CSharpStructureHelpers.Ellipsis,
autoCollapse: true));
Region("textspan2", "hint2", CSharpStructureHelpers.Ellipsis, autoCollapse: true));
}

[Fact, Trait(Traits.Feature, Traits.Features.Outlining)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Structure;
using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.CodeAnalysis.Text;
using Xunit;

namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Structure
Expand Down Expand Up @@ -162,23 +161,17 @@ public async Task TestConstructor10()
const string code = @"
class C
{
$$public C()
{|hint:$$public C(){|textspan:
{
}
}|}|}

public C(int x)
{
}
}";

await VerifyBlockSpansAsync(code,
new BlockSpan(
isCollapsible: true,
textSpan: TextSpan.FromBounds(28, 44),
hintSpan: TextSpan.FromBounds(18, 42),
type: BlockTypes.Nonstructural,
bannerText: CSharpStructureHelpers.Ellipsis,
autoCollapse: true));
Region("textspan", "hint", CSharpStructureHelpers.Ellipsis, autoCollapse: true));
}

[Fact, Trait(Traits.Feature, Traits.Features.Outlining)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Structure;
using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.CodeAnalysis.Text;
using Xunit;

namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Structure
Expand Down Expand Up @@ -55,23 +54,17 @@ public async Task TestOperator3()
const string code = @"
class C
{
$$public static explicit operator C(byte i)
{|hint:$$public static explicit operator C(byte i){|textspan:
{
}
}|}|}

public static explicit operator C(short i)
{
}
}";

await VerifyBlockSpansAsync(code,
new BlockSpan(
isCollapsible: true,
textSpan: TextSpan.FromBounds(59, 75),
hintSpan: TextSpan.FromBounds(18, 73),
type: BlockTypes.Nonstructural,
bannerText: CSharpStructureHelpers.Ellipsis,
autoCollapse: true));
Region("textspan", "hint", CSharpStructureHelpers.Ellipsis, autoCollapse: true));
}

[Fact,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Structure;
using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.CodeAnalysis.Text;
using Xunit;

namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Structure
Expand Down Expand Up @@ -55,22 +54,16 @@ await VerifyBlockSpansAsync(code,
public async Task TestEnum3(string typeKind)
{
var code = $@"
$$enum E
{{|hint:$$enum E{{|textspan:
{{
}}
}}|}}|}}

{typeKind} Following
{{
}}";

await VerifyBlockSpansAsync(code,
new BlockSpan(
isCollapsible: true,
textSpan: TextSpan.FromBounds(8, 16),
hintSpan: TextSpan.FromBounds(2, 14),
type: BlockTypes.Nonstructural,
bannerText: CSharpStructureHelpers.Ellipsis,
autoCollapse: false));
Region("textspan", "hint", CSharpStructureHelpers.Ellipsis, autoCollapse: false));
}

[Fact, Trait(Traits.Feature, Traits.Features.Outlining)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Structure;
using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.CodeAnalysis.Text;
using Xunit;

namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Structure
Expand Down Expand Up @@ -61,11 +60,11 @@ public async Task TestEvent3()
const string code = @"
class C
{
$$event EventHandler E
{|hint:$$event EventHandler E{|textspan:
{
add { }
remove { }
}
}|}|}

event EventHandler E2
{
Expand All @@ -75,13 +74,7 @@ event EventHandler E2
}";

await VerifyBlockSpansAsync(code,
new BlockSpan(
isCollapsible: true,
textSpan: TextSpan.FromBounds(38, 91),
hintSpan: TextSpan.FromBounds(18, 89),
type: BlockTypes.Nonstructural,
bannerText: CSharpStructureHelpers.Ellipsis,
autoCollapse: true));
Region("textspan", "hint", CSharpStructureHelpers.Ellipsis, autoCollapse: true));
}

[Fact, Trait(Traits.Feature, Traits.Features.Outlining)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Structure;
using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.CodeAnalysis.Text;
using Xunit;

namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Structure
Expand Down Expand Up @@ -55,22 +54,16 @@ public async Task TestIndexer3()
const string code = @"
class C
{
$$public string this[int index]
{|hint:$$public string this[int index]{|textspan:
{
get { }
}
}|}|}

int Value => 0;
}";

await VerifyBlockSpansAsync(code,
new BlockSpan(
isCollapsible: true,
textSpan: TextSpan.FromBounds(47, 80),
hintSpan: TextSpan.FromBounds(18, 78),
type: BlockTypes.Nonstructural,
bannerText: CSharpStructureHelpers.Ellipsis,
autoCollapse: true));
Region("textspan", "hint", CSharpStructureHelpers.Ellipsis, autoCollapse: true));
}

[Fact, Trait(Traits.Feature, Traits.Features.Outlining)]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp.Structure;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Structure;
using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.CodeAnalysis.Text;
using Xunit;

namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Structure.MetadataAsSource
{
public class AccessorDeclarationStructureTests : AbstractCSharpSyntaxNodeStructureTests<AccessorDeclarationSyntax>
{
protected override string WorkspaceKind => CodeAnalysis.WorkspaceKind.MetadataAsSource;
internal override AbstractSyntaxStructureProvider CreateProvider() => new AccessorDeclarationStructureProvider();

[Fact, Trait(Traits.Feature, Traits.Features.Outlining)]
public async Task TestPropertyGetter3()
{
const string code = @"
class C
{
public string Text
{
$${|hint:get{|textspan:
{
}|}
|}
set
{
}
}
}";

await VerifyBlockSpansAsync(code,
new BlockSpan(
isCollapsible: true,
textSpan: TextSpan.FromBounds(56, 80),
hintSpan: TextSpan.FromBounds(53, 78),
type: BlockTypes.Nonstructural,
bannerText: CSharpStructureHelpers.Ellipsis,
autoCollapse: true));
}

[Fact, Trait(Traits.Feature, Traits.Features.Outlining)]
public async Task TestPropertyGetterWithSingleLineComments3()
{
const string code = @"
class C
{
public string Text
{
{|span1:// My
// Getter|}
$${|hint2:get{|textspan2:
{
}|}
|}
set
{
}
}
}
";

await VerifyBlockSpansAsync(code,
Region("span1", "// My ...", autoCollapse: true),
new BlockSpan(
isCollapsible: true,
textSpan: TextSpan.FromBounds(90, 114),
hintSpan: TextSpan.FromBounds(87, 112),
type: BlockTypes.Nonstructural,
bannerText: CSharpStructureHelpers.Ellipsis,
autoCollapse: true));
}

[Fact, Trait(Traits.Feature, Traits.Features.Outlining)]
public async Task TestPropertyGetterWithMultiLineComments3()
{
const string code = @"
class C
{
public string Text
{
{|span1:/* My
Getter */|}
$${|hint2:get{|textspan2:
{
}|}
|}
set
{
}
}
}
";

await VerifyBlockSpansAsync(code,
Region("span1", "/* My ...", autoCollapse: true),
new BlockSpan(
isCollapsible: true,
textSpan: TextSpan.FromBounds(93, 117),
hintSpan: TextSpan.FromBounds(90, 115),
type: BlockTypes.Nonstructural,
bannerText: CSharpStructureHelpers.Ellipsis,
autoCollapse: true));
}
}
}
Loading