\n \n Attempt to connect to process #{0} failed, retrying ...\n Error al intentar conectar con el proceso #{0}, reintentando...\n \n \n \n Cannot resolve reference '{0}'.\n No se puede resolver la referencia '{0}'.\n \n \n \n Failed to create a remote process for interactive code execution: '{0}'\n No se pudo crear un proceso remoto para la ejecución de código interactivo: \"{0}\"\n \n \n \n Failed to initialize remote interactive process.\n Error al inicializar el proceso remoto interactivo.\n \n \n \n Failed to launch '{0}' process (exit code: {1}) with output: \n Error al iniciar el proceso '{0}' (código de salida: {1}) con la salida: \n \n \n \n Hosting process exited with exit code {0}.\n El proceso de hospedaje terminó con el código de salida {0}.\n \n \n \n Interactive Host not initialized.\n Host interactivo no inicializado.\n \n \n \n Loading context from '{0}'.\n Cargando contexto de '{0}'.\n \n \n \n Searched in directories:\n Buscado en directorios:\n \n \n \n Searched in directory:\n Buscado en directorio:\n \n \n \n Specified file not found.\n Archivo especificado no encontrado.\n \n \n \n Specified file not found: {0}\n Archivo especificado no encontrado: {0}\n \n \n \n Type \"#help\" for more information.\n Escriba \"#help\" para más información.\n \n \n \n Unable to create hosting process.\n No se puede crear el proceso de hospedaje.\n \n \n \n + additional {0} {1}\n + adicional {0} {1}\n \n \n
\n \n"},"label":{"kind":"number","value":-1,"string":"-1"}}},{"rowIdx":1509,"cells":{"repo_name":{"kind":"string","value":"dotnet/roslyn"},"pr_number":{"kind":"number","value":56310,"string":"56,310"},"pr_title":{"kind":"string","value":"Move semantic classification caching down to Editor layer"},"pr_description":{"kind":"string","value":""},"author":{"kind":"string","value":"CyrusNajmabadi"},"date_created":{"kind":"timestamp","value":"2021-09-09T23:15:16Z","string":"2021-09-09T23:15:16Z"},"date_merged":{"kind":"timestamp","value":"2021-09-10T19:26:25Z","string":"2021-09-10T19:26:25Z"},"previous_commit":{"kind":"string","value":"6e123012d868c56aba8acabfe1ccad1bf8f20b04"},"pr_commit":{"kind":"string","value":"7af13b6e3867198cd59c566a905b332888ea1dec"},"query":{"kind":"string","value":"Move semantic classification caching down to Editor layer. "},"filepath":{"kind":"string","value":"./src/Compilers/Test/Utilities/VisualBasic/TestOptions.vb"},"before_content":{"kind":"string","value":"' Licensed to the .NET Foundation under one or more agreements.\n' The .NET Foundation licenses this file to you under the MIT license.\n' See the LICENSE file in the project root for more information.\n\nImports System.Runtime.CompilerServices\nImports Microsoft.CodeAnalysis.Diagnostics\nImports Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax\nImports Roslyn.Test.Utilities\n\nPublic Class TestOptions\n Public Shared ReadOnly Script As New VisualBasicParseOptions(kind:=SourceCodeKind.Script)\n Public Shared ReadOnly Regular As New VisualBasicParseOptions(kind:=SourceCodeKind.Regular)\n Public Shared ReadOnly Regular15_5 As VisualBasicParseOptions = Regular.WithLanguageVersion(LanguageVersion.VisualBasic15_5)\n Public Shared ReadOnly Regular16 As VisualBasicParseOptions = Regular.WithLanguageVersion(LanguageVersion.VisualBasic16)\n Public Shared ReadOnly Regular16_9 As VisualBasicParseOptions = Regular.WithLanguageVersion(LanguageVersion.VisualBasic16_9)\n Public Shared ReadOnly RegularLatest As VisualBasicParseOptions = Regular.WithLanguageVersion(LanguageVersion.Latest)\n Public Shared ReadOnly RegularWithLegacyStrongName As VisualBasicParseOptions = Regular.WithFeature(\"UseLegacyStrongNameProvider\")\n\n Public Shared ReadOnly ReleaseDll As VisualBasicCompilationOptions = New VisualBasicCompilationOptions(OutputKind.DynamicallyLinkedLibrary, optimizationLevel:=OptimizationLevel.Release).WithParseOptions(Regular)\n Public Shared ReadOnly ReleaseExe As VisualBasicCompilationOptions = New VisualBasicCompilationOptions(OutputKind.ConsoleApplication, optimizationLevel:=OptimizationLevel.Release).WithParseOptions(Regular)\n\n Public Shared ReadOnly ReleaseDebugDll As VisualBasicCompilationOptions = New VisualBasicCompilationOptions(OutputKind.DynamicallyLinkedLibrary, optimizationLevel:=OptimizationLevel.Release).\n WithDebugPlusMode(True).WithParseOptions(Regular)\n\n Public Shared ReadOnly ReleaseDebugExe As VisualBasicCompilationOptions = New VisualBasicCompilationOptions(OutputKind.ConsoleApplication, optimizationLevel:=OptimizationLevel.Release).\n WithDebugPlusMode(True).WithParseOptions(Regular)\n\n Public Shared ReadOnly DebugDll As VisualBasicCompilationOptions = New VisualBasicCompilationOptions(OutputKind.DynamicallyLinkedLibrary, optimizationLevel:=OptimizationLevel.Debug).WithParseOptions(Regular)\n Public Shared ReadOnly DebugExe As VisualBasicCompilationOptions = New VisualBasicCompilationOptions(OutputKind.ConsoleApplication, optimizationLevel:=OptimizationLevel.Debug).WithParseOptions(Regular)\n\n Public Shared ReadOnly ReleaseModule As VisualBasicCompilationOptions = New VisualBasicCompilationOptions(OutputKind.NetModule, optimizationLevel:=OptimizationLevel.Release).WithParseOptions(Regular)\n Public Shared ReadOnly ReleaseWinMD As VisualBasicCompilationOptions = New VisualBasicCompilationOptions(OutputKind.WindowsRuntimeMetadata, optimizationLevel:=OptimizationLevel.Release).WithParseOptions(Regular)\n Public Shared ReadOnly DebugWinMD As VisualBasicCompilationOptions = New VisualBasicCompilationOptions(OutputKind.WindowsRuntimeMetadata, optimizationLevel:=OptimizationLevel.Debug).WithParseOptions(Regular)\n\n Public Shared ReadOnly SigningReleaseDll As VisualBasicCompilationOptions = ReleaseDll.WithStrongNameProvider(SigningTestHelpers.DefaultDesktopStrongNameProvider)\n Public Shared ReadOnly SigningReleaseExe As VisualBasicCompilationOptions = ReleaseExe.WithStrongNameProvider(SigningTestHelpers.DefaultDesktopStrongNameProvider)\n Public Shared ReadOnly SigningDebugDll As VisualBasicCompilationOptions = DebugDll.WithStrongNameProvider(SigningTestHelpers.DefaultDesktopStrongNameProvider)\n Public Shared ReadOnly SigningDebugExe As VisualBasicCompilationOptions = DebugExe.WithStrongNameProvider(SigningTestHelpers.DefaultDesktopStrongNameProvider)\n Public Shared ReadOnly SigningReleaseModule As VisualBasicCompilationOptions = ReleaseModule.WithStrongNameProvider(SigningTestHelpers.DefaultDesktopStrongNameProvider)\nEnd Class\n\nFriend Module TestOptionExtensions\n \n Public Function WithStrictFeature(options As VisualBasicParseOptions) As VisualBasicParseOptions\n Return WithFeature(options, \"Strict\")\n End Function\n\n \n Public Function WithFeature(options As VisualBasicParseOptions, feature As String, Optional value As String = \"True\") As VisualBasicParseOptions\n Return options.WithFeatures(options.Features.Concat(New KeyValuePair(Of String, String)() {New KeyValuePair(Of String, String)(feature, value)}))\n End Function\n\n \n Friend Function WithExperimental(options As VisualBasicParseOptions, ParamArray features As Feature()) As VisualBasicParseOptions\n If features.Length = 0 Then\n Throw New InvalidOperationException(\"Need at least one feature to enable\")\n End If\n Dim list As New List(Of KeyValuePair(Of String, String))\n For Each feature In features\n Dim flagName = feature.GetFeatureFlag()\n If flagName Is Nothing Then\n Throw New InvalidOperationException($\"{feature} is not an experimental feature\")\n End If\n list.Add(New KeyValuePair(Of String, String)(flagName, \"True\"))\n Next\n Return options.WithFeatures(options.Features.Concat(list))\n End Function\nEnd Module\n"},"after_content":{"kind":"string","value":"' Licensed to the .NET Foundation under one or more agreements.\n' The .NET Foundation licenses this file to you under the MIT license.\n' See the LICENSE file in the project root for more information.\n\nImports System.Runtime.CompilerServices\nImports Microsoft.CodeAnalysis.Diagnostics\nImports Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax\nImports Roslyn.Test.Utilities\n\nPublic Class TestOptions\n Public Shared ReadOnly Script As New VisualBasicParseOptions(kind:=SourceCodeKind.Script)\n Public Shared ReadOnly Regular As New VisualBasicParseOptions(kind:=SourceCodeKind.Regular)\n Public Shared ReadOnly Regular15_5 As VisualBasicParseOptions = Regular.WithLanguageVersion(LanguageVersion.VisualBasic15_5)\n Public Shared ReadOnly Regular16 As VisualBasicParseOptions = Regular.WithLanguageVersion(LanguageVersion.VisualBasic16)\n Public Shared ReadOnly Regular16_9 As VisualBasicParseOptions = Regular.WithLanguageVersion(LanguageVersion.VisualBasic16_9)\n Public Shared ReadOnly RegularLatest As VisualBasicParseOptions = Regular.WithLanguageVersion(LanguageVersion.Latest)\n Public Shared ReadOnly RegularWithLegacyStrongName As VisualBasicParseOptions = Regular.WithFeature(\"UseLegacyStrongNameProvider\")\n\n Public Shared ReadOnly ReleaseDll As VisualBasicCompilationOptions = New VisualBasicCompilationOptions(OutputKind.DynamicallyLinkedLibrary, optimizationLevel:=OptimizationLevel.Release).WithParseOptions(Regular)\n Public Shared ReadOnly ReleaseExe As VisualBasicCompilationOptions = New VisualBasicCompilationOptions(OutputKind.ConsoleApplication, optimizationLevel:=OptimizationLevel.Release).WithParseOptions(Regular)\n\n Public Shared ReadOnly ReleaseDebugDll As VisualBasicCompilationOptions = New VisualBasicCompilationOptions(OutputKind.DynamicallyLinkedLibrary, optimizationLevel:=OptimizationLevel.Release).\n WithDebugPlusMode(True).WithParseOptions(Regular)\n\n Public Shared ReadOnly ReleaseDebugExe As VisualBasicCompilationOptions = New VisualBasicCompilationOptions(OutputKind.ConsoleApplication, optimizationLevel:=OptimizationLevel.Release).\n WithDebugPlusMode(True).WithParseOptions(Regular)\n\n Public Shared ReadOnly DebugDll As VisualBasicCompilationOptions = New VisualBasicCompilationOptions(OutputKind.DynamicallyLinkedLibrary, optimizationLevel:=OptimizationLevel.Debug).WithParseOptions(Regular)\n Public Shared ReadOnly DebugExe As VisualBasicCompilationOptions = New VisualBasicCompilationOptions(OutputKind.ConsoleApplication, optimizationLevel:=OptimizationLevel.Debug).WithParseOptions(Regular)\n\n Public Shared ReadOnly ReleaseModule As VisualBasicCompilationOptions = New VisualBasicCompilationOptions(OutputKind.NetModule, optimizationLevel:=OptimizationLevel.Release).WithParseOptions(Regular)\n Public Shared ReadOnly ReleaseWinMD As VisualBasicCompilationOptions = New VisualBasicCompilationOptions(OutputKind.WindowsRuntimeMetadata, optimizationLevel:=OptimizationLevel.Release).WithParseOptions(Regular)\n Public Shared ReadOnly DebugWinMD As VisualBasicCompilationOptions = New VisualBasicCompilationOptions(OutputKind.WindowsRuntimeMetadata, optimizationLevel:=OptimizationLevel.Debug).WithParseOptions(Regular)\n\n Public Shared ReadOnly SigningReleaseDll As VisualBasicCompilationOptions = ReleaseDll.WithStrongNameProvider(SigningTestHelpers.DefaultDesktopStrongNameProvider)\n Public Shared ReadOnly SigningReleaseExe As VisualBasicCompilationOptions = ReleaseExe.WithStrongNameProvider(SigningTestHelpers.DefaultDesktopStrongNameProvider)\n Public Shared ReadOnly SigningDebugDll As VisualBasicCompilationOptions = DebugDll.WithStrongNameProvider(SigningTestHelpers.DefaultDesktopStrongNameProvider)\n Public Shared ReadOnly SigningDebugExe As VisualBasicCompilationOptions = DebugExe.WithStrongNameProvider(SigningTestHelpers.DefaultDesktopStrongNameProvider)\n Public Shared ReadOnly SigningReleaseModule As VisualBasicCompilationOptions = ReleaseModule.WithStrongNameProvider(SigningTestHelpers.DefaultDesktopStrongNameProvider)\nEnd Class\n\nFriend Module TestOptionExtensions\n \n Public Function WithStrictFeature(options As VisualBasicParseOptions) As VisualBasicParseOptions\n Return WithFeature(options, \"Strict\")\n End Function\n\n \n Public Function WithFeature(options As VisualBasicParseOptions, feature As String, Optional value As String = \"True\") As VisualBasicParseOptions\n Return options.WithFeatures(options.Features.Concat(New KeyValuePair(Of String, String)() {New KeyValuePair(Of String, String)(feature, value)}))\n End Function\n\n \n Friend Function WithExperimental(options As VisualBasicParseOptions, ParamArray features As Feature()) As VisualBasicParseOptions\n If features.Length = 0 Then\n Throw New InvalidOperationException(\"Need at least one feature to enable\")\n End If\n Dim list As New List(Of KeyValuePair(Of String, String))\n For Each feature In features\n Dim flagName = feature.GetFeatureFlag()\n If flagName Is Nothing Then\n Throw New InvalidOperationException($\"{feature} is not an experimental feature\")\n End If\n list.Add(New KeyValuePair(Of String, String)(flagName, \"True\"))\n Next\n Return options.WithFeatures(options.Features.Concat(list))\n End Function\nEnd Module\n"},"label":{"kind":"number","value":-1,"string":"-1"}}},{"rowIdx":1510,"cells":{"repo_name":{"kind":"string","value":"dotnet/roslyn"},"pr_number":{"kind":"number","value":56310,"string":"56,310"},"pr_title":{"kind":"string","value":"Move semantic classification caching down to Editor layer"},"pr_description":{"kind":"string","value":""},"author":{"kind":"string","value":"CyrusNajmabadi"},"date_created":{"kind":"timestamp","value":"2021-09-09T23:15:16Z","string":"2021-09-09T23:15:16Z"},"date_merged":{"kind":"timestamp","value":"2021-09-10T19:26:25Z","string":"2021-09-10T19:26:25Z"},"previous_commit":{"kind":"string","value":"6e123012d868c56aba8acabfe1ccad1bf8f20b04"},"pr_commit":{"kind":"string","value":"7af13b6e3867198cd59c566a905b332888ea1dec"},"query":{"kind":"string","value":"Move semantic classification caching down to Editor layer. "},"filepath":{"kind":"string","value":"./src/Compilers/VisualBasic/Portable/Symbols/SynthesizedSymbols/SynthesizedGlobalMethodBase.vb"},"before_content":{"kind":"string","value":"' Licensed to the .NET Foundation under one or more agreements.\n' The .NET Foundation licenses this file to you under the MIT license.\n' See the LICENSE file in the project root for more information.\n\nImports System.Collections.Immutable\nImports Microsoft.CodeAnalysis.CodeGen\nImports Microsoft.CodeAnalysis.Text\nImports Microsoft.CodeAnalysis.VisualBasic.Symbols\nImports Microsoft.CodeAnalysis.VisualBasic.Syntax\n\nNamespace Microsoft.CodeAnalysis.VisualBasic.Symbols\n\n ''' \n ''' This class represents a base class for compiler generated synthesized method symbols\n ''' that must be emitted in the compiler generated PrivateImplementationDetails class.\n ''' SynthesizedGlobalMethodBase symbols don't have a ContainingType, there are global to\n ''' the containing source module and are Public Shared methods.\n ''' \n Friend MustInherit Class SynthesizedGlobalMethodBase\n Inherits MethodSymbol\n\n Protected ReadOnly m_privateImplType As PrivateImplementationDetails\n\n Protected ReadOnly m_containingModule As SourceModuleSymbol\n Protected ReadOnly m_name As String\n\n Protected Sub New(containingModule As SourceModuleSymbol, name As String, privateImplType As PrivateImplementationDetails)\n Debug.Assert(containingModule IsNot Nothing)\n\n m_containingModule = containingModule\n m_name = name\n m_privateImplType = privateImplType\n End Sub\n\n\n Public NotOverridable Overrides ReadOnly Property IsImplicitlyDeclared As Boolean\n Get\n Return True\n End Get\n End Property\n\n ''' \n ''' Gets the symbol name. Returns the empty string if unnamed.\n ''' \n Public NotOverridable Overrides ReadOnly Property Name As String\n Get\n Return m_name\n End Get\n End Property\n\n Friend Overrides ReadOnly Property HasSpecialName As Boolean\n Get\n Return False\n End Get\n End Property\n\n Friend Overrides Function GetAppliedConditionalSymbols() As ImmutableArray(Of String)\n Return ImmutableArray(Of String).Empty\n End Function\n\n ''' \n ''' Gets a value indicating whether this instance is abstract or not.\n ''' \n ''' \n ''' true if this instance is abstract; otherwise, false.\n ''' \n Public Overrides ReadOnly Property IsMustOverride As Boolean\n Get\n Return False\n End Get\n End Property\n\n ''' \n ''' Gets a value indicating whether this instance is not overridable.\n ''' \n ''' \n ''' true if this instance is not overridable; otherwise, false.\n ''' \n Public Overrides ReadOnly Property IsNotOverridable As Boolean\n Get\n Return False\n End Get\n End Property\n\n ''' \n ''' Gets a value indicating whether this instance is overloads.\n ''' \n ''' \n ''' true if this instance is overloads; otherwise, false.\n ''' \n Public Overrides ReadOnly Property IsOverloads As Boolean\n Get\n Return False\n End Get\n End Property\n\n ''' \n ''' Gets a value indicating whether this instance is overridable.\n ''' \n ''' \n ''' true if this instance is overridable; otherwise, false.\n ''' \n Public Overrides ReadOnly Property IsOverridable As Boolean\n Get\n Return False\n End Get\n End Property\n\n ''' \n ''' Gets a value indicating whether this instance is overrides.\n ''' \n ''' \n ''' true if this instance is overrides; otherwise, false.\n ''' \n Public Overrides ReadOnly Property IsOverrides As Boolean\n Get\n Return False\n End Get\n End Property\n\n ''' \n ''' Gets a value indicating whether this instance is shared.\n ''' \n ''' \n ''' true if this instance is shared; otherwise, false.\n ''' \n Public NotOverridable Overrides ReadOnly Property IsShared As Boolean\n Get\n Return True\n End Get\n End Property\n\n Friend Overrides Function GetLexicalSortKey() As LexicalSortKey\n Return LexicalSortKey.NotInSource\n End Function\n\n ''' \n ''' A potentially empty collection of locations that correspond to this instance.\n ''' \n Public Overrides ReadOnly Property Locations As ImmutableArray(Of Location)\n Get\n Return ImmutableArray(Of Location).Empty\n End Get\n End Property\n\n Public Overrides ReadOnly Property DeclaringSyntaxReferences As ImmutableArray(Of SyntaxReference)\n Get\n Return ImmutableArray(Of SyntaxReference).Empty\n End Get\n End Property\n\n ''' \n ''' Gets what kind of method this is. There are several different kinds of things in the\n ''' VB language that are represented as methods. This property allow distinguishing those things\n ''' without having to decode the name of the method.\n ''' \n Public Overrides ReadOnly Property MethodKind As MethodKind\n Get\n Return MethodKind.Ordinary\n End Get\n End Property\n\n Friend NotOverridable Overrides ReadOnly Property IsMethodKindBasedOnSyntax As Boolean\n Get\n Return False\n End Get\n End Property\n\n ''' \n ''' The parameters forming part of this signature.\n ''' \n Public Overrides ReadOnly Property Parameters As ImmutableArray(Of ParameterSymbol)\n Get\n Return ImmutableArray(Of ParameterSymbol).Empty\n End Get\n End Property\n\n Public Overrides ReadOnly Property DeclaredAccessibility As Accessibility\n Get\n Return Accessibility.Friend\n End Get\n End Property\n\n Friend NotOverridable Overrides ReadOnly Property Syntax As SyntaxNode\n Get\n Return VisualBasic.VisualBasicSyntaxTree.Dummy.GetRoot()\n End Get\n End Property\n\n Public NotOverridable Overrides ReadOnly Property Arity As Integer\n Get\n Return 0\n End Get\n End Property\n\n Public Overrides ReadOnly Property AssociatedSymbol As Symbol\n Get\n Return Nothing\n End Get\n End Property\n\n Friend NotOverridable Overrides ReadOnly Property CallingConvention As Microsoft.Cci.CallingConvention\n Get\n Return If(IsShared, Microsoft.Cci.CallingConvention.Default, Microsoft.Cci.CallingConvention.HasThis)\n End Get\n End Property\n\n Public ReadOnly Property ContainingPrivateImplementationDetailsType As PrivateImplementationDetails\n Get\n Return m_privateImplType\n End Get\n End Property\n\n Public NotOverridable Overrides ReadOnly Property ContainingSymbol As Symbol\n Get\n Return Nothing\n End Get\n End Property\n\n Public Overrides ReadOnly Property ContainingType As NamedTypeSymbol\n Get\n Return Nothing\n End Get\n End Property\n\n Public Overrides ReadOnly Property ContainingModule As ModuleSymbol\n Get\n Return m_containingModule\n End Get\n End Property\n\n Public Overrides ReadOnly Property ContainingAssembly As AssemblySymbol\n Get\n Return m_containingModule.ContainingAssembly\n End Get\n End Property\n\n Public Overrides ReadOnly Property ExplicitInterfaceImplementations As ImmutableArray(Of MethodSymbol)\n Get\n Return ImmutableArray(Of MethodSymbol).Empty\n End Get\n End Property\n\n Public Overrides ReadOnly Property OverriddenMethod As MethodSymbol\n Get\n Return Nothing\n End Get\n End Property\n\n Public NotOverridable Overrides ReadOnly Property IsExtensionMethod As Boolean\n Get\n Return False\n End Get\n End Property\n\n Public NotOverridable Overrides ReadOnly Property IsExternalMethod As Boolean\n Get\n Return False\n End Get\n End Property\n\n Public NotOverridable Overrides Function GetDllImportData() As DllImportData\n Return Nothing\n End Function\n\n Friend NotOverridable Overrides ReadOnly Property ReturnTypeMarshallingInformation As MarshalPseudoCustomAttributeData\n Get\n Return Nothing\n End Get\n End Property\n\n Friend NotOverridable Overrides ReadOnly Property ImplementationAttributes As Reflection.MethodImplAttributes\n Get\n Return Nothing\n End Get\n End Property\n\n Friend NotOverridable Overrides ReadOnly Property HasDeclarativeSecurity As Boolean\n Get\n Return False\n End Get\n End Property\n\n Friend NotOverridable Overrides ReadOnly Property ObsoleteAttributeData As ObsoleteAttributeData\n Get\n Return Nothing\n End Get\n End Property\n\n Friend NotOverridable Overrides Function GetSecurityInformation() As IEnumerable(Of Microsoft.Cci.SecurityAttribute)\n Throw ExceptionUtilities.Unreachable\n End Function\n\n Public NotOverridable Overrides ReadOnly Property IsVararg As Boolean\n Get\n Return False\n End Get\n End Property\n\n Public Overrides ReadOnly Property TypeArguments As ImmutableArray(Of TypeSymbol)\n Get\n Return ImmutableArray(Of TypeSymbol).Empty\n End Get\n End Property\n\n Public Overrides ReadOnly Property TypeParameters As ImmutableArray(Of TypeParameterSymbol)\n Get\n Return ImmutableArray(Of TypeParameterSymbol).Empty\n End Get\n End Property\n\n Public Overrides ReadOnly Property ReturnTypeCustomModifiers As ImmutableArray(Of CustomModifier)\n Get\n Return ImmutableArray(Of CustomModifier).Empty\n End Get\n End Property\n\n Public Overrides ReadOnly Property RefCustomModifiers As ImmutableArray(Of CustomModifier)\n Get\n Return ImmutableArray(Of CustomModifier).Empty\n End Get\n End Property\n\n Public Overrides Function GetReturnTypeAttributes() As ImmutableArray(Of VisualBasicAttributeData)\n Return ImmutableArray(Of VisualBasicAttributeData).Empty\n End Function\n\n Public Overrides ReadOnly Property IsAsync As Boolean\n Get\n Return False\n End Get\n End Property\n\n Public Overrides ReadOnly Property IsIterator As Boolean\n Get\n Return False\n End Get\n End Property\n\n Public NotOverridable Overrides ReadOnly Property IsInitOnly As Boolean\n Get\n Return False\n End Get\n End Property\n\n Friend Overrides ReadOnly Property GenerateDebugInfoImpl As Boolean\n Get\n Return False\n End Get\n End Property\n\n Friend Overrides Function CalculateLocalSyntaxOffset(localPosition As Integer, localTree As SyntaxTree) As Integer\n Throw ExceptionUtilities.Unreachable\n End Function\n End Class\n\nEnd Namespace\n"},"after_content":{"kind":"string","value":"' Licensed to the .NET Foundation under one or more agreements.\n' The .NET Foundation licenses this file to you under the MIT license.\n' See the LICENSE file in the project root for more information.\n\nImports System.Collections.Immutable\nImports Microsoft.CodeAnalysis.CodeGen\nImports Microsoft.CodeAnalysis.Text\nImports Microsoft.CodeAnalysis.VisualBasic.Symbols\nImports Microsoft.CodeAnalysis.VisualBasic.Syntax\n\nNamespace Microsoft.CodeAnalysis.VisualBasic.Symbols\n\n ''' \n ''' This class represents a base class for compiler generated synthesized method symbols\n ''' that must be emitted in the compiler generated PrivateImplementationDetails class.\n ''' SynthesizedGlobalMethodBase symbols don't have a ContainingType, there are global to\n ''' the containing source module and are Public Shared methods.\n ''' \n Friend MustInherit Class SynthesizedGlobalMethodBase\n Inherits MethodSymbol\n\n Protected ReadOnly m_privateImplType As PrivateImplementationDetails\n\n Protected ReadOnly m_containingModule As SourceModuleSymbol\n Protected ReadOnly m_name As String\n\n Protected Sub New(containingModule As SourceModuleSymbol, name As String, privateImplType As PrivateImplementationDetails)\n Debug.Assert(containingModule IsNot Nothing)\n\n m_containingModule = containingModule\n m_name = name\n m_privateImplType = privateImplType\n End Sub\n\n\n Public NotOverridable Overrides ReadOnly Property IsImplicitlyDeclared As Boolean\n Get\n Return True\n End Get\n End Property\n\n ''' \n ''' Gets the symbol name. Returns the empty string if unnamed.\n ''' \n Public NotOverridable Overrides ReadOnly Property Name As String\n Get\n Return m_name\n End Get\n End Property\n\n Friend Overrides ReadOnly Property HasSpecialName As Boolean\n Get\n Return False\n End Get\n End Property\n\n Friend Overrides Function GetAppliedConditionalSymbols() As ImmutableArray(Of String)\n Return ImmutableArray(Of String).Empty\n End Function\n\n ''' \n ''' Gets a value indicating whether this instance is abstract or not.\n ''' \n ''' \n ''' true if this instance is abstract; otherwise, false.\n ''' \n Public Overrides ReadOnly Property IsMustOverride As Boolean\n Get\n Return False\n End Get\n End Property\n\n ''' \n ''' Gets a value indicating whether this instance is not overridable.\n ''' \n ''' \n ''' true if this instance is not overridable; otherwise, false.\n ''' \n Public Overrides ReadOnly Property IsNotOverridable As Boolean\n Get\n Return False\n End Get\n End Property\n\n ''' \n ''' Gets a value indicating whether this instance is overloads.\n ''' \n ''' \n ''' true if this instance is overloads; otherwise, false.\n ''' \n Public Overrides ReadOnly Property IsOverloads As Boolean\n Get\n Return False\n End Get\n End Property\n\n ''' \n ''' Gets a value indicating whether this instance is overridable.\n ''' \n ''' \n ''' true if this instance is overridable; otherwise, false.\n ''' \n Public Overrides ReadOnly Property IsOverridable As Boolean\n Get\n Return False\n End Get\n End Property\n\n ''' \n ''' Gets a value indicating whether this instance is overrides.\n ''' \n ''' \n ''' true if this instance is overrides; otherwise, false.\n ''' \n Public Overrides ReadOnly Property IsOverrides As Boolean\n Get\n Return False\n End Get\n End Property\n\n ''' \n ''' Gets a value indicating whether this instance is shared.\n ''' \n ''' \n ''' true if this instance is shared; otherwise, false.\n ''' \n Public NotOverridable Overrides ReadOnly Property IsShared As Boolean\n Get\n Return True\n End Get\n End Property\n\n Friend Overrides Function GetLexicalSortKey() As LexicalSortKey\n Return LexicalSortKey.NotInSource\n End Function\n\n ''' \n ''' A potentially empty collection of locations that correspond to this instance.\n ''' \n Public Overrides ReadOnly Property Locations As ImmutableArray(Of Location)\n Get\n Return ImmutableArray(Of Location).Empty\n End Get\n End Property\n\n Public Overrides ReadOnly Property DeclaringSyntaxReferences As ImmutableArray(Of SyntaxReference)\n Get\n Return ImmutableArray(Of SyntaxReference).Empty\n End Get\n End Property\n\n ''' \n ''' Gets what kind of method this is. There are several different kinds of things in the\n ''' VB language that are represented as methods. This property allow distinguishing those things\n ''' without having to decode the name of the method.\n ''' \n Public Overrides ReadOnly Property MethodKind As MethodKind\n Get\n Return MethodKind.Ordinary\n End Get\n End Property\n\n Friend NotOverridable Overrides ReadOnly Property IsMethodKindBasedOnSyntax As Boolean\n Get\n Return False\n End Get\n End Property\n\n ''' \n ''' The parameters forming part of this signature.\n ''' \n Public Overrides ReadOnly Property Parameters As ImmutableArray(Of ParameterSymbol)\n Get\n Return ImmutableArray(Of ParameterSymbol).Empty\n End Get\n End Property\n\n Public Overrides ReadOnly Property DeclaredAccessibility As Accessibility\n Get\n Return Accessibility.Friend\n End Get\n End Property\n\n Friend NotOverridable Overrides ReadOnly Property Syntax As SyntaxNode\n Get\n Return VisualBasic.VisualBasicSyntaxTree.Dummy.GetRoot()\n End Get\n End Property\n\n Public NotOverridable Overrides ReadOnly Property Arity As Integer\n Get\n Return 0\n End Get\n End Property\n\n Public Overrides ReadOnly Property AssociatedSymbol As Symbol\n Get\n Return Nothing\n End Get\n End Property\n\n Friend NotOverridable Overrides ReadOnly Property CallingConvention As Microsoft.Cci.CallingConvention\n Get\n Return If(IsShared, Microsoft.Cci.CallingConvention.Default, Microsoft.Cci.CallingConvention.HasThis)\n End Get\n End Property\n\n Public ReadOnly Property ContainingPrivateImplementationDetailsType As PrivateImplementationDetails\n Get\n Return m_privateImplType\n End Get\n End Property\n\n Public NotOverridable Overrides ReadOnly Property ContainingSymbol As Symbol\n Get\n Return Nothing\n End Get\n End Property\n\n Public Overrides ReadOnly Property ContainingType As NamedTypeSymbol\n Get\n Return Nothing\n End Get\n End Property\n\n Public Overrides ReadOnly Property ContainingModule As ModuleSymbol\n Get\n Return m_containingModule\n End Get\n End Property\n\n Public Overrides ReadOnly Property ContainingAssembly As AssemblySymbol\n Get\n Return m_containingModule.ContainingAssembly\n End Get\n End Property\n\n Public Overrides ReadOnly Property ExplicitInterfaceImplementations As ImmutableArray(Of MethodSymbol)\n Get\n Return ImmutableArray(Of MethodSymbol).Empty\n End Get\n End Property\n\n Public Overrides ReadOnly Property OverriddenMethod As MethodSymbol\n Get\n Return Nothing\n End Get\n End Property\n\n Public NotOverridable Overrides ReadOnly Property IsExtensionMethod As Boolean\n Get\n Return False\n End Get\n End Property\n\n Public NotOverridable Overrides ReadOnly Property IsExternalMethod As Boolean\n Get\n Return False\n End Get\n End Property\n\n Public NotOverridable Overrides Function GetDllImportData() As DllImportData\n Return Nothing\n End Function\n\n Friend NotOverridable Overrides ReadOnly Property ReturnTypeMarshallingInformation As MarshalPseudoCustomAttributeData\n Get\n Return Nothing\n End Get\n End Property\n\n Friend NotOverridable Overrides ReadOnly Property ImplementationAttributes As Reflection.MethodImplAttributes\n Get\n Return Nothing\n End Get\n End Property\n\n Friend NotOverridable Overrides ReadOnly Property HasDeclarativeSecurity As Boolean\n Get\n Return False\n End Get\n End Property\n\n Friend NotOverridable Overrides ReadOnly Property ObsoleteAttributeData As ObsoleteAttributeData\n Get\n Return Nothing\n End Get\n End Property\n\n Friend NotOverridable Overrides Function GetSecurityInformation() As IEnumerable(Of Microsoft.Cci.SecurityAttribute)\n Throw ExceptionUtilities.Unreachable\n End Function\n\n Public NotOverridable Overrides ReadOnly Property IsVararg As Boolean\n Get\n Return False\n End Get\n End Property\n\n Public Overrides ReadOnly Property TypeArguments As ImmutableArray(Of TypeSymbol)\n Get\n Return ImmutableArray(Of TypeSymbol).Empty\n End Get\n End Property\n\n Public Overrides ReadOnly Property TypeParameters As ImmutableArray(Of TypeParameterSymbol)\n Get\n Return ImmutableArray(Of TypeParameterSymbol).Empty\n End Get\n End Property\n\n Public Overrides ReadOnly Property ReturnTypeCustomModifiers As ImmutableArray(Of CustomModifier)\n Get\n Return ImmutableArray(Of CustomModifier).Empty\n End Get\n End Property\n\n Public Overrides ReadOnly Property RefCustomModifiers As ImmutableArray(Of CustomModifier)\n Get\n Return ImmutableArray(Of CustomModifier).Empty\n End Get\n End Property\n\n Public Overrides Function GetReturnTypeAttributes() As ImmutableArray(Of VisualBasicAttributeData)\n Return ImmutableArray(Of VisualBasicAttributeData).Empty\n End Function\n\n Public Overrides ReadOnly Property IsAsync As Boolean\n Get\n Return False\n End Get\n End Property\n\n Public Overrides ReadOnly Property IsIterator As Boolean\n Get\n Return False\n End Get\n End Property\n\n Public NotOverridable Overrides ReadOnly Property IsInitOnly As Boolean\n Get\n Return False\n End Get\n End Property\n\n Friend Overrides ReadOnly Property GenerateDebugInfoImpl As Boolean\n Get\n Return False\n End Get\n End Property\n\n Friend Overrides Function CalculateLocalSyntaxOffset(localPosition As Integer, localTree As SyntaxTree) As Integer\n Throw ExceptionUtilities.Unreachable\n End Function\n End Class\n\nEnd Namespace\n"},"label":{"kind":"number","value":-1,"string":"-1"}}},{"rowIdx":1511,"cells":{"repo_name":{"kind":"string","value":"dotnet/roslyn"},"pr_number":{"kind":"number","value":56310,"string":"56,310"},"pr_title":{"kind":"string","value":"Move semantic classification caching down to Editor layer"},"pr_description":{"kind":"string","value":""},"author":{"kind":"string","value":"CyrusNajmabadi"},"date_created":{"kind":"timestamp","value":"2021-09-09T23:15:16Z","string":"2021-09-09T23:15:16Z"},"date_merged":{"kind":"timestamp","value":"2021-09-10T19:26:25Z","string":"2021-09-10T19:26:25Z"},"previous_commit":{"kind":"string","value":"6e123012d868c56aba8acabfe1ccad1bf8f20b04"},"pr_commit":{"kind":"string","value":"7af13b6e3867198cd59c566a905b332888ea1dec"},"query":{"kind":"string","value":"Move semantic classification caching down to Editor layer. "},"filepath":{"kind":"string","value":"./src/Features/Core/Portable/Completion/Providers/Scripting/AbstractDirectivePathCompletionProvider.cs"},"before_content":{"kind":"string","value":"// Licensed to the .NET Foundation under one or more agreements.\n// The .NET Foundation licenses this file to you under the MIT license.\n// See the LICENSE file in the project root for more information.\n\nusing System;\nusing System.Collections.Immutable;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing Microsoft.CodeAnalysis.Completion;\nusing Microsoft.CodeAnalysis.Options;\nusing Microsoft.CodeAnalysis.Text;\nusing Microsoft.CodeAnalysis.Scripting;\nusing Roslyn.Utilities;\nusing Microsoft.CodeAnalysis.ErrorReporting;\nusing System.Diagnostics;\nusing Microsoft.CodeAnalysis.Scripting.Hosting;\nusing Microsoft.CodeAnalysis.Shared.Extensions;\n\nnamespace Microsoft.CodeAnalysis.Completion.Providers\n{\n internal abstract class AbstractDirectivePathCompletionProvider : CompletionProvider\n {\n protected static bool IsDirectorySeparator(char ch) =>\n ch == '/' || (ch == '\\\\' && !PathUtilities.IsUnixLikePlatform);\n\n protected abstract bool TryGetStringLiteralToken(SyntaxTree tree, int position, out SyntaxToken stringLiteral, CancellationToken cancellationToken);\n\n /// \n /// r for metadata reference directive, load for source file directive.\n /// \n protected abstract string DirectiveName { get; }\n\n public sealed override async Task ProvideCompletionsAsync(CompletionContext context)\n {\n try\n {\n var document = context.Document;\n var position = context.Position;\n var cancellationToken = context.CancellationToken;\n\n var tree = await document.GetRequiredSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);\n\n if (!TryGetStringLiteralToken(tree, position, out var stringLiteral, cancellationToken))\n {\n return;\n }\n\n var literalValue = stringLiteral.ToString();\n\n context.CompletionListSpan = GetTextChangeSpan(\n quotedPath: literalValue,\n quotedPathStart: stringLiteral.SpanStart,\n position: position);\n\n var pathThroughLastSlash = GetPathThroughLastSlash(\n quotedPath: literalValue,\n quotedPathStart: stringLiteral.SpanStart,\n position: position);\n\n await ProvideCompletionsAsync(context, pathThroughLastSlash).ConfigureAwait(false);\n }\n catch (Exception e) when (FatalError.ReportAndCatchUnlessCanceled(e))\n {\n // nop\n }\n }\n\n public sealed override bool ShouldTriggerCompletion(SourceText text, int caretPosition, CompletionTrigger trigger, OptionSet options)\n {\n var lineStart = text.Lines.GetLineFromPosition(caretPosition).Start;\n\n // check if the line starts with {whitespace}#{whitespace}{DirectiveName}{whitespace}\"\n\n var poundIndex = text.IndexOfNonWhiteSpace(lineStart, caretPosition - lineStart);\n if (poundIndex == -1 || text[poundIndex] != '#')\n {\n return false;\n }\n\n var directiveNameStartIndex = text.IndexOfNonWhiteSpace(poundIndex + 1, caretPosition - poundIndex - 1);\n if (directiveNameStartIndex == -1 || !text.ContentEquals(directiveNameStartIndex, DirectiveName))\n {\n return false;\n }\n\n var directiveNameEndIndex = directiveNameStartIndex + DirectiveName.Length;\n var quoteIndex = text.IndexOfNonWhiteSpace(directiveNameEndIndex, caretPosition - directiveNameEndIndex);\n if (quoteIndex == -1 || text[quoteIndex] != '\"')\n {\n return false;\n }\n\n return true;\n }\n\n private static string GetPathThroughLastSlash(string quotedPath, int quotedPathStart, int position)\n {\n Contract.ThrowIfTrue(quotedPath[0] != '\"');\n\n const int QuoteLength = 1;\n\n var positionInQuotedPath = position - quotedPathStart;\n var path = quotedPath[QuoteLength..positionInQuotedPath].Trim();\n var afterLastSlashIndex = AfterLastSlashIndex(path, path.Length);\n\n // We want the portion up to, and including the last slash if there is one. That way if\n // the user pops up completion in the middle of a path (i.e. \"C:\\Win\") then we'll\n // consider the path to be \"C:\\\" and we will show appropriate completions.\n return afterLastSlashIndex >= 0 ? path.Substring(0, afterLastSlashIndex) : path;\n }\n\n private static TextSpan GetTextChangeSpan(string quotedPath, int quotedPathStart, int position)\n {\n // We want the text change to be from after the last slash to the end of the quoted\n // path. If there is no last slash, then we want it from right after the start quote\n // character.\n var positionInQuotedPath = position - quotedPathStart;\n\n // Where we want to start tracking is right after the slash (if we have one), or else\n // right after the string starts.\n var afterLastSlashIndex = AfterLastSlashIndex(quotedPath, positionInQuotedPath);\n var afterFirstQuote = 1;\n\n var startIndex = Math.Max(afterLastSlashIndex, afterFirstQuote);\n var endIndex = quotedPath.Length;\n\n // If the string ends with a quote, the we do not want to consume that.\n if (EndsWithQuote(quotedPath))\n {\n endIndex--;\n }\n\n return TextSpan.FromBounds(startIndex + quotedPathStart, endIndex + quotedPathStart);\n }\n\n private static bool EndsWithQuote(string quotedPath)\n => quotedPath.Length >= 2 && quotedPath[quotedPath.Length - 1] == '\"';\n\n /// \n /// Returns the index right after the last slash that precedes 'position'. If there is no\n /// slash in the string, -1 is returned.\n /// \n private static int AfterLastSlashIndex(string text, int position)\n {\n // Position might be out of bounds of the string (if the string is unterminated. Make\n // sure it's within bounds.\n position = Math.Min(position, text.Length - 1);\n\n int index;\n if ((index = text.LastIndexOf('/', position)) >= 0 ||\n !PathUtilities.IsUnixLikePlatform && (index = text.LastIndexOf('\\\\', position)) >= 0)\n {\n return index + 1;\n }\n\n return -1;\n }\n\n protected abstract Task ProvideCompletionsAsync(CompletionContext context, string pathThroughLastSlash);\n\n protected static FileSystemCompletionHelper GetFileSystemCompletionHelper(\n Document document,\n Glyph itemGlyph,\n ImmutableArray extensions,\n CompletionItemRules completionRules)\n {\n ImmutableArray referenceSearchPaths;\n string? baseDirectory;\n if (document.Project.CompilationOptions?.MetadataReferenceResolver is RuntimeMetadataReferenceResolver resolver)\n {\n referenceSearchPaths = resolver.PathResolver.SearchPaths;\n baseDirectory = resolver.PathResolver.BaseDirectory;\n }\n else\n {\n referenceSearchPaths = ImmutableArray.Empty;\n baseDirectory = null;\n }\n\n return new FileSystemCompletionHelper(\n Glyph.OpenFolder,\n itemGlyph,\n referenceSearchPaths,\n GetBaseDirectory(document, baseDirectory),\n extensions,\n completionRules);\n }\n\n private static string? GetBaseDirectory(Document document, string? baseDirectory)\n {\n var result = PathUtilities.GetDirectoryName(document.FilePath);\n if (!PathUtilities.IsAbsolute(result))\n {\n result = baseDirectory;\n Debug.Assert(result == null || PathUtilities.IsAbsolute(result));\n }\n\n return result;\n }\n }\n}\n"},"after_content":{"kind":"string","value":"// Licensed to the .NET Foundation under one or more agreements.\n// The .NET Foundation licenses this file to you under the MIT license.\n// See the LICENSE file in the project root for more information.\n\nusing System;\nusing System.Collections.Immutable;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing Microsoft.CodeAnalysis.Completion;\nusing Microsoft.CodeAnalysis.Options;\nusing Microsoft.CodeAnalysis.Text;\nusing Microsoft.CodeAnalysis.Scripting;\nusing Roslyn.Utilities;\nusing Microsoft.CodeAnalysis.ErrorReporting;\nusing System.Diagnostics;\nusing Microsoft.CodeAnalysis.Scripting.Hosting;\nusing Microsoft.CodeAnalysis.Shared.Extensions;\n\nnamespace Microsoft.CodeAnalysis.Completion.Providers\n{\n internal abstract class AbstractDirectivePathCompletionProvider : CompletionProvider\n {\n protected static bool IsDirectorySeparator(char ch) =>\n ch == '/' || (ch == '\\\\' && !PathUtilities.IsUnixLikePlatform);\n\n protected abstract bool TryGetStringLiteralToken(SyntaxTree tree, int position, out SyntaxToken stringLiteral, CancellationToken cancellationToken);\n\n /// \n /// r for metadata reference directive, load for source file directive.\n /// \n protected abstract string DirectiveName { get; }\n\n public sealed override async Task ProvideCompletionsAsync(CompletionContext context)\n {\n try\n {\n var document = context.Document;\n var position = context.Position;\n var cancellationToken = context.CancellationToken;\n\n var tree = await document.GetRequiredSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);\n\n if (!TryGetStringLiteralToken(tree, position, out var stringLiteral, cancellationToken))\n {\n return;\n }\n\n var literalValue = stringLiteral.ToString();\n\n context.CompletionListSpan = GetTextChangeSpan(\n quotedPath: literalValue,\n quotedPathStart: stringLiteral.SpanStart,\n position: position);\n\n var pathThroughLastSlash = GetPathThroughLastSlash(\n quotedPath: literalValue,\n quotedPathStart: stringLiteral.SpanStart,\n position: position);\n\n await ProvideCompletionsAsync(context, pathThroughLastSlash).ConfigureAwait(false);\n }\n catch (Exception e) when (FatalError.ReportAndCatchUnlessCanceled(e))\n {\n // nop\n }\n }\n\n public sealed override bool ShouldTriggerCompletion(SourceText text, int caretPosition, CompletionTrigger trigger, OptionSet options)\n {\n var lineStart = text.Lines.GetLineFromPosition(caretPosition).Start;\n\n // check if the line starts with {whitespace}#{whitespace}{DirectiveName}{whitespace}\"\n\n var poundIndex = text.IndexOfNonWhiteSpace(lineStart, caretPosition - lineStart);\n if (poundIndex == -1 || text[poundIndex] != '#')\n {\n return false;\n }\n\n var directiveNameStartIndex = text.IndexOfNonWhiteSpace(poundIndex + 1, caretPosition - poundIndex - 1);\n if (directiveNameStartIndex == -1 || !text.ContentEquals(directiveNameStartIndex, DirectiveName))\n {\n return false;\n }\n\n var directiveNameEndIndex = directiveNameStartIndex + DirectiveName.Length;\n var quoteIndex = text.IndexOfNonWhiteSpace(directiveNameEndIndex, caretPosition - directiveNameEndIndex);\n if (quoteIndex == -1 || text[quoteIndex] != '\"')\n {\n return false;\n }\n\n return true;\n }\n\n private static string GetPathThroughLastSlash(string quotedPath, int quotedPathStart, int position)\n {\n Contract.ThrowIfTrue(quotedPath[0] != '\"');\n\n const int QuoteLength = 1;\n\n var positionInQuotedPath = position - quotedPathStart;\n var path = quotedPath[QuoteLength..positionInQuotedPath].Trim();\n var afterLastSlashIndex = AfterLastSlashIndex(path, path.Length);\n\n // We want the portion up to, and including the last slash if there is one. That way if\n // the user pops up completion in the middle of a path (i.e. \"C:\\Win\") then we'll\n // consider the path to be \"C:\\\" and we will show appropriate completions.\n return afterLastSlashIndex >= 0 ? path.Substring(0, afterLastSlashIndex) : path;\n }\n\n private static TextSpan GetTextChangeSpan(string quotedPath, int quotedPathStart, int position)\n {\n // We want the text change to be from after the last slash to the end of the quoted\n // path. If there is no last slash, then we want it from right after the start quote\n // character.\n var positionInQuotedPath = position - quotedPathStart;\n\n // Where we want to start tracking is right after the slash (if we have one), or else\n // right after the string starts.\n var afterLastSlashIndex = AfterLastSlashIndex(quotedPath, positionInQuotedPath);\n var afterFirstQuote = 1;\n\n var startIndex = Math.Max(afterLastSlashIndex, afterFirstQuote);\n var endIndex = quotedPath.Length;\n\n // If the string ends with a quote, the we do not want to consume that.\n if (EndsWithQuote(quotedPath))\n {\n endIndex--;\n }\n\n return TextSpan.FromBounds(startIndex + quotedPathStart, endIndex + quotedPathStart);\n }\n\n private static bool EndsWithQuote(string quotedPath)\n => quotedPath.Length >= 2 && quotedPath[quotedPath.Length - 1] == '\"';\n\n /// \n /// Returns the index right after the last slash that precedes 'position'. If there is no\n /// slash in the string, -1 is returned.\n /// \n private static int AfterLastSlashIndex(string text, int position)\n {\n // Position might be out of bounds of the string (if the string is unterminated. Make\n // sure it's within bounds.\n position = Math.Min(position, text.Length - 1);\n\n int index;\n if ((index = text.LastIndexOf('/', position)) >= 0 ||\n !PathUtilities.IsUnixLikePlatform && (index = text.LastIndexOf('\\\\', position)) >= 0)\n {\n return index + 1;\n }\n\n return -1;\n }\n\n protected abstract Task ProvideCompletionsAsync(CompletionContext context, string pathThroughLastSlash);\n\n protected static FileSystemCompletionHelper GetFileSystemCompletionHelper(\n Document document,\n Glyph itemGlyph,\n ImmutableArray extensions,\n CompletionItemRules completionRules)\n {\n ImmutableArray referenceSearchPaths;\n string? baseDirectory;\n if (document.Project.CompilationOptions?.MetadataReferenceResolver is RuntimeMetadataReferenceResolver resolver)\n {\n referenceSearchPaths = resolver.PathResolver.SearchPaths;\n baseDirectory = resolver.PathResolver.BaseDirectory;\n }\n else\n {\n referenceSearchPaths = ImmutableArray.Empty;\n baseDirectory = null;\n }\n\n return new FileSystemCompletionHelper(\n Glyph.OpenFolder,\n itemGlyph,\n referenceSearchPaths,\n GetBaseDirectory(document, baseDirectory),\n extensions,\n completionRules);\n }\n\n private static string? GetBaseDirectory(Document document, string? baseDirectory)\n {\n var result = PathUtilities.GetDirectoryName(document.FilePath);\n if (!PathUtilities.IsAbsolute(result))\n {\n result = baseDirectory;\n Debug.Assert(result == null || PathUtilities.IsAbsolute(result));\n }\n\n return result;\n }\n }\n}\n"},"label":{"kind":"number","value":-1,"string":"-1"}}},{"rowIdx":1512,"cells":{"repo_name":{"kind":"string","value":"dotnet/roslyn"},"pr_number":{"kind":"number","value":56310,"string":"56,310"},"pr_title":{"kind":"string","value":"Move semantic classification caching down to Editor layer"},"pr_description":{"kind":"string","value":""},"author":{"kind":"string","value":"CyrusNajmabadi"},"date_created":{"kind":"timestamp","value":"2021-09-09T23:15:16Z","string":"2021-09-09T23:15:16Z"},"date_merged":{"kind":"timestamp","value":"2021-09-10T19:26:25Z","string":"2021-09-10T19:26:25Z"},"previous_commit":{"kind":"string","value":"6e123012d868c56aba8acabfe1ccad1bf8f20b04"},"pr_commit":{"kind":"string","value":"7af13b6e3867198cd59c566a905b332888ea1dec"},"query":{"kind":"string","value":"Move semantic classification caching down to Editor layer. "},"filepath":{"kind":"string","value":"./src/Features/CSharp/Portable/UseExpressionBodyForLambda/UseExpressionBodyForLambdaCodeStyleProvider.cs"},"before_content":{"kind":"string","value":"// Licensed to the .NET Foundation under one or more agreements.\n// The .NET Foundation licenses this file to you under the MIT license.\n// See the LICENSE file in the project root for more information.\n\n#nullable disable\n\nusing System;\nusing System.Composition;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing Microsoft.CodeAnalysis.CodeActions;\nusing Microsoft.CodeAnalysis.CodeFixes;\nusing Microsoft.CodeAnalysis.CodeRefactorings;\nusing Microsoft.CodeAnalysis.CodeStyle;\nusing Microsoft.CodeAnalysis.CSharp.CodeStyle;\nusing Microsoft.CodeAnalysis.CSharp.Extensions;\nusing Microsoft.CodeAnalysis.CSharp.Syntax;\nusing Microsoft.CodeAnalysis.Diagnostics;\nusing Microsoft.CodeAnalysis.Formatting;\nusing Microsoft.CodeAnalysis.Shared.Extensions;\nusing Roslyn.Utilities;\n\nnamespace Microsoft.CodeAnalysis.CSharp.UseExpressionBodyForLambda\n{\n internal partial class UseExpressionBodyForLambdaCodeStyleProvider\n : AbstractCodeStyleProvider\n {\n private static readonly LocalizableString UseExpressionBodyTitle = new LocalizableResourceString(nameof(FeaturesResources.Use_expression_body_for_lambda_expressions), FeaturesResources.ResourceManager, typeof(FeaturesResources));\n private static readonly LocalizableString UseBlockBodyTitle = new LocalizableResourceString(nameof(FeaturesResources.Use_block_body_for_lambda_expressions), FeaturesResources.ResourceManager, typeof(FeaturesResources));\n\n public UseExpressionBodyForLambdaCodeStyleProvider()\n : base(CSharpCodeStyleOptions.PreferExpressionBodiedLambdas,\n LanguageNames.CSharp,\n IDEDiagnosticIds.UseExpressionBodyForLambdaExpressionsDiagnosticId,\n EnforceOnBuildValues.UseExpressionBodyForLambdaExpressions,\n UseExpressionBodyTitle,\n UseExpressionBodyTitle)\n {\n }\n\n // Shared code needed by all parts of the style provider for this feature.\n\n private static ExpressionSyntax GetBodyAsExpression(LambdaExpressionSyntax declaration)\n => declaration.Body as ExpressionSyntax;\n\n private static bool CanOfferUseExpressionBody(\n ExpressionBodyPreference preference, LambdaExpressionSyntax declaration)\n {\n var userPrefersExpressionBodies = preference != ExpressionBodyPreference.Never;\n if (!userPrefersExpressionBodies)\n {\n // If the user doesn't even want expression bodies, then certainly do not offer.\n return false;\n }\n\n var expressionBody = GetBodyAsExpression(declaration);\n if (expressionBody != null)\n {\n // they already have an expression body. so nothing to do here.\n return false;\n }\n\n // They don't have an expression body. See if we could convert the block they \n // have into one.\n var options = declaration.SyntaxTree.Options;\n return TryConvertToExpressionBody(declaration, options, preference, out _, out _);\n }\n\n private static bool TryConvertToExpressionBody(\n LambdaExpressionSyntax declaration,\n ParseOptions options, ExpressionBodyPreference conversionPreference,\n out ExpressionSyntax expression, out SyntaxToken semicolon)\n {\n var body = declaration.Body as BlockSyntax;\n\n return body.TryConvertToExpressionBody(\n options, conversionPreference,\n out expression, out semicolon);\n }\n\n private static bool CanOfferUseBlockBody(\n SemanticModel semanticModel, ExpressionBodyPreference preference,\n LambdaExpressionSyntax declaration, CancellationToken cancellationToken)\n {\n var userPrefersBlockBodies = preference == ExpressionBodyPreference.Never;\n if (!userPrefersBlockBodies)\n {\n // If the user doesn't even want block bodies, then certainly do not offer.\n return false;\n }\n\n var expressionBodyOpt = GetBodyAsExpression(declaration);\n if (expressionBodyOpt == null)\n {\n // they already have a block body.\n return false;\n }\n\n // We need to know what sort of lambda this is (void returning or not) in order to be\n // able to create the right sort of block body (i.e. with a return-statement or\n // expr-statement). So, if we can't figure out what lambda type this is, we should not\n // proceed.\n if (semanticModel.GetTypeInfo(declaration, cancellationToken).ConvertedType is not INamedTypeSymbol lambdaType || lambdaType.DelegateInvokeMethod == null)\n {\n return false;\n }\n\n var canOffer = expressionBodyOpt.TryConvertToStatement(\n semicolonTokenOpt: null, createReturnStatementForExpression: false, out _);\n if (!canOffer)\n {\n // Couldn't even convert the expression into statement form.\n return false;\n }\n\n var languageVersion = ((CSharpParseOptions)declaration.SyntaxTree.Options).LanguageVersion;\n if (expressionBodyOpt.IsKind(SyntaxKind.ThrowExpression) &&\n languageVersion < LanguageVersion.CSharp7)\n {\n // Can't convert this prior to C# 7 because ```a => throw ...``` isn't allowed.\n return false;\n }\n\n return true;\n }\n\n private static LambdaExpressionSyntax Update(SemanticModel semanticModel, LambdaExpressionSyntax originalDeclaration, LambdaExpressionSyntax currentDeclaration)\n => UpdateWorker(semanticModel, originalDeclaration, currentDeclaration).WithAdditionalAnnotations(Formatter.Annotation);\n\n private static LambdaExpressionSyntax UpdateWorker(\n SemanticModel semanticModel, LambdaExpressionSyntax originalDeclaration, LambdaExpressionSyntax currentDeclaration)\n {\n var expressionBody = GetBodyAsExpression(currentDeclaration);\n return expressionBody == null\n ? WithExpressionBody(currentDeclaration)\n : WithBlockBody(semanticModel, originalDeclaration, currentDeclaration);\n }\n\n private static LambdaExpressionSyntax WithExpressionBody(LambdaExpressionSyntax declaration)\n {\n if (!TryConvertToExpressionBody(\n declaration, declaration.SyntaxTree.Options, ExpressionBodyPreference.WhenPossible,\n out var expressionBody, out _))\n {\n return declaration;\n }\n\n var updatedDecl = declaration.WithBody(expressionBody);\n\n // If there will only be whitespace between the arrow and the body, then replace that\n // with a single space so that the lambda doesn't have superfluous newlines in it.\n if (declaration.ArrowToken.TrailingTrivia.All(t => t.IsWhitespaceOrEndOfLine()) &&\n expressionBody.GetLeadingTrivia().All(t => t.IsWhitespaceOrEndOfLine()))\n {\n updatedDecl = updatedDecl.WithArrowToken(updatedDecl.ArrowToken.WithTrailingTrivia(SyntaxFactory.ElasticSpace));\n }\n\n return updatedDecl;\n }\n\n private static LambdaExpressionSyntax WithBlockBody(\n SemanticModel semanticModel, LambdaExpressionSyntax originalDeclaration, LambdaExpressionSyntax currentDeclaration)\n {\n var expressionBody = GetBodyAsExpression(currentDeclaration);\n var createReturnStatementForExpression = CreateReturnStatementForExpression(\n semanticModel, originalDeclaration);\n\n if (!expressionBody.TryConvertToStatement(\n semicolonTokenOpt: null,\n createReturnStatementForExpression,\n out var statement))\n {\n return currentDeclaration;\n }\n\n // If the user is converting to a block, it's likely they intend to add multiple\n // statements to it. So make a multi-line block so that things are formatted properly\n // for them to do so.\n return currentDeclaration.WithBody(SyntaxFactory.Block(\n SyntaxFactory.Token(SyntaxKind.OpenBraceToken).WithAppendedTrailingTrivia(SyntaxFactory.ElasticCarriageReturnLineFeed),\n SyntaxFactory.SingletonList(statement),\n SyntaxFactory.Token(SyntaxKind.CloseBraceToken)));\n }\n\n private static bool CreateReturnStatementForExpression(\n SemanticModel semanticModel, LambdaExpressionSyntax declaration)\n {\n var lambdaType = (INamedTypeSymbol)semanticModel.GetTypeInfo(declaration).ConvertedType;\n if (lambdaType.DelegateInvokeMethod.ReturnsVoid)\n {\n return false;\n }\n\n // 'async Task' is effectively a void-returning lambda. we do not want to create \n // 'return statements' when converting.\n if (declaration.AsyncKeyword != default)\n {\n var returnType = lambdaType.DelegateInvokeMethod.ReturnType;\n if (returnType.IsErrorType())\n {\n // \"async Goo\" where 'Goo' failed to bind. If 'Goo' is 'Task' then it's\n // reasonable to assume this is just a missing 'using' and that this is a true\n // \"async Task\" lambda. If the name isn't 'Task', then this looks like a\n // real return type, and we should use return statements.\n return returnType.Name != nameof(Task);\n }\n\n var taskType = semanticModel.Compilation.GetTypeByMetadataName(typeof(Task).FullName);\n if (returnType.Equals(taskType))\n {\n // 'async Task'. definitely do not create a 'return' statement;\n return false;\n }\n }\n\n return true;\n }\n\n private class MyCodeAction : CodeAction.DocumentChangeAction\n {\n public MyCodeAction(string title, Func> createChangedDocument)\n : base(title, createChangedDocument, title)\n {\n }\n }\n }\n\n // Stub classes needed only for exporting purposes.\n\n [ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.UseExpressionBodyForLambda), Shared]\n internal sealed class UseExpressionBodyForLambdaCodeFixProvider : UseExpressionBodyForLambdaCodeStyleProvider.CodeFixProvider\n {\n [ImportingConstructor]\n [SuppressMessage(\"RoslynDiagnosticsReliability\", \"RS0033:Importing constructor should be [Obsolete]\", Justification = \"Used in test code: https://github.com/dotnet/roslyn/issues/42814\")]\n public UseExpressionBodyForLambdaCodeFixProvider()\n {\n }\n }\n\n [ExportCodeRefactoringProvider(LanguageNames.CSharp, Name = PredefinedCodeRefactoringProviderNames.UseExpressionBodyForLambda), Shared]\n internal sealed class UseExpressionBodyForLambdaCodeRefactoringProvider : UseExpressionBodyForLambdaCodeStyleProvider.CodeRefactoringProvider\n {\n [ImportingConstructor]\n [SuppressMessage(\"RoslynDiagnosticsReliability\", \"RS0033:Importing constructor should be [Obsolete]\", Justification = \"Used in test code: https://github.com/dotnet/roslyn/issues/42814\")]\n public UseExpressionBodyForLambdaCodeRefactoringProvider()\n {\n }\n }\n\n [DiagnosticAnalyzer(LanguageNames.CSharp)]\n internal sealed class UseExpressionBodyForLambdaDiagnosticAnalyzer : UseExpressionBodyForLambdaCodeStyleProvider.DiagnosticAnalyzer\n {\n }\n}\n"},"after_content":{"kind":"string","value":"// Licensed to the .NET Foundation under one or more agreements.\n// The .NET Foundation licenses this file to you under the MIT license.\n// See the LICENSE file in the project root for more information.\n\n#nullable disable\n\nusing System;\nusing System.Composition;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing Microsoft.CodeAnalysis.CodeActions;\nusing Microsoft.CodeAnalysis.CodeFixes;\nusing Microsoft.CodeAnalysis.CodeRefactorings;\nusing Microsoft.CodeAnalysis.CodeStyle;\nusing Microsoft.CodeAnalysis.CSharp.CodeStyle;\nusing Microsoft.CodeAnalysis.CSharp.Extensions;\nusing Microsoft.CodeAnalysis.CSharp.Syntax;\nusing Microsoft.CodeAnalysis.Diagnostics;\nusing Microsoft.CodeAnalysis.Formatting;\nusing Microsoft.CodeAnalysis.Shared.Extensions;\nusing Roslyn.Utilities;\n\nnamespace Microsoft.CodeAnalysis.CSharp.UseExpressionBodyForLambda\n{\n internal partial class UseExpressionBodyForLambdaCodeStyleProvider\n : AbstractCodeStyleProvider\n {\n private static readonly LocalizableString UseExpressionBodyTitle = new LocalizableResourceString(nameof(FeaturesResources.Use_expression_body_for_lambda_expressions), FeaturesResources.ResourceManager, typeof(FeaturesResources));\n private static readonly LocalizableString UseBlockBodyTitle = new LocalizableResourceString(nameof(FeaturesResources.Use_block_body_for_lambda_expressions), FeaturesResources.ResourceManager, typeof(FeaturesResources));\n\n public UseExpressionBodyForLambdaCodeStyleProvider()\n : base(CSharpCodeStyleOptions.PreferExpressionBodiedLambdas,\n LanguageNames.CSharp,\n IDEDiagnosticIds.UseExpressionBodyForLambdaExpressionsDiagnosticId,\n EnforceOnBuildValues.UseExpressionBodyForLambdaExpressions,\n UseExpressionBodyTitle,\n UseExpressionBodyTitle)\n {\n }\n\n // Shared code needed by all parts of the style provider for this feature.\n\n private static ExpressionSyntax GetBodyAsExpression(LambdaExpressionSyntax declaration)\n => declaration.Body as ExpressionSyntax;\n\n private static bool CanOfferUseExpressionBody(\n ExpressionBodyPreference preference, LambdaExpressionSyntax declaration)\n {\n var userPrefersExpressionBodies = preference != ExpressionBodyPreference.Never;\n if (!userPrefersExpressionBodies)\n {\n // If the user doesn't even want expression bodies, then certainly do not offer.\n return false;\n }\n\n var expressionBody = GetBodyAsExpression(declaration);\n if (expressionBody != null)\n {\n // they already have an expression body. so nothing to do here.\n return false;\n }\n\n // They don't have an expression body. See if we could convert the block they \n // have into one.\n var options = declaration.SyntaxTree.Options;\n return TryConvertToExpressionBody(declaration, options, preference, out _, out _);\n }\n\n private static bool TryConvertToExpressionBody(\n LambdaExpressionSyntax declaration,\n ParseOptions options, ExpressionBodyPreference conversionPreference,\n out ExpressionSyntax expression, out SyntaxToken semicolon)\n {\n var body = declaration.Body as BlockSyntax;\n\n return body.TryConvertToExpressionBody(\n options, conversionPreference,\n out expression, out semicolon);\n }\n\n private static bool CanOfferUseBlockBody(\n SemanticModel semanticModel, ExpressionBodyPreference preference,\n LambdaExpressionSyntax declaration, CancellationToken cancellationToken)\n {\n var userPrefersBlockBodies = preference == ExpressionBodyPreference.Never;\n if (!userPrefersBlockBodies)\n {\n // If the user doesn't even want block bodies, then certainly do not offer.\n return false;\n }\n\n var expressionBodyOpt = GetBodyAsExpression(declaration);\n if (expressionBodyOpt == null)\n {\n // they already have a block body.\n return false;\n }\n\n // We need to know what sort of lambda this is (void returning or not) in order to be\n // able to create the right sort of block body (i.e. with a return-statement or\n // expr-statement). So, if we can't figure out what lambda type this is, we should not\n // proceed.\n if (semanticModel.GetTypeInfo(declaration, cancellationToken).ConvertedType is not INamedTypeSymbol lambdaType || lambdaType.DelegateInvokeMethod == null)\n {\n return false;\n }\n\n var canOffer = expressionBodyOpt.TryConvertToStatement(\n semicolonTokenOpt: null, createReturnStatementForExpression: false, out _);\n if (!canOffer)\n {\n // Couldn't even convert the expression into statement form.\n return false;\n }\n\n var languageVersion = ((CSharpParseOptions)declaration.SyntaxTree.Options).LanguageVersion;\n if (expressionBodyOpt.IsKind(SyntaxKind.ThrowExpression) &&\n languageVersion < LanguageVersion.CSharp7)\n {\n // Can't convert this prior to C# 7 because ```a => throw ...``` isn't allowed.\n return false;\n }\n\n return true;\n }\n\n private static LambdaExpressionSyntax Update(SemanticModel semanticModel, LambdaExpressionSyntax originalDeclaration, LambdaExpressionSyntax currentDeclaration)\n => UpdateWorker(semanticModel, originalDeclaration, currentDeclaration).WithAdditionalAnnotations(Formatter.Annotation);\n\n private static LambdaExpressionSyntax UpdateWorker(\n SemanticModel semanticModel, LambdaExpressionSyntax originalDeclaration, LambdaExpressionSyntax currentDeclaration)\n {\n var expressionBody = GetBodyAsExpression(currentDeclaration);\n return expressionBody == null\n ? WithExpressionBody(currentDeclaration)\n : WithBlockBody(semanticModel, originalDeclaration, currentDeclaration);\n }\n\n private static LambdaExpressionSyntax WithExpressionBody(LambdaExpressionSyntax declaration)\n {\n if (!TryConvertToExpressionBody(\n declaration, declaration.SyntaxTree.Options, ExpressionBodyPreference.WhenPossible,\n out var expressionBody, out _))\n {\n return declaration;\n }\n\n var updatedDecl = declaration.WithBody(expressionBody);\n\n // If there will only be whitespace between the arrow and the body, then replace that\n // with a single space so that the lambda doesn't have superfluous newlines in it.\n if (declaration.ArrowToken.TrailingTrivia.All(t => t.IsWhitespaceOrEndOfLine()) &&\n expressionBody.GetLeadingTrivia().All(t => t.IsWhitespaceOrEndOfLine()))\n {\n updatedDecl = updatedDecl.WithArrowToken(updatedDecl.ArrowToken.WithTrailingTrivia(SyntaxFactory.ElasticSpace));\n }\n\n return updatedDecl;\n }\n\n private static LambdaExpressionSyntax WithBlockBody(\n SemanticModel semanticModel, LambdaExpressionSyntax originalDeclaration, LambdaExpressionSyntax currentDeclaration)\n {\n var expressionBody = GetBodyAsExpression(currentDeclaration);\n var createReturnStatementForExpression = CreateReturnStatementForExpression(\n semanticModel, originalDeclaration);\n\n if (!expressionBody.TryConvertToStatement(\n semicolonTokenOpt: null,\n createReturnStatementForExpression,\n out var statement))\n {\n return currentDeclaration;\n }\n\n // If the user is converting to a block, it's likely they intend to add multiple\n // statements to it. So make a multi-line block so that things are formatted properly\n // for them to do so.\n return currentDeclaration.WithBody(SyntaxFactory.Block(\n SyntaxFactory.Token(SyntaxKind.OpenBraceToken).WithAppendedTrailingTrivia(SyntaxFactory.ElasticCarriageReturnLineFeed),\n SyntaxFactory.SingletonList(statement),\n SyntaxFactory.Token(SyntaxKind.CloseBraceToken)));\n }\n\n private static bool CreateReturnStatementForExpression(\n SemanticModel semanticModel, LambdaExpressionSyntax declaration)\n {\n var lambdaType = (INamedTypeSymbol)semanticModel.GetTypeInfo(declaration).ConvertedType;\n if (lambdaType.DelegateInvokeMethod.ReturnsVoid)\n {\n return false;\n }\n\n // 'async Task' is effectively a void-returning lambda. we do not want to create \n // 'return statements' when converting.\n if (declaration.AsyncKeyword != default)\n {\n var returnType = lambdaType.DelegateInvokeMethod.ReturnType;\n if (returnType.IsErrorType())\n {\n // \"async Goo\" where 'Goo' failed to bind. If 'Goo' is 'Task' then it's\n // reasonable to assume this is just a missing 'using' and that this is a true\n // \"async Task\" lambda. If the name isn't 'Task', then this looks like a\n // real return type, and we should use return statements.\n return returnType.Name != nameof(Task);\n }\n\n var taskType = semanticModel.Compilation.GetTypeByMetadataName(typeof(Task).FullName);\n if (returnType.Equals(taskType))\n {\n // 'async Task'. definitely do not create a 'return' statement;\n return false;\n }\n }\n\n return true;\n }\n\n private class MyCodeAction : CodeAction.DocumentChangeAction\n {\n public MyCodeAction(string title, Func> createChangedDocument)\n : base(title, createChangedDocument, title)\n {\n }\n }\n }\n\n // Stub classes needed only for exporting purposes.\n\n [ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.UseExpressionBodyForLambda), Shared]\n internal sealed class UseExpressionBodyForLambdaCodeFixProvider : UseExpressionBodyForLambdaCodeStyleProvider.CodeFixProvider\n {\n [ImportingConstructor]\n [SuppressMessage(\"RoslynDiagnosticsReliability\", \"RS0033:Importing constructor should be [Obsolete]\", Justification = \"Used in test code: https://github.com/dotnet/roslyn/issues/42814\")]\n public UseExpressionBodyForLambdaCodeFixProvider()\n {\n }\n }\n\n [ExportCodeRefactoringProvider(LanguageNames.CSharp, Name = PredefinedCodeRefactoringProviderNames.UseExpressionBodyForLambda), Shared]\n internal sealed class UseExpressionBodyForLambdaCodeRefactoringProvider : UseExpressionBodyForLambdaCodeStyleProvider.CodeRefactoringProvider\n {\n [ImportingConstructor]\n [SuppressMessage(\"RoslynDiagnosticsReliability\", \"RS0033:Importing constructor should be [Obsolete]\", Justification = \"Used in test code: https://github.com/dotnet/roslyn/issues/42814\")]\n public UseExpressionBodyForLambdaCodeRefactoringProvider()\n {\n }\n }\n\n [DiagnosticAnalyzer(LanguageNames.CSharp)]\n internal sealed class UseExpressionBodyForLambdaDiagnosticAnalyzer : UseExpressionBodyForLambdaCodeStyleProvider.DiagnosticAnalyzer\n {\n }\n}\n"},"label":{"kind":"number","value":-1,"string":"-1"}}},{"rowIdx":1513,"cells":{"repo_name":{"kind":"string","value":"dotnet/roslyn"},"pr_number":{"kind":"number","value":56310,"string":"56,310"},"pr_title":{"kind":"string","value":"Move semantic classification caching down to Editor layer"},"pr_description":{"kind":"string","value":""},"author":{"kind":"string","value":"CyrusNajmabadi"},"date_created":{"kind":"timestamp","value":"2021-09-09T23:15:16Z","string":"2021-09-09T23:15:16Z"},"date_merged":{"kind":"timestamp","value":"2021-09-10T19:26:25Z","string":"2021-09-10T19:26:25Z"},"previous_commit":{"kind":"string","value":"6e123012d868c56aba8acabfe1ccad1bf8f20b04"},"pr_commit":{"kind":"string","value":"7af13b6e3867198cd59c566a905b332888ea1dec"},"query":{"kind":"string","value":"Move semantic classification caching down to Editor layer. "},"filepath":{"kind":"string","value":"./src/Workspaces/Core/Portable/EmbeddedLanguages/LanguageServices/FallbackSyntaxClassifier.cs"},"before_content":{"kind":"string","value":"// Licensed to the .NET Foundation under one or more agreements.\n// The .NET Foundation licenses this file to you under the MIT license.\n// See the LICENSE file in the project root for more information.\n\n#nullable disable\n\nusing System.Collections.Immutable;\nusing System.Threading;\nusing Microsoft.CodeAnalysis.Classification;\nusing Microsoft.CodeAnalysis.Classification.Classifiers;\nusing Microsoft.CodeAnalysis.PooledObjects;\n\nnamespace Microsoft.CodeAnalysis.EmbeddedLanguages.LanguageServices\n{\n internal class FallbackSyntaxClassifier : AbstractSyntaxClassifier\n {\n private readonly EmbeddedLanguageInfo _info;\n\n public override ImmutableArray SyntaxTokenKinds { get; }\n\n public FallbackSyntaxClassifier(EmbeddedLanguageInfo info)\n {\n _info = info;\n SyntaxTokenKinds = ImmutableArray.Create(\n info.CharLiteralTokenKind,\n info.StringLiteralTokenKind,\n info.InterpolatedTextTokenKind);\n }\n\n public override void AddClassifications(\n Workspace workspace, SyntaxToken token, SemanticModel semanticModel,\n ArrayBuilder result, CancellationToken cancellationToken)\n {\n if (_info.CharLiteralTokenKind != token.RawKind &&\n _info.StringLiteralTokenKind != token.RawKind &&\n _info.InterpolatedTextTokenKind != token.RawKind)\n {\n return;\n }\n\n var virtualChars = _info.VirtualCharService.TryConvertToVirtualChars(token);\n if (virtualChars.IsDefaultOrEmpty)\n {\n return;\n }\n\n foreach (var vc in virtualChars)\n {\n if (vc.Span.Length > 1)\n {\n result.Add(new ClassifiedSpan(ClassificationTypeNames.StringEscapeCharacter, vc.Span));\n }\n }\n }\n }\n}\n"},"after_content":{"kind":"string","value":"// Licensed to the .NET Foundation under one or more agreements.\n// The .NET Foundation licenses this file to you under the MIT license.\n// See the LICENSE file in the project root for more information.\n\n#nullable disable\n\nusing System.Collections.Immutable;\nusing System.Threading;\nusing Microsoft.CodeAnalysis.Classification;\nusing Microsoft.CodeAnalysis.Classification.Classifiers;\nusing Microsoft.CodeAnalysis.PooledObjects;\n\nnamespace Microsoft.CodeAnalysis.EmbeddedLanguages.LanguageServices\n{\n internal class FallbackSyntaxClassifier : AbstractSyntaxClassifier\n {\n private readonly EmbeddedLanguageInfo _info;\n\n public override ImmutableArray SyntaxTokenKinds { get; }\n\n public FallbackSyntaxClassifier(EmbeddedLanguageInfo info)\n {\n _info = info;\n SyntaxTokenKinds = ImmutableArray.Create(\n info.CharLiteralTokenKind,\n info.StringLiteralTokenKind,\n info.InterpolatedTextTokenKind);\n }\n\n public override void AddClassifications(\n Workspace workspace, SyntaxToken token, SemanticModel semanticModel,\n ArrayBuilder result, CancellationToken cancellationToken)\n {\n if (_info.CharLiteralTokenKind != token.RawKind &&\n _info.StringLiteralTokenKind != token.RawKind &&\n _info.InterpolatedTextTokenKind != token.RawKind)\n {\n return;\n }\n\n var virtualChars = _info.VirtualCharService.TryConvertToVirtualChars(token);\n if (virtualChars.IsDefaultOrEmpty)\n {\n return;\n }\n\n foreach (var vc in virtualChars)\n {\n if (vc.Span.Length > 1)\n {\n result.Add(new ClassifiedSpan(ClassificationTypeNames.StringEscapeCharacter, vc.Span));\n }\n }\n }\n }\n}\n"},"label":{"kind":"number","value":-1,"string":"-1"}}},{"rowIdx":1514,"cells":{"repo_name":{"kind":"string","value":"dotnet/roslyn"},"pr_number":{"kind":"number","value":56310,"string":"56,310"},"pr_title":{"kind":"string","value":"Move semantic classification caching down to Editor layer"},"pr_description":{"kind":"string","value":""},"author":{"kind":"string","value":"CyrusNajmabadi"},"date_created":{"kind":"timestamp","value":"2021-09-09T23:15:16Z","string":"2021-09-09T23:15:16Z"},"date_merged":{"kind":"timestamp","value":"2021-09-10T19:26:25Z","string":"2021-09-10T19:26:25Z"},"previous_commit":{"kind":"string","value":"6e123012d868c56aba8acabfe1ccad1bf8f20b04"},"pr_commit":{"kind":"string","value":"7af13b6e3867198cd59c566a905b332888ea1dec"},"query":{"kind":"string","value":"Move semantic classification caching down to Editor layer. "},"filepath":{"kind":"string","value":"./src/Compilers/VisualBasic/Portable/Scanner/QuickTokenAccumulator.vb"},"before_content":{"kind":"string","value":"' Licensed to the .NET Foundation under one or more agreements.\n' The .NET Foundation licenses this file to you under the MIT license.\n' See the LICENSE file in the project root for more information.\n\n'-----------------------------------------------------------------------------\n' Contains quick token accumulator.\n'-----------------------------------------------------------------------------\n\nOption Compare Binary\nOption Strict On\n\nImports System.Text\nImports Microsoft.CodeAnalysis.Text\nImports Microsoft.CodeAnalysis.VisualBasic\nImports Microsoft.CodeAnalysis.VisualBasic.Symbols\nImports Microsoft.CodeAnalysis.VisualBasic.Syntax\n\nNamespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax\n '' The QuickTokenAccumulator is a small mini-tokenizer that may fail. It consumes characters and\n '' eventually either decides that either it found a complete token (including the trivia on either\n '' side), or it gives up and says that the full scanner should take an attempt. It also accumulates the \n '' token into a character buffer and computes a hash code. The entire tokenization is done by a single\n '' routine without any memory allocations to keep it very fast.\n '' \n '' Currently it only handles two cases:\n '' optional-whitespace keyword-or-identifier optional-whitespace\n '' optional-whitespace single-char-punctuation optional-whitespace\n '' \n '' where the whitespace does not include newlines.\n ' \n '' The VB tokenization rules are complex, and care needs to be taken in constructing the quick\n '' tokenization. For example \"REM\" begins a comment, so it can't be tokenized as a keyword or identifier.\n '' Similar problems arise with multi-character punctuation tokens, which can have embedded spaces.\n Partial Friend Class Scanner\n ''' \n ''' The possible states that the mini scanning can be in.\n ''' \n Private Enum AccumulatorState\n Initial\n InitialAllowLeadingMultilineTrivia\n Ident\n TypeChar\n FollowingWhite\n Punctuation\n CompoundPunctStart\n CR\n Done\n Bad\n End Enum\n\n ' Flags used to classify characters.\n \n Private Enum CharFlags As UShort\n White = 1 << 0 ' simple whitespace (space/tab)\n Letter = 1 << 1 ' letter, except for \"R\" (because of REM) and \"_\"\n IdentOnly = 1 << 2 ' allowed only in identifiers (cannot start one) - letter \"R\" (because of REM), \"_\"\n TypeChar = 1 << 3 ' legal type character (except !, which is contextually dictionary lookup\n Punct = 1 << 4 ' some simple punctuation (parens, braces, dot, comma, equals, question)\n CompoundPunctStart = 1 << 5 ' may be a part of compound punctuation. will be used only if followed by (not white) && (not punct)\n CR = 1 << 6 ' CR\n LF = 1 << 7 ' LF\n Digit = 1 << 8 ' digit 0-9\n Complex = 1 << 9 ' complex - causes scanning to abort\n End Enum\n\n 'TODO: why : and ; are complex? (8th row, 3 and 4)\n\n ' The following table classifies the first &H180 Unicode characters. \n ' R and r are marked as COMPLEX so that quick-scanning doesn't stop after \"REM\".\n ' # is marked complex as it may start directives.\n ' < = > are complex because they might start a merge conflict marker.\n ' PERF: Use UShort instead of CharFlags so the compiler can use array literal initialization.\n ' The most natural type choice, Enum arrays, are not blittable due to a CLR limitation.\n Private Shared ReadOnly s_charProperties As UShort() = {\n CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex,\n CharFlags.Complex, CharFlags.White, CharFlags.LF, CharFlags.Complex, CharFlags.Complex, CharFlags.CR, CharFlags.Complex, CharFlags.Complex,\n CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex,\n CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, _\n _\n CharFlags.White, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.TypeChar, CharFlags.TypeChar, CharFlags.TypeChar, CharFlags.Complex,\n CharFlags.Punct, CharFlags.Punct, CharFlags.CompoundPunctStart, CharFlags.CompoundPunctStart, CharFlags.Punct, CharFlags.CompoundPunctStart, CharFlags.Punct, CharFlags.CompoundPunctStart,\n CharFlags.Digit, CharFlags.Digit, CharFlags.Digit, CharFlags.Digit, CharFlags.Digit, CharFlags.Digit, CharFlags.Digit, CharFlags.Digit,\n CharFlags.Digit, CharFlags.Digit, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Punct, _\n _\n CharFlags.TypeChar, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.IdentOnly, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Complex, CharFlags.CompoundPunctStart, CharFlags.Complex, CharFlags.CompoundPunctStart, CharFlags.IdentOnly, _\n _\n CharFlags.Complex, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.IdentOnly, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Punct, CharFlags.Complex, CharFlags.Punct, CharFlags.Complex, CharFlags.Complex,\n _\n CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex,\n CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex,\n CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex,\n CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, _\n _\n CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex,\n CharFlags.Complex, CharFlags.Complex, CharFlags.Letter, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex,\n CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Letter, CharFlags.Complex, CharFlags.Complex,\n CharFlags.Complex, CharFlags.Complex, CharFlags.Letter, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, _\n _\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Complex,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, _\n _\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Complex,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, _\n _\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, _\n _\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, _\n _\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, _\n _\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter}\n\n ' Size of the above table.\n Private Const s_CHARPROP_LENGTH = &H180\n\n ' Maximum length of a token to scan\n Friend Const MAX_CACHED_TOKENSIZE = 42\n\n Shared Sub New()\n Debug.Assert(s_charProperties.Length = s_CHARPROP_LENGTH)\n End Sub\n\n Public Structure QuickScanResult\n Public Sub New(start As Integer, length As Integer, chars As Char(), hashCode As Integer, terminatorLength As Byte)\n Me.Start = start\n Me.Length = length\n Me.Chars = chars\n Me.HashCode = hashCode\n Me.TerminatorLength = terminatorLength\n End Sub\n\n Public ReadOnly Chars As Char()\n Public ReadOnly Start As Integer\n Public ReadOnly Length As Integer\n Public ReadOnly HashCode As Integer\n Public ReadOnly TerminatorLength As Byte\n\n Public ReadOnly Property Succeeded As Boolean\n Get\n Return Me.Length > 0\n End Get\n End Property\n End Structure\n\n ' Attempt to scan a single token.\n ' If it succeeds, return True, and the characters, length, and hashcode of the token\n ' can be retrieved by other functions. \n ' If it fails (the token is too complex), return False.\n Public Function QuickScanToken(allowLeadingMultilineTrivia As Boolean) As QuickScanResult\n Dim state As AccumulatorState = If(allowLeadingMultilineTrivia, AccumulatorState.InitialAllowLeadingMultilineTrivia, AccumulatorState.Initial)\n\n Dim offset = _lineBufferOffset\n Dim page = _curPage\n If page Is Nothing OrElse\n page._pageStart <> (offset And s_NOT_PAGE_MASK) Then\n\n page = GetPage(offset)\n End If\n\n Dim pageArr As Char() = page._arr\n Dim qtChars = pageArr\n\n Dim index = _lineBufferOffset And s_PAGE_MASK\n Dim qtStart = index\n\n Dim limit = index + Math.Min(MAX_CACHED_TOKENSIZE, _bufferLen - offset)\n limit = Math.Min(limit, pageArr.Length)\n\n Dim hashCode As Integer = Hash.FnvOffsetBias\n Dim terminatorLength As Byte = 0\n Dim unicodeValue As Integer = 0\n\n While index < limit\n ' Get current character.\n Dim c = pageArr(index)\n\n ' Get the flags for that character.\n unicodeValue = AscW(c)\n\n If unicodeValue >= s_CHARPROP_LENGTH Then\n Exit While\n End If\n\n Dim flags = s_charProperties(unicodeValue)\n\n ' Advance the scanner state.\n Select Case state\n Case AccumulatorState.InitialAllowLeadingMultilineTrivia\n If flags = CharFlags.Letter Then\n state = AccumulatorState.Ident\n ElseIf flags = CharFlags.Punct Then\n state = AccumulatorState.Punctuation\n ElseIf flags = CharFlags.CompoundPunctStart Then\n state = AccumulatorState.CompoundPunctStart\n ElseIf (flags And (CharFlags.White Or CharFlags.CR Or CharFlags.LF)) <> 0 Then\n ' stay in AccumulatorState.InitialNewStatement\n Else\n state = AccumulatorState.Bad\n Exit While\n End If\n\n Case AccumulatorState.Initial\n If flags = CharFlags.Letter Then\n state = AccumulatorState.Ident\n ElseIf flags = CharFlags.Punct Then\n state = AccumulatorState.Punctuation\n ElseIf flags = CharFlags.CompoundPunctStart Then\n state = AccumulatorState.CompoundPunctStart\n ElseIf flags = CharFlags.White Then\n ' stay in AccumulatorState.Initial\n Else\n state = AccumulatorState.Bad\n Exit While\n End If\n\n Case AccumulatorState.Ident\n If (flags And (CharFlags.Letter Or CharFlags.IdentOnly Or CharFlags.Digit)) <> 0 Then\n ' stay in Ident\n ElseIf flags = CharFlags.White Then\n state = AccumulatorState.FollowingWhite\n ElseIf flags = CharFlags.CR Then\n state = AccumulatorState.CR\n ElseIf flags = CharFlags.LF Then\n terminatorLength = 1\n state = AccumulatorState.Done\n Exit While\n ElseIf flags = CharFlags.TypeChar Then\n state = AccumulatorState.TypeChar\n ElseIf flags = CharFlags.Punct Then\n state = AccumulatorState.Done\n Exit While\n Else\n state = AccumulatorState.Bad\n Exit While\n End If\n\n Case AccumulatorState.TypeChar\n If flags = CharFlags.White Then\n state = AccumulatorState.FollowingWhite\n ElseIf flags = CharFlags.CR Then\n state = AccumulatorState.CR\n ElseIf flags = CharFlags.LF Then\n terminatorLength = 1\n state = AccumulatorState.Done\n Exit While\n ElseIf (flags And (CharFlags.Punct Or CharFlags.Digit Or CharFlags.TypeChar)) <> 0 Then\n state = AccumulatorState.Done\n Exit While\n Else\n state = AccumulatorState.Bad\n Exit While\n End If\n\n Case AccumulatorState.FollowingWhite\n If flags = CharFlags.White Then\n ' stay in FollowingWhite\n ElseIf flags = CharFlags.CR Then\n state = AccumulatorState.CR\n ElseIf flags = CharFlags.LF Then\n terminatorLength = 1\n state = AccumulatorState.Done\n Exit While\n ElseIf (flags And (CharFlags.Complex Or CharFlags.IdentOnly)) <> 0 Then\n state = AccumulatorState.Bad\n Exit While\n Else\n state = AccumulatorState.Done\n Exit While\n End If\n\n Case AccumulatorState.Punctuation\n If flags = CharFlags.White Then\n state = AccumulatorState.FollowingWhite\n ElseIf flags = CharFlags.CR Then\n state = AccumulatorState.CR\n ElseIf flags = CharFlags.LF Then\n terminatorLength = 1\n state = AccumulatorState.Done\n Exit While\n ElseIf (flags And (CharFlags.Letter Or CharFlags.Punct)) <> 0 Then\n state = AccumulatorState.Done\n Exit While\n Else\n state = AccumulatorState.Bad\n Exit While\n End If\n\n Case AccumulatorState.CompoundPunctStart\n If flags = CharFlags.White Then\n ' stay in CompoundPunctStart\n ElseIf (flags And (CharFlags.Letter Or CharFlags.Digit)) <> 0 Then\n state = AccumulatorState.Done\n Exit While\n Else\n state = AccumulatorState.Bad\n Exit While\n End If\n\n Case AccumulatorState.CR\n If flags = CharFlags.LF Then\n terminatorLength = 2\n state = AccumulatorState.Done\n Exit While\n Else\n state = AccumulatorState.Bad\n End If\n Exit While\n Case Else\n Debug.Assert(False, \"should not get here\")\n End Select\n\n index += 1\n\n 'FNV-like hash should work here \n 'since these strings are short and mostly ASCII\n hashCode = (hashCode Xor unicodeValue) * Hash.FnvPrime\n End While\n\n If state = AccumulatorState.Done AndAlso (terminatorLength = 0 OrElse Not Me._IsScanningXmlDoc) Then\n If terminatorLength <> 0 Then\n index += 1\n hashCode = (hashCode Xor unicodeValue) * Hash.FnvPrime\n End If\n Return New QuickScanResult(qtStart, index - qtStart, qtChars, hashCode, terminatorLength)\n Else\n Return Nothing\n End If\n End Function\n End Class\nEnd Namespace\n"},"after_content":{"kind":"string","value":"' Licensed to the .NET Foundation under one or more agreements.\n' The .NET Foundation licenses this file to you under the MIT license.\n' See the LICENSE file in the project root for more information.\n\n'-----------------------------------------------------------------------------\n' Contains quick token accumulator.\n'-----------------------------------------------------------------------------\n\nOption Compare Binary\nOption Strict On\n\nImports System.Text\nImports Microsoft.CodeAnalysis.Text\nImports Microsoft.CodeAnalysis.VisualBasic\nImports Microsoft.CodeAnalysis.VisualBasic.Symbols\nImports Microsoft.CodeAnalysis.VisualBasic.Syntax\n\nNamespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax\n '' The QuickTokenAccumulator is a small mini-tokenizer that may fail. It consumes characters and\n '' eventually either decides that either it found a complete token (including the trivia on either\n '' side), or it gives up and says that the full scanner should take an attempt. It also accumulates the \n '' token into a character buffer and computes a hash code. The entire tokenization is done by a single\n '' routine without any memory allocations to keep it very fast.\n '' \n '' Currently it only handles two cases:\n '' optional-whitespace keyword-or-identifier optional-whitespace\n '' optional-whitespace single-char-punctuation optional-whitespace\n '' \n '' where the whitespace does not include newlines.\n ' \n '' The VB tokenization rules are complex, and care needs to be taken in constructing the quick\n '' tokenization. For example \"REM\" begins a comment, so it can't be tokenized as a keyword or identifier.\n '' Similar problems arise with multi-character punctuation tokens, which can have embedded spaces.\n Partial Friend Class Scanner\n ''' \n ''' The possible states that the mini scanning can be in.\n ''' \n Private Enum AccumulatorState\n Initial\n InitialAllowLeadingMultilineTrivia\n Ident\n TypeChar\n FollowingWhite\n Punctuation\n CompoundPunctStart\n CR\n Done\n Bad\n End Enum\n\n ' Flags used to classify characters.\n \n Private Enum CharFlags As UShort\n White = 1 << 0 ' simple whitespace (space/tab)\n Letter = 1 << 1 ' letter, except for \"R\" (because of REM) and \"_\"\n IdentOnly = 1 << 2 ' allowed only in identifiers (cannot start one) - letter \"R\" (because of REM), \"_\"\n TypeChar = 1 << 3 ' legal type character (except !, which is contextually dictionary lookup\n Punct = 1 << 4 ' some simple punctuation (parens, braces, dot, comma, equals, question)\n CompoundPunctStart = 1 << 5 ' may be a part of compound punctuation. will be used only if followed by (not white) && (not punct)\n CR = 1 << 6 ' CR\n LF = 1 << 7 ' LF\n Digit = 1 << 8 ' digit 0-9\n Complex = 1 << 9 ' complex - causes scanning to abort\n End Enum\n\n 'TODO: why : and ; are complex? (8th row, 3 and 4)\n\n ' The following table classifies the first &H180 Unicode characters. \n ' R and r are marked as COMPLEX so that quick-scanning doesn't stop after \"REM\".\n ' # is marked complex as it may start directives.\n ' < = > are complex because they might start a merge conflict marker.\n ' PERF: Use UShort instead of CharFlags so the compiler can use array literal initialization.\n ' The most natural type choice, Enum arrays, are not blittable due to a CLR limitation.\n Private Shared ReadOnly s_charProperties As UShort() = {\n CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex,\n CharFlags.Complex, CharFlags.White, CharFlags.LF, CharFlags.Complex, CharFlags.Complex, CharFlags.CR, CharFlags.Complex, CharFlags.Complex,\n CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex,\n CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, _\n _\n CharFlags.White, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.TypeChar, CharFlags.TypeChar, CharFlags.TypeChar, CharFlags.Complex,\n CharFlags.Punct, CharFlags.Punct, CharFlags.CompoundPunctStart, CharFlags.CompoundPunctStart, CharFlags.Punct, CharFlags.CompoundPunctStart, CharFlags.Punct, CharFlags.CompoundPunctStart,\n CharFlags.Digit, CharFlags.Digit, CharFlags.Digit, CharFlags.Digit, CharFlags.Digit, CharFlags.Digit, CharFlags.Digit, CharFlags.Digit,\n CharFlags.Digit, CharFlags.Digit, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Punct, _\n _\n CharFlags.TypeChar, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.IdentOnly, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Complex, CharFlags.CompoundPunctStart, CharFlags.Complex, CharFlags.CompoundPunctStart, CharFlags.IdentOnly, _\n _\n CharFlags.Complex, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.IdentOnly, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Punct, CharFlags.Complex, CharFlags.Punct, CharFlags.Complex, CharFlags.Complex,\n _\n CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex,\n CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex,\n CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex,\n CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, _\n _\n CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex,\n CharFlags.Complex, CharFlags.Complex, CharFlags.Letter, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex,\n CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Letter, CharFlags.Complex, CharFlags.Complex,\n CharFlags.Complex, CharFlags.Complex, CharFlags.Letter, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, CharFlags.Complex, _\n _\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Complex,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, _\n _\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Complex,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, _\n _\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, _\n _\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, _\n _\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, _\n _\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter,\n CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter, CharFlags.Letter}\n\n ' Size of the above table.\n Private Const s_CHARPROP_LENGTH = &H180\n\n ' Maximum length of a token to scan\n Friend Const MAX_CACHED_TOKENSIZE = 42\n\n Shared Sub New()\n Debug.Assert(s_charProperties.Length = s_CHARPROP_LENGTH)\n End Sub\n\n Public Structure QuickScanResult\n Public Sub New(start As Integer, length As Integer, chars As Char(), hashCode As Integer, terminatorLength As Byte)\n Me.Start = start\n Me.Length = length\n Me.Chars = chars\n Me.HashCode = hashCode\n Me.TerminatorLength = terminatorLength\n End Sub\n\n Public ReadOnly Chars As Char()\n Public ReadOnly Start As Integer\n Public ReadOnly Length As Integer\n Public ReadOnly HashCode As Integer\n Public ReadOnly TerminatorLength As Byte\n\n Public ReadOnly Property Succeeded As Boolean\n Get\n Return Me.Length > 0\n End Get\n End Property\n End Structure\n\n ' Attempt to scan a single token.\n ' If it succeeds, return True, and the characters, length, and hashcode of the token\n ' can be retrieved by other functions. \n ' If it fails (the token is too complex), return False.\n Public Function QuickScanToken(allowLeadingMultilineTrivia As Boolean) As QuickScanResult\n Dim state As AccumulatorState = If(allowLeadingMultilineTrivia, AccumulatorState.InitialAllowLeadingMultilineTrivia, AccumulatorState.Initial)\n\n Dim offset = _lineBufferOffset\n Dim page = _curPage\n If page Is Nothing OrElse\n page._pageStart <> (offset And s_NOT_PAGE_MASK) Then\n\n page = GetPage(offset)\n End If\n\n Dim pageArr As Char() = page._arr\n Dim qtChars = pageArr\n\n Dim index = _lineBufferOffset And s_PAGE_MASK\n Dim qtStart = index\n\n Dim limit = index + Math.Min(MAX_CACHED_TOKENSIZE, _bufferLen - offset)\n limit = Math.Min(limit, pageArr.Length)\n\n Dim hashCode As Integer = Hash.FnvOffsetBias\n Dim terminatorLength As Byte = 0\n Dim unicodeValue As Integer = 0\n\n While index < limit\n ' Get current character.\n Dim c = pageArr(index)\n\n ' Get the flags for that character.\n unicodeValue = AscW(c)\n\n If unicodeValue >= s_CHARPROP_LENGTH Then\n Exit While\n End If\n\n Dim flags = s_charProperties(unicodeValue)\n\n ' Advance the scanner state.\n Select Case state\n Case AccumulatorState.InitialAllowLeadingMultilineTrivia\n If flags = CharFlags.Letter Then\n state = AccumulatorState.Ident\n ElseIf flags = CharFlags.Punct Then\n state = AccumulatorState.Punctuation\n ElseIf flags = CharFlags.CompoundPunctStart Then\n state = AccumulatorState.CompoundPunctStart\n ElseIf (flags And (CharFlags.White Or CharFlags.CR Or CharFlags.LF)) <> 0 Then\n ' stay in AccumulatorState.InitialNewStatement\n Else\n state = AccumulatorState.Bad\n Exit While\n End If\n\n Case AccumulatorState.Initial\n If flags = CharFlags.Letter Then\n state = AccumulatorState.Ident\n ElseIf flags = CharFlags.Punct Then\n state = AccumulatorState.Punctuation\n ElseIf flags = CharFlags.CompoundPunctStart Then\n state = AccumulatorState.CompoundPunctStart\n ElseIf flags = CharFlags.White Then\n ' stay in AccumulatorState.Initial\n Else\n state = AccumulatorState.Bad\n Exit While\n End If\n\n Case AccumulatorState.Ident\n If (flags And (CharFlags.Letter Or CharFlags.IdentOnly Or CharFlags.Digit)) <> 0 Then\n ' stay in Ident\n ElseIf flags = CharFlags.White Then\n state = AccumulatorState.FollowingWhite\n ElseIf flags = CharFlags.CR Then\n state = AccumulatorState.CR\n ElseIf flags = CharFlags.LF Then\n terminatorLength = 1\n state = AccumulatorState.Done\n Exit While\n ElseIf flags = CharFlags.TypeChar Then\n state = AccumulatorState.TypeChar\n ElseIf flags = CharFlags.Punct Then\n state = AccumulatorState.Done\n Exit While\n Else\n state = AccumulatorState.Bad\n Exit While\n End If\n\n Case AccumulatorState.TypeChar\n If flags = CharFlags.White Then\n state = AccumulatorState.FollowingWhite\n ElseIf flags = CharFlags.CR Then\n state = AccumulatorState.CR\n ElseIf flags = CharFlags.LF Then\n terminatorLength = 1\n state = AccumulatorState.Done\n Exit While\n ElseIf (flags And (CharFlags.Punct Or CharFlags.Digit Or CharFlags.TypeChar)) <> 0 Then\n state = AccumulatorState.Done\n Exit While\n Else\n state = AccumulatorState.Bad\n Exit While\n End If\n\n Case AccumulatorState.FollowingWhite\n If flags = CharFlags.White Then\n ' stay in FollowingWhite\n ElseIf flags = CharFlags.CR Then\n state = AccumulatorState.CR\n ElseIf flags = CharFlags.LF Then\n terminatorLength = 1\n state = AccumulatorState.Done\n Exit While\n ElseIf (flags And (CharFlags.Complex Or CharFlags.IdentOnly)) <> 0 Then\n state = AccumulatorState.Bad\n Exit While\n Else\n state = AccumulatorState.Done\n Exit While\n End If\n\n Case AccumulatorState.Punctuation\n If flags = CharFlags.White Then\n state = AccumulatorState.FollowingWhite\n ElseIf flags = CharFlags.CR Then\n state = AccumulatorState.CR\n ElseIf flags = CharFlags.LF Then\n terminatorLength = 1\n state = AccumulatorState.Done\n Exit While\n ElseIf (flags And (CharFlags.Letter Or CharFlags.Punct)) <> 0 Then\n state = AccumulatorState.Done\n Exit While\n Else\n state = AccumulatorState.Bad\n Exit While\n End If\n\n Case AccumulatorState.CompoundPunctStart\n If flags = CharFlags.White Then\n ' stay in CompoundPunctStart\n ElseIf (flags And (CharFlags.Letter Or CharFlags.Digit)) <> 0 Then\n state = AccumulatorState.Done\n Exit While\n Else\n state = AccumulatorState.Bad\n Exit While\n End If\n\n Case AccumulatorState.CR\n If flags = CharFlags.LF Then\n terminatorLength = 2\n state = AccumulatorState.Done\n Exit While\n Else\n state = AccumulatorState.Bad\n End If\n Exit While\n Case Else\n Debug.Assert(False, \"should not get here\")\n End Select\n\n index += 1\n\n 'FNV-like hash should work here \n 'since these strings are short and mostly ASCII\n hashCode = (hashCode Xor unicodeValue) * Hash.FnvPrime\n End While\n\n If state = AccumulatorState.Done AndAlso (terminatorLength = 0 OrElse Not Me._IsScanningXmlDoc) Then\n If terminatorLength <> 0 Then\n index += 1\n hashCode = (hashCode Xor unicodeValue) * Hash.FnvPrime\n End If\n Return New QuickScanResult(qtStart, index - qtStart, qtChars, hashCode, terminatorLength)\n Else\n Return Nothing\n End If\n End Function\n End Class\nEnd Namespace\n"},"label":{"kind":"number","value":-1,"string":"-1"}}},{"rowIdx":1515,"cells":{"repo_name":{"kind":"string","value":"dotnet/roslyn"},"pr_number":{"kind":"number","value":56310,"string":"56,310"},"pr_title":{"kind":"string","value":"Move semantic classification caching down to Editor layer"},"pr_description":{"kind":"string","value":""},"author":{"kind":"string","value":"CyrusNajmabadi"},"date_created":{"kind":"timestamp","value":"2021-09-09T23:15:16Z","string":"2021-09-09T23:15:16Z"},"date_merged":{"kind":"timestamp","value":"2021-09-10T19:26:25Z","string":"2021-09-10T19:26:25Z"},"previous_commit":{"kind":"string","value":"6e123012d868c56aba8acabfe1ccad1bf8f20b04"},"pr_commit":{"kind":"string","value":"7af13b6e3867198cd59c566a905b332888ea1dec"},"query":{"kind":"string","value":"Move semantic classification caching down to Editor layer. "},"filepath":{"kind":"string","value":"./src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/CastExpressionSyntaxExtensions.vb"},"before_content":{"kind":"string","value":"' Licensed to the .NET Foundation under one or more agreements.\n' The .NET Foundation licenses this file to you under the MIT license.\n' See the LICENSE file in the project root for more information.\n\nImports System.Runtime.CompilerServices\nImports Microsoft.CodeAnalysis.Simplification\nImports Microsoft.CodeAnalysis.VisualBasic.Syntax\n\nNamespace Microsoft.CodeAnalysis.VisualBasic.Extensions\n Friend Module CastExpressionSyntaxExtensions\n \n Public Function Uncast(cast As CastExpressionSyntax) As ExpressionSyntax\n Return Uncast(cast, cast.Expression)\n End Function\n\n \n Public Function Uncast(cast As PredefinedCastExpressionSyntax) As ExpressionSyntax\n Return Uncast(cast, cast.Expression)\n End Function\n\n Private Function Uncast(castNode As ExpressionSyntax, innerNode As ExpressionSyntax) As ExpressionSyntax\n Dim resultNode = innerNode.WithTriviaFrom(castNode)\n\n resultNode = SimplificationHelpers.CopyAnnotations(castNode, resultNode)\n\n Return resultNode\n\n End Function\n End Module\nEnd Namespace\n"},"after_content":{"kind":"string","value":"' Licensed to the .NET Foundation under one or more agreements.\n' The .NET Foundation licenses this file to you under the MIT license.\n' See the LICENSE file in the project root for more information.\n\nImports System.Runtime.CompilerServices\nImports Microsoft.CodeAnalysis.Simplification\nImports Microsoft.CodeAnalysis.VisualBasic.Syntax\n\nNamespace Microsoft.CodeAnalysis.VisualBasic.Extensions\n Friend Module CastExpressionSyntaxExtensions\n \n Public Function Uncast(cast As CastExpressionSyntax) As ExpressionSyntax\n Return Uncast(cast, cast.Expression)\n End Function\n\n \n Public Function Uncast(cast As PredefinedCastExpressionSyntax) As ExpressionSyntax\n Return Uncast(cast, cast.Expression)\n End Function\n\n Private Function Uncast(castNode As ExpressionSyntax, innerNode As ExpressionSyntax) As ExpressionSyntax\n Dim resultNode = innerNode.WithTriviaFrom(castNode)\n\n resultNode = SimplificationHelpers.CopyAnnotations(castNode, resultNode)\n\n Return resultNode\n\n End Function\n End Module\nEnd Namespace\n"},"label":{"kind":"number","value":-1,"string":"-1"}}},{"rowIdx":1516,"cells":{"repo_name":{"kind":"string","value":"dotnet/roslyn"},"pr_number":{"kind":"number","value":56293,"string":"56,293"},"pr_title":{"kind":"string","value":"Control exposure of tuple fields"},"pr_description":{"kind":"string","value":"Fixes https://github.com/dotnet/roslyn/issues/51204\r\n\r\nThe point of this change is to remove the special case for tuples in `AssertMemberExposure`."},"author":{"kind":"string","value":"jcouv"},"date_created":{"kind":"timestamp","value":"2021-09-09T18:17:36Z","string":"2021-09-09T18:17:36Z"},"date_merged":{"kind":"timestamp","value":"2021-09-14T19:56:11Z","string":"2021-09-14T19:56:11Z"},"previous_commit":{"kind":"string","value":"dcadde85baf3b034319815445e453538a807ba4e"},"pr_commit":{"kind":"string","value":"0bcaa937e2560ad2e442e2a70386109f6195aab6"},"query":{"kind":"string","value":"Control exposure of tuple fields. Fixes https://github.com/dotnet/roslyn/issues/51204\r\n\r\nThe point of this change is to remove the special case for tuples in `AssertMemberExposure`."},"filepath":{"kind":"string","value":"./src/Compilers/CSharp/Portable/FlowAnalysis/LocalDataFlowPass.cs"},"before_content":{"kind":"string","value":"// Licensed to the .NET Foundation under one or more agreements.\n// The .NET Foundation licenses this file to you under the MIT license.\n// See the LICENSE file in the project root for more information.\n\nusing System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing Microsoft.CodeAnalysis.CSharp.Symbols;\n\nnamespace Microsoft.CodeAnalysis.CSharp\n{\n /// \n /// Does a data flow analysis for state attached to local variables and fields of struct locals.\n /// \n internal abstract partial class LocalDataFlowPass : AbstractFlowPass\n where TLocalState : LocalDataFlowPass.ILocalDataFlowState\n where TLocalFunctionState : AbstractFlowPass.AbstractLocalFunctionState\n {\n internal interface ILocalDataFlowState : ILocalState\n {\n /// \n /// True if new variables introduced in should be set\n /// to the bottom state. False if they should be set to the top state.\n /// \n bool NormalizeToBottom { get; }\n }\n\n /// \n /// A cache for remember which structs are empty.\n /// \n protected readonly EmptyStructTypeCache _emptyStructTypeCache;\n\n protected LocalDataFlowPass(\n CSharpCompilation compilation,\n Symbol? member,\n BoundNode node,\n EmptyStructTypeCache emptyStructs,\n bool trackUnassignments)\n : base(compilation, member, node, nonMonotonicTransferFunction: trackUnassignments)\n {\n Debug.Assert(emptyStructs != null);\n _emptyStructTypeCache = emptyStructs;\n }\n\n protected LocalDataFlowPass(\n CSharpCompilation compilation,\n Symbol member,\n BoundNode node,\n EmptyStructTypeCache emptyStructs,\n BoundNode firstInRegion,\n BoundNode lastInRegion,\n bool trackRegions,\n bool trackUnassignments)\n : base(compilation, member, node, firstInRegion, lastInRegion, trackRegions: trackRegions, nonMonotonicTransferFunction: trackUnassignments)\n {\n _emptyStructTypeCache = emptyStructs;\n }\n\n protected abstract bool TryGetVariable(VariableIdentifier identifier, out int slot);\n\n protected abstract int AddVariable(VariableIdentifier identifier);\n\n /// \n /// Locals are given slots when their declarations are encountered. We only need give slots\n /// to local variables, out parameters, and the \"this\" variable of a struct constructs.\n /// Other variables are not given slots, and are therefore not tracked by the analysis. This\n /// returns -1 for a variable that is not tracked, for fields of structs that have the same\n /// assigned status as the container, and for structs that (recursively) contain no data members.\n /// We do not need to track references to\n /// variables that occur before the variable is declared, as those are reported in an\n /// earlier phase as \"use before declaration\". That allows us to avoid giving slots to local\n /// variables before processing their declarations.\n /// \n protected int VariableSlot(Symbol symbol, int containingSlot = 0)\n {\n containingSlot = DescendThroughTupleRestFields(ref symbol, containingSlot, forceContainingSlotsToExist: false);\n\n int slot;\n return TryGetVariable(new VariableIdentifier(symbol, containingSlot), out slot) ? slot : -1;\n }\n\n protected virtual bool IsEmptyStructType(TypeSymbol type)\n {\n return _emptyStructTypeCache.IsEmptyStructType(type);\n }\n\n /// \n /// Force a variable to have a slot. Returns -1 if the variable has an empty struct type.\n /// \n protected virtual int GetOrCreateSlot(Symbol symbol, int containingSlot = 0, bool forceSlotEvenIfEmpty = false, bool createIfMissing = true)\n {\n Debug.Assert(containingSlot >= 0);\n Debug.Assert(symbol != null);\n\n if (symbol.Kind == SymbolKind.RangeVariable) return -1;\n\n containingSlot = DescendThroughTupleRestFields(ref symbol, containingSlot, forceContainingSlotsToExist: true);\n\n if (containingSlot < 0)\n {\n // Error case. Diagnostics should already have been produced.\n return -1;\n }\n\n VariableIdentifier identifier = new VariableIdentifier(symbol, containingSlot);\n int slot;\n\n // Since analysis may proceed in multiple passes, it is possible the slot is already assigned.\n if (!TryGetVariable(identifier, out slot))\n {\n if (!createIfMissing)\n {\n return -1;\n }\n\n var variableType = symbol.GetTypeOrReturnType().Type;\n if (!forceSlotEvenIfEmpty && IsEmptyStructType(variableType))\n {\n return -1;\n }\n\n slot = AddVariable(identifier);\n }\n\n if (IsConditionalState)\n {\n Normalize(ref this.StateWhenTrue);\n Normalize(ref this.StateWhenFalse);\n }\n else\n {\n Normalize(ref this.State);\n }\n\n return slot;\n }\n\n /// \n /// Sets the starting state for any newly declared variables in the LocalDataFlowPass.\n /// \n protected abstract void Normalize(ref TLocalState state);\n\n /// \n /// Descends through Rest fields of a tuple if \"symbol\" is an extended field\n /// As a result the \"symbol\" will be adjusted to be the field of the innermost tuple\n /// and a corresponding containingSlot is returned.\n /// Return value -1 indicates a failure which could happen for the following reasons\n /// a) Rest field does not exist, which could happen in rare error scenarios involving broken ValueTuple types\n /// b) Rest is not tracked already and forceSlotsToExist is false (otherwise we create slots on demand)\n /// \n private int DescendThroughTupleRestFields(ref Symbol symbol, int containingSlot, bool forceContainingSlotsToExist)\n {\n if (symbol is TupleElementFieldSymbol fieldSymbol)\n {\n TypeSymbol containingType = symbol.ContainingType;\n\n // for tuple fields the variable identifier represents the underlying field\n symbol = fieldSymbol.TupleUnderlyingField;\n\n // descend through Rest fields\n // force corresponding slots if do not exist\n while (!TypeSymbol.Equals(containingType, symbol.ContainingType, TypeCompareKind.ConsiderEverything))\n {\n var restField = containingType.GetMembers(NamedTypeSymbol.ValueTupleRestFieldName).FirstOrDefault() as FieldSymbol;\n if (restField is null)\n {\n return -1;\n }\n\n if (forceContainingSlotsToExist)\n {\n containingSlot = GetOrCreateSlot(restField, containingSlot);\n }\n else\n {\n if (!TryGetVariable(new VariableIdentifier(restField, containingSlot), out containingSlot))\n {\n return -1;\n }\n }\n\n containingType = restField.Type;\n }\n }\n\n return containingSlot;\n }\n\n protected abstract bool TryGetReceiverAndMember(BoundExpression expr, out BoundExpression? receiver, [NotNullWhen(true)] out Symbol? member);\n\n /// \n /// Return the slot for a variable, or -1 if it is not tracked (because, for example, it is an empty struct).\n /// \n /// \n /// \n protected virtual int MakeSlot(BoundExpression node)\n {\n switch (node.Kind)\n {\n case BoundKind.ThisReference:\n case BoundKind.BaseReference:\n return (object)MethodThisParameter != null ? GetOrCreateSlot(MethodThisParameter) : -1;\n case BoundKind.Local:\n return GetOrCreateSlot(((BoundLocal)node).LocalSymbol);\n case BoundKind.Parameter:\n return GetOrCreateSlot(((BoundParameter)node).ParameterSymbol);\n case BoundKind.RangeVariable:\n return MakeSlot(((BoundRangeVariable)node).Value);\n case BoundKind.FieldAccess:\n case BoundKind.EventAccess:\n case BoundKind.PropertyAccess:\n if (TryGetReceiverAndMember(node, out BoundExpression? receiver, out Symbol? member))\n {\n Debug.Assert((receiver is null) != member.RequiresInstanceReceiver());\n return MakeMemberSlot(receiver, member);\n }\n break;\n case BoundKind.AssignmentOperator:\n return MakeSlot(((BoundAssignmentOperator)node).Left);\n }\n return -1;\n }\n\n protected int MakeMemberSlot(BoundExpression? receiverOpt, Symbol member)\n {\n int containingSlot;\n if (member.RequiresInstanceReceiver())\n {\n if (receiverOpt is null)\n {\n return -1;\n }\n containingSlot = MakeSlot(receiverOpt);\n if (containingSlot < 0)\n {\n return -1;\n }\n }\n else\n {\n containingSlot = 0;\n }\n\n return GetOrCreateSlot(member, containingSlot);\n }\n\n protected static bool HasInitializer(Symbol field) => field switch\n {\n SourceMemberFieldSymbol f => f.HasInitializer,\n SynthesizedBackingFieldSymbol f => f.HasInitializer,\n SourceFieldLikeEventSymbol e => e.AssociatedEventField?.HasInitializer == true,\n _ => false\n };\n }\n}\n"},"after_content":{"kind":"string","value":"// Licensed to the .NET Foundation under one or more agreements.\n// The .NET Foundation licenses this file to you under the MIT license.\n// See the LICENSE file in the project root for more information.\n\nusing System;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing Microsoft.CodeAnalysis.CSharp.Symbols;\n\nnamespace Microsoft.CodeAnalysis.CSharp\n{\n /// \n /// Does a data flow analysis for state attached to local variables and fields of struct locals.\n /// \n internal abstract partial class LocalDataFlowPass : AbstractFlowPass\n where TLocalState : LocalDataFlowPass.ILocalDataFlowState\n where TLocalFunctionState : AbstractFlowPass.AbstractLocalFunctionState\n {\n internal interface ILocalDataFlowState : ILocalState\n {\n /// \n /// True if new variables introduced in should be set\n /// to the bottom state. False if they should be set to the top state.\n /// \n bool NormalizeToBottom { get; }\n }\n\n /// \n /// A cache for remember which structs are empty.\n /// \n protected readonly EmptyStructTypeCache _emptyStructTypeCache;\n\n protected LocalDataFlowPass(\n CSharpCompilation compilation,\n Symbol? member,\n BoundNode node,\n EmptyStructTypeCache emptyStructs,\n bool trackUnassignments)\n : base(compilation, member, node, nonMonotonicTransferFunction: trackUnassignments)\n {\n Debug.Assert(emptyStructs != null);\n _emptyStructTypeCache = emptyStructs;\n }\n\n protected LocalDataFlowPass(\n CSharpCompilation compilation,\n Symbol member,\n BoundNode node,\n EmptyStructTypeCache emptyStructs,\n BoundNode firstInRegion,\n BoundNode lastInRegion,\n bool trackRegions,\n bool trackUnassignments)\n : base(compilation, member, node, firstInRegion, lastInRegion, trackRegions: trackRegions, nonMonotonicTransferFunction: trackUnassignments)\n {\n _emptyStructTypeCache = emptyStructs;\n }\n\n protected abstract bool TryGetVariable(VariableIdentifier identifier, out int slot);\n\n protected abstract int AddVariable(VariableIdentifier identifier);\n\n /// \n /// Locals are given slots when their declarations are encountered. We only need give slots\n /// to local variables, out parameters, and the \"this\" variable of a struct constructs.\n /// Other variables are not given slots, and are therefore not tracked by the analysis. This\n /// returns -1 for a variable that is not tracked, for fields of structs that have the same\n /// assigned status as the container, and for structs that (recursively) contain no data members.\n /// We do not need to track references to\n /// variables that occur before the variable is declared, as those are reported in an\n /// earlier phase as \"use before declaration\". That allows us to avoid giving slots to local\n /// variables before processing their declarations.\n /// \n protected int VariableSlot(Symbol symbol, int containingSlot = 0)\n {\n containingSlot = DescendThroughTupleRestFields(ref symbol, containingSlot, forceContainingSlotsToExist: false);\n\n int slot;\n return TryGetVariable(new VariableIdentifier(symbol, containingSlot), out slot) ? slot : -1;\n }\n\n protected virtual bool IsEmptyStructType(TypeSymbol type)\n {\n return _emptyStructTypeCache.IsEmptyStructType(type);\n }\n\n /// \n /// Force a variable to have a slot. Returns -1 if the variable has an empty struct type.\n /// \n protected virtual int GetOrCreateSlot(Symbol symbol, int containingSlot = 0, bool forceSlotEvenIfEmpty = false, bool createIfMissing = true)\n {\n Debug.Assert(containingSlot >= 0);\n Debug.Assert(symbol != null);\n\n if (symbol.Kind == SymbolKind.RangeVariable) return -1;\n\n containingSlot = DescendThroughTupleRestFields(ref symbol, containingSlot, forceContainingSlotsToExist: true);\n\n if (containingSlot < 0)\n {\n // Error case. Diagnostics should already have been produced.\n return -1;\n }\n\n VariableIdentifier identifier = new VariableIdentifier(symbol, containingSlot);\n int slot;\n\n // Since analysis may proceed in multiple passes, it is possible the slot is already assigned.\n if (!TryGetVariable(identifier, out slot))\n {\n if (!createIfMissing)\n {\n return -1;\n }\n\n var variableType = symbol.GetTypeOrReturnType().Type;\n if (!forceSlotEvenIfEmpty && IsEmptyStructType(variableType))\n {\n return -1;\n }\n\n slot = AddVariable(identifier);\n }\n\n if (IsConditionalState)\n {\n Normalize(ref this.StateWhenTrue);\n Normalize(ref this.StateWhenFalse);\n }\n else\n {\n Normalize(ref this.State);\n }\n\n return slot;\n }\n\n /// \n /// Sets the starting state for any newly declared variables in the LocalDataFlowPass.\n /// \n protected abstract void Normalize(ref TLocalState state);\n\n /// \n /// Descends through Rest fields of a tuple if \"symbol\" is an extended field\n /// As a result the \"symbol\" will be adjusted to be the field of the innermost tuple\n /// and a corresponding containingSlot is returned.\n /// Return value -1 indicates a failure which could happen for the following reasons\n /// a) Rest field does not exist, which could happen in rare error scenarios involving broken ValueTuple types\n /// b) Rest is not tracked already and forceSlotsToExist is false (otherwise we create slots on demand)\n /// \n private int DescendThroughTupleRestFields(ref Symbol symbol, int containingSlot, bool forceContainingSlotsToExist)\n {\n if (symbol is TupleElementFieldSymbol fieldSymbol)\n {\n TypeSymbol containingType = symbol.ContainingType;\n\n // for tuple fields the variable identifier represents the underlying field\n symbol = fieldSymbol.TupleUnderlyingField;\n\n // descend through Rest fields\n // force corresponding slots if do not exist\n while (!TypeSymbol.Equals(containingType, symbol.ContainingType, TypeCompareKind.ConsiderEverything))\n {\n var restField = containingType.GetMembers(NamedTypeSymbol.ValueTupleRestFieldName).FirstOrDefault(s => s is not TupleVirtualElementFieldSymbol) as FieldSymbol;\n if (restField is null)\n {\n return -1;\n }\n\n if (forceContainingSlotsToExist)\n {\n containingSlot = GetOrCreateSlot(restField, containingSlot);\n }\n else\n {\n if (!TryGetVariable(new VariableIdentifier(restField, containingSlot), out containingSlot))\n {\n return -1;\n }\n }\n\n containingType = restField.Type;\n }\n }\n\n return containingSlot;\n }\n\n protected abstract bool TryGetReceiverAndMember(BoundExpression expr, out BoundExpression? receiver, [NotNullWhen(true)] out Symbol? member);\n\n /// \n /// Return the slot for a variable, or -1 if it is not tracked (because, for example, it is an empty struct).\n /// \n /// \n /// \n protected virtual int MakeSlot(BoundExpression node)\n {\n switch (node.Kind)\n {\n case BoundKind.ThisReference:\n case BoundKind.BaseReference:\n return (object)MethodThisParameter != null ? GetOrCreateSlot(MethodThisParameter) : -1;\n case BoundKind.Local:\n return GetOrCreateSlot(((BoundLocal)node).LocalSymbol);\n case BoundKind.Parameter:\n return GetOrCreateSlot(((BoundParameter)node).ParameterSymbol);\n case BoundKind.RangeVariable:\n return MakeSlot(((BoundRangeVariable)node).Value);\n case BoundKind.FieldAccess:\n case BoundKind.EventAccess:\n case BoundKind.PropertyAccess:\n if (TryGetReceiverAndMember(node, out BoundExpression? receiver, out Symbol? member))\n {\n Debug.Assert((receiver is null) != member.RequiresInstanceReceiver());\n return MakeMemberSlot(receiver, member);\n }\n break;\n case BoundKind.AssignmentOperator:\n return MakeSlot(((BoundAssignmentOperator)node).Left);\n }\n return -1;\n }\n\n protected int MakeMemberSlot(BoundExpression? receiverOpt, Symbol member)\n {\n int containingSlot;\n if (member.RequiresInstanceReceiver())\n {\n if (receiverOpt is null)\n {\n return -1;\n }\n containingSlot = MakeSlot(receiverOpt);\n if (containingSlot < 0)\n {\n return -1;\n }\n }\n else\n {\n containingSlot = 0;\n }\n\n return GetOrCreateSlot(member, containingSlot);\n }\n\n protected static bool HasInitializer(Symbol field) => field switch\n {\n SourceMemberFieldSymbol f => f.HasInitializer,\n SynthesizedBackingFieldSymbol f => f.HasInitializer,\n SourceFieldLikeEventSymbol e => e.AssociatedEventField?.HasInitializer == true,\n _ => false\n };\n }\n}\n"},"label":{"kind":"number","value":1,"string":"1"}}},{"rowIdx":1517,"cells":{"repo_name":{"kind":"string","value":"dotnet/roslyn"},"pr_number":{"kind":"number","value":56293,"string":"56,293"},"pr_title":{"kind":"string","value":"Control exposure of tuple fields"},"pr_description":{"kind":"string","value":"Fixes https://github.com/dotnet/roslyn/issues/51204\r\n\r\nThe point of this change is to remove the special case for tuples in `AssertMemberExposure`."},"author":{"kind":"string","value":"jcouv"},"date_created":{"kind":"timestamp","value":"2021-09-09T18:17:36Z","string":"2021-09-09T18:17:36Z"},"date_merged":{"kind":"timestamp","value":"2021-09-14T19:56:11Z","string":"2021-09-14T19:56:11Z"},"previous_commit":{"kind":"string","value":"dcadde85baf3b034319815445e453538a807ba4e"},"pr_commit":{"kind":"string","value":"0bcaa937e2560ad2e442e2a70386109f6195aab6"},"query":{"kind":"string","value":"Control exposure of tuple fields. Fixes https://github.com/dotnet/roslyn/issues/51204\r\n\r\nThe point of this change is to remove the special case for tuples in `AssertMemberExposure`."},"filepath":{"kind":"string","value":"./src/Compilers/CSharp/Portable/Symbols/ErrorTypeSymbol.cs"},"before_content":{"kind":"string","value":"// Licensed to the .NET Foundation under one or more agreements.\n// The .NET Foundation licenses this file to you under the MIT license.\n// See the LICENSE file in the project root for more information.\n\nusing Roslyn.Utilities;\nusing System.Collections.Generic;\nusing System.Collections.Immutable;\nusing System.Diagnostics;\nusing System.Runtime.InteropServices;\n\nnamespace Microsoft.CodeAnalysis.CSharp.Symbols\n{\n /// \n /// An ErrorSymbol is used when the compiler cannot determine a symbol object to return because\n /// of an error. For example, if a field is declared \"Goo x;\", and the type \"Goo\" cannot be\n /// found, an ErrorSymbol is returned when asking the field \"x\" what it's type is.\n /// \n internal abstract partial class ErrorTypeSymbol : NamedTypeSymbol\n {\n internal static readonly ErrorTypeSymbol UnknownResultType = new UnsupportedMetadataTypeSymbol();\n\n private ImmutableArray _lazyTypeParameters;\n\n /// \n /// The underlying error.\n /// \n internal abstract DiagnosticInfo? ErrorInfo { get; }\n\n /// \n /// Summary of the reason why the type is bad.\n /// \n internal virtual LookupResultKind ResultKind { get { return LookupResultKind.Empty; } }\n\n /// \n /// Called by to perform substitution\n /// on types with TypeKind ErrorType. The general pattern is to use the type map\n /// to perform substitution on the wrapped type, if any, and then construct a new\n /// error type symbol from the result (if there was a change).\n /// \n internal TypeWithAnnotations Substitute(AbstractTypeMap typeMap)\n {\n return TypeWithAnnotations.Create(typeMap.SubstituteNamedType(this));\n }\n\n /// \n /// When constructing this ErrorTypeSymbol, there may have been symbols that seemed to\n /// be what the user intended, but were unsuitable. For example, a type might have been\n /// inaccessible, or ambiguous. This property returns the possible symbols that the user\n /// might have intended. It will return no symbols if no possible symbols were found.\n /// See the CandidateReason property to understand why the symbols were unsuitable.\n /// \n public virtual ImmutableArray CandidateSymbols\n {\n get\n {\n return ImmutableArray.Empty;\n }\n }\n\n ///\n /// If CandidateSymbols returns one or more symbols, returns the reason that those\n /// symbols were not chosen. Otherwise, returns None.\n /// \n public CandidateReason CandidateReason\n {\n get\n {\n if (!CandidateSymbols.IsEmpty)\n {\n Debug.Assert(ResultKind != LookupResultKind.Viable, \"Shouldn't have viable result kind on error symbol\");\n return ResultKind.ToCandidateReason();\n }\n else\n {\n return CandidateReason.None;\n }\n }\n }\n\n internal override UseSiteInfo GetUseSiteInfo()\n {\n return new UseSiteInfo(this.ErrorInfo);\n }\n\n /// \n /// Returns true if this type is known to be a reference type. It is never the case that\n /// IsReferenceType and IsValueType both return true. However, for an unconstrained type\n /// parameter, IsReferenceType and IsValueType will both return false.\n /// \n public override bool IsReferenceType\n {\n // TODO: Consider returning False.\n get { return true; }\n }\n\n /// \n /// Returns true if this type is known to be a value type. It is never the case that\n /// IsReferenceType and IsValueType both return true. However, for an unconstrained type\n /// parameter, IsReferenceType and IsValueType will both return false.\n /// \n public sealed override bool IsValueType\n {\n get { return false; }\n }\n\n public sealed override bool IsRefLikeType\n {\n get\n {\n return false;\n }\n }\n\n public sealed override bool IsReadOnly\n {\n get\n {\n return false;\n }\n }\n\n /// \n /// Collection of names of members declared within this type.\n /// \n public override IEnumerable MemberNames\n {\n get\n {\n return SpecializedCollections.EmptyEnumerable();\n }\n }\n\n /// \n /// Get all the members of this symbol.\n /// \n /// An ImmutableArray containing all the members of this symbol. If this symbol has no members,\n /// returns an empty ImmutableArray. Never returns Null.\n public override ImmutableArray GetMembers()\n {\n if (IsTupleType)\n {\n var result = AddOrWrapTupleMembers(ImmutableArray.Empty);\n RoslynDebug.Assert(result is object);\n return result.ToImmutableAndFree();\n }\n\n return ImmutableArray.Empty;\n }\n\n /// \n /// Get all the members of this symbol that have a particular name.\n /// \n /// An ImmutableArray containing all the members of this symbol with the given name. If there are\n /// no members with this name, returns an empty ImmutableArray. Never returns Null.\n public override ImmutableArray GetMembers(string name)\n {\n return GetMembers().WhereAsArray((m, name) => m.Name == name, name);\n }\n\n internal sealed override IEnumerable GetFieldsToEmit()\n {\n throw ExceptionUtilities.Unreachable;\n }\n\n internal override ImmutableArray GetEarlyAttributeDecodingMembers()\n {\n return this.GetMembersUnordered();\n }\n\n internal override ImmutableArray GetEarlyAttributeDecodingMembers(string name)\n {\n return this.GetMembers(name);\n }\n\n /// \n /// Get all the members of this symbol that are types.\n /// \n /// An ImmutableArray containing all the types that are members of this symbol. If this symbol has no type members,\n /// returns an empty ImmutableArray. Never returns null.\n public override ImmutableArray GetTypeMembers()\n {\n return ImmutableArray.Empty;\n }\n\n /// \n /// Get all the members of this symbol that are types that have a particular name, of any arity.\n /// \n /// An ImmutableArray containing all the types that are members of this symbol with the given name.\n /// If this symbol has no type members with this name,\n /// returns an empty ImmutableArray. Never returns null.\n public override ImmutableArray GetTypeMembers(string name)\n {\n return ImmutableArray.Empty;\n }\n\n /// \n /// Get all the members of this symbol that are types that have a particular name and arity\n /// \n /// An ImmutableArray containing all the types that are members of this symbol with the given name and arity.\n /// If this symbol has no type members with this name and arity,\n /// returns an empty ImmutableArray. Never returns null.\n public override ImmutableArray GetTypeMembers(string name, int arity)\n {\n return ImmutableArray.Empty;\n }\n\n /// \n /// Gets the kind of this symbol.\n /// \n public sealed override SymbolKind Kind\n {\n get\n {\n return SymbolKind.ErrorType;\n }\n }\n\n /// \n /// Gets the kind of this type.\n /// \n public sealed override TypeKind TypeKind\n {\n get\n {\n return TypeKind.Error;\n }\n }\n\n internal sealed override bool IsInterface\n {\n get { return false; }\n }\n\n /// \n /// Get the symbol that logically contains this symbol. \n /// \n public override Symbol? ContainingSymbol\n {\n get\n {\n return null;\n }\n }\n\n /// \n /// Gets the locations where this symbol was originally defined, either in source or\n /// metadata. Some symbols (for example, partial classes) may be defined in more than one\n /// location.\n /// \n public override ImmutableArray Locations\n {\n get\n {\n return ImmutableArray.Empty;\n }\n }\n\n public override ImmutableArray DeclaringSyntaxReferences\n {\n get\n {\n return ImmutableArray.Empty;\n }\n }\n\n /// \n /// Returns the arity of this type, or the number of type parameters it takes.\n /// A non-generic type has zero arity.\n /// \n public override int Arity\n {\n get\n {\n return 0;\n }\n }\n\n /// \n /// Gets the name of this symbol. Symbols without a name return the empty string; null is\n /// never returned.\n /// \n public override string Name\n {\n get\n {\n return string.Empty;\n }\n }\n\n /// \n /// Returns the type arguments that have been substituted for the type parameters. \n /// If nothing has been substituted for a give type parameters,\n /// then the type parameter itself is consider the type argument.\n /// \n internal override ImmutableArray TypeArgumentsWithAnnotationsNoUseSiteDiagnostics\n {\n get\n {\n return GetTypeParametersAsTypeArguments();\n }\n }\n\n /// \n /// Returns the type parameters that this type has. If this is a non-generic type,\n /// returns an empty ImmutableArray. \n /// \n public override ImmutableArray TypeParameters\n {\n get\n {\n if (_lazyTypeParameters.IsDefault)\n {\n ImmutableInterlocked.InterlockedCompareExchange(ref _lazyTypeParameters,\n GetTypeParameters(),\n default(ImmutableArray));\n }\n return _lazyTypeParameters;\n }\n }\n\n private ImmutableArray GetTypeParameters()\n {\n int arity = this.Arity;\n if (arity == 0)\n {\n return ImmutableArray.Empty;\n }\n else\n {\n var @params = new TypeParameterSymbol[arity];\n for (int i = 0; i < arity; i++)\n {\n @params[i] = new ErrorTypeParameterSymbol(this, string.Empty, i);\n }\n return @params.AsImmutableOrNull();\n }\n }\n\n /// \n /// Returns the type symbol that this type was constructed from. This type symbol\n /// has the same containing type (if any), but has type arguments that are the same\n /// as the type parameters (although its containing type might not).\n /// \n public override NamedTypeSymbol ConstructedFrom\n {\n get\n {\n return this;\n }\n }\n\n /// \n /// Implements visitor pattern.\n /// \n internal override TResult Accept(CSharpSymbolVisitor visitor, TArgument argument)\n {\n return visitor.VisitErrorType(this, argument);\n }\n\n // Only the compiler should create error symbols.\n internal ErrorTypeSymbol(TupleExtraData? tupleData = null)\n : base(tupleData)\n {\n }\n\n /// \n /// Get this accessibility that was declared on this symbol. For symbols that do not have\n /// accessibility declared on them, returns NotApplicable.\n /// \n public sealed override Accessibility DeclaredAccessibility\n {\n get\n {\n return Accessibility.NotApplicable;\n }\n }\n\n /// \n /// Returns true if this symbol is \"static\"; i.e., declared with the \"static\" modifier or\n /// implicitly static.\n /// \n public sealed override bool IsStatic\n {\n get\n {\n return false;\n }\n }\n\n /// \n /// Returns true if this symbol was declared as requiring an override; i.e., declared with\n /// the \"abstract\" modifier. Also returns true on a type declared as \"abstract\", all\n /// interface types, and members of interface types.\n /// \n public sealed override bool IsAbstract\n {\n get\n {\n return false;\n }\n }\n\n /// \n /// Returns true if this symbol was declared to override a base class member and was also\n /// sealed from further overriding; i.e., declared with the \"sealed\" modifier. Also set for\n /// types that do not allow a derived class (declared with \"sealed\" or \"static\" or \"struct\"\n /// or \"enum\" or \"delegate\").\n /// \n public sealed override bool IsSealed\n {\n get\n {\n return false;\n }\n }\n\n internal sealed override bool HasSpecialName\n {\n get { return false; }\n }\n\n public sealed override bool MightContainExtensionMethods\n {\n get\n {\n return false;\n }\n }\n\n internal override NamedTypeSymbol? BaseTypeNoUseSiteDiagnostics => null;\n\n internal override bool HasCodeAnalysisEmbeddedAttribute => false;\n\n internal override bool IsInterpolatedStringHandlerType => false;\n\n internal override ImmutableArray InterfacesNoUseSiteDiagnostics(ConsList? basesBeingResolved)\n {\n return ImmutableArray.Empty;\n }\n\n internal override ImmutableArray GetInterfacesToEmit()\n {\n return ImmutableArray.Empty;\n }\n\n internal override NamedTypeSymbol? GetDeclaredBaseType(ConsList basesBeingResolved)\n {\n return null;\n }\n\n internal override ImmutableArray GetDeclaredInterfaces(ConsList basesBeingResolved)\n {\n return ImmutableArray.Empty;\n }\n\n protected override NamedTypeSymbol ConstructCore(ImmutableArray typeArguments, bool unbound)\n {\n return new ConstructedErrorTypeSymbol(this, typeArguments);\n }\n\n internal override NamedTypeSymbol AsMember(NamedTypeSymbol newOwner)\n {\n Debug.Assert(this.IsDefinition);\n Debug.Assert(ReferenceEquals(newOwner.OriginalDefinition, this.ContainingSymbol?.OriginalDefinition));\n return newOwner.IsDefinition ? this : new SubstitutedNestedErrorTypeSymbol(newOwner, this);\n }\n\n internal sealed override bool ShouldAddWinRTMembers\n {\n get { return false; }\n }\n\n internal sealed override bool IsWindowsRuntimeImport\n {\n get { return false; }\n }\n\n internal sealed override TypeLayout Layout\n {\n get { return default(TypeLayout); }\n }\n\n internal override CharSet MarshallingCharSet\n {\n get { return DefaultMarshallingCharSet; }\n }\n\n public sealed override bool IsSerializable\n {\n get { return false; }\n }\n\n internal sealed override bool HasDeclarativeSecurity\n {\n get { return false; }\n }\n\n internal sealed override bool IsComImport\n {\n get { return false; }\n }\n\n internal sealed override ObsoleteAttributeData? ObsoleteAttributeData\n {\n get { return null; }\n }\n\n internal sealed override IEnumerable GetSecurityInformation()\n {\n throw ExceptionUtilities.Unreachable;\n }\n\n internal sealed override ImmutableArray GetAppliedConditionalSymbols()\n {\n return ImmutableArray.Empty;\n }\n\n internal override AttributeUsageInfo GetAttributeUsageInfo()\n {\n return AttributeUsageInfo.Null;\n }\n\n internal virtual bool Unreported\n {\n get { return false; }\n }\n\n public sealed override bool AreLocalsZeroed\n {\n get { throw ExceptionUtilities.Unreachable; }\n }\n\n internal override NamedTypeSymbol AsNativeInteger() => throw ExceptionUtilities.Unreachable;\n\n internal override NamedTypeSymbol? NativeIntegerUnderlyingType => null;\n\n protected sealed override ISymbol CreateISymbol()\n {\n return new PublicModel.ErrorTypeSymbol(this, DefaultNullableAnnotation);\n }\n\n protected sealed override ITypeSymbol CreateITypeSymbol(CodeAnalysis.NullableAnnotation nullableAnnotation)\n {\n Debug.Assert(nullableAnnotation != DefaultNullableAnnotation);\n return new PublicModel.ErrorTypeSymbol(this, nullableAnnotation);\n }\n\n internal sealed override bool IsRecord => false;\n internal override bool IsRecordStruct => false;\n internal sealed override bool HasPossibleWellKnownCloneMethod() => false;\n\n internal sealed override IEnumerable<(MethodSymbol Body, MethodSymbol Implemented)> SynthesizedInterfaceMethodImpls()\n {\n return SpecializedCollections.EmptyEnumerable<(MethodSymbol Body, MethodSymbol Implemented)>();\n }\n }\n\n internal abstract class SubstitutedErrorTypeSymbol : ErrorTypeSymbol\n {\n private readonly ErrorTypeSymbol _originalDefinition;\n private int _hashCode;\n\n protected SubstitutedErrorTypeSymbol(ErrorTypeSymbol originalDefinition, TupleExtraData? tupleData = null)\n : base(tupleData)\n {\n _originalDefinition = originalDefinition;\n }\n\n public override NamedTypeSymbol OriginalDefinition\n {\n get { return _originalDefinition; }\n }\n\n internal override bool MangleName\n {\n get { return _originalDefinition.MangleName; }\n }\n\n internal override DiagnosticInfo? ErrorInfo\n {\n get { return _originalDefinition.ErrorInfo; }\n }\n\n public override int Arity\n {\n get { return _originalDefinition.Arity; }\n }\n\n public override string Name\n {\n get { return _originalDefinition.Name; }\n }\n\n public override ImmutableArray Locations\n {\n get { return _originalDefinition.Locations; }\n }\n\n public override ImmutableArray CandidateSymbols\n {\n get { return _originalDefinition.CandidateSymbols; }\n }\n\n internal override LookupResultKind ResultKind\n {\n get { return _originalDefinition.ResultKind; }\n }\n\n internal override UseSiteInfo GetUseSiteInfo()\n {\n return _originalDefinition.GetUseSiteInfo();\n }\n\n public override int GetHashCode()\n {\n if (_hashCode == 0)\n {\n _hashCode = this.ComputeHashCode();\n }\n return _hashCode;\n }\n }\n\n internal sealed class ConstructedErrorTypeSymbol : SubstitutedErrorTypeSymbol\n {\n private readonly ErrorTypeSymbol _constructedFrom;\n private readonly ImmutableArray _typeArgumentsWithAnnotations;\n private readonly TypeMap _map;\n\n public ConstructedErrorTypeSymbol(ErrorTypeSymbol constructedFrom, ImmutableArray typeArgumentsWithAnnotations, TupleExtraData? tupleData = null) :\n base((ErrorTypeSymbol)constructedFrom.OriginalDefinition, tupleData)\n {\n _constructedFrom = constructedFrom;\n _typeArgumentsWithAnnotations = typeArgumentsWithAnnotations;\n _map = new TypeMap(constructedFrom.ContainingType, constructedFrom.OriginalDefinition.TypeParameters, typeArgumentsWithAnnotations);\n }\n\n protected override NamedTypeSymbol WithTupleDataCore(TupleExtraData newData)\n {\n return new ConstructedErrorTypeSymbol(_constructedFrom, _typeArgumentsWithAnnotations, tupleData: newData);\n }\n\n public override ImmutableArray TypeParameters\n {\n get { return _constructedFrom.TypeParameters; }\n }\n\n internal override ImmutableArray TypeArgumentsWithAnnotationsNoUseSiteDiagnostics\n {\n get { return _typeArgumentsWithAnnotations; }\n }\n\n public override NamedTypeSymbol ConstructedFrom\n {\n get { return _constructedFrom; }\n }\n\n public override Symbol? ContainingSymbol\n {\n get { return _constructedFrom.ContainingSymbol; }\n }\n\n internal override TypeMap TypeSubstitution\n {\n get { return _map; }\n }\n }\n\n internal sealed class SubstitutedNestedErrorTypeSymbol : SubstitutedErrorTypeSymbol\n {\n private readonly NamedTypeSymbol _containingSymbol;\n private readonly ImmutableArray _typeParameters;\n private readonly TypeMap _map;\n\n public SubstitutedNestedErrorTypeSymbol(NamedTypeSymbol containingSymbol, ErrorTypeSymbol originalDefinition) :\n base(originalDefinition)\n {\n _containingSymbol = containingSymbol;\n _map = containingSymbol.TypeSubstitution.WithAlphaRename(originalDefinition, this, out _typeParameters);\n }\n\n public override ImmutableArray TypeParameters\n {\n get { return _typeParameters; }\n }\n\n internal override ImmutableArray TypeArgumentsWithAnnotationsNoUseSiteDiagnostics\n {\n get { return GetTypeParametersAsTypeArguments(); }\n }\n\n public override NamedTypeSymbol ConstructedFrom\n {\n get { return this; }\n }\n\n public override Symbol ContainingSymbol\n {\n get { return _containingSymbol; }\n }\n\n internal override TypeMap TypeSubstitution\n {\n get { return _map; }\n }\n\n protected override NamedTypeSymbol WithTupleDataCore(TupleExtraData newData)\n => throw ExceptionUtilities.Unreachable;\n }\n}\n"},"after_content":{"kind":"string","value":"// Licensed to the .NET Foundation under one or more agreements.\n// The .NET Foundation licenses this file to you under the MIT license.\n// See the LICENSE file in the project root for more information.\n\nusing Roslyn.Utilities;\nusing System.Collections.Generic;\nusing System.Collections.Immutable;\nusing System.Diagnostics;\nusing System.Runtime.InteropServices;\n\nnamespace Microsoft.CodeAnalysis.CSharp.Symbols\n{\n /// \n /// An ErrorSymbol is used when the compiler cannot determine a symbol object to return because\n /// of an error. For example, if a field is declared \"Goo x;\", and the type \"Goo\" cannot be\n /// found, an ErrorSymbol is returned when asking the field \"x\" what it's type is.\n /// \n internal abstract partial class ErrorTypeSymbol : NamedTypeSymbol\n {\n internal static readonly ErrorTypeSymbol UnknownResultType = new UnsupportedMetadataTypeSymbol();\n\n private ImmutableArray _lazyTypeParameters;\n\n /// \n /// The underlying error.\n /// \n internal abstract DiagnosticInfo? ErrorInfo { get; }\n\n /// \n /// Summary of the reason why the type is bad.\n /// \n internal virtual LookupResultKind ResultKind { get { return LookupResultKind.Empty; } }\n\n /// \n /// Called by to perform substitution\n /// on types with TypeKind ErrorType. The general pattern is to use the type map\n /// to perform substitution on the wrapped type, if any, and then construct a new\n /// error type symbol from the result (if there was a change).\n /// \n internal TypeWithAnnotations Substitute(AbstractTypeMap typeMap)\n {\n return TypeWithAnnotations.Create(typeMap.SubstituteNamedType(this));\n }\n\n /// \n /// When constructing this ErrorTypeSymbol, there may have been symbols that seemed to\n /// be what the user intended, but were unsuitable. For example, a type might have been\n /// inaccessible, or ambiguous. This property returns the possible symbols that the user\n /// might have intended. It will return no symbols if no possible symbols were found.\n /// See the CandidateReason property to understand why the symbols were unsuitable.\n /// \n public virtual ImmutableArray CandidateSymbols\n {\n get\n {\n return ImmutableArray.Empty;\n }\n }\n\n ///\n /// If CandidateSymbols returns one or more symbols, returns the reason that those\n /// symbols were not chosen. Otherwise, returns None.\n /// \n public CandidateReason CandidateReason\n {\n get\n {\n if (!CandidateSymbols.IsEmpty)\n {\n Debug.Assert(ResultKind != LookupResultKind.Viable, \"Shouldn't have viable result kind on error symbol\");\n return ResultKind.ToCandidateReason();\n }\n else\n {\n return CandidateReason.None;\n }\n }\n }\n\n internal override UseSiteInfo GetUseSiteInfo()\n {\n return new UseSiteInfo(this.ErrorInfo);\n }\n\n /// \n /// Returns true if this type is known to be a reference type. It is never the case that\n /// IsReferenceType and IsValueType both return true. However, for an unconstrained type\n /// parameter, IsReferenceType and IsValueType will both return false.\n /// \n public override bool IsReferenceType\n {\n // TODO: Consider returning False.\n get { return true; }\n }\n\n /// \n /// Returns true if this type is known to be a value type. It is never the case that\n /// IsReferenceType and IsValueType both return true. However, for an unconstrained type\n /// parameter, IsReferenceType and IsValueType will both return false.\n /// \n public sealed override bool IsValueType\n {\n get { return false; }\n }\n\n public sealed override bool IsRefLikeType\n {\n get\n {\n return false;\n }\n }\n\n public sealed override bool IsReadOnly\n {\n get\n {\n return false;\n }\n }\n\n /// \n /// Collection of names of members declared within this type.\n /// \n public override IEnumerable MemberNames\n {\n get\n {\n return SpecializedCollections.EmptyEnumerable();\n }\n }\n\n /// \n /// Get all the members of this symbol.\n /// \n /// An ImmutableArray containing all the members of this symbol. If this symbol has no members,\n /// returns an empty ImmutableArray. Never returns Null.\n public override ImmutableArray GetMembers()\n {\n if (IsTupleType)\n {\n var result = MakeSynthesizedTupleMembers(ImmutableArray.Empty);\n RoslynDebug.Assert(result is object);\n return result.ToImmutableAndFree();\n }\n\n return ImmutableArray.Empty;\n }\n\n /// \n /// Get all the members of this symbol that have a particular name.\n /// \n /// An ImmutableArray containing all the members of this symbol with the given name. If there are\n /// no members with this name, returns an empty ImmutableArray. Never returns Null.\n public override ImmutableArray GetMembers(string name)\n {\n return GetMembers().WhereAsArray((m, name) => m.Name == name, name);\n }\n\n internal sealed override IEnumerable GetFieldsToEmit()\n {\n throw ExceptionUtilities.Unreachable;\n }\n\n internal override ImmutableArray GetEarlyAttributeDecodingMembers()\n {\n return this.GetMembersUnordered();\n }\n\n internal override ImmutableArray GetEarlyAttributeDecodingMembers(string name)\n {\n return this.GetMembers(name);\n }\n\n /// \n /// Get all the members of this symbol that are types.\n /// \n /// An ImmutableArray containing all the types that are members of this symbol. If this symbol has no type members,\n /// returns an empty ImmutableArray. Never returns null.\n public override ImmutableArray GetTypeMembers()\n {\n return ImmutableArray.Empty;\n }\n\n /// \n /// Get all the members of this symbol that are types that have a particular name, of any arity.\n /// \n /// An ImmutableArray containing all the types that are members of this symbol with the given name.\n /// If this symbol has no type members with this name,\n /// returns an empty ImmutableArray. Never returns null.\n public override ImmutableArray GetTypeMembers(string name)\n {\n return ImmutableArray.Empty;\n }\n\n /// \n /// Get all the members of this symbol that are types that have a particular name and arity\n /// \n /// An ImmutableArray containing all the types that are members of this symbol with the given name and arity.\n /// If this symbol has no type members with this name and arity,\n /// returns an empty ImmutableArray. Never returns null.\n public override ImmutableArray GetTypeMembers(string name, int arity)\n {\n return ImmutableArray.Empty;\n }\n\n /// \n /// Gets the kind of this symbol.\n /// \n public sealed override SymbolKind Kind\n {\n get\n {\n return SymbolKind.ErrorType;\n }\n }\n\n /// \n /// Gets the kind of this type.\n /// \n public sealed override TypeKind TypeKind\n {\n get\n {\n return TypeKind.Error;\n }\n }\n\n internal sealed override bool IsInterface\n {\n get { return false; }\n }\n\n /// \n /// Get the symbol that logically contains this symbol. \n /// \n public override Symbol? ContainingSymbol\n {\n get\n {\n return null;\n }\n }\n\n /// \n /// Gets the locations where this symbol was originally defined, either in source or\n /// metadata. Some symbols (for example, partial classes) may be defined in more than one\n /// location.\n /// \n public override ImmutableArray Locations\n {\n get\n {\n return ImmutableArray.Empty;\n }\n }\n\n public override ImmutableArray DeclaringSyntaxReferences\n {\n get\n {\n return ImmutableArray.Empty;\n }\n }\n\n /// \n /// Returns the arity of this type, or the number of type parameters it takes.\n /// A non-generic type has zero arity.\n /// \n public override int Arity\n {\n get\n {\n return 0;\n }\n }\n\n /// \n /// Gets the name of this symbol. Symbols without a name return the empty string; null is\n /// never returned.\n /// \n public override string Name\n {\n get\n {\n return string.Empty;\n }\n }\n\n /// \n /// Returns the type arguments that have been substituted for the type parameters. \n /// If nothing has been substituted for a give type parameters,\n /// then the type parameter itself is consider the type argument.\n /// \n internal override ImmutableArray TypeArgumentsWithAnnotationsNoUseSiteDiagnostics\n {\n get\n {\n return GetTypeParametersAsTypeArguments();\n }\n }\n\n /// \n /// Returns the type parameters that this type has. If this is a non-generic type,\n /// returns an empty ImmutableArray. \n /// \n public override ImmutableArray TypeParameters\n {\n get\n {\n if (_lazyTypeParameters.IsDefault)\n {\n ImmutableInterlocked.InterlockedCompareExchange(ref _lazyTypeParameters,\n GetTypeParameters(),\n default(ImmutableArray));\n }\n return _lazyTypeParameters;\n }\n }\n\n private ImmutableArray GetTypeParameters()\n {\n int arity = this.Arity;\n if (arity == 0)\n {\n return ImmutableArray.Empty;\n }\n else\n {\n var @params = new TypeParameterSymbol[arity];\n for (int i = 0; i < arity; i++)\n {\n @params[i] = new ErrorTypeParameterSymbol(this, string.Empty, i);\n }\n return @params.AsImmutableOrNull();\n }\n }\n\n /// \n /// Returns the type symbol that this type was constructed from. This type symbol\n /// has the same containing type (if any), but has type arguments that are the same\n /// as the type parameters (although its containing type might not).\n /// \n public override NamedTypeSymbol ConstructedFrom\n {\n get\n {\n return this;\n }\n }\n\n /// \n /// Implements visitor pattern.\n /// \n internal override TResult Accept(CSharpSymbolVisitor visitor, TArgument argument)\n {\n return visitor.VisitErrorType(this, argument);\n }\n\n // Only the compiler should create error symbols.\n internal ErrorTypeSymbol(TupleExtraData? tupleData = null)\n : base(tupleData)\n {\n }\n\n /// \n /// Get this accessibility that was declared on this symbol. For symbols that do not have\n /// accessibility declared on them, returns NotApplicable.\n /// \n public sealed override Accessibility DeclaredAccessibility\n {\n get\n {\n return Accessibility.NotApplicable;\n }\n }\n\n /// \n /// Returns true if this symbol is \"static\"; i.e., declared with the \"static\" modifier or\n /// implicitly static.\n /// \n public sealed override bool IsStatic\n {\n get\n {\n return false;\n }\n }\n\n /// \n /// Returns true if this symbol was declared as requiring an override; i.e., declared with\n /// the \"abstract\" modifier. Also returns true on a type declared as \"abstract\", all\n /// interface types, and members of interface types.\n /// \n public sealed override bool IsAbstract\n {\n get\n {\n return false;\n }\n }\n\n /// \n /// Returns true if this symbol was declared to override a base class member and was also\n /// sealed from further overriding; i.e., declared with the \"sealed\" modifier. Also set for\n /// types that do not allow a derived class (declared with \"sealed\" or \"static\" or \"struct\"\n /// or \"enum\" or \"delegate\").\n /// \n public sealed override bool IsSealed\n {\n get\n {\n return false;\n }\n }\n\n internal sealed override bool HasSpecialName\n {\n get { return false; }\n }\n\n public sealed override bool MightContainExtensionMethods\n {\n get\n {\n return false;\n }\n }\n\n internal override NamedTypeSymbol? BaseTypeNoUseSiteDiagnostics => null;\n\n internal override bool HasCodeAnalysisEmbeddedAttribute => false;\n\n internal override bool IsInterpolatedStringHandlerType => false;\n\n internal override ImmutableArray InterfacesNoUseSiteDiagnostics(ConsList? basesBeingResolved)\n {\n return ImmutableArray.Empty;\n }\n\n internal override ImmutableArray GetInterfacesToEmit()\n {\n return ImmutableArray.Empty;\n }\n\n internal override NamedTypeSymbol? GetDeclaredBaseType(ConsList basesBeingResolved)\n {\n return null;\n }\n\n internal override ImmutableArray GetDeclaredInterfaces(ConsList basesBeingResolved)\n {\n return ImmutableArray.Empty;\n }\n\n protected override NamedTypeSymbol ConstructCore(ImmutableArray typeArguments, bool unbound)\n {\n return new ConstructedErrorTypeSymbol(this, typeArguments);\n }\n\n internal override NamedTypeSymbol AsMember(NamedTypeSymbol newOwner)\n {\n Debug.Assert(this.IsDefinition);\n Debug.Assert(ReferenceEquals(newOwner.OriginalDefinition, this.ContainingSymbol?.OriginalDefinition));\n return newOwner.IsDefinition ? this : new SubstitutedNestedErrorTypeSymbol(newOwner, this);\n }\n\n internal sealed override bool ShouldAddWinRTMembers\n {\n get { return false; }\n }\n\n internal sealed override bool IsWindowsRuntimeImport\n {\n get { return false; }\n }\n\n internal sealed override TypeLayout Layout\n {\n get { return default(TypeLayout); }\n }\n\n internal override CharSet MarshallingCharSet\n {\n get { return DefaultMarshallingCharSet; }\n }\n\n public sealed override bool IsSerializable\n {\n get { return false; }\n }\n\n internal sealed override bool HasDeclarativeSecurity\n {\n get { return false; }\n }\n\n internal sealed override bool IsComImport\n {\n get { return false; }\n }\n\n internal sealed override ObsoleteAttributeData? ObsoleteAttributeData\n {\n get { return null; }\n }\n\n internal sealed override IEnumerable GetSecurityInformation()\n {\n throw ExceptionUtilities.Unreachable;\n }\n\n internal sealed override ImmutableArray GetAppliedConditionalSymbols()\n {\n return ImmutableArray.Empty;\n }\n\n internal override AttributeUsageInfo GetAttributeUsageInfo()\n {\n return AttributeUsageInfo.Null;\n }\n\n internal virtual bool Unreported\n {\n get { return false; }\n }\n\n public sealed override bool AreLocalsZeroed\n {\n get { throw ExceptionUtilities.Unreachable; }\n }\n\n internal override NamedTypeSymbol AsNativeInteger() => throw ExceptionUtilities.Unreachable;\n\n internal override NamedTypeSymbol? NativeIntegerUnderlyingType => null;\n\n protected sealed override ISymbol CreateISymbol()\n {\n return new PublicModel.ErrorTypeSymbol(this, DefaultNullableAnnotation);\n }\n\n protected sealed override ITypeSymbol CreateITypeSymbol(CodeAnalysis.NullableAnnotation nullableAnnotation)\n {\n Debug.Assert(nullableAnnotation != DefaultNullableAnnotation);\n return new PublicModel.ErrorTypeSymbol(this, nullableAnnotation);\n }\n\n internal sealed override bool IsRecord => false;\n internal override bool IsRecordStruct => false;\n internal sealed override bool HasPossibleWellKnownCloneMethod() => false;\n\n internal sealed override IEnumerable<(MethodSymbol Body, MethodSymbol Implemented)> SynthesizedInterfaceMethodImpls()\n {\n return SpecializedCollections.EmptyEnumerable<(MethodSymbol Body, MethodSymbol Implemented)>();\n }\n }\n\n internal abstract class SubstitutedErrorTypeSymbol : ErrorTypeSymbol\n {\n private readonly ErrorTypeSymbol _originalDefinition;\n private int _hashCode;\n\n protected SubstitutedErrorTypeSymbol(ErrorTypeSymbol originalDefinition, TupleExtraData? tupleData = null)\n : base(tupleData)\n {\n _originalDefinition = originalDefinition;\n }\n\n public override NamedTypeSymbol OriginalDefinition\n {\n get { return _originalDefinition; }\n }\n\n internal override bool MangleName\n {\n get { return _originalDefinition.MangleName; }\n }\n\n internal override DiagnosticInfo? ErrorInfo\n {\n get { return _originalDefinition.ErrorInfo; }\n }\n\n public override int Arity\n {\n get { return _originalDefinition.Arity; }\n }\n\n public override string Name\n {\n get { return _originalDefinition.Name; }\n }\n\n public override ImmutableArray Locations\n {\n get { return _originalDefinition.Locations; }\n }\n\n public override ImmutableArray CandidateSymbols\n {\n get { return _originalDefinition.CandidateSymbols; }\n }\n\n internal override LookupResultKind ResultKind\n {\n get { return _originalDefinition.ResultKind; }\n }\n\n internal override UseSiteInfo GetUseSiteInfo()\n {\n return _originalDefinition.GetUseSiteInfo();\n }\n\n public override int GetHashCode()\n {\n if (_hashCode == 0)\n {\n _hashCode = this.ComputeHashCode();\n }\n return _hashCode;\n }\n }\n\n internal sealed class ConstructedErrorTypeSymbol : SubstitutedErrorTypeSymbol\n {\n private readonly ErrorTypeSymbol _constructedFrom;\n private readonly ImmutableArray _typeArgumentsWithAnnotations;\n private readonly TypeMap _map;\n\n public ConstructedErrorTypeSymbol(ErrorTypeSymbol constructedFrom, ImmutableArray typeArgumentsWithAnnotations, TupleExtraData? tupleData = null) :\n base((ErrorTypeSymbol)constructedFrom.OriginalDefinition, tupleData)\n {\n _constructedFrom = constructedFrom;\n _typeArgumentsWithAnnotations = typeArgumentsWithAnnotations;\n _map = new TypeMap(constructedFrom.ContainingType, constructedFrom.OriginalDefinition.TypeParameters, typeArgumentsWithAnnotations);\n }\n\n protected override NamedTypeSymbol WithTupleDataCore(TupleExtraData newData)\n {\n return new ConstructedErrorTypeSymbol(_constructedFrom, _typeArgumentsWithAnnotations, tupleData: newData);\n }\n\n public override ImmutableArray TypeParameters\n {\n get { return _constructedFrom.TypeParameters; }\n }\n\n internal override ImmutableArray TypeArgumentsWithAnnotationsNoUseSiteDiagnostics\n {\n get { return _typeArgumentsWithAnnotations; }\n }\n\n public override NamedTypeSymbol ConstructedFrom\n {\n get { return _constructedFrom; }\n }\n\n public override Symbol? ContainingSymbol\n {\n get { return _constructedFrom.ContainingSymbol; }\n }\n\n internal override TypeMap TypeSubstitution\n {\n get { return _map; }\n }\n }\n\n internal sealed class SubstitutedNestedErrorTypeSymbol : SubstitutedErrorTypeSymbol\n {\n private readonly NamedTypeSymbol _containingSymbol;\n private readonly ImmutableArray _typeParameters;\n private readonly TypeMap _map;\n\n public SubstitutedNestedErrorTypeSymbol(NamedTypeSymbol containingSymbol, ErrorTypeSymbol originalDefinition) :\n base(originalDefinition)\n {\n _containingSymbol = containingSymbol;\n _map = containingSymbol.TypeSubstitution.WithAlphaRename(originalDefinition, this, out _typeParameters);\n }\n\n public override ImmutableArray TypeParameters\n {\n get { return _typeParameters; }\n }\n\n internal override ImmutableArray TypeArgumentsWithAnnotationsNoUseSiteDiagnostics\n {\n get { return GetTypeParametersAsTypeArguments(); }\n }\n\n public override NamedTypeSymbol ConstructedFrom\n {\n get { return this; }\n }\n\n public override Symbol ContainingSymbol\n {\n get { return _containingSymbol; }\n }\n\n internal override TypeMap TypeSubstitution\n {\n get { return _map; }\n }\n\n protected override NamedTypeSymbol WithTupleDataCore(TupleExtraData newData)\n => throw ExceptionUtilities.Unreachable;\n }\n}\n"},"label":{"kind":"number","value":1,"string":"1"}}},{"rowIdx":1518,"cells":{"repo_name":{"kind":"string","value":"dotnet/roslyn"},"pr_number":{"kind":"number","value":56293,"string":"56,293"},"pr_title":{"kind":"string","value":"Control exposure of tuple fields"},"pr_description":{"kind":"string","value":"Fixes https://github.com/dotnet/roslyn/issues/51204\r\n\r\nThe point of this change is to remove the special case for tuples in `AssertMemberExposure`."},"author":{"kind":"string","value":"jcouv"},"date_created":{"kind":"timestamp","value":"2021-09-09T18:17:36Z","string":"2021-09-09T18:17:36Z"},"date_merged":{"kind":"timestamp","value":"2021-09-14T19:56:11Z","string":"2021-09-14T19:56:11Z"},"previous_commit":{"kind":"string","value":"dcadde85baf3b034319815445e453538a807ba4e"},"pr_commit":{"kind":"string","value":"0bcaa937e2560ad2e442e2a70386109f6195aab6"},"query":{"kind":"string","value":"Control exposure of tuple fields. Fixes https://github.com/dotnet/roslyn/issues/51204\r\n\r\nThe point of this change is to remove the special case for tuples in `AssertMemberExposure`."},"filepath":{"kind":"string","value":"./src/Compilers/CSharp/Portable/Symbols/Metadata/PE/PENamedTypeSymbol.cs"},"before_content":{"kind":"string","value":"// Licensed to the .NET Foundation under one or more agreements.\n// The .NET Foundation licenses this file to you under the MIT license.\n// See the LICENSE file in the project root for more information.\n\n#nullable disable\n\nusing System;\nusing System.Collections.Generic;\nusing System.Collections.Immutable;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.Linq;\nusing System.Runtime.InteropServices;\nusing System.Reflection;\nusing System.Reflection.Metadata;\nusing System.Threading;\nusing Microsoft.CodeAnalysis.CSharp.DocumentationComments;\nusing Microsoft.CodeAnalysis.CSharp.Emit;\nusing Microsoft.CodeAnalysis.PooledObjects;\nusing Roslyn.Utilities;\n\nnamespace Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE\n{\n /// \n /// The class to represent all types imported from a PE/module.\n /// \n internal abstract class PENamedTypeSymbol : NamedTypeSymbol\n {\n private static readonly Dictionary> s_emptyNestedTypes = new Dictionary>(EmptyComparer.Instance);\n\n private readonly NamespaceOrTypeSymbol _container;\n private readonly TypeDefinitionHandle _handle;\n private readonly string _name;\n private readonly TypeAttributes _flags;\n private readonly SpecialType _corTypeId;\n\n /// \n /// A set of all the names of the members in this type.\n /// We can get names without getting members (which is a more expensive operation)\n /// \n private ICollection _lazyMemberNames;\n\n /// \n /// We used to sort symbols on demand and relied on row ids to figure out the order between symbols of the same kind.\n /// However, that was fragile because, when map tables are used in metadata, row ids in the map table define the order\n /// and we don't have them.\n /// Members are grouped by kind. First we store fields, then methods, then properties, then events and finally nested types.\n /// Within groups, members are sorted based on declaration order.\n /// \n private ImmutableArray _lazyMembersInDeclarationOrder;\n\n /// \n /// A map of members immediately contained within this type \n /// grouped by their name (case-sensitively).\n /// \n private Dictionary> _lazyMembersByName;\n\n /// \n /// A map of types immediately contained within this type \n /// grouped by their name (case-sensitively).\n /// \n private Dictionary> _lazyNestedTypes;\n\n /// \n /// Lazily initialized by TypeKind property.\n /// \n private TypeKind _lazyKind;\n\n private NullableContextKind _lazyNullableContextValue;\n\n private NamedTypeSymbol _lazyBaseType = ErrorTypeSymbol.UnknownResultType;\n private ImmutableArray _lazyInterfaces = default(ImmutableArray);\n private NamedTypeSymbol _lazyDeclaredBaseType = ErrorTypeSymbol.UnknownResultType;\n private ImmutableArray _lazyDeclaredInterfaces = default(ImmutableArray);\n\n private Tuple _lazyDocComment;\n\n private CachedUseSiteInfo _lazyCachedUseSiteInfo = CachedUseSiteInfo.Uninitialized;\n\n // There is a bunch of type properties relevant only for enums or types with custom attributes.\n // It is fairly easy to check whether a type s is not \"uncommon\". So we store uncommon properties in \n // a separate class with a noUncommonProperties singleton used for cases when type is \"common\".\n // this is done purely to save memory with expectation that \"uncommon\" cases are indeed uncommon. \n #region \"Uncommon properties\"\n private static readonly UncommonProperties s_noUncommonProperties = new UncommonProperties();\n private UncommonProperties _lazyUncommonProperties;\n\n private UncommonProperties GetUncommonProperties()\n {\n var result = _lazyUncommonProperties;\n if (result != null)\n {\n#if DEBUG\n Debug.Assert(result != s_noUncommonProperties || result.IsDefaultValue(), \"default value was modified\");\n#endif\n return result;\n }\n\n if (this.IsUncommon())\n {\n result = new UncommonProperties();\n return Interlocked.CompareExchange(ref _lazyUncommonProperties, result, null) ?? result;\n }\n\n _lazyUncommonProperties = result = s_noUncommonProperties;\n return result;\n }\n\n // enums and types with custom attributes are considered uncommon\n private bool IsUncommon()\n {\n if (this.ContainingPEModule.HasAnyCustomAttributes(_handle))\n {\n return true;\n }\n\n if (this.TypeKind == TypeKind.Enum)\n {\n return true;\n }\n\n return false;\n }\n\n private class UncommonProperties\n {\n /// \n /// Need to import them for an enum from a linked assembly, when we are embedding it. These symbols are not included into lazyMembersInDeclarationOrder. \n /// \n internal ImmutableArray lazyInstanceEnumFields;\n internal NamedTypeSymbol lazyEnumUnderlyingType;\n\n // CONSIDER: Should we use a CustomAttributeBag for PE symbols?\n internal ImmutableArray lazyCustomAttributes;\n internal ImmutableArray lazyConditionalAttributeSymbols;\n internal ObsoleteAttributeData lazyObsoleteAttributeData = ObsoleteAttributeData.Uninitialized;\n internal AttributeUsageInfo lazyAttributeUsageInfo = AttributeUsageInfo.Null;\n internal ThreeState lazyContainsExtensionMethods;\n internal ThreeState lazyIsByRefLike;\n internal ThreeState lazyIsReadOnly;\n internal string lazyDefaultMemberName;\n internal NamedTypeSymbol lazyComImportCoClassType = ErrorTypeSymbol.UnknownResultType;\n internal ThreeState lazyHasEmbeddedAttribute = ThreeState.Unknown;\n internal ThreeState lazyHasInterpolatedStringHandlerAttribute = ThreeState.Unknown;\n\n#if DEBUG\n internal bool IsDefaultValue()\n {\n return lazyInstanceEnumFields.IsDefault &&\n (object)lazyEnumUnderlyingType == null &&\n lazyCustomAttributes.IsDefault &&\n lazyConditionalAttributeSymbols.IsDefault &&\n lazyObsoleteAttributeData == ObsoleteAttributeData.Uninitialized &&\n lazyAttributeUsageInfo.IsNull &&\n !lazyContainsExtensionMethods.HasValue() &&\n lazyDefaultMemberName == null &&\n (object)lazyComImportCoClassType == (object)ErrorTypeSymbol.UnknownResultType &&\n !lazyHasEmbeddedAttribute.HasValue() &&\n !lazyHasInterpolatedStringHandlerAttribute.HasValue();\n }\n#endif\n }\n\n #endregion // Uncommon properties\n\n internal static PENamedTypeSymbol Create(\n PEModuleSymbol moduleSymbol,\n PENamespaceSymbol containingNamespace,\n TypeDefinitionHandle handle,\n string emittedNamespaceName)\n {\n GenericParameterHandleCollection genericParameterHandles;\n ushort arity;\n BadImageFormatException mrEx = null;\n\n GetGenericInfo(moduleSymbol, handle, out genericParameterHandles, out arity, out mrEx);\n\n bool mangleName;\n PENamedTypeSymbol result;\n\n if (arity == 0)\n {\n result = new PENamedTypeSymbolNonGeneric(moduleSymbol, containingNamespace, handle, emittedNamespaceName, out mangleName);\n }\n else\n {\n result = new PENamedTypeSymbolGeneric(\n moduleSymbol,\n containingNamespace,\n handle,\n emittedNamespaceName,\n genericParameterHandles,\n arity,\n out mangleName);\n }\n\n if (mrEx != null)\n {\n result._lazyCachedUseSiteInfo.Initialize(new CSDiagnosticInfo(ErrorCode.ERR_BogusType, result));\n }\n\n return result;\n }\n\n private static void GetGenericInfo(PEModuleSymbol moduleSymbol, TypeDefinitionHandle handle, out GenericParameterHandleCollection genericParameterHandles, out ushort arity, out BadImageFormatException mrEx)\n {\n try\n {\n genericParameterHandles = moduleSymbol.Module.GetTypeDefGenericParamsOrThrow(handle);\n arity = (ushort)genericParameterHandles.Count;\n mrEx = null;\n }\n catch (BadImageFormatException e)\n {\n arity = 0;\n genericParameterHandles = default(GenericParameterHandleCollection);\n mrEx = e;\n }\n }\n\n internal static PENamedTypeSymbol Create(\n PEModuleSymbol moduleSymbol,\n PENamedTypeSymbol containingType,\n TypeDefinitionHandle handle)\n {\n GenericParameterHandleCollection genericParameterHandles;\n ushort metadataArity;\n BadImageFormatException mrEx = null;\n\n GetGenericInfo(moduleSymbol, handle, out genericParameterHandles, out metadataArity, out mrEx);\n\n ushort arity = 0;\n var containerMetadataArity = containingType.MetadataArity;\n\n if (metadataArity > containerMetadataArity)\n {\n arity = (ushort)(metadataArity - containerMetadataArity);\n }\n\n bool mangleName;\n PENamedTypeSymbol result;\n\n if (metadataArity == 0)\n {\n result = new PENamedTypeSymbolNonGeneric(moduleSymbol, containingType, handle, null, out mangleName);\n }\n else\n {\n result = new PENamedTypeSymbolGeneric(\n moduleSymbol,\n containingType,\n handle,\n null,\n genericParameterHandles,\n arity,\n out mangleName);\n }\n\n if (mrEx != null || metadataArity < containerMetadataArity)\n {\n result._lazyCachedUseSiteInfo.Initialize(new CSDiagnosticInfo(ErrorCode.ERR_BogusType, result));\n }\n\n return result;\n }\n\n private PENamedTypeSymbol(\n PEModuleSymbol moduleSymbol,\n NamespaceOrTypeSymbol container,\n TypeDefinitionHandle handle,\n string emittedNamespaceName,\n ushort arity,\n out bool mangleName)\n {\n Debug.Assert(!handle.IsNil);\n Debug.Assert((object)container != null);\n Debug.Assert(arity == 0 || this is PENamedTypeSymbolGeneric);\n\n string metadataName;\n bool makeBad = false;\n\n try\n {\n metadataName = moduleSymbol.Module.GetTypeDefNameOrThrow(handle);\n }\n catch (BadImageFormatException)\n {\n metadataName = string.Empty;\n makeBad = true;\n }\n\n _handle = handle;\n _container = container;\n\n try\n {\n _flags = moduleSymbol.Module.GetTypeDefFlagsOrThrow(handle);\n }\n catch (BadImageFormatException)\n {\n makeBad = true;\n }\n\n if (arity == 0)\n {\n _name = metadataName;\n mangleName = false;\n }\n else\n {\n // Unmangle name for a generic type.\n _name = MetadataHelpers.UnmangleMetadataNameForArity(metadataName, arity);\n Debug.Assert(ReferenceEquals(_name, metadataName) == (_name == metadataName));\n mangleName = !ReferenceEquals(_name, metadataName);\n }\n\n // check if this is one of the COR library types\n if (emittedNamespaceName != null &&\n moduleSymbol.ContainingAssembly.KeepLookingForDeclaredSpecialTypes &&\n this.DeclaredAccessibility == Accessibility.Public) // NB: this.flags was set above.\n {\n _corTypeId = SpecialTypes.GetTypeFromMetadataName(MetadataHelpers.BuildQualifiedName(emittedNamespaceName, metadataName));\n }\n else\n {\n _corTypeId = SpecialType.None;\n }\n\n if (makeBad)\n {\n _lazyCachedUseSiteInfo.Initialize(new CSDiagnosticInfo(ErrorCode.ERR_BogusType, this));\n }\n }\n\n public override SpecialType SpecialType\n {\n get\n {\n return _corTypeId;\n }\n }\n\n internal PEModuleSymbol ContainingPEModule\n {\n get\n {\n Symbol s = _container;\n\n while (s.Kind != SymbolKind.Namespace)\n {\n s = s.ContainingSymbol;\n }\n\n return ((PENamespaceSymbol)s).ContainingPEModule;\n }\n }\n\n internal override ModuleSymbol ContainingModule\n {\n get\n {\n return ContainingPEModule;\n }\n }\n\n public abstract override int Arity\n {\n get;\n }\n\n internal abstract override bool MangleName\n {\n get;\n }\n\n internal abstract int MetadataArity\n {\n get;\n }\n\n internal TypeDefinitionHandle Handle\n {\n get\n {\n return _handle;\n }\n }\n\n internal sealed override bool IsInterpolatedStringHandlerType\n {\n get\n {\n var uncommon = GetUncommonProperties();\n if (uncommon == s_noUncommonProperties)\n {\n return false;\n }\n\n if (!uncommon.lazyHasInterpolatedStringHandlerAttribute.HasValue())\n {\n uncommon.lazyHasInterpolatedStringHandlerAttribute = ContainingPEModule.Module.HasInterpolatedStringHandlerAttribute(_handle).ToThreeState();\n }\n\n return uncommon.lazyHasInterpolatedStringHandlerAttribute.Value();\n }\n }\n\n internal override bool HasCodeAnalysisEmbeddedAttribute\n {\n get\n {\n var uncommon = GetUncommonProperties();\n if (uncommon == s_noUncommonProperties)\n {\n return false;\n }\n\n if (!uncommon.lazyHasEmbeddedAttribute.HasValue())\n {\n uncommon.lazyHasEmbeddedAttribute = ContainingPEModule.Module.HasCodeAnalysisEmbeddedAttribute(_handle).ToThreeState();\n }\n\n return uncommon.lazyHasEmbeddedAttribute.Value();\n }\n }\n\n internal override NamedTypeSymbol BaseTypeNoUseSiteDiagnostics\n {\n get\n {\n if (ReferenceEquals(_lazyBaseType, ErrorTypeSymbol.UnknownResultType))\n {\n Interlocked.CompareExchange(ref _lazyBaseType, MakeAcyclicBaseType(), ErrorTypeSymbol.UnknownResultType);\n }\n\n return _lazyBaseType;\n }\n }\n\n internal override ImmutableArray InterfacesNoUseSiteDiagnostics(ConsList basesBeingResolved = null)\n {\n if (_lazyInterfaces.IsDefault)\n {\n ImmutableInterlocked.InterlockedCompareExchange(ref _lazyInterfaces, MakeAcyclicInterfaces(), default(ImmutableArray));\n }\n\n return _lazyInterfaces;\n }\n\n internal override ImmutableArray GetInterfacesToEmit()\n {\n return InterfacesNoUseSiteDiagnostics();\n }\n\n internal override NamedTypeSymbol GetDeclaredBaseType(ConsList basesBeingResolved)\n {\n return GetDeclaredBaseType(skipTransformsIfNecessary: false);\n }\n\n private NamedTypeSymbol GetDeclaredBaseType(bool skipTransformsIfNecessary)\n {\n if (ReferenceEquals(_lazyDeclaredBaseType, ErrorTypeSymbol.UnknownResultType))\n {\n var baseType = MakeDeclaredBaseType();\n if (baseType is object)\n {\n if (skipTransformsIfNecessary)\n {\n // If the transforms are not necessary, return early without updating the\n // base type field. This avoids cycles decoding nullability in particular.\n return baseType;\n }\n\n var moduleSymbol = ContainingPEModule;\n TypeSymbol decodedType = DynamicTypeDecoder.TransformType(baseType, 0, _handle, moduleSymbol);\n decodedType = NativeIntegerTypeDecoder.TransformType(decodedType, _handle, moduleSymbol);\n decodedType = TupleTypeDecoder.DecodeTupleTypesIfApplicable(decodedType, _handle, moduleSymbol);\n baseType = (NamedTypeSymbol)NullableTypeDecoder.TransformType(TypeWithAnnotations.Create(decodedType), _handle, moduleSymbol, accessSymbol: this, nullableContext: this).Type;\n }\n\n Interlocked.CompareExchange(ref _lazyDeclaredBaseType, baseType, ErrorTypeSymbol.UnknownResultType);\n }\n\n return _lazyDeclaredBaseType;\n }\n\n internal override ImmutableArray GetDeclaredInterfaces(ConsList basesBeingResolved)\n {\n if (_lazyDeclaredInterfaces.IsDefault)\n {\n ImmutableInterlocked.InterlockedCompareExchange(ref _lazyDeclaredInterfaces, MakeDeclaredInterfaces(), default(ImmutableArray));\n }\n\n return _lazyDeclaredInterfaces;\n }\n\n private NamedTypeSymbol MakeDeclaredBaseType()\n {\n if (!_flags.IsInterface())\n {\n try\n {\n var moduleSymbol = ContainingPEModule;\n EntityHandle token = moduleSymbol.Module.GetBaseTypeOfTypeOrThrow(_handle);\n if (!token.IsNil)\n {\n return (NamedTypeSymbol)new MetadataDecoder(moduleSymbol, this).GetTypeOfToken(token);\n }\n }\n catch (BadImageFormatException mrEx)\n {\n return new UnsupportedMetadataTypeSymbol(mrEx);\n }\n }\n\n return null;\n }\n\n private ImmutableArray MakeDeclaredInterfaces()\n {\n try\n {\n var moduleSymbol = ContainingPEModule;\n var interfaceImpls = moduleSymbol.Module.GetInterfaceImplementationsOrThrow(_handle);\n\n if (interfaceImpls.Count > 0)\n {\n var symbols = ArrayBuilder.GetInstance(interfaceImpls.Count);\n var tokenDecoder = new MetadataDecoder(moduleSymbol, this);\n\n foreach (var interfaceImpl in interfaceImpls)\n {\n EntityHandle interfaceHandle = moduleSymbol.Module.MetadataReader.GetInterfaceImplementation(interfaceImpl).Interface;\n TypeSymbol typeSymbol = tokenDecoder.GetTypeOfToken(interfaceHandle);\n\n typeSymbol = NativeIntegerTypeDecoder.TransformType(typeSymbol, interfaceImpl, moduleSymbol);\n typeSymbol = TupleTypeDecoder.DecodeTupleTypesIfApplicable(typeSymbol, interfaceImpl, moduleSymbol);\n typeSymbol = NullableTypeDecoder.TransformType(TypeWithAnnotations.Create(typeSymbol), interfaceImpl, moduleSymbol, accessSymbol: this, nullableContext: this).Type;\n\n var namedTypeSymbol = typeSymbol as NamedTypeSymbol ?? new UnsupportedMetadataTypeSymbol(); // interface list contains a bad type\n symbols.Add(namedTypeSymbol);\n }\n\n return symbols.ToImmutableAndFree();\n }\n\n return ImmutableArray.Empty;\n }\n catch (BadImageFormatException mrEx)\n {\n return ImmutableArray.Create(new UnsupportedMetadataTypeSymbol(mrEx));\n }\n }\n\n public override NamedTypeSymbol ConstructedFrom\n {\n get\n {\n return this;\n }\n }\n\n public override Symbol ContainingSymbol\n {\n get\n {\n return _container;\n }\n }\n\n public override NamedTypeSymbol ContainingType\n {\n get\n {\n return _container as NamedTypeSymbol;\n }\n }\n\n internal override bool IsRecord\n {\n get\n {\n var discardedUseSiteInfo = CompoundUseSiteInfo.Discarded;\n return SynthesizedRecordClone.FindValidCloneMethod(this, ref discardedUseSiteInfo) != null;\n }\n }\n\n // Record structs get erased when emitted to metadata\n internal override bool IsRecordStruct => false;\n\n public override Accessibility DeclaredAccessibility\n {\n get\n {\n Accessibility access = Accessibility.Private;\n\n switch (_flags & TypeAttributes.VisibilityMask)\n {\n case TypeAttributes.NestedAssembly:\n access = Accessibility.Internal;\n break;\n\n case TypeAttributes.NestedFamORAssem:\n access = Accessibility.ProtectedOrInternal;\n break;\n\n case TypeAttributes.NestedFamANDAssem:\n access = Accessibility.ProtectedAndInternal;\n break;\n\n case TypeAttributes.NestedPrivate:\n access = Accessibility.Private;\n break;\n\n case TypeAttributes.Public:\n case TypeAttributes.NestedPublic:\n access = Accessibility.Public;\n break;\n\n case TypeAttributes.NestedFamily:\n access = Accessibility.Protected;\n break;\n\n case TypeAttributes.NotPublic:\n access = Accessibility.Internal;\n break;\n\n default:\n throw ExceptionUtilities.UnexpectedValue(_flags & TypeAttributes.VisibilityMask);\n }\n\n return access;\n }\n }\n\n public override NamedTypeSymbol EnumUnderlyingType\n {\n get\n {\n var uncommon = GetUncommonProperties();\n if (uncommon == s_noUncommonProperties)\n {\n return null;\n }\n\n this.EnsureEnumUnderlyingTypeIsLoaded(uncommon);\n return uncommon.lazyEnumUnderlyingType;\n }\n }\n\n public override ImmutableArray GetAttributes()\n {\n var uncommon = GetUncommonProperties();\n if (uncommon == s_noUncommonProperties)\n {\n return ImmutableArray.Empty;\n }\n\n if (uncommon.lazyCustomAttributes.IsDefault)\n {\n var loadedCustomAttributes = ContainingPEModule.GetCustomAttributesForToken(\n Handle,\n out _,\n // Filter out [Extension]\n MightContainExtensionMethods ? AttributeDescription.CaseSensitiveExtensionAttribute : default,\n out _,\n // Filter out [Obsolete], unless it was user defined\n (IsRefLikeType && ObsoleteAttributeData is null) ? AttributeDescription.ObsoleteAttribute : default,\n out _,\n // Filter out [IsReadOnly]\n IsReadOnly ? AttributeDescription.IsReadOnlyAttribute : default,\n out _,\n // Filter out [IsByRefLike]\n IsRefLikeType ? AttributeDescription.IsByRefLikeAttribute : default);\n\n ImmutableInterlocked.InterlockedInitialize(ref uncommon.lazyCustomAttributes, loadedCustomAttributes);\n }\n\n return uncommon.lazyCustomAttributes;\n }\n\n internal override IEnumerable GetCustomAttributesToEmit(PEModuleBuilder moduleBuilder)\n {\n return GetAttributes();\n }\n\n internal override byte? GetNullableContextValue()\n {\n byte? value;\n if (!_lazyNullableContextValue.TryGetByte(out value))\n {\n value = ContainingPEModule.Module.HasNullableContextAttribute(_handle, out byte arg) ?\n arg :\n _container.GetNullableContextValue();\n _lazyNullableContextValue = value.ToNullableContextFlags();\n }\n return value;\n }\n\n internal override byte? GetLocalNullableContextValue()\n {\n throw ExceptionUtilities.Unreachable;\n }\n\n public override IEnumerable MemberNames\n {\n get\n {\n EnsureNonTypeMemberNamesAreLoaded();\n return _lazyMemberNames;\n }\n }\n\n private void EnsureNonTypeMemberNamesAreLoaded()\n {\n if (_lazyMemberNames == null)\n {\n var moduleSymbol = ContainingPEModule;\n var module = moduleSymbol.Module;\n\n var names = new HashSet();\n\n try\n {\n foreach (var methodDef in module.GetMethodsOfTypeOrThrow(_handle))\n {\n try\n {\n names.Add(module.GetMethodDefNameOrThrow(methodDef));\n }\n catch (BadImageFormatException)\n { }\n }\n }\n catch (BadImageFormatException)\n { }\n\n try\n {\n foreach (var propertyDef in module.GetPropertiesOfTypeOrThrow(_handle))\n {\n try\n {\n names.Add(module.GetPropertyDefNameOrThrow(propertyDef));\n }\n catch (BadImageFormatException)\n { }\n }\n }\n catch (BadImageFormatException)\n { }\n\n try\n {\n foreach (var eventDef in module.GetEventsOfTypeOrThrow(_handle))\n {\n try\n {\n names.Add(module.GetEventDefNameOrThrow(eventDef));\n }\n catch (BadImageFormatException)\n { }\n }\n }\n catch (BadImageFormatException)\n { }\n\n try\n {\n foreach (var fieldDef in module.GetFieldsOfTypeOrThrow(_handle))\n {\n try\n {\n names.Add(module.GetFieldDefNameOrThrow(fieldDef));\n }\n catch (BadImageFormatException)\n { }\n }\n }\n catch (BadImageFormatException)\n { }\n\n // From C#'s perspective, structs always have a public constructor\n // (even if it's not in metadata). Add it unconditionally and let\n // the hash set de-dup.\n if (this.IsValueType)\n {\n names.Add(WellKnownMemberNames.InstanceConstructorName);\n }\n\n Interlocked.CompareExchange(ref _lazyMemberNames, CreateReadOnlyMemberNames(names), null);\n }\n }\n\n private static ICollection CreateReadOnlyMemberNames(HashSet names)\n {\n switch (names.Count)\n {\n case 0:\n return SpecializedCollections.EmptySet();\n\n case 1:\n return SpecializedCollections.SingletonCollection(names.First());\n\n case 2:\n case 3:\n case 4:\n case 5:\n case 6:\n // PERF: Small collections can be implemented as ImmutableArray.\n // While lookup is O(n), when n is small, the memory savings are more valuable.\n // Size 6 was chosen because that represented 50% of the names generated in the Picasso end to end.\n // This causes boxing, but that's still superior to a wrapped HashSet\n return ImmutableArray.CreateRange(names);\n\n default:\n return SpecializedCollections.ReadOnlySet(names);\n }\n }\n\n public override ImmutableArray GetMembers()\n {\n EnsureAllMembersAreLoaded();\n return _lazyMembersInDeclarationOrder;\n }\n\n private IEnumerable GetEnumFieldsToEmit()\n {\n var uncommon = GetUncommonProperties();\n if (uncommon == s_noUncommonProperties)\n {\n yield break;\n }\n\n var moduleSymbol = this.ContainingPEModule;\n var module = moduleSymbol.Module;\n\n // Non-static fields of enum types are not imported by default because they are not bindable,\n // but we need them for NoPia.\n\n var fieldDefs = ArrayBuilder.GetInstance();\n\n try\n {\n foreach (var fieldDef in module.GetFieldsOfTypeOrThrow(_handle))\n {\n fieldDefs.Add(fieldDef);\n }\n }\n catch (BadImageFormatException)\n { }\n\n if (uncommon.lazyInstanceEnumFields.IsDefault)\n {\n var builder = ArrayBuilder.GetInstance();\n\n foreach (var fieldDef in fieldDefs)\n {\n try\n {\n FieldAttributes fieldFlags = module.GetFieldDefFlagsOrThrow(fieldDef);\n if ((fieldFlags & FieldAttributes.Static) == 0 && ModuleExtensions.ShouldImportField(fieldFlags, moduleSymbol.ImportOptions))\n {\n builder.Add(new PEFieldSymbol(moduleSymbol, this, fieldDef));\n }\n }\n catch (BadImageFormatException)\n { }\n }\n\n ImmutableInterlocked.InterlockedInitialize(ref uncommon.lazyInstanceEnumFields, builder.ToImmutableAndFree());\n }\n\n int staticIndex = 0;\n ImmutableArray staticFields = GetMembers();\n int instanceIndex = 0;\n\n foreach (var fieldDef in fieldDefs)\n {\n if (instanceIndex < uncommon.lazyInstanceEnumFields.Length && uncommon.lazyInstanceEnumFields[instanceIndex].Handle == fieldDef)\n {\n yield return uncommon.lazyInstanceEnumFields[instanceIndex];\n instanceIndex++;\n continue;\n }\n\n if (staticIndex < staticFields.Length && staticFields[staticIndex].Kind == SymbolKind.Field)\n {\n var field = (PEFieldSymbol)staticFields[staticIndex];\n\n if (field.Handle == fieldDef)\n {\n yield return field;\n staticIndex++;\n continue;\n }\n }\n }\n\n fieldDefs.Free();\n\n Debug.Assert(instanceIndex == uncommon.lazyInstanceEnumFields.Length);\n Debug.Assert(staticIndex == staticFields.Length || staticFields[staticIndex].Kind != SymbolKind.Field);\n }\n\n internal override IEnumerable GetFieldsToEmit()\n {\n if (this.TypeKind == TypeKind.Enum)\n {\n return GetEnumFieldsToEmit();\n }\n else\n {\n // If there are any non-event fields, they are at the very beginning.\n IEnumerable nonEventFields = GetMembers(this.GetMembers().WhereAsArray(m => !(m is TupleErrorFieldSymbol)), SymbolKind.Field, offset: 0);\n\n // Event backing fields are not part of the set returned by GetMembers. Let's add them manually.\n ArrayBuilder eventFields = null;\n\n foreach (var eventSymbol in GetEventsToEmit())\n {\n FieldSymbol associatedField = eventSymbol.AssociatedField;\n if ((object)associatedField != null)\n {\n Debug.Assert((object)associatedField.AssociatedSymbol != null);\n Debug.Assert(!nonEventFields.Contains(associatedField));\n\n if (eventFields == null)\n {\n eventFields = ArrayBuilder.GetInstance();\n }\n\n eventFields.Add(associatedField);\n }\n }\n\n if (eventFields == null)\n {\n // Simple case\n return nonEventFields;\n }\n\n // We need to merge non-event fields with event fields while preserving their relative declaration order\n var handleToFieldMap = new SmallDictionary();\n int count = 0;\n\n foreach (PEFieldSymbol field in nonEventFields)\n {\n handleToFieldMap.Add(field.Handle, field);\n count++;\n }\n\n foreach (PEFieldSymbol field in eventFields)\n {\n handleToFieldMap.Add(field.Handle, field);\n }\n\n count += eventFields.Count;\n eventFields.Free();\n\n var result = ArrayBuilder.GetInstance(count);\n\n try\n {\n foreach (var handle in this.ContainingPEModule.Module.GetFieldsOfTypeOrThrow(_handle))\n {\n FieldSymbol field;\n if (handleToFieldMap.TryGetValue(handle, out field))\n {\n result.Add(field);\n }\n }\n }\n catch (BadImageFormatException)\n { }\n\n Debug.Assert(result.Count == count);\n\n return result.ToImmutableAndFree();\n }\n }\n\n internal override IEnumerable GetMethodsToEmit()\n {\n ImmutableArray members = GetMembers();\n\n // Get to methods.\n int index = GetIndexOfFirstMember(members, SymbolKind.Method);\n\n if (!this.IsInterfaceType())\n {\n for (; index < members.Length; index++)\n {\n if (members[index].Kind != SymbolKind.Method)\n {\n break;\n }\n\n var method = (MethodSymbol)members[index];\n\n // Don't emit the default value type constructor - the runtime handles that.\n // For parameterless struct constructors from metadata, IsDefaultValueTypeConstructor()\n // ignores requireZeroInit and simply checks if the method is implicitly declared.\n if (!method.IsDefaultValueTypeConstructor(requireZeroInit: false))\n {\n yield return method;\n }\n }\n }\n else\n {\n // We do not create symbols for v-table gap methods, let's figure out where the gaps go.\n\n if (index >= members.Length || members[index].Kind != SymbolKind.Method)\n {\n // We didn't import any methods, it is Ok to return an empty set.\n yield break;\n }\n\n var method = (PEMethodSymbol)members[index];\n var module = this.ContainingPEModule.Module;\n\n var methodDefs = ArrayBuilder.GetInstance();\n\n try\n {\n foreach (var methodDef in module.GetMethodsOfTypeOrThrow(_handle))\n {\n methodDefs.Add(methodDef);\n }\n }\n catch (BadImageFormatException)\n { }\n\n foreach (var methodDef in methodDefs)\n {\n if (method.Handle == methodDef)\n {\n yield return method;\n index++;\n\n if (index == members.Length || members[index].Kind != SymbolKind.Method)\n {\n // no need to return any gaps at the end.\n methodDefs.Free();\n yield break;\n }\n\n method = (PEMethodSymbol)members[index];\n }\n else\n {\n // Encountered a gap.\n int gapSize;\n\n try\n {\n gapSize = ModuleExtensions.GetVTableGapSize(module.GetMethodDefNameOrThrow(methodDef));\n }\n catch (BadImageFormatException)\n {\n gapSize = 1;\n }\n\n // We don't have a symbol to return, so, even if the name doesn't represent a gap, we still have a gap.\n do\n {\n yield return null;\n gapSize--;\n }\n while (gapSize > 0);\n }\n }\n\n // Ensure we explicitly returned from inside loop.\n throw ExceptionUtilities.Unreachable;\n }\n }\n\n internal override IEnumerable GetPropertiesToEmit()\n {\n return GetMembers(this.GetMembers(), SymbolKind.Property);\n }\n\n internal override IEnumerable GetEventsToEmit()\n {\n return GetMembers(this.GetMembers(), SymbolKind.Event);\n }\n\n internal override ImmutableArray GetEarlyAttributeDecodingMembers()\n {\n return this.GetMembersUnordered();\n }\n\n internal override ImmutableArray GetEarlyAttributeDecodingMembers(string name)\n {\n return this.GetMembers(name);\n }\n\n private class DeclarationOrderTypeSymbolComparer : IComparer\n {\n public static readonly DeclarationOrderTypeSymbolComparer Instance = new DeclarationOrderTypeSymbolComparer();\n\n private DeclarationOrderTypeSymbolComparer() { }\n\n public int Compare(Symbol x, Symbol y)\n {\n return HandleComparer.Default.Compare(((PENamedTypeSymbol)x).Handle, ((PENamedTypeSymbol)y).Handle);\n }\n }\n\n private void EnsureEnumUnderlyingTypeIsLoaded(UncommonProperties uncommon)\n {\n if ((object)(uncommon.lazyEnumUnderlyingType) == null\n && this.TypeKind == TypeKind.Enum)\n {\n // From §8.5.2\n // An enum is considerably more restricted than a true type, as\n // follows:\n // - It shall have exactly one instance field, and the type of that field defines the underlying type of\n // the enumeration.\n // - It shall not have any static fields unless they are literal. (see §8.6.1.2)\n\n // The underlying type shall be a built-in integer type. Enums shall derive from System.Enum, hence they are\n // value types. Like all value types, they shall be sealed (see §8.9.9).\n\n var moduleSymbol = this.ContainingPEModule;\n var module = moduleSymbol.Module;\n var decoder = new MetadataDecoder(moduleSymbol, this);\n NamedTypeSymbol underlyingType = null;\n\n try\n {\n foreach (var fieldDef in module.GetFieldsOfTypeOrThrow(_handle))\n {\n FieldAttributes fieldFlags;\n\n try\n {\n fieldFlags = module.GetFieldDefFlagsOrThrow(fieldDef);\n }\n catch (BadImageFormatException)\n {\n continue;\n }\n\n if ((fieldFlags & FieldAttributes.Static) == 0)\n {\n // Instance field used to determine underlying type.\n ImmutableArray> customModifiers;\n TypeSymbol type = decoder.DecodeFieldSignature(fieldDef, out customModifiers);\n\n if (type.SpecialType.IsValidEnumUnderlyingType() && !customModifiers.AnyRequired())\n {\n if ((object)underlyingType == null)\n {\n underlyingType = (NamedTypeSymbol)type;\n }\n else\n {\n underlyingType = new UnsupportedMetadataTypeSymbol(); // ambiguous underlying type\n }\n }\n }\n }\n\n if ((object)underlyingType == null)\n {\n underlyingType = new UnsupportedMetadataTypeSymbol(); // undefined underlying type\n }\n }\n catch (BadImageFormatException mrEx)\n {\n if ((object)underlyingType == null)\n {\n underlyingType = new UnsupportedMetadataTypeSymbol(mrEx);\n }\n }\n\n Interlocked.CompareExchange(ref uncommon.lazyEnumUnderlyingType, underlyingType, null);\n }\n }\n\n private void EnsureAllMembersAreLoaded()\n {\n if (_lazyMembersByName == null)\n {\n LoadMembers();\n }\n }\n\n private void LoadMembers()\n {\n ArrayBuilder members = null;\n\n if (_lazyMembersInDeclarationOrder.IsDefault)\n {\n EnsureNestedTypesAreLoaded();\n\n members = ArrayBuilder.GetInstance();\n\n Debug.Assert(SymbolKind.Field.ToSortOrder() < SymbolKind.Method.ToSortOrder());\n Debug.Assert(SymbolKind.Method.ToSortOrder() < SymbolKind.Property.ToSortOrder());\n Debug.Assert(SymbolKind.Property.ToSortOrder() < SymbolKind.Event.ToSortOrder());\n Debug.Assert(SymbolKind.Event.ToSortOrder() < SymbolKind.NamedType.ToSortOrder());\n\n if (this.TypeKind == TypeKind.Enum)\n {\n EnsureEnumUnderlyingTypeIsLoaded(this.GetUncommonProperties());\n\n var moduleSymbol = this.ContainingPEModule;\n var module = moduleSymbol.Module;\n\n try\n {\n foreach (var fieldDef in module.GetFieldsOfTypeOrThrow(_handle))\n {\n FieldAttributes fieldFlags;\n\n try\n {\n fieldFlags = module.GetFieldDefFlagsOrThrow(fieldDef);\n if ((fieldFlags & FieldAttributes.Static) == 0)\n {\n continue;\n }\n }\n catch (BadImageFormatException)\n {\n fieldFlags = 0;\n }\n\n if (ModuleExtensions.ShouldImportField(fieldFlags, moduleSymbol.ImportOptions))\n {\n var field = new PEFieldSymbol(moduleSymbol, this, fieldDef);\n members.Add(field);\n }\n }\n }\n catch (BadImageFormatException)\n { }\n\n var syntheticCtor = new SynthesizedInstanceConstructor(this);\n members.Add(syntheticCtor);\n }\n else\n {\n ArrayBuilder fieldMembers = ArrayBuilder.GetInstance();\n ArrayBuilder nonFieldMembers = ArrayBuilder.GetInstance();\n\n MultiDictionary privateFieldNameToSymbols = this.CreateFields(fieldMembers);\n\n // A method may be referenced as an accessor by one or more properties. And,\n // any of those properties may be \"bogus\" if one of the property accessors\n // does not match the property signature. If the method is referenced by at\n // least one non-bogus property, then the method is created as an accessor,\n // and (for purposes of error reporting if the method is referenced directly) the\n // associated property is set (arbitrarily) to the first non-bogus property found\n // in metadata. If the method is not referenced by any non-bogus properties,\n // then the method is created as a normal method rather than an accessor.\n\n // Create a dictionary of method symbols indexed by metadata handle\n // (to allow efficient lookup when matching property accessors).\n PooledDictionary methodHandleToSymbol = this.CreateMethods(nonFieldMembers);\n\n if (this.TypeKind == TypeKind.Struct)\n {\n bool haveParameterlessConstructor = false;\n foreach (MethodSymbol method in nonFieldMembers)\n {\n if (method.IsParameterlessConstructor())\n {\n haveParameterlessConstructor = true;\n break;\n }\n }\n\n // Structs have an implicit parameterless constructor, even if it\n // does not appear in metadata (11.3.8)\n if (!haveParameterlessConstructor)\n {\n nonFieldMembers.Insert(0, new SynthesizedInstanceConstructor(this));\n }\n }\n\n this.CreateProperties(methodHandleToSymbol, nonFieldMembers);\n this.CreateEvents(privateFieldNameToSymbols, methodHandleToSymbol, nonFieldMembers);\n\n foreach (PEFieldSymbol field in fieldMembers)\n {\n if ((object)field.AssociatedSymbol == null)\n {\n members.Add(field);\n }\n else\n {\n // As for source symbols, our public API presents the fiction that all\n // operations are performed on the event, rather than on the backing field. \n // The backing field is not accessible through the API. As an additional \n // bonus, lookup is easier when the names don't collide.\n Debug.Assert(field.AssociatedSymbol.Kind == SymbolKind.Event);\n }\n }\n\n members.AddRange(nonFieldMembers);\n\n nonFieldMembers.Free();\n fieldMembers.Free();\n\n methodHandleToSymbol.Free();\n }\n\n // Now add types to the end.\n int membersCount = members.Count;\n\n foreach (var typeArray in _lazyNestedTypes.Values)\n {\n members.AddRange(typeArray);\n }\n\n // Sort the types based on row id.\n members.Sort(membersCount, DeclarationOrderTypeSymbolComparer.Instance);\n\n#if DEBUG\n Symbol previous = null;\n\n foreach (var s in members)\n {\n if (previous == null)\n {\n previous = s;\n }\n else\n {\n Symbol current = s;\n Debug.Assert(previous.Kind.ToSortOrder() <= current.Kind.ToSortOrder());\n previous = current;\n }\n }\n#endif\n\n if (IsTupleType)\n {\n int originalCount = members.Count;\n members = AddOrWrapTupleMembers(members.ToImmutableAndFree());\n membersCount += (members.Count - originalCount); // account for added tuple error fields\n Debug.Assert(members is object);\n }\n\n var membersInDeclarationOrder = members.ToImmutable();\n\n if (!ImmutableInterlocked.InterlockedInitialize(ref _lazyMembersInDeclarationOrder, membersInDeclarationOrder))\n {\n members.Free();\n members = null;\n }\n else\n {\n // remove the types\n members.Clip(membersCount);\n }\n }\n\n if (_lazyMembersByName == null)\n {\n if (members == null)\n {\n members = ArrayBuilder.GetInstance();\n foreach (var member in _lazyMembersInDeclarationOrder)\n {\n if (member.Kind == SymbolKind.NamedType)\n {\n break;\n }\n members.Add(member);\n }\n }\n\n Dictionary> membersDict = GroupByName(members);\n\n var exchangeResult = Interlocked.CompareExchange(ref _lazyMembersByName, membersDict, null);\n if (exchangeResult == null)\n {\n // we successfully swapped in the members dictionary.\n\n // Now, use these as the canonical member names. This saves us memory by not having\n // two collections around at the same time with redundant data in them.\n //\n // NOTE(cyrusn): We must use an interlocked exchange here so that the full\n // construction of this object will be seen from 'MemberNames'. Also, doing a\n // straight InterlockedExchange here is the right thing to do. Consider the case\n // where one thread is calling in through \"MemberNames\" while we are in the middle\n // of this method. Either that thread will compute the member names and store it\n // first (in which case we overwrite it), or we will store first (in which case\n // their CompareExchange(..., ..., null) will fail. Either way, this will be certain\n // to become the canonical set of member names.\n //\n // NOTE(cyrusn): This means that it is possible (and by design) for people to get a\n // different object back when they call MemberNames multiple times. However, outside\n // of object identity, both collections should appear identical to the user.\n var memberNames = SpecializedCollections.ReadOnlyCollection(membersDict.Keys);\n Interlocked.Exchange(ref _lazyMemberNames, memberNames);\n }\n }\n\n if (members != null)\n {\n members.Free();\n }\n }\n\n internal override ImmutableArray GetSimpleNonTypeMembers(string name)\n {\n EnsureAllMembersAreLoaded();\n\n ImmutableArray m;\n if (!_lazyMembersByName.TryGetValue(name, out m))\n {\n m = ImmutableArray.Empty;\n }\n\n return m;\n }\n\n public override ImmutableArray GetMembers(string name)\n {\n EnsureAllMembersAreLoaded();\n\n ImmutableArray m;\n if (!_lazyMembersByName.TryGetValue(name, out m))\n {\n m = ImmutableArray.Empty;\n }\n\n // nested types are not common, but we need to check just in case\n ImmutableArray t;\n if (_lazyNestedTypes.TryGetValue(name, out t))\n {\n m = m.Concat(StaticCast.From(t));\n }\n\n return m;\n }\n\n internal sealed override bool HasPossibleWellKnownCloneMethod()\n => MemberNames.Contains(WellKnownMemberNames.CloneMethodName);\n\n internal override FieldSymbol FixedElementField\n {\n get\n {\n FieldSymbol result = null;\n\n var candidates = this.GetMembers(FixedFieldImplementationType.FixedElementFieldName);\n if (!candidates.IsDefault && candidates.Length == 1)\n {\n result = candidates[0] as FieldSymbol;\n }\n\n return result;\n }\n }\n\n internal override ImmutableArray GetTypeMembersUnordered()\n {\n return GetTypeMembers().ConditionallyDeOrder();\n }\n\n public override ImmutableArray GetTypeMembers()\n {\n EnsureNestedTypesAreLoaded();\n return GetMemberTypesPrivate();\n }\n\n private ImmutableArray GetMemberTypesPrivate()\n {\n var builder = ArrayBuilder.GetInstance();\n foreach (var typeArray in _lazyNestedTypes.Values)\n {\n builder.AddRange(typeArray);\n }\n\n return builder.ToImmutableAndFree();\n }\n\n private void EnsureNestedTypesAreLoaded()\n {\n if (_lazyNestedTypes == null)\n {\n var types = ArrayBuilder.GetInstance();\n types.AddRange(this.CreateNestedTypes());\n var typesDict = GroupByName(types);\n\n var exchangeResult = Interlocked.CompareExchange(ref _lazyNestedTypes, typesDict, null);\n if (exchangeResult == null)\n {\n // Build cache of TypeDef Tokens\n // Potentially this can be done in the background.\n var moduleSymbol = this.ContainingPEModule;\n moduleSymbol.OnNewTypeDeclarationsLoaded(typesDict);\n }\n types.Free();\n }\n }\n\n public override ImmutableArray GetTypeMembers(string name)\n {\n EnsureNestedTypesAreLoaded();\n\n ImmutableArray t;\n\n if (_lazyNestedTypes.TryGetValue(name, out t))\n {\n return StaticCast.From(t);\n }\n\n return ImmutableArray.Empty;\n }\n\n public override ImmutableArray GetTypeMembers(string name, int arity)\n {\n return GetTypeMembers(name).WhereAsArray((type, arity) => type.Arity == arity, arity);\n }\n\n public override ImmutableArray Locations\n {\n get\n {\n return ContainingPEModule.MetadataLocation.Cast();\n }\n }\n\n public override ImmutableArray DeclaringSyntaxReferences\n {\n get\n {\n return ImmutableArray.Empty;\n }\n }\n\n public override string Name\n {\n get\n {\n return _name;\n }\n }\n\n internal override bool HasSpecialName\n {\n get\n {\n return (_flags & TypeAttributes.SpecialName) != 0;\n }\n }\n\n internal override ImmutableArray TypeArgumentsWithAnnotationsNoUseSiteDiagnostics\n {\n get\n {\n return ImmutableArray.Empty;\n }\n }\n\n public override ImmutableArray TypeParameters\n {\n get\n {\n return ImmutableArray.Empty;\n }\n }\n\n public override bool IsStatic\n {\n get\n {\n return\n (_flags & TypeAttributes.Sealed) != 0 &&\n (_flags & TypeAttributes.Abstract) != 0;\n }\n }\n\n public override bool IsAbstract\n {\n get\n {\n return\n (_flags & TypeAttributes.Abstract) != 0 &&\n (_flags & TypeAttributes.Sealed) == 0;\n }\n }\n\n internal override bool IsMetadataAbstract\n {\n get\n {\n return (_flags & TypeAttributes.Abstract) != 0;\n }\n }\n\n public override bool IsSealed\n {\n get\n {\n return\n (_flags & TypeAttributes.Sealed) != 0 &&\n (_flags & TypeAttributes.Abstract) == 0;\n }\n }\n\n internal override bool IsMetadataSealed\n {\n get\n {\n return (_flags & TypeAttributes.Sealed) != 0;\n }\n }\n\n internal TypeAttributes Flags\n {\n get\n {\n return _flags;\n }\n }\n\n public sealed override bool AreLocalsZeroed\n {\n get { throw ExceptionUtilities.Unreachable; }\n }\n\n public override bool MightContainExtensionMethods\n {\n get\n {\n var uncommon = GetUncommonProperties();\n if (uncommon == s_noUncommonProperties)\n {\n return false;\n }\n\n if (!uncommon.lazyContainsExtensionMethods.HasValue())\n {\n var contains = ThreeState.False;\n // Dev11 supports extension methods defined on non-static\n // classes, structs, delegates, and generic types.\n switch (this.TypeKind)\n {\n case TypeKind.Class:\n case TypeKind.Struct:\n case TypeKind.Delegate:\n var moduleSymbol = this.ContainingPEModule;\n var module = moduleSymbol.Module;\n bool moduleHasExtension = module.HasExtensionAttribute(_handle, ignoreCase: false);\n\n var containingAssembly = this.ContainingAssembly as PEAssemblySymbol;\n if ((object)containingAssembly != null)\n {\n contains = (moduleHasExtension\n && containingAssembly.MightContainExtensionMethods).ToThreeState();\n }\n else\n {\n contains = moduleHasExtension.ToThreeState();\n }\n break;\n }\n\n uncommon.lazyContainsExtensionMethods = contains;\n }\n\n return uncommon.lazyContainsExtensionMethods.Value();\n }\n }\n\n public override TypeKind TypeKind\n {\n get\n {\n TypeKind result = _lazyKind;\n\n if (result == TypeKind.Unknown)\n {\n if (_flags.IsInterface())\n {\n result = TypeKind.Interface;\n }\n else\n {\n TypeSymbol @base = GetDeclaredBaseType(skipTransformsIfNecessary: true);\n\n result = TypeKind.Class;\n\n if ((object)@base != null)\n {\n SpecialType baseCorTypeId = @base.SpecialType;\n\n switch (baseCorTypeId)\n {\n case SpecialType.System_Enum:\n // Enum\n result = TypeKind.Enum;\n break;\n\n case SpecialType.System_MulticastDelegate:\n // Delegate\n result = TypeKind.Delegate;\n break;\n\n case SpecialType.System_ValueType:\n // System.Enum is the only class that derives from ValueType\n if (this.SpecialType != SpecialType.System_Enum)\n {\n // Struct\n result = TypeKind.Struct;\n }\n break;\n }\n }\n }\n\n _lazyKind = result;\n }\n\n return result;\n }\n }\n\n internal sealed override bool IsInterface\n {\n get\n {\n return _flags.IsInterface();\n }\n }\n\n private static ExtendedErrorTypeSymbol CyclicInheritanceError(PENamedTypeSymbol type, TypeSymbol declaredBase)\n {\n var info = new CSDiagnosticInfo(ErrorCode.ERR_ImportedCircularBase, declaredBase, type);\n return new ExtendedErrorTypeSymbol(declaredBase, LookupResultKind.NotReferencable, info, true);\n }\n\n private NamedTypeSymbol MakeAcyclicBaseType()\n {\n NamedTypeSymbol declaredBase = GetDeclaredBaseType(null);\n\n // implicit base is not interesting for metadata cycle detection\n if ((object)declaredBase == null)\n {\n return null;\n }\n\n if (BaseTypeAnalysis.TypeDependsOn(declaredBase, this))\n {\n return CyclicInheritanceError(this, declaredBase);\n }\n\n this.SetKnownToHaveNoDeclaredBaseCycles();\n return declaredBase;\n }\n\n private ImmutableArray MakeAcyclicInterfaces()\n {\n var declaredInterfaces = GetDeclaredInterfaces(null);\n if (!IsInterface)\n {\n // only interfaces needs to check for inheritance cycles via interfaces.\n return declaredInterfaces;\n }\n\n return declaredInterfaces\n .SelectAsArray(t => BaseTypeAnalysis.TypeDependsOn(t, this) ? CyclicInheritanceError(this, t) : t);\n }\n\n public override string GetDocumentationCommentXml(CultureInfo preferredCulture = null, bool expandIncludes = false, CancellationToken cancellationToken = default(CancellationToken))\n {\n return PEDocumentationCommentUtils.GetDocumentationComment(this, ContainingPEModule, preferredCulture, cancellationToken, ref _lazyDocComment);\n }\n\n private IEnumerable CreateNestedTypes()\n {\n var moduleSymbol = this.ContainingPEModule;\n var module = moduleSymbol.Module;\n\n ImmutableArray nestedTypeDefs;\n\n try\n {\n nestedTypeDefs = module.GetNestedTypeDefsOrThrow(_handle);\n }\n catch (BadImageFormatException)\n {\n yield break;\n }\n\n foreach (var typeRid in nestedTypeDefs)\n {\n if (module.ShouldImportNestedType(typeRid))\n {\n yield return PENamedTypeSymbol.Create(moduleSymbol, this, typeRid);\n }\n }\n }\n\n private MultiDictionary CreateFields(ArrayBuilder fieldMembers)\n {\n var privateFieldNameToSymbols = new MultiDictionary();\n\n var moduleSymbol = this.ContainingPEModule;\n var module = moduleSymbol.Module;\n\n // for ordinary struct types we import private fields so that we can distinguish empty structs from non-empty structs\n var isOrdinaryStruct = false;\n // for ordinary embeddable struct types we import private members so that we can report appropriate errors if the structure is used \n var isOrdinaryEmbeddableStruct = false;\n\n if (this.TypeKind == TypeKind.Struct)\n {\n if (this.SpecialType == Microsoft.CodeAnalysis.SpecialType.None)\n {\n isOrdinaryStruct = true;\n isOrdinaryEmbeddableStruct = this.ContainingAssembly.IsLinked;\n }\n else\n {\n isOrdinaryStruct = (this.SpecialType == Microsoft.CodeAnalysis.SpecialType.System_Nullable_T);\n }\n }\n\n try\n {\n foreach (var fieldRid in module.GetFieldsOfTypeOrThrow(_handle))\n {\n try\n {\n if (!(isOrdinaryEmbeddableStruct ||\n (isOrdinaryStruct && (module.GetFieldDefFlagsOrThrow(fieldRid) & FieldAttributes.Static) == 0) ||\n module.ShouldImportField(fieldRid, moduleSymbol.ImportOptions)))\n {\n continue;\n }\n }\n catch (BadImageFormatException)\n { }\n\n var symbol = new PEFieldSymbol(moduleSymbol, this, fieldRid);\n fieldMembers.Add(symbol);\n\n // Only private fields are potentially backing fields for field-like events.\n if (symbol.DeclaredAccessibility == Accessibility.Private)\n {\n var name = symbol.Name;\n if (name.Length > 0)\n {\n privateFieldNameToSymbols.Add(name, symbol);\n }\n }\n }\n }\n catch (BadImageFormatException)\n { }\n\n return privateFieldNameToSymbols;\n }\n\n private PooledDictionary CreateMethods(ArrayBuilder members)\n {\n var moduleSymbol = this.ContainingPEModule;\n var module = moduleSymbol.Module;\n var map = PooledDictionary.GetInstance();\n\n // for ordinary embeddable struct types we import private members so that we can report appropriate errors if the structure is used \n var isOrdinaryEmbeddableStruct = (this.TypeKind == TypeKind.Struct) && (this.SpecialType == Microsoft.CodeAnalysis.SpecialType.None) && this.ContainingAssembly.IsLinked;\n\n try\n {\n foreach (var methodHandle in module.GetMethodsOfTypeOrThrow(_handle))\n {\n if (isOrdinaryEmbeddableStruct || module.ShouldImportMethod(_handle, methodHandle, moduleSymbol.ImportOptions))\n {\n var method = new PEMethodSymbol(moduleSymbol, this, methodHandle);\n members.Add(method);\n map.Add(methodHandle, method);\n }\n }\n }\n catch (BadImageFormatException)\n { }\n\n return map;\n }\n\n private void CreateProperties(Dictionary methodHandleToSymbol, ArrayBuilder members)\n {\n var moduleSymbol = this.ContainingPEModule;\n var module = moduleSymbol.Module;\n\n try\n {\n foreach (var propertyDef in module.GetPropertiesOfTypeOrThrow(_handle))\n {\n try\n {\n var methods = module.GetPropertyMethodsOrThrow(propertyDef);\n\n PEMethodSymbol getMethod = GetAccessorMethod(module, methodHandleToSymbol, _handle, methods.Getter);\n PEMethodSymbol setMethod = GetAccessorMethod(module, methodHandleToSymbol, _handle, methods.Setter);\n\n if (((object)getMethod != null) || ((object)setMethod != null))\n {\n members.Add(PEPropertySymbol.Create(moduleSymbol, this, propertyDef, getMethod, setMethod));\n }\n }\n catch (BadImageFormatException)\n { }\n }\n }\n catch (BadImageFormatException)\n { }\n }\n\n private void CreateEvents(\n MultiDictionary privateFieldNameToSymbols,\n Dictionary methodHandleToSymbol,\n ArrayBuilder members)\n {\n var moduleSymbol = this.ContainingPEModule;\n var module = moduleSymbol.Module;\n\n try\n {\n foreach (var eventRid in module.GetEventsOfTypeOrThrow(_handle))\n {\n try\n {\n var methods = module.GetEventMethodsOrThrow(eventRid);\n\n // NOTE: C# ignores all other accessors (most notably, raise/fire).\n PEMethodSymbol addMethod = GetAccessorMethod(module, methodHandleToSymbol, _handle, methods.Adder);\n PEMethodSymbol removeMethod = GetAccessorMethod(module, methodHandleToSymbol, _handle, methods.Remover);\n\n // NOTE: both accessors are required, but that will be reported separately.\n // Create the symbol unless both accessors are missing.\n if (((object)addMethod != null) || ((object)removeMethod != null))\n {\n members.Add(new PEEventSymbol(moduleSymbol, this, eventRid, addMethod, removeMethod, privateFieldNameToSymbols));\n }\n }\n catch (BadImageFormatException)\n { }\n }\n }\n catch (BadImageFormatException)\n { }\n }\n\n private PEMethodSymbol GetAccessorMethod(PEModule module, Dictionary methodHandleToSymbol, TypeDefinitionHandle typeDef, MethodDefinitionHandle methodDef)\n {\n if (methodDef.IsNil)\n {\n return null;\n }\n\n PEMethodSymbol method;\n bool found = methodHandleToSymbol.TryGetValue(methodDef, out method);\n Debug.Assert(found || !module.ShouldImportMethod(typeDef, methodDef, this.ContainingPEModule.ImportOptions));\n return method;\n }\n\n private static Dictionary> GroupByName(ArrayBuilder symbols)\n {\n return symbols.ToDictionary(s => s.Name, StringOrdinalComparer.Instance);\n }\n\n private static Dictionary