`RaisePropertyChanged` method in `ObservableObject`
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 45/100
- Issue-Typ
- Feature
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- csharp
- Bereich
- developer-experience
Rechercherichtung
Finde die ObservableObject-Implementierung und die vorhandenen PropertyChanged-Tests oder Einstiegspunkte. Vergleiche das vorgeschlagene Verhalten von RaisePropertyChanged und OnPropertyChanged und verifiziere anschließend, dass der direkte Ereignisauslösungspfad funktioniert, ohne Überschreibungen aufzurufen, und dass die relevanten Tests erfolgreich sind.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Overview
Trying to replace an internal, legacy implementation of ObservableCollection with the one in CommunityToolkit it was noticed there is no way to simply raise the PropertyChanged event without invoking OnPropertyChanged and any overrides.
This functionality is relied upon in some cases and it's time consuming to work around. Since it seems harmless adding upstream here to ObservableObject I created this ticket.
API breakdown
class ObservableObject
{
protected void RaisePropertyChanged([CallerMemberName] string? propertyName = null)
{
PropertyChanged?.Invoke(new PropertyChangedEventArgs(propertyName));
}
protected void OnPropertyChanged(PropertyChangedEventArgs e)
{
PropertyChanged?.Invoke(e);
}
}
Usage example
The cases where this is most useful are those where you are doing something within an OnPropertyChanged override and want to raise some event manually (you just calculated something manually). If you use OnPropertyChanged again it's going to crash with a stack overflow as it keeps calling itself. Of course you can guard against this but it seems easy enough just to support the ability to raise the event directly. Tooling should generally let you do what you want to do while guiding towards a proper flow. Not restrict you completely.
Breaking change?
No
Alternatives
None in this context. Would just have to force all code to work with OnPropertyChanged only.
Additional context
No response
Help us help you
No, just wanted to propose this
- Vorherrschende Sprache
- C#
- Sterne
- 3.8k
- Forks
- 400
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus CommunityToolkit/dotnet
-
RelayCommand<T>.CanExecute(null) returns false for value types without a predicateEvtl. vergeben @apachezy hat das vor 122 Tagen übernommen. Offenbug :bug:
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
CommunityToolkit/dotnet#1206 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
CommunityToolkit/dotnet#1186 ·
-
bug :bug:
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 68/100
CommunityToolkit/dotnet#648 ·
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 20/100
CommunityToolkit/dotnet#1218 ·
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
CommunityToolkit/dotnet#1217 ·
Alle Issues in CommunityToolkit/dotnet
Ähnliche Issues
-
Scaffold marks an association as required when its composite foreign key has a nullable columnOffenarea: scaffold status: needs-tests
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
Maintainer antworten meist innerhalb von 1 Tag
-
provider:flagd type:fix
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
open-feature/dotnet-sdk-contrib#789 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 72/100
NimblePros/Metronome#23 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
jsboige/CoursIA#28504 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
要トリアージ
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
Maintainer antworten meist innerhalb von 1 Tag