Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

We need to consider a unified API for validation

Aperta
#37 2 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@marchc1 ci sta già lavorando.

Dal 15/10/2025.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

Enhancement Needs More Info

Right now, a lot of things in the engine (Materials, Textures, Panels, etc) do not have a better way to determine if they're valid or not. While we won't get UAF's for having invalid pointers or anything, we will keep around resources that dont need to be kept, which also can lead to unintended behavior.

My previous engines have had something along the lines of this:

public interface IValidatable : IDisposable 
{
    bool Valid();
}
public static class IValidatableExts
{
    public static bool IsValid<T>(this T? object) where T : IValidatable => object == null ? false : object.Valid();
}

This would allow us to have Panel for example implement it as such:

public class Panel() {
    bool valid = true;
    ...
    void Remove() {
        ...
        Dispose();
        ...
    }
    void Dispose() {
        valid = false;
    }
    bool Valid() => valid;
    ...
}

The nice thing about the extension-based API here is that T can be nullable, which allows us to run this even on a null object - meaning we don't have to do something like obj != null && obj.IsValid() - this is all valid:

Panel? panel = null;
Assert(!panel.IsValid())
panel = new Button(...);
Assert(panel.IsValid())
panel.Remove();
Assert(!panel.IsValid())

It just deviates from what Source does (ie. Source has PHandles, etc). I just think this is a little nicer given we're working with C#.

Lingua principale
C#
Stelle
104
Fork
9
Merge medio
6h 45m
PR unite (30g)
118

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di SourceDotNET/Source.NET

Tutte le issue di SourceDotNET/Source.NET

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.