Skip to content
This repository was archived by the owner on Apr 8, 2019. It is now read-only.

Commit 44a80ba

Browse files
committed
Include changes from dotnet/roslyn-analyzers#1657
1 parent 82fc62b commit 44a80ba

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

PublicApiAnalyzer/PublicApiAnalyzer.Test/ApiDesign/DeclarePublicAPIAnalyzerTests.cs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ private void Method() { }
465465
}
466466

467467
[Fact]
468-
public async Task TypeForwardsAreProcessedAsync()
468+
public async Task TypeForwardsAreProcessed1Async()
469469
{
470470
var source = @"
471471
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.StringComparison))]
@@ -485,6 +485,34 @@ public async Task TypeForwardsAreProcessedAsync()
485485
await this.VerifyCSharpDiagnosticAsync(source, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
486486
}
487487

488+
[Fact]
489+
public async Task TypeForwardsAreProcessed2Async()
490+
{
491+
var source = @"
492+
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.StringComparer))]
493+
";
494+
this.shippedText = $@"
495+
System.StringComparer (forwarded, contained in mscorlib)
496+
static System.StringComparer.InvariantCulture.get -> System.StringComparer (forwarded, contained in mscorlib)
497+
static System.StringComparer.InvariantCultureIgnoreCase.get -> System.StringComparer (forwarded, contained in mscorlib)
498+
static System.StringComparer.CurrentCulture.get -> System.StringComparer (forwarded, contained in mscorlib)
499+
static System.StringComparer.CurrentCultureIgnoreCase.get -> System.StringComparer (forwarded, contained in mscorlib)
500+
static System.StringComparer.Ordinal.get -> System.StringComparer (forwarded, contained in mscorlib)
501+
static System.StringComparer.OrdinalIgnoreCase.get -> System.StringComparer (forwarded, contained in mscorlib)
502+
static System.StringComparer.Create(System.Globalization.CultureInfo culture, bool ignoreCase) -> System.StringComparer (forwarded, contained in mscorlib)
503+
System.StringComparer.Compare(object x, object y) -> int (forwarded, contained in mscorlib)
504+
System.StringComparer.Equals(object x, object y) -> bool (forwarded, contained in mscorlib)
505+
System.StringComparer.GetHashCode(object obj) -> int (forwarded, contained in mscorlib)
506+
abstract System.StringComparer.Compare(string x, string y) -> int (forwarded, contained in mscorlib)
507+
abstract System.StringComparer.Equals(string x, string y) -> bool (forwarded, contained in mscorlib)
508+
abstract System.StringComparer.GetHashCode(string obj) -> int (forwarded, contained in mscorlib)
509+
System.StringComparer.StringComparer() -> void (forwarded, contained in mscorlib)
510+
";
511+
this.unshippedText = $@"";
512+
513+
await this.VerifyCSharpDiagnosticAsync(source, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
514+
}
515+
488516
[Fact]
489517
public async Task TestAvoidMultipleOverloadsWithOptionalParametersAsync()
490518
{

PublicApiAnalyzer/PublicApiAnalyzer/ApiDesign/DeclarePublicAPIAnalyzer.Impl.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,13 @@ private bool IsPublicAPI(ISymbol symbol)
519519
return false;
520520
}
521521

522+
// We don't consider properties to be public APIs. Instead, property getters and setters
523+
// (which are IMethodSymbols) are considered as public APIs.
524+
if (symbol is IPropertySymbol)
525+
{
526+
return false;
527+
}
528+
522529
return this.IsPublicApiCore(symbol);
523530
}
524531

0 commit comments

Comments
 (0)