Skip to content

Commit

Permalink
Update doc wording.
Browse files Browse the repository at this point in the history
  • Loading branch information
333fred committed Sep 12, 2018
1 parent 02909f6 commit dc5dedf
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 23 deletions.
10 changes: 5 additions & 5 deletions src/Compilers/Core/Portable/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ Microsoft.CodeAnalysis.IFieldSymbol.DeclaredNullability.get -> Microsoft.CodeAna
Microsoft.CodeAnalysis.ILocalSymbol.DeclaredNullability.get -> Microsoft.CodeAnalysis.Nullability
Microsoft.CodeAnalysis.IMethodSymbol.ReturnNullability.get -> Microsoft.CodeAnalysis.Nullability
Microsoft.CodeAnalysis.IMethodSymbol.TypeArgumentsNullability.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.Nullability>
Microsoft.CodeAnalysis.INamedTypeSymbol.TypeArgumentNullability.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.Nullability>
Microsoft.CodeAnalysis.INamedTypeSymbol.TypeParameterNullability.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.Nullability>
Microsoft.CodeAnalysis.INamedTypeSymbol.TypeArgumentsNullability.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.Nullability>
Microsoft.CodeAnalysis.IOperation.SemanticModel.get -> Microsoft.CodeAnalysis.SemanticModel
Microsoft.CodeAnalysis.IParameterSymbol.DeclaredNullability.get -> Microsoft.CodeAnalysis.Nullability
Microsoft.CodeAnalysis.IPropertySymbol.DeclaredNullability.get -> Microsoft.CodeAnalysis.Nullability
Expand All @@ -32,9 +31,10 @@ Microsoft.CodeAnalysis.ISymbol.ToMinimalDisplayParts(Microsoft.CodeAnalysis.Sema
Microsoft.CodeAnalysis.ISymbol.ToMinimalDisplayString(Microsoft.CodeAnalysis.SemanticModel semanticModel, int position, Microsoft.CodeAnalysis.Nullability nullability, Microsoft.CodeAnalysis.SymbolDisplayFormat format = null) -> string
Microsoft.CodeAnalysis.ITypeParameterSymbol.ConstraintsNullability.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.Nullability>
Microsoft.CodeAnalysis.Nullability
Microsoft.CodeAnalysis.Nullability.MaybeNull = 2 -> Microsoft.CodeAnalysis.Nullability
Microsoft.CodeAnalysis.Nullability.NonNull = 1 -> Microsoft.CodeAnalysis.Nullability
Microsoft.CodeAnalysis.Nullability.Unknown = 0 -> Microsoft.CodeAnalysis.Nullability
Microsoft.CodeAnalysis.Nullability.MaybeNull = 3 -> Microsoft.CodeAnalysis.Nullability
Microsoft.CodeAnalysis.Nullability.NonNull = 2 -> Microsoft.CodeAnalysis.Nullability
Microsoft.CodeAnalysis.Nullability.NotApplicable = 0 -> Microsoft.CodeAnalysis.Nullability
Microsoft.CodeAnalysis.Nullability.Unknown = 1 -> Microsoft.CodeAnalysis.Nullability
Microsoft.CodeAnalysis.OperationKind.SuppressNullableWarning = 97 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.Operations.CommonConversion.IsImplicit.get -> bool
Microsoft.CodeAnalysis.Operations.ISuppressNullableWarningOperation
Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/Core/Portable/Symbols/ILocalSymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public interface ILocalSymbol : ISymbol
ITypeSymbol Type { get; }

/// <summary>
/// The initial declared nullability of this local. If the local's type was inferred (i.e. via <code>var</code>), then
/// The declared nullability of this local. If the local's type was inferred (i.e. via <code>var</code>), then
/// this declared nullability is inferred from the expression that initialized the local.
/// </summary>
Nullability DeclaredNullability { get; }
Expand Down
6 changes: 5 additions & 1 deletion src/Compilers/Core/Portable/Symbols/INamedTypeSymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ public interface INamedTypeSymbol : ITypeSymbol
/// </summary>
ImmutableArray<ITypeSymbol> TypeArguments { get; }

ImmutableArray<Nullability> TypeArgumentNullability { get; }
/// <summary>
/// Returns the nullability of the type arguments that have been substituted for the
/// type paramters.
/// </summary>
ImmutableArray<Nullability> TypeArgumentsNullability { get; }

/// <summary>
/// Returns custom modifiers for the type argument that has been substituted for the type parameter.
Expand Down
42 changes: 26 additions & 16 deletions src/Compilers/Core/Portable/Symbols/Nullability.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Microsoft.CodeAnalysis
{
/// <summary>
/// Enumeration of the possible nullability states for types.
/// Enumeration of the possible nullability states for variables and values.
/// </summary>
/// <remarks>
/// <para>
Expand Down Expand Up @@ -33,12 +33,12 @@ namespace Microsoft.CodeAnalysis
/// o2.ToString(); // Warning reported
/// if (o2 != null) o2.ToString(); // No warning reported
/// </code>
/// <code>o1</code> is inferred to be <see cref="NonNull"/>, despite being declared
/// <see cref="MaybeNull"/>, and no warning is reported when it is dereferenced.
/// However, the first dereference of <code>o2</code> has not been inferred to
/// be <see cref="NonNull"/>, so a warning is reported. The second dereference
/// occurs inside an <code>if</code> statement check for <see langword="null"/>, so
/// the compiler can infer that <code>o2</code> must not be <see langword="null"/>
/// The use of <code>o1</code> is inferred to be <see cref="NonNull"/>, despite
/// being declared <see cref="MaybeNull"/>, and no warning is reported when it
/// is dereferenced. However, the first dereference of <code>o2</code> has not
/// been inferred to be <see cref="NonNull"/>, so a warning is reported. The second
/// dereference occurs inside an <code>if</code> statement check for <see langword="null"/>,
/// so the compiler can infer that <code>o2</code> must not be <see langword="null"/>
/// inside the <code>if</code> statement.
/// </para>
/// <para>
Expand All @@ -63,24 +63,34 @@ namespace Microsoft.CodeAnalysis
/// </code>
/// This is because both <code>string</code> and <code>string?</code> can be substituted
/// for <code>T</code>, so the user must account for the strictest possible scenario
/// in all cases.
/// in all cases. For this reason, variables and values of type unconstrained type
/// parameter are considered <see cref="MaybeNull"/> until checked.
/// </para>
/// </remarks>
public enum Nullability
{
/// <summary>
/// There is no information on the current nullable state.
/// The given <see cref="SyntaxNode"/> or <see cref="IOperation"/> does not represent
/// a variable or value, and does not have a nullability.
/// </summary>
/// <remarks>
/// This is used for statements, and for expressions that do not have nullabilities,
/// such as method groups.
/// </remarks>
NotApplicable = 0,
/// <summary>
/// There is no information on the current nullable state of the variable
/// or value.
/// </summary>
/// <remarks>
/// This is used for legacy code scenarios, where a legacy API that does
/// not provide nullability information is being used. Expressions that
/// have unknown nullability are also referred to as oblivious expressions,
/// and they generally do not provide warnings when converting to
/// <see langword="null"/>, or when dereferencing them.
/// and they generally do not provide warnings for assignment or dereference.
/// </remarks>
Unknown = 0,
Unknown = 1,
/// <summary>
/// The variable is either known or declared to be non-null.
/// The variable or value is either known or declared to be non-null.
/// </summary>
/// <remarks>
/// It is possible for a variable to have a declared nullability of NonNull,
Expand All @@ -95,13 +105,13 @@ public enum Nullability
/// <see cref="MaybeNull"/>, because the compiler tracks null state regardless
/// of the declared nullability.
/// </remarks>
NonNull = 1,
NonNull = 2,
/// <summary>
/// The variable is either known or declared to possibly be null.
/// The variable or value is either known or declared to possibly be null.
/// </summary>
/// <remarks>
/// Nullable value types will always be considered to be <see cref="MaybeNull"/>.
/// </remarks>
MaybeNull = 2
MaybeNull = 3
}
}

0 comments on commit dc5dedf

Please sign in to comment.