Skip to content

Commit 924092e

Browse files
Merge remote-tracking branch 'upstream/main' into norecurse
2 parents 010fcdc + 78cc604 commit 924092e

File tree

7 files changed

+144
-12
lines changed

7 files changed

+144
-12
lines changed

azure-pipelines.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,14 @@ stages:
206206
testArguments: --testCoreClr
207207
queueName: Build.Ubuntu.1804.Amd64.Open
208208

209-
- template: eng/pipelines/test-unix-job.yml
210-
parameters:
211-
testRunName: 'Test macOS Debug'
212-
jobName: Test_macOS_Debug
213-
testArtifactName: Transport_Artifacts_Unix_Debug
214-
configuration: Debug
215-
testArguments: --testCoreClr --helixQueueName OSX.1015.Amd64.Open
209+
- ${{ if ne(variables['Build.Reason'], 'PullRequest') }}:
210+
- template: eng/pipelines/test-unix-job.yml
211+
parameters:
212+
testRunName: 'Test macOS Debug'
213+
jobName: Test_macOS_Debug
214+
testArtifactName: Transport_Artifacts_Unix_Debug
215+
configuration: Debug
216+
testArguments: --testCoreClr --helixQueueName OSX.1015.Amd64.Open
216217

217218
- stage: Correctness
218219
dependsOn: []

src/Compilers/CSharp/Portable/Declarations/DeclarationTreeBuilder.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,15 @@ private SingleTypeDeclaration VisitTypeDeclaration(TypeDeclarationSyntax node, D
693693
{
694694
declFlags |= SingleTypeDeclaration.TypeDeclarationFlags.HasAnyNontypeMembers;
695695
declFlags |= SingleTypeDeclaration.TypeDeclarationFlags.HasPrimaryConstructor;
696+
697+
foreach (var attributeListSyntax in node.AttributeLists)
698+
{
699+
if (attributeListSyntax.Target?.Identifier.ToAttributeLocation() == AttributeLocation.Method)
700+
{
701+
declFlags |= SingleTypeDeclaration.TypeDeclarationFlags.AnyMemberHasAttributes;
702+
break;
703+
}
704+
}
696705
}
697706

698707
var memberNames = GetNonTypeMemberNames(

src/Compilers/CSharp/Test/Emit/PDB/PDBUsingTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ class C { void M() { } }
275275
</symbols>");
276276
}
277277

278-
[Fact]
278+
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/68312")]
279279
public void TestTypeAliases1_B()
280280
{
281281
var text = @"
@@ -435,7 +435,7 @@ class C { void M() { } }
435435
</symbols>");
436436
}
437437

438-
[Fact]
438+
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/68312")]
439439
public void TestTypeAliases3()
440440
{
441441
var text = @"

src/Compilers/CSharp/Test/Semantic/Semantics/PrimaryConstructorTests.cs

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3428,6 +3428,121 @@ class C(int someParam)
34283428
Assert.Equal(@"A(""someParam"")", c.PrimaryConstructor.GetAttributes().Single().ToString());
34293429
}
34303430

3431+
[Theory]
3432+
[CombinatorialData]
3433+
[WorkItem("https://github.com/dotnet/roslyn/issues/68349")]
3434+
public void AttributesOnPrimaryConstructor_11([CombinatorialValues("class C();", "struct C();", "record C();", "record class C();", "record struct C();")] string declaration)
3435+
{
3436+
string source = @"
3437+
_ = new C();
3438+
3439+
[method: System.Obsolete(""Obsolete!!!"", error: true)]
3440+
" + declaration + @"
3441+
";
3442+
var comp = CreateCompilation(source);
3443+
comp.VerifyDiagnostics(
3444+
// (2,5): error CS0619: 'C.C()' is obsolete: 'Obsolete!!!'
3445+
// _ = new C();
3446+
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "new C()").WithArguments("C.C()", "Obsolete!!!").WithLocation(2, 5)
3447+
);
3448+
3449+
var c = (SourceMemberContainerTypeSymbol)comp.GetTypeByMetadataName("C");
3450+
Assert.True(c.AnyMemberHasAttributes);
3451+
}
3452+
3453+
[Theory]
3454+
[CombinatorialData]
3455+
public void AttributesOnPrimaryConstructor_12([CombinatorialValues("class", "struct", "record", "record class", "record struct")] string declaration)
3456+
{
3457+
string source = @"
3458+
_ = new C1();
3459+
3460+
partial " + declaration + @" C1();
3461+
3462+
#line 100
3463+
[method: System.Obsolete(""Obsolete!!!"", error: true)]
3464+
partial " + declaration + @" C1
3465+
#line 200
3466+
;
3467+
";
3468+
var comp = CreateCompilation(source);
3469+
comp.VerifyDiagnostics(
3470+
// (100,2): warning CS0657: 'method' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'type'. All attributes in this block will be ignored.
3471+
// [method: System.Obsolete("Obsolete!!!", error: true)]
3472+
Diagnostic(ErrorCode.WRN_AttributeLocationOnBadDeclaration, "method").WithArguments("method", "type").WithLocation(100, 2)
3473+
);
3474+
3475+
var c1 = (SourceMemberContainerTypeSymbol)comp.GetTypeByMetadataName("C1");
3476+
Assert.False(c1.AnyMemberHasAttributes);
3477+
}
3478+
3479+
[Theory]
3480+
[CombinatorialData]
3481+
public void AttributesOnPrimaryConstructor_13([CombinatorialValues("class", "struct", "record", "record class", "record struct")] string declaration)
3482+
{
3483+
string source = @"
3484+
_ = new C1();
3485+
3486+
[method: System.Obsolete(""Obsolete!!!"", error: true)]
3487+
partial " + declaration + @" C1();
3488+
3489+
partial " + declaration + @" C1;
3490+
";
3491+
var comp = CreateCompilation(source);
3492+
comp.VerifyDiagnostics(
3493+
// (2,5): error CS0619: 'C1.C1()' is obsolete: 'Obsolete!!!'
3494+
// _ = new C1();
3495+
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "new C1()").WithArguments("C1.C1()", "Obsolete!!!").WithLocation(2, 5)
3496+
);
3497+
3498+
var c1 = (SourceMemberContainerTypeSymbol)comp.GetTypeByMetadataName("C1");
3499+
Assert.True(c1.AnyMemberHasAttributes);
3500+
}
3501+
3502+
[Theory]
3503+
[CombinatorialData]
3504+
[WorkItem("https://github.com/dotnet/roslyn/issues/68349")]
3505+
public void AttributesOnPrimaryConstructor_14([CombinatorialValues("class C();", "struct C();", "record C();", "record class C();", "record struct C();")] string declaration)
3506+
{
3507+
string source = @"
3508+
_ = new C();
3509+
3510+
[System.Obsolete(""Obsolete!!!"", error: true)]
3511+
" + declaration + @"
3512+
";
3513+
var comp = CreateCompilation(source);
3514+
comp.VerifyDiagnostics(
3515+
// (2,9): error CS0619: 'C' is obsolete: 'Obsolete!!!'
3516+
// _ = new C();
3517+
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "C").WithArguments("C", "Obsolete!!!").WithLocation(2, 9)
3518+
);
3519+
3520+
var c = (SourceMemberContainerTypeSymbol)comp.GetTypeByMetadataName("C");
3521+
Assert.False(c.AnyMemberHasAttributes);
3522+
}
3523+
3524+
[Theory]
3525+
[CombinatorialData]
3526+
[WorkItem("https://github.com/dotnet/roslyn/issues/68349")]
3527+
public void AttributesOnPrimaryConstructor_15([CombinatorialValues("class C();", "struct C();", "record C();", "record class C();", "record struct C();")] string declaration)
3528+
{
3529+
string source = @"
3530+
_ = new C();
3531+
3532+
[type: System.Obsolete(""Obsolete!!!"", error: true)]
3533+
" + declaration + @"
3534+
";
3535+
var comp = CreateCompilation(source);
3536+
comp.VerifyDiagnostics(
3537+
// (2,9): error CS0619: 'C' is obsolete: 'Obsolete!!!'
3538+
// _ = new C();
3539+
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "C").WithArguments("C", "Obsolete!!!").WithLocation(2, 9)
3540+
);
3541+
3542+
var c = (SourceMemberContainerTypeSymbol)comp.GetTypeByMetadataName("C");
3543+
Assert.False(c.AnyMemberHasAttributes);
3544+
}
3545+
34313546
[Fact]
34323547
public void AnalyzerActions_01_Class()
34333548
{

src/EditorFeatures/Test2/InlineHints/CSharpInlineParameterNameHintsTests.vb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ class A
458458

459459
public void Main(string[] args)
460460
{
461-
UseParams(list: 1, 2, 3, 4, 5, 6);
461+
UseParams(1, 2, 3, 4, 5, 6);
462462
}
463463
}
464464
</Document>

