dotnet / dotnet/dotnet-api-docs
Incorrect doc on 'Type.FullName'
- Lingua principale
- C#
- Stelle
- 950
- Fork
- 1.7k
- Merge medio
- 2g 19h
- PR unite (30g)
- 52
Descrizione
Currently, the docs for what `Type.FullName` returns says:
> The fully qualified name of the type, including its namespace but not its assembly;
> or null if the current instance represents a generic type parameter, an array
> type, pointer type, or byref type based on a type parameter, or a generic type
> that is not a generic type definition but contains unresolved type parameters.
However, I've found that some of the conditions in which this property is documented to return `null` are false. [SharpLab shows](https://sharplab.io/#v2:C4LgTgrgdgPgAgJgIwFgBQiDM6De6AEh+iCBReaRVxSAnABQBiA9swDwCWUwAfAHQAVAHIBDALYBTAJQBuMtRoMW7OEgAM/YeOlzKCxU1aduAbQC6m0ZNnzqqpUYCCYMCICel7Tb2EAvun80dDhMYgR8ZTYBHlxbLmAJMCgRABsaADYaNXwtSXwcfABzCWAZfF98AF58YDcABwlmADN6ASk+RggUlKsJXV8gA===) the property will happily state that the full name for `int[]` is `"System.Int32[]"`, and according to @CyrusNajmabadi it also does not seem to return a `null` for pointer types. This means that the doc comment seems to be in need of an update to be more accurate.
As an aside, this stems from the following question I had: Can I be reasonably guaranteed the property won't ever return `null` in the following situation?
```cs
public class Foo
where T : MyBase
{
private static string _tName = typeof(T).FullName;
}
public abstract partial class MyBase { }
```
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia dalla documentazione dell’API Type.FullName identificata nell’issue e confronta la formulazione relativa alla restituzione di null con il comportamento segnalato per array e puntatori, nonché con l’esempio di parametro di tipo generico. Aggiorna la documentazione per descrivere accuratamente quando FullName può restituire null, quindi verifica la formulazione rivista rispetto ai risultati SharpLab indicati e al comportamento in fase di esecuzione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- csharp
- Ambito
- documentation
- Tipo di issue
- Documentazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 48/100