Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge main to features/rename_ui_rework #58334

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
5078eae
Check operations when doing type name simplification
CyrusNajmabadi Dec 12, 2021
c90eac8
Update test
CyrusNajmabadi Dec 12, 2021
19a596e
Update test
CyrusNajmabadi Dec 12, 2021
70c17f4
Update src/EditorFeatures/VisualBasicTest/SimplifyTypeNames/SimplifyT…
CyrusNajmabadi Dec 12, 2021
a3e5adb
Ensure VB case still works
CyrusNajmabadi Dec 12, 2021
3992ec7
Merge branch 'speculationOperation' of https://github.com/CyrusNajmab…
CyrusNajmabadi Dec 12, 2021
621529b
Add explanatory comment
CyrusNajmabadi Dec 13, 2021
a8f1691
Update the status of required members. (#58308)
333fred Dec 14, 2021
c673c6f
Move cached semantic classification into normal semantic classification
CyrusNajmabadi Dec 14, 2021
85f60db
Merge pull request #58285 from CyrusNajmabadi/speculationOperation
CyrusNajmabadi Dec 14, 2021
d762693
IN progress
CyrusNajmabadi Dec 14, 2021
1968ebd
In progress
CyrusNajmabadi Dec 14, 2021
0a5ca5f
IN progress
CyrusNajmabadi Dec 14, 2021
b422417
Full transition
CyrusNajmabadi Dec 14, 2021
0da2f1c
Deletes
CyrusNajmabadi Dec 14, 2021
3f51943
Remove classification cache service
CyrusNajmabadi Dec 14, 2021
a42ef47
Make non partial
CyrusNajmabadi Dec 14, 2021
5068d86
Simplify
CyrusNajmabadi Dec 14, 2021
e719ffe
Simplify
CyrusNajmabadi Dec 14, 2021
86ee03b
Update src/Workspaces/Remote/ServiceHub/Services/SemanticClassificati…
CyrusNajmabadi Dec 14, 2021
cd8c409
Simplify
CyrusNajmabadi Dec 14, 2021
fe97922
Merge branch 'classificationQueue' of https://github.com/CyrusNajmaba…
CyrusNajmabadi Dec 14, 2021
baa1b1b
Update src/Workspaces/Remote/ServiceHub/Services/SemanticClassificati…
CyrusNajmabadi Dec 14, 2021
21bb520
Remove descriptor
CyrusNajmabadi Dec 14, 2021
275d6a1
Add comment
CyrusNajmabadi Dec 14, 2021
6fa1f24
Merge branch 'classificationQueue' of https://github.com/CyrusNajmaba…
CyrusNajmabadi Dec 14, 2021
2cd1e6f
Fix regression in Equals/GetHashCode of LambdaSymbol. (#58247)
Youssef1313 Dec 14, 2021
e77005a
Merge pull request #58326 from CyrusNajmabadi/classificationQueue
CyrusNajmabadi Dec 14, 2021
e11adfb
Fix the bad words in TestDeepAlternation
Cosifne Dec 14, 2021
28c6950
Merge pull request #58330 from Cosifne/dev/shech/poliFix
Cosifne Dec 14, 2021
3e32282
Nullable enable GetTypeByMetadataName (#58317)
333fred Dec 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/Language Feature Status.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ efforts behind them.
| [List patterns](https://github.com/dotnet/csharplang/issues/3435) | [list-patterns](https://github.com/dotnet/roslyn/tree/features/list-patterns) | [In Progress](https://github.com/dotnet/roslyn/issues/51289) | [alrz](https://github.com/alrz) | [jcouv](https://github.com/jcouv), [333fred](https://github.com/333fred) | [333fred](https://github.com/333fred) |
| [Raw string literals](https://github.com/dotnet/csharplang/issues/4304) | [RawStringLiterals](https://github.com/dotnet/roslyn/tree/features/features/RawStringLiterals) | [In Progress](https://github.com/dotnet/roslyn/issues/55306) | [CyrusNajmabadi](https://github.com/CyrusNajmabadi) | [jcouv](https://github.com/jcouv) | [CyrusNajmabadi](https://github.com/CyrusNajmabadi) |
| [Semi-auto-properties](https://github.com/dotnet/csharplang/issues/140) | [semi-auto-properties](https://github.com/dotnet/roslyn/tree/features/features/semi-auto-properties) | [In Progress](https://github.com/dotnet/roslyn/issues/57012) | [Youssef1313](https://github.com/Youssef1313) | TBD | [CyrusNajmabadi](https://github.com/CyrusNajmabadi) |
| [Required properties](https://github.com/dotnet/csharplang/issues/3630) | [required-properties](https://github.com/dotnet/roslyn/tree/features/features/required-properties) | [In Progress](https://github.com/dotnet/roslyn/issues/57046) | [333fred](https://github.com/333fred) | TBD | [333fred](https://github.com/333fred) |
| [Required members](https://github.com/dotnet/csharplang/issues/3630) | [required-members](https://github.com/dotnet/roslyn/tree/features/required-members) | [In Progress](https://github.com/dotnet/roslyn/issues/57046) | [333fred](https://github.com/333fred) | [jcouv](https://github.com/jcouv), [RikkiGibson](https://github.com/RikkiGibson) | [333fred](https://github.com/333fred) |
| [Top Level statement attribute specifiers](https://github.com/dotnet/csharplang/issues/5045) | [main-attributes](https://github.com/dotnet/roslyn/tree/features/features/main-attributes) | [In Progress](https://github.com/dotnet/roslyn/issues/57047) | [chsienki](https://github.com/chsienki) | TBD | [jaredpar](https://github.com/jaredpar) |
| [Primary Constructors](https://github.com/dotnet/csharplang/issues/2691) | [primary-constructors](https://github.com/dotnet/roslyn/tree/features/features/primary-constructors) | [In Progress](https://github.com/dotnet/roslyn/issues/57048) | TBD | TBD | [MadsTorgersen](https://github.com/MadsTorgersen) |
| [Params Span<T> + Stackalloc any array type](https://github.com/dotnet/csharplang/issues/1757) | [params-span](https://github.com/dotnet/roslyn/tree/features/features/params-span) | [In Progress](https://github.com/dotnet/roslyn/issues/57049) | [cston](https://github.com/cston) | TBD | [jaredpar](https://github.com/jaredpar) |
Expand Down
1 change: 0 additions & 1 deletion eng/targets/Services.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<ServiceHubService Include="Microsoft.VisualStudio.LanguageServices.AsynchronousOperationListener" ClassName="Microsoft.CodeAnalysis.Remote.RemoteAsynchronousOperationListenerService+Factory" Audience="AllClientsIncludingGuests"/>
<ServiceHubService Include="Microsoft.VisualStudio.LanguageServices.DiagnosticAnalyzer" ClassName="Microsoft.CodeAnalysis.Remote.RemoteDiagnosticAnalyzerService+Factory" />
<ServiceHubService Include="Microsoft.VisualStudio.LanguageServices.SemanticClassification" ClassName="Microsoft.CodeAnalysis.Remote.RemoteSemanticClassificationService+Factory" />
<ServiceHubService Include="Microsoft.VisualStudio.LanguageServices.SemanticClassificationCache" ClassName="Microsoft.CodeAnalysis.Remote.RemoteSemanticClassificationCacheService+Factory" />
<ServiceHubService Include="Microsoft.VisualStudio.LanguageServices.DocumentHighlights" ClassName="Microsoft.CodeAnalysis.Remote.RemoteDocumentHighlightsService+Factory" />
<ServiceHubService Include="Microsoft.VisualStudio.LanguageServices.EncapsulateField" ClassName="Microsoft.CodeAnalysis.Remote.RemoteEncapsulateFieldService+Factory" />
<ServiceHubService Include="Microsoft.VisualStudio.LanguageServices.Renamer" ClassName="Microsoft.CodeAnalysis.Remote.RemoteRenamerService+Factory" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1562,7 +1562,7 @@ internal override ISymbolInternal CommonGetSpecialTypeMember(SpecialMember speci
internal TypeSymbol GetTypeByReflectionType(Type type, BindingDiagnosticBag diagnostics)
{
var result = Assembly.GetTypeByReflectionType(type, includeReferences: true);
if ((object)result == null)
if (result is null)
{
var errorType = new ExtendedErrorTypeSymbol(this, type.Name, 0, CreateReflectionTypeNotFoundError(type));
diagnostics.Add(errorType.ErrorInfo, NoLocation.Singleton);
Expand Down Expand Up @@ -1590,9 +1590,9 @@ protected override ITypeSymbol? CommonScriptGlobalsType
{
if (HostObjectType != null && _lazyHostObjectTypeSymbol is null)
{
TypeSymbol symbol = Assembly.GetTypeByReflectionType(HostObjectType, includeReferences: true);
TypeSymbol? symbol = Assembly.GetTypeByReflectionType(HostObjectType, includeReferences: true);

if ((object)symbol == null)
if (symbol is null)
{
MetadataTypeName mdName = MetadataTypeName.FromNamespaceAndTypeName(HostObjectType.Namespace ?? String.Empty,
HostObjectType.Name,
Expand Down
65 changes: 34 additions & 31 deletions src/Compilers/CSharp/Portable/Symbols/AssemblySymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using System.Reflection.PortableExecutable;
Expand Down Expand Up @@ -565,12 +566,13 @@ internal NamedTypeSymbol GetPrimitiveType(Microsoft.Cci.PrimitiveTypeCode type)
return GetSpecialType(SpecialTypes.GetTypeFromMetadataName(type));
}

#nullable enable
/// <summary>
/// Lookup a type within the assembly using the canonical CLR metadata name of the type.
/// </summary>
/// <param name="fullyQualifiedMetadataName">Type name.</param>
/// <returns>Symbol for the type or null if type cannot be found or is ambiguous. </returns>
public NamedTypeSymbol GetTypeByMetadataName(string fullyQualifiedMetadataName)
public NamedTypeSymbol? GetTypeByMetadataName(string fullyQualifiedMetadataName)
{
if (fullyQualifiedMetadataName == null)
{
Expand Down Expand Up @@ -606,16 +608,16 @@ public NamedTypeSymbol GetTypeByMetadataName(string fullyQualifiedMetadataName)
/// In cases a type could not be found because of ambiguity, we return two of the candidates that caused the ambiguity.
/// </param>
/// <returns>Null if the type can't be found.</returns>
internal NamedTypeSymbol GetTypeByMetadataName(
internal NamedTypeSymbol? GetTypeByMetadataName(
string metadataName,
bool includeReferences,
bool isWellKnownType,
out (AssemblySymbol, AssemblySymbol) conflicts,
bool useCLSCompliantNameArityEncoding = false,
DiagnosticBag warnings = null,
DiagnosticBag? warnings = null,
bool ignoreCorLibraryDuplicatedTypes = false)
{
NamedTypeSymbol type;
NamedTypeSymbol? type;
MetadataTypeName mdName;

if (metadataName.IndexOf('+') >= 0)
Expand All @@ -626,7 +628,7 @@ internal NamedTypeSymbol GetTypeByMetadataName(
type = GetTopLevelTypeByMetadataName(ref mdName, assemblyOpt: null, includeReferences: includeReferences, isWellKnownType: isWellKnownType,
conflicts: out conflicts, warnings: warnings, ignoreCorLibraryDuplicatedTypes: ignoreCorLibraryDuplicatedTypes);

for (int i = 1; (object)type != null && !type.IsErrorType() && i < parts.Length; i++)
for (int i = 1; type is object && !type.IsErrorType() && i < parts.Length; i++)
{
mdName = MetadataTypeName.FromTypeName(parts[i]);
NamedTypeSymbol temp = type.LookupMetadataType(ref mdName);
Expand All @@ -640,7 +642,7 @@ internal NamedTypeSymbol GetTypeByMetadataName(
conflicts: out conflicts, warnings: warnings, ignoreCorLibraryDuplicatedTypes: ignoreCorLibraryDuplicatedTypes);
}

return ((object)type == null || type.IsErrorType()) ? null : type;
return (type is null || type.IsErrorType()) ? null : type;
}

private static readonly char[] s_nestedTypeNameSeparators = new char[] { '+' };
Expand All @@ -652,7 +654,7 @@ internal NamedTypeSymbol GetTypeByMetadataName(
/// <param name="type">The type to resolve.</param>
/// <param name="includeReferences">Use referenced assemblies for resolution.</param>
/// <returns>The resolved symbol if successful or null on failure.</returns>
internal TypeSymbol GetTypeByReflectionType(Type type, bool includeReferences)
internal TypeSymbol? GetTypeByReflectionType(Type type, bool includeReferences)
{
System.Reflection.TypeInfo typeInfo = type.GetTypeInfo();

Expand All @@ -663,8 +665,8 @@ internal TypeSymbol GetTypeByReflectionType(Type type, bool includeReferences)

if (typeInfo.IsArray)
{
TypeSymbol symbol = GetTypeByReflectionType(typeInfo.GetElementType(), includeReferences);
if ((object)symbol == null)
TypeSymbol? symbol = GetTypeByReflectionType(typeInfo.GetElementType()!, includeReferences);
if (symbol is null)
{
return null;
}
Expand All @@ -675,8 +677,8 @@ internal TypeSymbol GetTypeByReflectionType(Type type, bool includeReferences)
}
else if (typeInfo.IsPointer)
{
TypeSymbol symbol = GetTypeByReflectionType(typeInfo.GetElementType(), includeReferences);
if ((object)symbol == null)
TypeSymbol? symbol = GetTypeByReflectionType(typeInfo.GetElementType()!, includeReferences);
if (symbol is null)
{
return null;
}
Expand Down Expand Up @@ -707,8 +709,8 @@ internal TypeSymbol GetTypeByReflectionType(Type type, bool includeReferences)
}

int i = nestedTypes.Count - 1;
var symbol = (NamedTypeSymbol)GetTypeByReflectionType(nestedTypes[i].AsType(), includeReferences);
if ((object)symbol == null)
var symbol = (NamedTypeSymbol?)GetTypeByReflectionType(nestedTypes[i].AsType(), includeReferences);
if (symbol is null)
{
return null;
}
Expand All @@ -719,13 +721,13 @@ internal TypeSymbol GetTypeByReflectionType(Type type, bool includeReferences)
MetadataTypeName mdName = MetadataTypeName.FromTypeName(nestedTypes[i].Name, forcedArity: forcedArity);

symbol = symbol.LookupMetadataType(ref mdName);
if ((object)symbol == null || symbol.IsErrorType())
if (symbol is null || symbol.IsErrorType())
{
return null;
}

symbol = ApplyGenericArguments(symbol, genericArguments, ref typeArgumentIndex, includeReferences);
if ((object)symbol == null)
if (symbol is null)
{
return null;
}
Expand All @@ -744,9 +746,9 @@ internal TypeSymbol GetTypeByReflectionType(Type type, bool includeReferences)
typeInfo.Name,
forcedArity: typeInfo.GenericTypeArguments.Length);

NamedTypeSymbol symbol = GetTopLevelTypeByMetadataName(ref mdName, assemblyId, includeReferences, isWellKnownType: false, conflicts: out var _);
NamedTypeSymbol? symbol = GetTopLevelTypeByMetadataName(ref mdName, assemblyId, includeReferences, isWellKnownType: false, conflicts: out var _);

if ((object)symbol == null || symbol.IsErrorType())
if (symbol is null || symbol.IsErrorType())
{
return null;
}
Expand All @@ -759,7 +761,7 @@ internal TypeSymbol GetTypeByReflectionType(Type type, bool includeReferences)
}
}

private NamedTypeSymbol ApplyGenericArguments(NamedTypeSymbol symbol, Type[] typeArguments, ref int currentTypeArgument, bool includeReferences)
private NamedTypeSymbol? ApplyGenericArguments(NamedTypeSymbol symbol, Type[] typeArguments, ref int currentTypeArgument, bool includeReferences)
{
int remainingTypeArguments = typeArguments.Length - currentTypeArgument;

Expand All @@ -776,7 +778,7 @@ private NamedTypeSymbol ApplyGenericArguments(NamedTypeSymbol symbol, Type[] typ
for (int i = 0; i < length; i++)
{
var argSymbol = GetTypeByReflectionType(typeArguments[currentTypeArgument++], includeReferences);
if ((object)argSymbol == null)
if (argSymbol is null)
{
return null;
}
Expand All @@ -786,13 +788,13 @@ private NamedTypeSymbol ApplyGenericArguments(NamedTypeSymbol symbol, Type[] typ
return symbol.ConstructIfGeneric(typeArgumentSymbols.ToImmutableAndFree());
}

internal NamedTypeSymbol GetTopLevelTypeByMetadataName(
internal NamedTypeSymbol? GetTopLevelTypeByMetadataName(
ref MetadataTypeName metadataName,
AssemblyIdentity assemblyOpt,
AssemblyIdentity? assemblyOpt,
bool includeReferences,
bool isWellKnownType,
out (AssemblySymbol, AssemblySymbol) conflicts,
DiagnosticBag warnings = null, // this is set to collect ambiguity warning for well-known types before C# 7
DiagnosticBag? warnings = null, // this is set to collect ambiguity warning for well-known types before C# 7
bool ignoreCorLibraryDuplicatedTypes = false)
{
// Type from this assembly always wins.
Expand All @@ -805,7 +807,7 @@ internal NamedTypeSymbol GetTopLevelTypeByMetadataName(
Debug.Assert(warnings is null || isWellKnownType);

conflicts = default;
NamedTypeSymbol result;
NamedTypeSymbol? result;

// First try this assembly
result = GetTopLevelTypeByMetadataName(this, ref metadataName, assemblyOpt);
Expand All @@ -816,7 +818,7 @@ internal NamedTypeSymbol GetTopLevelTypeByMetadataName(
}

// ignore any types of the same name that might be in referenced assemblies (prefer the current assembly):
if ((object)result != null || !includeReferences)
if (result is object || !includeReferences)
{
return result;
}
Expand All @@ -829,7 +831,7 @@ internal NamedTypeSymbol GetTopLevelTypeByMetadataName(
!CorLibrary.IsMissing &&
!isWellKnownTypeBeforeCSharp7 && !ignoreCorLibraryDuplicatedTypes)
{
NamedTypeSymbol corLibCandidate = GetTopLevelTypeByMetadataName(CorLibrary, ref metadataName, assemblyOpt);
NamedTypeSymbol? corLibCandidate = GetTopLevelTypeByMetadataName(CorLibrary, ref metadataName, assemblyOpt);
skipCorLibrary = true;

if (isValidCandidate(corLibCandidate, isWellKnownType))
Expand Down Expand Up @@ -863,7 +865,7 @@ internal NamedTypeSymbol GetTopLevelTypeByMetadataName(
continue;
}

NamedTypeSymbol candidate = GetTopLevelTypeByMetadataName(assembly, ref metadataName, assemblyOpt);
NamedTypeSymbol? candidate = GetTopLevelTypeByMetadataName(assembly, ref metadataName, assemblyOpt);

if (!isValidCandidate(candidate, isWellKnownType))
{
Expand All @@ -872,7 +874,7 @@ internal NamedTypeSymbol GetTopLevelTypeByMetadataName(

Debug.Assert(!TypeSymbol.Equals(candidate, result, TypeCompareKind.ConsiderEverything));

if ((object)result != null)
if (result is object)
{
// duplicate
if (ignoreCorLibraryDuplicatedTypes)
Expand Down Expand Up @@ -910,7 +912,7 @@ internal NamedTypeSymbol GetTopLevelTypeByMetadataName(
assemblies.Free();
return result;

bool isValidCandidate(NamedTypeSymbol candidate, bool isWellKnownType)
bool isValidCandidate([NotNullWhen(true)] NamedTypeSymbol? candidate, bool isWellKnownType)
{
return candidate is not null
&& (!isWellKnownType || IsValidWellKnownType(candidate))
Expand All @@ -923,9 +925,9 @@ private bool IsInCorLib(NamedTypeSymbol type)
return (object)type.ContainingAssembly == CorLibrary;
}

private bool IsValidWellKnownType(NamedTypeSymbol result)
private bool IsValidWellKnownType(NamedTypeSymbol? result)
{
if ((object)result == null || result.TypeKind == TypeKind.Error)
if (result is null || result.TypeKind == TypeKind.Error)
{
return false;
}
Expand All @@ -936,7 +938,7 @@ private bool IsValidWellKnownType(NamedTypeSymbol result)
return result.DeclaredAccessibility == Accessibility.Public || IsSymbolAccessible(result, this);
}

private static NamedTypeSymbol GetTopLevelTypeByMetadataName(AssemblySymbol assembly, ref MetadataTypeName metadataName, AssemblyIdentity assemblyOpt)
private static NamedTypeSymbol? GetTopLevelTypeByMetadataName(AssemblySymbol assembly, ref MetadataTypeName metadataName, AssemblyIdentity? assemblyOpt)
{
var result = assembly.LookupTopLevelMetadataType(ref metadataName, digThroughForwardedTypes: false);
if (!IsAcceptableMatchForGetTypeByMetadataName(result))
Expand All @@ -956,6 +958,7 @@ private static bool IsAcceptableMatchForGetTypeByMetadataName(NamedTypeSymbol ca
{
return candidate.Kind != SymbolKind.ErrorType || !(candidate is MissingMetadataTypeSymbol);
}
#nullable disable

/// <summary>
/// Lookup member declaration in predefined CorLib type in this Assembly. Only valid if this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,12 @@ bool IAssemblySymbol.GivesAccessTo(IAssemblySymbol assemblyWantingAccess)
return false;
}

INamedTypeSymbol IAssemblySymbol.GetTypeByMetadataName(string metadataName)
#nullable enable
INamedTypeSymbol? IAssemblySymbol.GetTypeByMetadataName(string metadataName)
{
return UnderlyingAssemblySymbol.GetTypeByMetadataName(metadataName).GetPublicSymbol();
}
#nullable disable

#region ISymbol Members

Expand Down
Loading