Skip to content

Commit f8b0861

Browse files
committed
More parameters
1 parent cddd25c commit f8b0861

File tree

9 files changed

+22
-26
lines changed

9 files changed

+22
-26
lines changed

src/Compilers/CSharp/Portable/Lowering/MethodToClassRewriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ internal override void AddSynthesizedAttributes(PEModuleBuilder moduleBuilder, r
722722
{
723723
base.AddSynthesizedAttributes(moduleBuilder, ref attributes);
724724

725-
AddSynthesizedAttribute(ref attributes, this.DeclaringCompilation.TrySynthesizeAttribute(WellKnownMember.System_Diagnostics_DebuggerHiddenAttribute__ctor));
725+
AddSynthesizedAttribute(ref attributes, this.DeclaringCompilation!.TrySynthesizeAttribute(WellKnownMember.System_Diagnostics_DebuggerHiddenAttribute__ctor));
726726
}
727727

728728
internal override TypeWithAnnotations IteratorElementTypeWithAnnotations

src/Compilers/CSharp/Portable/Symbols/FunctionPointers/FunctionPointerParameterSymbol.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
using System.Collections.Generic;
66
using System.Collections.Immutable;
7+
using System.Diagnostics;
78
using System.Linq;
89
using Roslyn.Utilities;
910

@@ -15,6 +16,7 @@ internal sealed class FunctionPointerParameterSymbol : ParameterSymbol
1516

1617
public FunctionPointerParameterSymbol(TypeWithAnnotations typeWithAnnotations, RefKind refKind, int ordinal, FunctionPointerMethodSymbol containingSymbol, ImmutableArray<CustomModifier> refCustomModifiers)
1718
{
19+
Debug.Assert(typeWithAnnotations.HasType);
1820
TypeWithAnnotations = typeWithAnnotations;
1921
RefKind = refKind;
2022
Ordinal = ordinal;

src/Compilers/CSharp/Portable/Symbols/ParameterSymbol.cs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
#nullable disable
6-
75
using System;
86
using System.Collections.Generic;
97
using System.Collections.Immutable;
108
using System.Diagnostics;
9+
using System.Diagnostics.CodeAnalysis;
1110
using System.Runtime.InteropServices;
1211
using Microsoft.CodeAnalysis.CSharp.Symbols;
1312
using Microsoft.CodeAnalysis.CSharp.Syntax;
@@ -49,12 +48,6 @@ protected sealed override Symbol OriginalSymbolDefinition
4948
}
5049
}
5150

52-
#nullable enable
53-
54-
public abstract override Symbol? ContainingSymbol { get; }
55-
56-
#nullable disable
57-
5851
/// <summary>
5952
/// Gets the type of the parameter along with its annotations.
6053
/// </summary>
@@ -80,17 +73,13 @@ protected sealed override Symbol OriginalSymbolDefinition
8073
/// </summary>
8174
public abstract ImmutableArray<CustomModifier> RefCustomModifiers { get; }
8275

83-
#nullable enable
84-
8576
/// <summary>
8677
/// Describes how the parameter is marshalled when passed to native code.
8778
/// Null if no specific marshalling information is available for the parameter.
8879
/// </summary>
8980
/// <remarks>PE symbols don't provide this information and always return null.</remarks>
9081
internal abstract MarshalPseudoCustomAttributeData? MarshallingInformation { get; }
9182

