dotnet / dotnet/dotnet-api-docs

The Rectangle.Union remarks indicate a behavior that is not seen and unreasonable.

Offen
#11,633 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area-System.Drawing untriaged
Vorherrschende Sprache
C#
Sterne
949
Forks
1.7k
Ø Merge
2 T. 19 Std.
Gemergte PRs (30 T.)
52

Beschreibung

### Type of issue

Crazy, Incorrect Remarks

### Description

The remarks are incorrect and would be very weird *if they were correct*.

🚧 THE REMARKS SHOULD BE REMOVED. 🚧

The remarks state:

> When one of the two rectangles is empty, meaning all of its values are zero, the [Union](https://learn.microsoft.com/en-us/dotnet/api/system.drawing.rectangle.union?view=net-9.0) method returns a rectangle with a starting point of (0, 0), and the height and width of the non-empty rectangle. For example, if you have two rectangles: A = (0, 0; 0, 0) and B = (1, 1; 2, 2), then the union of A and B is (0, 0; 2, 2).

However, using the exact values from the remarks does not give the value promised.

// Declare two rectangles and draw them.
var rectangle1 = new Rectangle(0, 0, 0, 0);
var rectangle2 = new Rectangle(1, 1, 2, 2);
g.DrawRectangle(Pens.Sienna, rectangle1);
g.DrawRectangle(Pens.BlueViolet, rectangle2);

// Declare a third rectangle as a union of the first two.
var rectangle3 = Rectangle.Union(rectangle1, rectangle2).Dump();

Result:

> {X=0,Y=0,**Width=3,Height=3**}

🚧 THIS IS CORRECT AND REASONABLE. THE REMARKS ARE UNNECESSARY AND INCORRECT. 🚧

Image

### Page URL

https://learn.microsoft.com/en-us/dotnet/api/system.drawing.rectangle.union?view=net-9.0&devlangs=csharp&f1url=%3FappId%3DDev17IDEF1%26l%3DEN-US%26k%3Dk(System.Drawing.Rectangle.Union)%3Bk(DevLang-csharp)%26rd%3Dtrue

### Content source URL

https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System.Drawing/Rectangle.xml

### Document Version Independent Id

71367ba3-b782-10ab-e718-4151739eaafa

### Platform Id

5aef8bd6-6060-ace5-8d11-a512d660587e

### Article author

@dotnet-bot

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Öffne xml/System.Drawing/Rectangle.xml und finde die im Issue beschriebenen Rectangle.Union-Anmerkungen. Vergleiche den Quelltext mit der verknüpften API-Seite und aktualisiere die Anmerkungen, sodass sie das falsche Verhalten für leere Rechtecke nicht mehr beschreiben. Als erledigt gilt, wenn der Quelltext korrigiert ist und die generierte Dokumentation diese Behauptung nicht mehr anzeigt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
csharp
Bereich
documentation
Issue-Typ
Dokumentation
Schwierigkeit
1/5
Geschätzter Aufwand
Unter einer Stunde
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.