Skip to content

Commit 93b0344

Browse files
authored
Revert "Revert temporary ITypeSymbol extension APIs" (#4404)
1 parent aae1a9b commit 93b0344

7 files changed

Lines changed: 46 additions & 2 deletions

File tree

‎src/roslyn/src/Compilers/CSharp/Portable/Symbols/PublicModel/TypeSymbol.cs‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,20 @@ TypeKind ITypeSymbol.TypeKind
156156

157157
bool ITypeSymbol.IsNativeIntegerType => UnderlyingTypeSymbol.IsNativeIntegerType;
158158

159+
#nullable enable
160+
bool ITypeSymbol.IsExtension => UnderlyingTypeSymbol is Symbols.NamedTypeSymbol { IsExtension: true };
161+
162+
IParameterSymbol? ITypeSymbol.ExtensionParameter
163+
{
164+
get
165+
{
166+
return UnderlyingTypeSymbol is Symbols.NamedTypeSymbol namedType
167+
? namedType.ExtensionParameter?.GetPublicSymbol()
168+
: null;
169+
}
170+
}
171+
#nullable disable
172+
159173
string ITypeSymbol.ToDisplayString(CodeAnalysis.NullableFlowState topLevelNullability, SymbolDisplayFormat format)
160174
{
161175
return SymbolDisplay.ToDisplayString(this, topLevelNullability, format);

‎src/roslyn/src/Compilers/Core/Portable/PublicAPI.Shipped.txt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1695,9 +1695,11 @@ Microsoft.CodeAnalysis.ITypeParameterSymbol.Variance.get -> Microsoft.CodeAnalys
16951695
Microsoft.CodeAnalysis.ITypeSymbol
16961696
Microsoft.CodeAnalysis.ITypeSymbol.AllInterfaces.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.INamedTypeSymbol!>
16971697
Microsoft.CodeAnalysis.ITypeSymbol.BaseType.get -> Microsoft.CodeAnalysis.INamedTypeSymbol?
1698+
Microsoft.CodeAnalysis.ITypeSymbol.ExtensionParameter.get -> Microsoft.CodeAnalysis.IParameterSymbol?
16981699
Microsoft.CodeAnalysis.ITypeSymbol.FindImplementationForInterfaceMember(Microsoft.CodeAnalysis.ISymbol! interfaceMember) -> Microsoft.CodeAnalysis.ISymbol?
16991700
Microsoft.CodeAnalysis.ITypeSymbol.Interfaces.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.INamedTypeSymbol!>
17001701
Microsoft.CodeAnalysis.ITypeSymbol.IsAnonymousType.get -> bool
1702+
Microsoft.CodeAnalysis.ITypeSymbol.IsExtension.get -> bool
17011703
Microsoft.CodeAnalysis.ITypeSymbol.IsNativeIntegerType.get -> bool
17021704
Microsoft.CodeAnalysis.ITypeSymbol.IsReadOnly.get -> bool
17031705
Microsoft.CodeAnalysis.ITypeSymbol.IsRecord.get -> bool

‎src/roslyn/src/Compilers/Core/Portable/Symbols/INamedTypeSymbol.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,13 @@ public interface INamedTypeSymbol : ITypeSymbol
202202
/// Is this a symbol for an extension declaration.
203203
/// </summary>
204204
[MemberNotNullWhen(true, nameof(ExtensionGroupingName), nameof(ExtensionMarkerName))]
205-
bool IsExtension { get; }
205+
new bool IsExtension { get; }
206206

207207
/// <summary>
208208
/// The extension parameter if this is an extension declaration (<see cref="IsExtension"/> is true).
209209
/// Note: this may be null even if <see cref="IsExtension"/> is true, in error cases.
210210
/// </summary>
211-
IParameterSymbol? ExtensionParameter { get; }
211+
new IParameterSymbol? ExtensionParameter { get; }
212212

213213
/// <summary>
214214
/// For extensions, returns the synthesized identifier for the grouping type.

‎src/roslyn/src/Compilers/Core/Portable/Symbols/ITypeSymbol.cs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ public interface ITypeSymbol : INamespaceOrTypeSymbol
8080
/// </summary>
8181
bool IsNativeIntegerType { get; }
8282

83+
[Obsolete($"This API will be removed in the future. Use {nameof(INamedTypeSymbol)}.{nameof(INamedTypeSymbol.IsExtension)} instead.")]
84+
bool IsExtension { get; }
85+
86+
[Obsolete($"This API will be removed in the future. Use {nameof(INamedTypeSymbol)}.{nameof(INamedTypeSymbol.ExtensionParameter)} instead.")]
87+
IParameterSymbol? ExtensionParameter { get; }
88+
8389
/// <summary>
8490
/// The original definition of this symbol. If this symbol is constructed from another
8591
/// symbol by type substitution then <see cref="OriginalDefinition"/> gets the original symbol as it was defined in

‎src/roslyn/src/Compilers/VisualBasic/Portable/Symbols/TypeSymbol.vb‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,5 +782,19 @@ Done:
782782
Private Function ITypeSymbolInternal_GetITypeSymbol() As ITypeSymbol Implements ITypeSymbolInternal.GetITypeSymbol
783783
Return Me
784784
End Function
785+
786+
<Obsolete>
787+
Private ReadOnly Property ITypeSymbol_IsExtension As Boolean Implements ITypeSymbol.IsExtension
788+
Get
789+
Return False
790+
End Get
791+
End Property
792+
793+
<Obsolete>
794+
Private ReadOnly Property ITypeSymbol_ExtensionParameter As IParameterSymbol Implements ITypeSymbol.ExtensionParameter
795+
Get
796+
Return Nothing
797+
End Get
798+
End Property
785799
End Class
786800
End Namespace

‎src/roslyn/src/Tools/SemanticSearch/ReferenceAssemblies/Apis/Microsoft.CodeAnalysis.txt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,8 +1480,10 @@ Microsoft.CodeAnalysis.ITypeSymbol.ToMinimalDisplayString(Microsoft.CodeAnalysis
14801480
Microsoft.CodeAnalysis.ITypeSymbol.WithNullableAnnotation(Microsoft.CodeAnalysis.NullableAnnotation)
14811481
Microsoft.CodeAnalysis.ITypeSymbol.get_AllInterfaces
14821482
Microsoft.CodeAnalysis.ITypeSymbol.get_BaseType
1483+
Microsoft.CodeAnalysis.ITypeSymbol.get_ExtensionParameter
14831484
Microsoft.CodeAnalysis.ITypeSymbol.get_Interfaces
14841485
Microsoft.CodeAnalysis.ITypeSymbol.get_IsAnonymousType
1486+
Microsoft.CodeAnalysis.ITypeSymbol.get_IsExtension
14851487
Microsoft.CodeAnalysis.ITypeSymbol.get_IsNativeIntegerType
14861488
Microsoft.CodeAnalysis.ITypeSymbol.get_IsReadOnly
14871489
Microsoft.CodeAnalysis.ITypeSymbol.get_IsRecord

‎src/roslyn/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeGeneration/Symbols/CodeGenerationTypeSymbol.cs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ public ImmutableArray<INamedTypeSymbol> AllInterfaces
4242

4343
public bool IsNativeIntegerType => false;
4444

45+
#if !ROSLYN_4_12_OR_LOWER
46+
bool ITypeSymbol.IsExtension => false;
47+
48+
IParameterSymbol ITypeSymbol.ExtensionParameter => null;
49+
#endif
50+
4551
public static ImmutableArray<ITypeSymbol> TupleElementTypes => default;
4652

4753
public static ImmutableArray<string> TupleElementNames => default;

0 commit comments

Comments
 (0)