dotnet / docs

This repository contains .NET Documentation.
https://learn.microsoft.com/dotnet
Creative Commons Attribution 4.0 International
4.27k stars 5.9k forks source link

IStructuralComparable.CompareTo() documentation "Returns" is incorrect #7874

Closed irontoby closed 6 years ago

irontoby commented 6 years ago

[Enter feedback here] Documentation indicates that IStructuralComparable.CompareTo(object other, System.Collections.IComparer comparer) returns -1, 0, or 1. This is incorrect. It can return any number less than zero if current instance precedes other, and any number greater than zero if current instance follows other.

Compare to correct documentation here for IComparable.CompareTo().

Simple test case:

var val1 = new byte[] { 0, 55, };
var val2 = new byte[] { 0, 99, };

var comp = ((IStructuralComparable)val1).CompareTo(val2, Comparer<byte>.Default);
Console.WriteLine(comp); // writes -44, not -1

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

rpetrusha commented 6 years ago

Thanks for pointing this out, @irontoby. We've opened dotnet/dotnet-api-docs#555 to correct the issue.