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

Commit

Permalink
Merge pull request #25 from sharwell/fix-type-forwarded-properties
Browse files Browse the repository at this point in the history
Only add getters and setters for type-forwarded properties to public API
  • Loading branch information
sharwell authored Jan 7, 2019
2 parents dc2a045 + 44a80ba commit 24a4170
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ private void Method() { }
}

[Fact]
public async Task TypeForwardsAreProcessedAsync()
public async Task TypeForwardsAreProcessed1Async()
{
var source = @"
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.StringComparison))]
Expand All @@ -529,6 +529,34 @@ public async Task TypeForwardsAreProcessedAsync()
await this.VerifyCSharpDiagnosticAsync(source, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

[Fact]
public async Task TypeForwardsAreProcessed2Async()
{
var source = @"
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.StringComparer))]
";
this.shippedText = $@"
System.StringComparer (forwarded, contained in mscorlib)
static System.StringComparer.InvariantCulture.get -> System.StringComparer (forwarded, contained in mscorlib)
static System.StringComparer.InvariantCultureIgnoreCase.get -> System.StringComparer (forwarded, contained in mscorlib)
static System.StringComparer.CurrentCulture.get -> System.StringComparer (forwarded, contained in mscorlib)
static System.StringComparer.CurrentCultureIgnoreCase.get -> System.StringComparer (forwarded, contained in mscorlib)
static System.StringComparer.Ordinal.get -> System.StringComparer (forwarded, contained in mscorlib)
static System.StringComparer.OrdinalIgnoreCase.get -> System.StringComparer (forwarded, contained in mscorlib)
static System.StringComparer.Create(System.Globalization.CultureInfo culture, bool ignoreCase) -> System.StringComparer (forwarded, contained in mscorlib)
System.StringComparer.Compare(object x, object y) -> int (forwarded, contained in mscorlib)
System.StringComparer.Equals(object x, object y) -> bool (forwarded, contained in mscorlib)
System.StringComparer.GetHashCode(object obj) -> int (forwarded, contained in mscorlib)
abstract System.StringComparer.Compare(string x, string y) -> int (forwarded, contained in mscorlib)
abstract System.StringComparer.Equals(string x, string y) -> bool (forwarded, contained in mscorlib)
abstract System.StringComparer.GetHashCode(string obj) -> int (forwarded, contained in mscorlib)
System.StringComparer.StringComparer() -> void (forwarded, contained in mscorlib)
";
this.unshippedText = $@"";

await this.VerifyCSharpDiagnosticAsync(source, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

[Fact]
public async Task TestAvoidMultipleOverloadsWithOptionalParametersAsync()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,13 @@ private bool IsPublicAPI(ISymbol symbol)
return false;
}

// We don't consider properties to be public APIs. Instead, property getters and setters
// (which are IMethodSymbols) are considered as public APIs.
if (symbol is IPropertySymbol)
{
return false;
}

return this.IsPublicApiCore(symbol);
}

Expand Down

0 comments on commit 24a4170

Please sign in to comment.