src/EditorFeatures/Test2/InlineHints/VisualBasicInlineParameterNameHintsTests.vb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.InlineHints
466466
End Sub
467467

468468
Public Sub Main()
469-
UseParams(args:=1, 2, 3, 4, 5)
469+
UseParams(1, 2, 3, 4, 5)
470470
End Sub
471471
End Class
472472
</Document>

src/Features/Core/Portable/InlineHints/AbstractInlineParameterNameHintsService.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,17 @@ void AddHintsIfAppropriate(SyntaxNode node)
102102
{
103103
var inlineHintText = GetReplacementText(parameter.Name);
104104
var textSpan = new TextSpan(position, 0);
105+
106+
TextChange? replacementTextChange = null;
107+
if (!parameter.IsParams)
108+
{
109+
replacementTextChange = new TextChange(textSpan, inlineHintText);
110+
}
111+
105112
result.Add(new InlineHint(
106113
textSpan,
107114
ImmutableArray.Create(new TaggedText(TextTags.Text, parameter.Name + ": ")),
108-
new TextChange(textSpan, inlineHintText),
115+
replacementTextChange,
109116
ranking: InlineHintsConstants.ParameterRanking,
110117
InlineHintHelpers.GetDescriptionFunction(position, parameter.GetSymbolKey(cancellationToken: cancellationToken), displayOptions)));
111118
}

0 commit comments

Comments
 (0)