92-
#nullable disable
93-
9483
/// <summary>
9584
/// Returns the marshalling type of this parameter, or 0 if marshalling information isn't available.
9685
/// </summary>
@@ -112,6 +101,8 @@ internal bool IsMarshalAsObject
112101
{
113102
get
114103
{
104+
object? o = null;
105+
Console.WriteLine(o);
115106
switch (this.MarshallingType)
116107
{
117108
case UnmanagedType.Interface:
@@ -205,6 +196,7 @@ public bool IsOptional
205196
///
206197
/// The default value can be obtained with <see cref="ExplicitDefaultValue"/> property.
207198
/// </remarks>
199+
[MemberNotNullWhen(true, nameof(ExplicitDefaultConstantValue))]
208200
public bool HasExplicitDefaultValue
209201
{
210202
get
@@ -234,7 +226,7 @@ public bool HasExplicitDefaultValue
234226
/// </remarks>
235227
/// <exception cref="InvalidOperationException">The parameter has no default value.</exception>
236228
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
237-
public object ExplicitDefaultValue
229+
public object? ExplicitDefaultValue
238230
{
239231
get
240232
{
@@ -247,7 +239,6 @@ public object ExplicitDefaultValue
247239
}
248240
}
249241

250-
#nullable enable
251242
/// <summary>
252243
/// Returns the default value constant of the parameter,
253244
/// or null if the parameter doesn't have a default value or
@@ -260,7 +251,6 @@ public object ExplicitDefaultValue
260251
/// (i.e. even non-optional parameters can have default values).
261252
/// </remarks>
262253
internal abstract ConstantValue? ExplicitDefaultConstantValue { get; }
263-
#nullable disable
264254

265255
/// <summary>
266256
/// Gets the kind of this symbol.
@@ -395,7 +385,7 @@ public virtual bool IsThis
395385
/// Returns data decoded from Obsolete attribute or null if there is no Obsolete attribute.
396386
/// This property returns ObsoleteAttributeData.Uninitialized if attribute arguments haven't been decoded yet.
397387
/// </summary>
398-
internal sealed override ObsoleteAttributeData ObsoleteAttributeData
388+
internal sealed override ObsoleteAttributeData? ObsoleteAttributeData
399389
{
400390
get { return null; }
401391
}

src/Compilers/CSharp/Portable/Symbols/Retargeting/RetargetingParameterSymbol.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ internal override ImmutableArray<byte> MarshallingDescriptor
116116
}
117117
}
118118

119-
internal sealed override CSharpCompilation DeclaringCompilation // perf, not correctness
119+
internal sealed override CSharpCompilation? DeclaringCompilation // perf, not correctness
120120
{
121121
get { return null; }
122122
}

src/Compilers/CSharp/Portable/Symbols/Source/ThisParameterSymbol.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System;
66
using System.Collections.Concurrent;
77
using System.Collections.Immutable;
8+
using System.Diagnostics;
89
using System.Threading;
910
using Microsoft.CodeAnalysis.CSharp.Symbols;
1011
using Microsoft.CodeAnalysis.CSharp.Syntax;
@@ -25,6 +26,7 @@ internal ThisParameterSymbol(MethodSymbol forMethod) : this(forMethod, forMethod
2526

2627
internal ThisParameterSymbol(MethodSymbol? forMethod, TypeSymbol containingType)
2728
{
29+
Debug.Assert(containingType is not null);
2830
_containingMethod = forMethod;
2931
_containingType = containingType;
3032
}

src/Compilers/CSharp/Portable/Symbols/SubstitutedParameterSymbol.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public sealed override bool Equals(Symbol obj, TypeCompareKind compareKind)
111111
// ReferenceEquals.
112112

113113
var other = obj as SubstitutedParameterSymbol;
114-
return (object)other != null &&
114+
return other is not null &&
115115
this.Ordinal == other.Ordinal &&
116116
this.ContainingSymbol.Equals(other.ContainingSymbol, compareKind);
117117
}

src/Compilers/CSharp/Portable/Symbols/Symbol.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ internal virtual CSharpCompilation DeclaringCompilation
200200
}
201201

202202
var sourceModuleSymbol = this.ContainingModule as SourceModuleSymbol;
203-
return (object)sourceModuleSymbol == null ? null : sourceModuleSymbol.DeclaringCompilation;
203+
return sourceModuleSymbol == null ? null : sourceModuleSymbol.DeclaringCompilation;
204204
}
205205
}
206206

@@ -837,6 +837,7 @@ public virtual string GetDocumentationCommentId()
837837
}
838838
}
839839

840+
#nullable enable
840841
/// <summary>
841842
/// Fetches the documentation comment for this element with a cancellation token.
842843
/// </summary>
@@ -845,12 +846,13 @@ public virtual string GetDocumentationCommentId()
845846
/// <param name="cancellationToken">Optionally, allow cancellation of documentation comment retrieval.</param>
846847
/// <returns>The XML that would be written to the documentation file for the symbol.</returns>
847848
public virtual string GetDocumentationCommentXml(
848-
CultureInfo preferredCulture = null,
849+
CultureInfo? preferredCulture = null,
849850
bool expandIncludes = false,
850851
CancellationToken cancellationToken = default(CancellationToken))
851852
{
852853
return "";
853854
}
855+
#nullable disable
854856

855857
private static readonly SymbolDisplayFormat s_debuggerDisplayFormat =
856858
SymbolDisplayFormat.TestFormat

src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedParameterSymbol.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ public SynthesizedParameterSymbolBase(
2929
string name,
3030
bool isNullChecked)
3131
{
32-
RoslynDebug.Assert(type.HasType);
33-
RoslynDebug.Assert(name != null);
34-
RoslynDebug.Assert(ordinal >= 0);
32+
Debug.Assert(type.HasType);
33+
Debug.Assert(name != null);
34+
Debug.Assert(ordinal >= 0);
3535

3636
_container = container;
3737
_type = type;

src/Compilers/CSharp/Portable/Symbols/Wrapped/WrappedParameterSymbol.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public override ImmutableArray<CustomModifier> RefCustomModifiers
116116
get { return _underlyingParameter.RefCustomModifiers; }
117117
}
118118

119-
internal override MarshalPseudoCustomAttributeData MarshallingInformation
119+
internal override MarshalPseudoCustomAttributeData? MarshallingInformation
120120
{
121121
get { return _underlyingParameter.MarshallingInformation; }
122122
}
@@ -147,7 +147,7 @@ internal override ImmutableHashSet<string> NotNullIfParameterNotNull
147147
get { return _underlyingParameter.NotNullIfParameterNotNull; }
148148
}
149149

150-
public override string GetDocumentationCommentXml(CultureInfo preferredCulture = null, bool expandIncludes = false, CancellationToken cancellationToken = default)
150+
public override string GetDocumentationCommentXml(CultureInfo? preferredCulture = null, bool expandIncludes = false, CancellationToken cancellationToken = default)
151151
{
152152
return _underlyingParameter.GetDocumentationCommentXml(preferredCulture, expandIncludes, cancellationToken);
153153
}

0 commit comments

Comments
 (0)