From 856df7f74517aa9afcc1db69988bb5999edae7fa Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Thu, 17 Jun 2021 11:06:44 -0700 Subject: [PATCH] Assert non-null return values from MethodSymbol.Parameters --- .../Portable/Symbols/Source/SourceDelegateMethodSymbol.cs | 3 ++- .../Symbols/Synthesized/SynthesizedGlobalMethodSymbol.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/SourceDelegateMethodSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Source/SourceDelegateMethodSymbol.cs index b4eab31db8f74..d1282fe90152f 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/SourceDelegateMethodSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/SourceDelegateMethodSymbol.cs @@ -126,7 +126,8 @@ public sealed override ImmutableArray Parameters { get { - return _parameters; + Debug.Assert(!_parameters.IsDefault, $"Expected {nameof(InitializeParameters)} prior to accessing this property."); + return _parameters.NullToEmpty(); } } diff --git a/src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedGlobalMethodSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedGlobalMethodSymbol.cs index 8f7155d60dadd..4b66d9d66ebfe 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedGlobalMethodSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedGlobalMethodSymbol.cs @@ -167,7 +167,8 @@ public override ImmutableArray Parameters { get { - if (_parameters.IsEmpty) + Debug.Assert(!_parameters.IsDefault, $"Expected {nameof(SetParameters)} prior to accessing this property."); + if (_parameters.IsDefault) { return ImmutableArray.Empty; }