Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

We need to consider a unified API for validation

Aberta
#37 2 comentários 0 reações 1 responsável Ver no GitHub

Mantenedores costumam responder em até 1 dia

@marchc1 já está trabalhando nisso.

Desde 15/10/2025.

Avaliação

Esta issue ainda não foi avaliada.

Descrição

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#.

Linguagem predominante
C#
Estrelas
104
Forks
9
Merge médio
8h 40min
PRs com merge (30d)
110

Preparar o ambiente

Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de SourceDotNET/Source.NET

Todas as issues de SourceDotNET/Source.NET

Issues semelhantes

Mais issues de C#

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.