diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_Constraints.cs b/src/Compilers/CSharp/Portable/Binder/Binder_Constraints.cs index 01e38f749c160..36c970f15990a 100644 --- a/src/Compilers/CSharp/Portable/Binder/Binder_Constraints.cs +++ b/src/Compilers/CSharp/Portable/Binder/Binder_Constraints.cs @@ -411,9 +411,9 @@ private static void CheckConstraintTypeVisibility( diagnostics.Add(ErrorCode.ERR_BadVisBound, location, containingSymbol, constraintType.Type); } - if (constraintType.Type.IsFileTypeOrUsesFileTypes()) + if (constraintType.Type.HasFileLocalTypes()) { - // if the containing symbol of the constraint is a member, we need to ensure the nearest containing type is a file type. + // if the containing symbol of the constraint is a member, we need to ensure the nearest containing type is a file-local type. var possibleFileType = containingSymbol switch { TypeSymbol typeSymbol => typeSymbol, @@ -422,7 +422,7 @@ private static void CheckConstraintTypeVisibility( _ => throw ExceptionUtilities.UnexpectedValue(containingSymbol) }; Debug.Assert(possibleFileType?.IsDefinition != false); - if (possibleFileType?.IsFileTypeOrUsesFileTypes() == false) + if (possibleFileType?.HasFileLocalTypes() == false) { diagnostics.Add(ErrorCode.ERR_FileTypeDisallowedInSignature, location, constraintType.Type, containingSymbol); } diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_Lookup.cs b/src/Compilers/CSharp/Portable/Binder/Binder_Lookup.cs index 47bd4d832fccd..f6b33f84e5770 100644 --- a/src/Compilers/CSharp/Portable/Binder/Binder_Lookup.cs +++ b/src/Compilers/CSharp/Portable/Binder/Binder_Lookup.cs @@ -1308,14 +1308,14 @@ internal static ImmutableArray GetCandidateMembers(NamespaceOrTypeSymbol private bool IsInScopeOfAssociatedSyntaxTree(Symbol symbol) { - while (symbol is not null and not SourceMemberContainerTypeSymbol { IsFile: true }) + while (symbol is not null and not SourceMemberContainerTypeSymbol { IsFileLocal: true }) { symbol = symbol.ContainingType; } if (symbol is null) { - // the passed-in symbol was not contained in a file type. + // the passed-in symbol was not contained in a file-local type. return true; } diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_Symbols.cs b/src/Compilers/CSharp/Portable/Binder/Binder_Symbols.cs index ee5c62da9ec38..72fab753cff6b 100644 --- a/src/Compilers/CSharp/Portable/Binder/Binder_Symbols.cs +++ b/src/Compilers/CSharp/Portable/Binder/Binder_Symbols.cs @@ -1818,7 +1818,7 @@ Symbol resultSymbol( if (best.IsFromFile && !secondBest.IsFromFile) { - // a lookup of a file type is "better" than a lookup of a non-file type; no need to further diagnose + // a lookup of a file-local type is "better" than a lookup of a non-file-local type; no need to further diagnose // https://github.com/dotnet/roslyn/issues/62331 // some "single symbol" diagnostics are missed here for similar reasons // that make us miss diagnostics when reporting WRN_SameFullNameThisAggAgg. @@ -2300,7 +2300,7 @@ private BestSymbolInfo GetBestSymbolInfo(ArrayBuilder symbols, out BestS private static BestSymbolLocation GetLocation(CSharpCompilation compilation, Symbol symbol) { - if (symbol is SourceMemberContainerTypeSymbol { IsFile: true }) + if (symbol is SourceMemberContainerTypeSymbol { IsFileLocal: true }) { return BestSymbolLocation.FromFile; } diff --git a/src/Compilers/CSharp/Portable/CSharpResources.resx b/src/Compilers/CSharp/Portable/CSharpResources.resx index 71812dab8308f..69bfcdca2d78c 100644 --- a/src/Compilers/CSharp/Portable/CSharpResources.resx +++ b/src/Compilers/CSharp/Portable/CSharpResources.resx @@ -7125,19 +7125,19 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ '{2}' cannot satisfy the 'new()' constraint on parameter '{1}' in the generic type or or method '{0}' because '{2}' has required members. - File type '{0}' cannot be used in a member signature in non-file type '{1}'. + File-local type '{0}' cannot be used in a member signature in non-file-local type '{1}'. - File type '{0}' cannot use accessibility modifiers. + File-local type '{0}' cannot use accessibility modifiers. - File type '{0}' cannot be used as a base type of non-file type '{1}'. + File-local type '{0}' cannot be used as a base type of non-file-local type '{1}'. - File type '{0}' must be defined in a top level type; '{0}' is a nested type. + File-local type '{0}' must be defined in a top level type; '{0}' is a nested type. - File type '{0}' cannot be used in a 'global using static' directive. + File-local type '{0}' cannot be used in a 'global using static' directive. Types and aliases cannot be named 'file'. diff --git a/src/Compilers/CSharp/Portable/Symbols/NamedTypeSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/NamedTypeSymbol.cs index ba0392ec81bbb..7e761e6004936 100644 --- a/src/Compilers/CSharp/Portable/Symbols/NamedTypeSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/NamedTypeSymbol.cs @@ -497,7 +497,7 @@ public override string MetadataName } /// - /// If this type is a file type, returns the syntax tree where this type is visible. Otherwise, returns null. + /// If this type is a file-local type, returns the syntax tree where this type is visible. Otherwise, returns null. /// internal abstract SyntaxTree? AssociatedSyntaxTree { get; } #nullable disable diff --git a/src/Compilers/CSharp/Portable/Symbols/PublicModel/NamedTypeSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/PublicModel/NamedTypeSymbol.cs index 6f09cef0e4714..00c5b7985b11c 100644 --- a/src/Compilers/CSharp/Portable/Symbols/PublicModel/NamedTypeSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/PublicModel/NamedTypeSymbol.cs @@ -194,7 +194,7 @@ INamedTypeSymbol INamedTypeSymbol.TupleUnderlyingType bool INamedTypeSymbol.IsSerializable => UnderlyingNamedTypeSymbol.IsSerializable; - bool INamedTypeSymbol.IsFile => UnderlyingNamedTypeSymbol.AssociatedSyntaxTree is not null; + bool INamedTypeSymbol.IsFileLocal => UnderlyingNamedTypeSymbol.AssociatedSyntaxTree is not null; INamedTypeSymbol INamedTypeSymbol.NativeIntegerUnderlyingType => UnderlyingNamedTypeSymbol.NativeIntegerUnderlyingType.GetPublicSymbol(); diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/SourceDelegateMethodSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Source/SourceDelegateMethodSymbol.cs index 987d3a7e93160..211d1913e0330 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/SourceDelegateMethodSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/SourceDelegateMethodSymbol.cs @@ -96,8 +96,8 @@ internal static void AddDelegateMembers( diagnostics.Add(ErrorCode.ERR_BadVisDelegateReturn, delegateType.Locations[0], delegateType, invoke.ReturnType); } - var delegateTypeIsFile = delegateType.IsFileTypeOrUsesFileTypes(); - if (!delegateTypeIsFile && invoke.ReturnType.IsFileTypeOrUsesFileTypes()) + var delegateTypeIsFile = delegateType.HasFileLocalTypes(); + if (!delegateTypeIsFile && invoke.ReturnType.HasFileLocalTypes()) { diagnostics.Add(ErrorCode.ERR_FileTypeDisallowedInSignature, delegateType.Locations[0], invoke.ReturnType, delegateType); } @@ -110,7 +110,7 @@ internal static void AddDelegateMembers( // Inconsistent accessibility: parameter type '{1}' is less accessible than delegate '{0}' diagnostics.Add(ErrorCode.ERR_BadVisDelegateParam, delegateType.Locations[0], delegateType, parameterSymbol.Type); } - else if (!delegateTypeIsFile && parameterSymbol.Type.IsFileTypeOrUsesFileTypes()) + else if (!delegateTypeIsFile && parameterSymbol.Type.HasFileLocalTypes()) { diagnostics.Add(ErrorCode.ERR_FileTypeDisallowedInSignature, delegateType.Locations[0], parameterSymbol.Type, delegateType); } diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol.cs index eb9c4c3be96b4..0ba470a975e8d 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol.cs @@ -275,7 +275,7 @@ private DeclarationModifiers MakeModifiers(TypeKind typeKind, BindingDiagnosticB Symbol containingSymbol = this.ContainingSymbol; DeclarationModifiers defaultAccess; - // note: we give a specific diagnostic when a file type is nested + // note: we give a specific diagnostic when a file-local type is nested var allowedModifiers = DeclarationModifiers.AccessibilityMask | DeclarationModifiers.File; if (containingSymbol.Kind == SymbolKind.Namespace) @@ -826,9 +826,9 @@ internal override ManagedKind GetManagedKind(ref CompoundUseSiteInfo HasFlag(DeclarationModifiers.New); - internal bool IsFile => HasFlag(DeclarationModifiers.File); + internal bool IsFileLocal => HasFlag(DeclarationModifiers.File); - internal sealed override SyntaxTree? AssociatedSyntaxTree => IsFile ? declaration.Declarations[0].Location.SourceTree : null; + internal sealed override SyntaxTree? AssociatedSyntaxTree => IsFileLocal ? declaration.Declarations[0].Location.SourceTree : null; [MethodImpl(MethodImplOptions.AggressiveInlining)] private bool HasFlag(DeclarationModifiers flag) => (_declModifiers & flag) != 0; @@ -1744,7 +1744,7 @@ protected void AfterMembersChecks(BindingDiagnosticBag diagnostics) } } - if (IsFile && (object?)ContainingType != null) + if (IsFileLocal && (object?)ContainingType != null) { diagnostics.Add(ErrorCode.ERR_FileTypeNested, location, this); } diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberFieldSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberFieldSymbol.cs index 791b88c38b64d..ee31d81fceb4a 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberFieldSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberFieldSymbol.cs @@ -46,7 +46,7 @@ protected sealed override DeclarationModifiers Modifiers protected void TypeChecks(TypeSymbol type, BindingDiagnosticBag diagnostics) { - if (type.IsFileTypeOrUsesFileTypes() && !ContainingType.IsFileTypeOrUsesFileTypes()) + if (type.HasFileLocalTypes() && !ContainingType.HasFileLocalTypes()) { diagnostics.Add(ErrorCode.ERR_FileTypeDisallowedInSignature, this.ErrorLocation, type, ContainingType); } diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberMethodSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberMethodSymbol.cs index 225c383d4f001..0f85bdb093238 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberMethodSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberMethodSymbol.cs @@ -280,19 +280,19 @@ protected void CheckEffectiveAccessibility(TypeWithAnnotations returnType, Immut protected void CheckFileTypeUsage(TypeWithAnnotations returnType, ImmutableArray parameters, BindingDiagnosticBag diagnostics) { - if (ContainingType.IsFileTypeOrUsesFileTypes()) + if (ContainingType.HasFileLocalTypes()) { return; } - if (returnType.Type.IsFileTypeOrUsesFileTypes()) + if (returnType.Type.HasFileLocalTypes()) { diagnostics.Add(ErrorCode.ERR_FileTypeDisallowedInSignature, Locations[0], returnType.Type, ContainingType); } foreach (var param in parameters) { - if (param.Type.IsFileTypeOrUsesFileTypes()) + if (param.Type.HasFileLocalTypes()) { diagnostics.Add(ErrorCode.ERR_FileTypeDisallowedInSignature, Locations[0], param.Type, ContainingType); } diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/SourceNamedTypeSymbol_Bases.cs b/src/Compilers/CSharp/Portable/Symbols/Source/SourceNamedTypeSymbol_Bases.cs index 93fe92389fec6..578f93c6c578d 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/SourceNamedTypeSymbol_Bases.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/SourceNamedTypeSymbol_Bases.cs @@ -385,7 +385,7 @@ static bool containsOnlyOblivious(TypeSymbol type) diagnostics.Add(ErrorCode.ERR_BadVisBaseClass, baseTypeLocation, this, baseType); } - if (baseType.IsFileTypeOrUsesFileTypes() && !this.IsFileTypeOrUsesFileTypes()) + if (baseType.HasFileLocalTypes() && !this.HasFileLocalTypes()) { diagnostics.Add(ErrorCode.ERR_FileTypeBase, baseTypeLocation, baseType, this); } @@ -402,7 +402,7 @@ static bool containsOnlyOblivious(TypeSymbol type) diagnostics.Add(ErrorCode.ERR_BadVisBaseInterface, interfaceLocations[i], this, i); } - if (i.IsFileTypeOrUsesFileTypes() && !this.IsFileTypeOrUsesFileTypes()) + if (i.HasFileLocalTypes() && !this.HasFileLocalTypes()) { diagnostics.Add(ErrorCode.ERR_FileTypeBase, interfaceLocations[i], i, this); } diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/SourceNamespaceSymbol.AliasesAndUsings.cs b/src/Compilers/CSharp/Portable/Symbols/Source/SourceNamespaceSymbol.AliasesAndUsings.cs index b1098e3ea273f..3c43ab7020c94 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/SourceNamespaceSymbol.AliasesAndUsings.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/SourceNamespaceSymbol.AliasesAndUsings.cs @@ -757,7 +757,7 @@ UsingsAndDiagnostics buildUsings( else { var importedType = (NamedTypeSymbol)imported; - if (usingDirective.GlobalKeyword != default(SyntaxToken) && importedType.IsFileTypeOrUsesFileTypes()) + if (usingDirective.GlobalKeyword != default(SyntaxToken) && importedType.HasFileLocalTypes()) { diagnostics.Add(ErrorCode.ERR_GlobalUsingStaticFileType, usingDirective.Name.Location, imported); } diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/SourceNamespaceSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Source/SourceNamespaceSymbol.cs index 5bba097c91837..edd2c8d9c133e 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/SourceNamespaceSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/SourceNamespaceSymbol.cs @@ -374,7 +374,7 @@ private static void CheckMembers(NamespaceSymbol @namespace, Dictionary (object)loc.SourceTree == leftTree, leftTree)) { return false; diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertySymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertySymbol.cs index 781b6bac6a5c7..4426258799b56 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertySymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertySymbol.cs @@ -451,7 +451,7 @@ private TypeWithAnnotations ComputeType(Binder binder, SyntaxNode syntax, Bindin diagnostics.Add((this.IsIndexer ? ErrorCode.ERR_BadVisIndexerReturn : ErrorCode.ERR_BadVisPropertyType), Location, this, type.Type); } - if (type.Type.IsFileTypeOrUsesFileTypes() && !ContainingType.IsFileTypeOrUsesFileTypes()) + if (type.Type.HasFileLocalTypes() && !ContainingType.HasFileLocalTypes()) { diagnostics.Add(ErrorCode.ERR_FileTypeDisallowedInSignature, Location, type.Type, ContainingType); } @@ -533,7 +533,7 @@ internal override void AfterAddingTypeMembersChecks(ConversionsBase conversions, { diagnostics.Add(ErrorCode.ERR_BadVisIndexerParam, Location, this, param.Type); } - else if (param.Type.IsFileTypeOrUsesFileTypes() && !this.ContainingType.IsFileTypeOrUsesFileTypes()) + else if (param.Type.HasFileLocalTypes() && !this.ContainingType.HasFileLocalTypes()) { diagnostics.Add(ErrorCode.ERR_FileTypeDisallowedInSignature, Location, param.Type, this.ContainingType); } diff --git a/src/Compilers/CSharp/Portable/Symbols/Synthesized/GeneratedNameParser.cs b/src/Compilers/CSharp/Portable/Symbols/Synthesized/GeneratedNameParser.cs index 55f6d2b85c572..1faeda09dbd5c 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Synthesized/GeneratedNameParser.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Synthesized/GeneratedNameParser.cs @@ -172,12 +172,12 @@ internal static bool TryParseAnonymousTypeParameterName(string typeParameterName return false; } - // A full metadata name for a generic file type looks like: + // A full metadata name for a generic file-local type looks like: // FN__ClassName`A // where 'N' is the syntax tree ordinal, 'A' is the arity, // and 'ClassName' is the source name of the type. // - // The "unmangled" name of a generic file type looks like: + // The "unmangled" name of a generic file-local type looks like: // FN__ClassName private static readonly Regex s_fileTypeOrdinalPattern = new Regex(@"<([a-zA-Z_0-9]*)>F(\d)+__", RegexOptions.Compiled); diff --git a/src/Compilers/CSharp/Portable/Symbols/TypeSymbolExtensions.cs b/src/Compilers/CSharp/Portable/Symbols/TypeSymbolExtensions.cs index c754ed3038577..16f7cd6b8144a 100644 --- a/src/Compilers/CSharp/Portable/Symbols/TypeSymbolExtensions.cs +++ b/src/Compilers/CSharp/Portable/Symbols/TypeSymbolExtensions.cs @@ -1361,9 +1361,9 @@ public static bool IsPartial(this TypeSymbol type) return type is SourceNamedTypeSymbol { IsPartial: true }; } - public static bool IsFileTypeOrUsesFileTypes(this TypeSymbol type) + public static bool HasFileLocalTypes(this TypeSymbol type) { - var foundType = type.VisitType(predicate: (type, _, _) => type is SourceMemberContainerTypeSymbol { IsFile: true }, arg: (object?)null); + var foundType = type.VisitType(predicate: (type, _, _) => type is SourceMemberContainerTypeSymbol { IsFileLocal: true }, arg: (object?)null); return foundType is not null; } diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf index a6b62e33cdfaf..7e58ff02580a0 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf @@ -588,13 +588,13 @@ - File type '{0}' cannot be used as a base type of non-file type '{1}'. - File type '{0}' cannot be used as a base type of non-file type '{1}'. + File-local type '{0}' cannot be used as a base type of non-file-local type '{1}'. + File-local type '{0}' cannot be used as a base type of non-file-local type '{1}'. - File type '{0}' cannot be used in a member signature in non-file type '{1}'. - File type '{0}' cannot be used in a member signature in non-file type '{1}'. + File-local type '{0}' cannot be used in a member signature in non-file-local type '{1}'. + File-local type '{0}' cannot be used in a member signature in non-file-local type '{1}'. @@ -603,13 +603,13 @@ - File type '{0}' must be defined in a top level type; '{0}' is a nested type. - File type '{0}' must be defined in a top level type; '{0}' is a nested type. + File-local type '{0}' must be defined in a top level type; '{0}' is a nested type. + File-local type '{0}' must be defined in a top level type; '{0}' is a nested type. - File type '{0}' cannot use accessibility modifiers. - File type '{0}' cannot use accessibility modifiers. + File-local type '{0}' cannot use accessibility modifiers. + File-local type '{0}' cannot use accessibility modifiers. @@ -658,8 +658,8 @@ - File type '{0}' cannot be used in a 'global using static' directive. - File type '{0}' cannot be used in a 'global using static' directive. + File-local type '{0}' cannot be used in a 'global using static' directive. + File-local type '{0}' cannot be used in a 'global using static' directive. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf index ac2a69e0f8fb3..3affc94baac3d 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf @@ -588,13 +588,13 @@ - File type '{0}' cannot be used as a base type of non-file type '{1}'. - File type '{0}' cannot be used as a base type of non-file type '{1}'. + File-local type '{0}' cannot be used as a base type of non-file-local type '{1}'. + File-local type '{0}' cannot be used as a base type of non-file-local type '{1}'. - File type '{0}' cannot be used in a member signature in non-file type '{1}'. - File type '{0}' cannot be used in a member signature in non-file type '{1}'. + File-local type '{0}' cannot be used in a member signature in non-file-local type '{1}'. + File-local type '{0}' cannot be used in a member signature in non-file-local type '{1}'. @@ -603,13 +603,13 @@ - File type '{0}' must be defined in a top level type; '{0}' is a nested type. - File type '{0}' must be defined in a top level type; '{0}' is a nested type. + File-local type '{0}' must be defined in a top level type; '{0}' is a nested type. + File-local type '{0}' must be defined in a top level type; '{0}' is a nested type. - File type '{0}' cannot use accessibility modifiers. - File type '{0}' cannot use accessibility modifiers. + File-local type '{0}' cannot use accessibility modifiers. + File-local type '{0}' cannot use accessibility modifiers. @@ -658,8 +658,8 @@ - File type '{0}' cannot be used in a 'global using static' directive. - File type '{0}' cannot be used in a 'global using static' directive. + File-local type '{0}' cannot be used in a 'global using static' directive. + File-local type '{0}' cannot be used in a 'global using static' directive. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf index 0f5fa3e1a17c3..8cac02df3fc3e 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf @@ -588,13 +588,13 @@ - File type '{0}' cannot be used as a base type of non-file type '{1}'. - File type '{0}' cannot be used as a base type of non-file type '{1}'. + File-local type '{0}' cannot be used as a base type of non-file-local type '{1}'. + File-local type '{0}' cannot be used as a base type of non-file-local type '{1}'. - File type '{0}' cannot be used in a member signature in non-file type '{1}'. - File type '{0}' cannot be used in a member signature in non-file type '{1}'. + File-local type '{0}' cannot be used in a member signature in non-file-local type '{1}'. + File-local type '{0}' cannot be used in a member signature in non-file-local type '{1}'. @@ -603,13 +603,13 @@ - File type '{0}' must be defined in a top level type; '{0}' is a nested type. - File type '{0}' must be defined in a top level type; '{0}' is a nested type. + File-local type '{0}' must be defined in a top level type; '{0}' is a nested type. + File-local type '{0}' must be defined in a top level type; '{0}' is a nested type. - File type '{0}' cannot use accessibility modifiers. - File type '{0}' cannot use accessibility modifiers. + File-local type '{0}' cannot use accessibility modifiers. + File-local type '{0}' cannot use accessibility modifiers. @@ -658,8 +658,8 @@ - File type '{0}' cannot be used in a 'global using static' directive. - File type '{0}' cannot be used in a 'global using static' directive. + File-local type '{0}' cannot be used in a 'global using static' directive. + File-local type '{0}' cannot be used in a 'global using static' directive. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf index 99a504c03c8db..e44ebe336ed86 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf @@ -588,13 +588,13 @@ - File type '{0}' cannot be used as a base type of non-file type '{1}'. - File type '{0}' cannot be used as a base type of non-file type '{1}'. + File-local type '{0}' cannot be used as a base type of non-file-local type '{1}'. + File-local type '{0}' cannot be used as a base type of non-file-local type '{1}'. - File type '{0}' cannot be used in a member signature in non-file type '{1}'. - File type '{0}' cannot be used in a member signature in non-file type '{1}'. + File-local type '{0}' cannot be used in a member signature in non-file-local type '{1}'. + File-local type '{0}' cannot be used in a member signature in non-file-local type '{1}'. @@ -603,13 +603,13 @@ - File type '{0}' must be defined in a top level type; '{0}' is a nested type. - File type '{0}' must be defined in a top level type; '{0}' is a nested type. + File-local type '{0}' must be defined in a top level type; '{0}' is a nested type. + File-local type '{0}' must be defined in a top level type; '{0}' is a nested type. - File type '{0}' cannot use accessibility modifiers. - File type '{0}' cannot use accessibility modifiers. + File-local type '{0}' cannot use accessibility modifiers. + File-local type '{0}' cannot use accessibility modifiers. @@ -658,8 +658,8 @@ - File type '{0}' cannot be used in a 'global using static' directive. - File type '{0}' cannot be used in a 'global using static' directive. + File-local type '{0}' cannot be used in a 'global using static' directive. + File-local type '{0}' cannot be used in a 'global using static' directive. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf index 1c481b4cde75c..e339116673a1e 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf @@ -588,13 +588,13 @@ - File type '{0}' cannot be used as a base type of non-file type '{1}'. - File type '{0}' cannot be used as a base type of non-file type '{1}'. + File-local type '{0}' cannot be used as a base type of non-file-local type '{1}'. + File-local type '{0}' cannot be used as a base type of non-file-local type '{1}'. - File type '{0}' cannot be used in a member signature in non-file type '{1}'. - File type '{0}' cannot be used in a member signature in non-file type '{1}'. + File-local type '{0}' cannot be used in a member signature in non-file-local type '{1}'. + File-local type '{0}' cannot be used in a member signature in non-file-local type '{1}'. @@ -603,13 +603,13 @@ - File type '{0}' must be defined in a top level type; '{0}' is a nested type. - File type '{0}' must be defined in a top level type; '{0}' is a nested type. + File-local type '{0}' must be defined in a top level type; '{0}' is a nested type. + File-local type '{0}' must be defined in a top level type; '{0}' is a nested type. - File type '{0}' cannot use accessibility modifiers. - File type '{0}' cannot use accessibility modifiers. + File-local type '{0}' cannot use accessibility modifiers. + File-local type '{0}' cannot use accessibility modifiers. @@ -658,8 +658,8 @@ - File type '{0}' cannot be used in a 'global using static' directive. - File type '{0}' cannot be used in a 'global using static' directive. + File-local type '{0}' cannot be used in a 'global using static' directive. + File-local type '{0}' cannot be used in a 'global using static' directive. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf index c5b80e20dfd6f..e109544a8f9cb 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf @@ -588,13 +588,13 @@ - File type '{0}' cannot be used as a base type of non-file type '{1}'. - File type '{0}' cannot be used as a base type of non-file type '{1}'. + File-local type '{0}' cannot be used as a base type of non-file-local type '{1}'. + File-local type '{0}' cannot be used as a base type of non-file-local type '{1}'. - File type '{0}' cannot be used in a member signature in non-file type '{1}'. - File type '{0}' cannot be used in a member signature in non-file type '{1}'. + File-local type '{0}' cannot be used in a member signature in non-file-local type '{1}'. + File-local type '{0}' cannot be used in a member signature in non-file-local type '{1}'. @@ -603,13 +603,13 @@ - File type '{0}' must be defined in a top level type; '{0}' is a nested type. - File type '{0}' must be defined in a top level type; '{0}' is a nested type. + File-local type '{0}' must be defined in a top level type; '{0}' is a nested type. + File-local type '{0}' must be defined in a top level type; '{0}' is a nested type. - File type '{0}' cannot use accessibility modifiers. - File type '{0}' cannot use accessibility modifiers. + File-local type '{0}' cannot use accessibility modifiers. + File-local type '{0}' cannot use accessibility modifiers. @@ -658,8 +658,8 @@ - File type '{0}' cannot be used in a 'global using static' directive. - File type '{0}' cannot be used in a 'global using static' directive. + File-local type '{0}' cannot be used in a 'global using static' directive. + File-local type '{0}' cannot be used in a 'global using static' directive. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf index f00c5e27564ca..adb4fec56b30e 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf @@ -588,13 +588,13 @@ - File type '{0}' cannot be used as a base type of non-file type '{1}'. - File type '{0}' cannot be used as a base type of non-file type '{1}'. + File-local type '{0}' cannot be used as a base type of non-file-local type '{1}'. + File-local type '{0}' cannot be used as a base type of non-file-local type '{1}'. - File type '{0}' cannot be used in a member signature in non-file type '{1}'. - File type '{0}' cannot be used in a member signature in non-file type '{1}'. + File-local type '{0}' cannot be used in a member signature in non-file-local type '{1}'. + File-local type '{0}' cannot be used in a member signature in non-file-local type '{1}'. @@ -603,13 +603,13 @@ - File type '{0}' must be defined in a top level type; '{0}' is a nested type. - File type '{0}' must be defined in a top level type; '{0}' is a nested type. + File-local type '{0}' must be defined in a top level type; '{0}' is a nested type. + File-local type '{0}' must be defined in a top level type; '{0}' is a nested type. - File type '{0}' cannot use accessibility modifiers. - File type '{0}' cannot use accessibility modifiers. + File-local type '{0}' cannot use accessibility modifiers. + File-local type '{0}' cannot use accessibility modifiers. @@ -658,8 +658,8 @@ - File type '{0}' cannot be used in a 'global using static' directive. - File type '{0}' cannot be used in a 'global using static' directive. + File-local type '{0}' cannot be used in a 'global using static' directive. + File-local type '{0}' cannot be used in a 'global using static' directive. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf index f5152eea06c8a..36ed6f0d45577 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf @@ -588,13 +588,13 @@ - File type '{0}' cannot be used as a base type of non-file type '{1}'. - File type '{0}' cannot be used as a base type of non-file type '{1}'. + File-local type '{0}' cannot be used as a base type of non-file-local type '{1}'. + File-local type '{0}' cannot be used as a base type of non-file-local type '{1}'. - File type '{0}' cannot be used in a member signature in non-file type '{1}'. - File type '{0}' cannot be used in a member signature in non-file type '{1}'. + File-local type '{0}' cannot be used in a member signature in non-file-local type '{1}'. + File-local type '{0}' cannot be used in a member signature in non-file-local type '{1}'. @@ -603,13 +603,13 @@ - File type '{0}' must be defined in a top level type; '{0}' is a nested type. - File type '{0}' must be defined in a top level type; '{0}' is a nested type. + File-local type '{0}' must be defined in a top level type; '{0}' is a nested type. + File-local type '{0}' must be defined in a top level type; '{0}' is a nested type. - File type '{0}' cannot use accessibility modifiers. - File type '{0}' cannot use accessibility modifiers. + File-local type '{0}' cannot use accessibility modifiers. + File-local type '{0}' cannot use accessibility modifiers. @@ -658,8 +658,8 @@ - File type '{0}' cannot be used in a 'global using static' directive. - File type '{0}' cannot be used in a 'global using static' directive. + File-local type '{0}' cannot be used in a 'global using static' directive. + File-local type '{0}' cannot be used in a 'global using static' directive. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf index b4825d1d8710a..702e8b212618e 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf @@ -588,13 +588,13 @@ - File type '{0}' cannot be used as a base type of non-file type '{1}'. - File type '{0}' cannot be used as a base type of non-file type '{1}'. + File-local type '{0}' cannot be used as a base type of non-file-local type '{1}'. + File-local type '{0}' cannot be used as a base type of non-file-local type '{1}'. - File type '{0}' cannot be used in a member signature in non-file type '{1}'. - File type '{0}' cannot be used in a member signature in non-file type '{1}'. + File-local type '{0}' cannot be used in a member signature in non-file-local type '{1}'. + File-local type '{0}' cannot be used in a member signature in non-file-local type '{1}'. @@ -603,13 +603,13 @@ - File type '{0}' must be defined in a top level type; '{0}' is a nested type. - File type '{0}' must be defined in a top level type; '{0}' is a nested type. + File-local type '{0}' must be defined in a top level type; '{0}' is a nested type. + File-local type '{0}' must be defined in a top level type; '{0}' is a nested type. - File type '{0}' cannot use accessibility modifiers. - File type '{0}' cannot use accessibility modifiers. + File-local type '{0}' cannot use accessibility modifiers. + File-local type '{0}' cannot use accessibility modifiers. @@ -658,8 +658,8 @@ - File type '{0}' cannot be used in a 'global using static' directive. - File type '{0}' cannot be used in a 'global using static' directive. + File-local type '{0}' cannot be used in a 'global using static' directive. + File-local type '{0}' cannot be used in a 'global using static' directive. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf index 163f1fdbc972f..c2af4d66a1c1b 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf @@ -588,13 +588,13 @@ - File type '{0}' cannot be used as a base type of non-file type '{1}'. - File type '{0}' cannot be used as a base type of non-file type '{1}'. + File-local type '{0}' cannot be used as a base type of non-file-local type '{1}'. + File-local type '{0}' cannot be used as a base type of non-file-local type '{1}'. - File type '{0}' cannot be used in a member signature in non-file type '{1}'. - File type '{0}' cannot be used in a member signature in non-file type '{1}'. + File-local type '{0}' cannot be used in a member signature in non-file-local type '{1}'. + File-local type '{0}' cannot be used in a member signature in non-file-local type '{1}'. @@ -603,13 +603,13 @@ - File type '{0}' must be defined in a top level type; '{0}' is a nested type. - File type '{0}' must be defined in a top level type; '{0}' is a nested type. + File-local type '{0}' must be defined in a top level type; '{0}' is a nested type. + File-local type '{0}' must be defined in a top level type; '{0}' is a nested type. - File type '{0}' cannot use accessibility modifiers. - File type '{0}' cannot use accessibility modifiers. + File-local type '{0}' cannot use accessibility modifiers. + File-local type '{0}' cannot use accessibility modifiers. @@ -658,8 +658,8 @@ - File type '{0}' cannot be used in a 'global using static' directive. - File type '{0}' cannot be used in a 'global using static' directive. + File-local type '{0}' cannot be used in a 'global using static' directive. + File-local type '{0}' cannot be used in a 'global using static' directive. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf index ccb8dd1311727..4d9f80bbddfef 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf @@ -588,13 +588,13 @@ - File type '{0}' cannot be used as a base type of non-file type '{1}'. - File type '{0}' cannot be used as a base type of non-file type '{1}'. + File-local type '{0}' cannot be used as a base type of non-file-local type '{1}'. + File-local type '{0}' cannot be used as a base type of non-file-local type '{1}'. - File type '{0}' cannot be used in a member signature in non-file type '{1}'. - File type '{0}' cannot be used in a member signature in non-file type '{1}'. + File-local type '{0}' cannot be used in a member signature in non-file-local type '{1}'. + File-local type '{0}' cannot be used in a member signature in non-file-local type '{1}'. @@ -603,13 +603,13 @@ - File type '{0}' must be defined in a top level type; '{0}' is a nested type. - File type '{0}' must be defined in a top level type; '{0}' is a nested type. + File-local type '{0}' must be defined in a top level type; '{0}' is a nested type. + File-local type '{0}' must be defined in a top level type; '{0}' is a nested type. - File type '{0}' cannot use accessibility modifiers. - File type '{0}' cannot use accessibility modifiers. + File-local type '{0}' cannot use accessibility modifiers. + File-local type '{0}' cannot use accessibility modifiers. @@ -658,8 +658,8 @@ - File type '{0}' cannot be used in a 'global using static' directive. - File type '{0}' cannot be used in a 'global using static' directive. + File-local type '{0}' cannot be used in a 'global using static' directive. + File-local type '{0}' cannot be used in a 'global using static' directive. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf index a8ea9ff3480d1..5117c46b5cb7f 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf @@ -588,13 +588,13 @@ - File type '{0}' cannot be used as a base type of non-file type '{1}'. - File type '{0}' cannot be used as a base type of non-file type '{1}'. + File-local type '{0}' cannot be used as a base type of non-file-local type '{1}'. + File-local type '{0}' cannot be used as a base type of non-file-local type '{1}'. - File type '{0}' cannot be used in a member signature in non-file type '{1}'. - File type '{0}' cannot be used in a member signature in non-file type '{1}'. + File-local type '{0}' cannot be used in a member signature in non-file-local type '{1}'. + File-local type '{0}' cannot be used in a member signature in non-file-local type '{1}'. @@ -603,13 +603,13 @@ - File type '{0}' must be defined in a top level type; '{0}' is a nested type. - File type '{0}' must be defined in a top level type; '{0}' is a nested type. + File-local type '{0}' must be defined in a top level type; '{0}' is a nested type. + File-local type '{0}' must be defined in a top level type; '{0}' is a nested type. - File type '{0}' cannot use accessibility modifiers. - File type '{0}' cannot use accessibility modifiers. + File-local type '{0}' cannot use accessibility modifiers. + File-local type '{0}' cannot use accessibility modifiers. @@ -658,8 +658,8 @@ - File type '{0}' cannot be used in a 'global using static' directive. - File type '{0}' cannot be used in a 'global using static' directive. + File-local type '{0}' cannot be used in a 'global using static' directive. + File-local type '{0}' cannot be used in a 'global using static' directive. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf index b733798cd83b4..7953331173964 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf @@ -588,13 +588,13 @@ - File type '{0}' cannot be used as a base type of non-file type '{1}'. - File type '{0}' cannot be used as a base type of non-file type '{1}'. + File-local type '{0}' cannot be used as a base type of non-file-local type '{1}'. + File-local type '{0}' cannot be used as a base type of non-file-local type '{1}'. - File type '{0}' cannot be used in a member signature in non-file type '{1}'. - File type '{0}' cannot be used in a member signature in non-file type '{1}'. + File-local type '{0}' cannot be used in a member signature in non-file-local type '{1}'. + File-local type '{0}' cannot be used in a member signature in non-file-local type '{1}'. @@ -603,13 +603,13 @@ - File type '{0}' must be defined in a top level type; '{0}' is a nested type. - File type '{0}' must be defined in a top level type; '{0}' is a nested type. + File-local type '{0}' must be defined in a top level type; '{0}' is a nested type. + File-local type '{0}' must be defined in a top level type; '{0}' is a nested type. - File type '{0}' cannot use accessibility modifiers. - File type '{0}' cannot use accessibility modifiers. + File-local type '{0}' cannot use accessibility modifiers. + File-local type '{0}' cannot use accessibility modifiers. @@ -658,8 +658,8 @@ - File type '{0}' cannot be used in a 'global using static' directive. - File type '{0}' cannot be used in a 'global using static' directive. + File-local type '{0}' cannot be used in a 'global using static' directive. + File-local type '{0}' cannot be used in a 'global using static' directive. diff --git a/src/Compilers/CSharp/Test/Symbol/Symbols/Source/FileModifierTests.cs b/src/Compilers/CSharp/Test/Symbol/Symbols/Source/FileModifierTests.cs index dd70659524ee9..b27f17ef1d8f8 100644 --- a/src/Compilers/CSharp/Test/Symbol/Symbols/Source/FileModifierTests.cs +++ b/src/Compilers/CSharp/Test/Symbol/Symbols/Source/FileModifierTests.cs @@ -47,13 +47,13 @@ file class C { } // (3,16): error CS8936: Feature 'file types' is not available in C# 10.0. Please use language version 11.0 or greater. // file class C { } Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion10, "C").WithArguments("file types", "11.0").WithLocation(3, 16), - // (3,16): error CS9054: File type 'Outer.C' must be defined in a top level type; 'Outer.C' is a nested type. + // (3,16): error CS9054: File-local type 'Outer.C' must be defined in a top level type; 'Outer.C' is a nested type. // file class C { } Diagnostic(ErrorCode.ERR_FileTypeNested, "C").WithArguments("Outer.C").WithLocation(3, 16)); comp = CreateCompilation(source); comp.VerifyDiagnostics( - // (3,16): error CS9054: File type 'Outer.C' must be defined in a top level type; 'Outer.C' is a nested type. + // (3,16): error CS9054: File-local type 'Outer.C' must be defined in a top level type; 'Outer.C' is a nested type. // file class C { } Diagnostic(ErrorCode.ERR_FileTypeNested, "C").WithArguments("Outer.C").WithLocation(3, 16)); } @@ -83,11 +83,11 @@ void verify() { var outer = comp.GetMember("Outer"); Assert.Equal(Accessibility.Internal, outer.DeclaredAccessibility); - Assert.True(((SourceMemberContainerTypeSymbol)outer).IsFile); + Assert.True(((SourceMemberContainerTypeSymbol)outer).IsFileLocal); var classC = comp.GetMember("Outer.C"); Assert.Equal(Accessibility.Private, classC.DeclaredAccessibility); - Assert.False(((SourceMemberContainerTypeSymbol)classC).IsFile); + Assert.False(((SourceMemberContainerTypeSymbol)classC).IsFileLocal); } } @@ -109,13 +109,13 @@ file class C { } // (3,16): error CS8936: Feature 'file types' is not available in C# 10.0. Please use language version 11.0 or greater. // file class C { } Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion10, "C").WithArguments("file types", "11.0").WithLocation(3, 16), - // (3,16): error CS9054: File type 'Outer.C' must be defined in a top level type; 'Outer.C' is a nested type. + // (3,16): error CS9054: File-local type 'Outer.C' must be defined in a top level type; 'Outer.C' is a nested type. // file class C { } Diagnostic(ErrorCode.ERR_FileTypeNested, "C").WithArguments("Outer.C").WithLocation(3, 16)); comp = CreateCompilation(source); comp.VerifyDiagnostics( - // (3,16): error CS9054: File type 'Outer.C' must be defined in a top level type; 'Outer.C' is a nested type. + // (3,16): error CS9054: File-local type 'Outer.C' must be defined in a top level type; 'Outer.C' is a nested type. // file class C { } Diagnostic(ErrorCode.ERR_FileTypeNested, "C").WithArguments("Outer.C").WithLocation(3, 16)); } @@ -137,7 +137,7 @@ void M(Outer.C c) { } // 1 var comp = CreateCompilation(source); comp.VerifyDiagnostics( - // (8,10): error CS9051: File type 'Outer.C' cannot be used in a member signature in non-file type 'D'. + // (8,10): error CS9051: File-local type 'Outer.C' cannot be used in a member signature in non-file-local type 'D'. // void M(Outer.C c) { } // 1 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "M").WithArguments("Outer.C", "D").WithLocation(8, 10)); } @@ -396,7 +396,7 @@ static void Main() var comp = CreateCompilation(source); comp.VerifyDiagnostics( - // (10,12): error CS9051: File type 'E' cannot be used in a member signature in non-file type 'Attr'. + // (10,12): error CS9051: File-local type 'E' cannot be used in a member signature in non-file-local type 'Attr'. // public Attr(E e) { } // 1 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "Attr").WithArguments("E", "Attr").WithLocation(10, 12)); } @@ -713,8 +713,8 @@ void validateSymbols(ModuleSymbol module) [InlineData("", "file", "C", "<>F1__C")] public void Duplication_01(string firstFileModifier, string secondFileModifier, string firstMetadataName, string secondMetadataName) { - // A file type is allowed to have the same name as a non-file type from a different file. - // When both a file type and non-file type with the same name are in scope, the file type is preferred, since it's "more local". + // A file-local type is allowed to have the same name as a non-file-local type from a different file. + // When both a file-local type and non-file-local type with the same name are in scope, the file-local type is preferred, since it's "more local". var source1 = $$""" using System; @@ -896,7 +896,7 @@ static void Main() Assert.Equal(2, cs.Length); var c0 = cs[0]; - Assert.True(c0 is SourceMemberContainerTypeSymbol { IsFile: false }); + Assert.True(c0 is SourceMemberContainerTypeSymbol { IsFileLocal: false }); var syntaxReferences = c0.DeclaringSyntaxReferences; Assert.Equal(2, syntaxReferences.Length); @@ -904,7 +904,7 @@ static void Main() Assert.Equal(comp.SyntaxTrees[1], syntaxReferences[1].SyntaxTree); var c1 = cs[1]; - Assert.True(c1 is SourceMemberContainerTypeSymbol { IsFile: true }); + Assert.True(c1 is SourceMemberContainerTypeSymbol { IsFileLocal: true }); Assert.Equal(comp.SyntaxTrees[2], c1.DeclaringSyntaxReferences.Single().SyntaxTree); var tree = comp.SyntaxTrees[2]; @@ -962,11 +962,11 @@ static void Main() Assert.Equal(2, cs.Length); var c0 = cs[0]; - Assert.True(c0 is SourceMemberContainerTypeSymbol { IsFile: false }); + Assert.True(c0 is SourceMemberContainerTypeSymbol { IsFileLocal: false }); Assert.Equal(comp.SyntaxTrees[0], c0.DeclaringSyntaxReferences.Single().SyntaxTree); var c1 = cs[1]; - Assert.True(c1 is SourceMemberContainerTypeSymbol { IsFile: true }); + Assert.True(c1 is SourceMemberContainerTypeSymbol { IsFileLocal: true }); var syntaxReferences = c1.DeclaringSyntaxReferences; Assert.Equal(2, syntaxReferences.Length); @@ -1024,11 +1024,11 @@ static void Main() Assert.Equal(2, cs.Length); var c0 = cs[0]; - Assert.Equal(firstClassIsFile, ((SourceMemberContainerTypeSymbol)c0).IsFile); + Assert.Equal(firstClassIsFile, ((SourceMemberContainerTypeSymbol)c0).IsFileLocal); Assert.Equal(comp.SyntaxTrees[0], c0.DeclaringSyntaxReferences.Single().SyntaxTree); var c1 = cs[1]; - Assert.True(c1 is SourceMemberContainerTypeSymbol { IsFile: true }); + Assert.True(c1 is SourceMemberContainerTypeSymbol { IsFileLocal: true }); Assert.Equal(comp.SyntaxTrees[1], c1.DeclaringSyntaxReferences.Single().SyntaxTree); var tree = comp.SyntaxTrees[1]; @@ -1082,14 +1082,14 @@ public static void M() Assert.Equal(2, cs.Length); var c0 = cs[0]; - Assert.True(c0 is SourceMemberContainerTypeSymbol { IsFile: false }); + Assert.True(c0 is SourceMemberContainerTypeSymbol { IsFileLocal: false }); var syntaxReferences = c0.DeclaringSyntaxReferences; Assert.Equal(2, syntaxReferences.Length); Assert.Equal(comp.SyntaxTrees[0], syntaxReferences[0].SyntaxTree); Assert.Equal(comp.SyntaxTrees[1], syntaxReferences[1].SyntaxTree); var c1 = cs[1]; - Assert.True(c1 is SourceMemberContainerTypeSymbol { IsFile: true }); + Assert.True(c1 is SourceMemberContainerTypeSymbol { IsFileLocal: true }); Assert.Equal(comp.SyntaxTrees[1], c1.DeclaringSyntaxReferences.Single().SyntaxTree); @@ -1103,7 +1103,7 @@ public static void M() Diagnostic(ErrorCode.ERR_MissingPartial, "C").WithArguments("C").WithLocation(8, 12)); var c = comp.GetMember("C"); - Assert.True(c is SourceMemberContainerTypeSymbol { IsFile: true }); + Assert.True(c is SourceMemberContainerTypeSymbol { IsFileLocal: true }); syntaxReferences = c.DeclaringSyntaxReferences; Assert.Equal(3, syntaxReferences.Length); Assert.Equal(comp.SyntaxTrees[0], syntaxReferences[0].SyntaxTree); @@ -1153,11 +1153,11 @@ file class C Assert.Equal(2, cs.Length); var c0 = cs[0]; - Assert.True(c0 is SourceMemberContainerTypeSymbol { IsFile: true }); + Assert.True(c0 is SourceMemberContainerTypeSymbol { IsFileLocal: true }); Assert.Equal(comp.SyntaxTrees[0], c0.DeclaringSyntaxReferences.Single().SyntaxTree); var c1 = cs[1]; - Assert.True(c1 is SourceMemberContainerTypeSymbol { IsFile: true }); + Assert.True(c1 is SourceMemberContainerTypeSymbol { IsFileLocal: true }); var syntaxReferences = c1.DeclaringSyntaxReferences; Assert.Equal(2, syntaxReferences.Length); Assert.Equal(comp.SyntaxTrees[1], syntaxReferences[0].SyntaxTree); @@ -1174,14 +1174,14 @@ file class C Assert.Equal(2, cs.Length); c0 = cs[0]; - Assert.True(c0 is SourceMemberContainerTypeSymbol { IsFile: true }); + Assert.True(c0 is SourceMemberContainerTypeSymbol { IsFileLocal: true }); syntaxReferences = c0.DeclaringSyntaxReferences; Assert.Equal(2, syntaxReferences.Length); Assert.Equal(comp.SyntaxTrees[0], syntaxReferences[0].SyntaxTree); Assert.Equal(comp.SyntaxTrees[0], syntaxReferences[1].SyntaxTree); c1 = cs[1]; - Assert.True(c1 is SourceMemberContainerTypeSymbol { IsFile: true }); + Assert.True(c1 is SourceMemberContainerTypeSymbol { IsFileLocal: true }); Assert.Equal(comp.SyntaxTrees[1], c1.DeclaringSyntaxReferences.Single().SyntaxTree); } @@ -1220,19 +1220,19 @@ public static void M() { } var compilation = CreateCompilation(new[] { source1, source2, source3 }); compilation.VerifyDiagnostics( - // (3,16): error CS9054: File type 'Outer.C' must be defined in a top level type; 'Outer.C' is a nested type. + // (3,16): error CS9054: File-local type 'Outer.C' must be defined in a top level type; 'Outer.C' is a nested type. // file class C Diagnostic(ErrorCode.ERR_FileTypeNested, "C").WithArguments("Outer.C").WithLocation(3, 16), - // (3,16): error CS9054: File type 'Outer.C' must be defined in a top level type; 'Outer.C' is a nested type. + // (3,16): error CS9054: File-local type 'Outer.C' must be defined in a top level type; 'Outer.C' is a nested type. // file class C Diagnostic(ErrorCode.ERR_FileTypeNested, "C").WithArguments("Outer.C").WithLocation(3, 16)); var classOuter = compilation.GetMember("Outer"); var cs = classOuter.GetMembers("C"); Assert.Equal(3, cs.Length); - Assert.True(cs[0] is SourceMemberContainerTypeSymbol { IsFile: true }); - Assert.True(cs[1] is SourceMemberContainerTypeSymbol { IsFile: true }); - Assert.True(cs[2] is SourceMemberContainerTypeSymbol { IsFile: false }); + Assert.True(cs[0] is SourceMemberContainerTypeSymbol { IsFileLocal: true }); + Assert.True(cs[1] is SourceMemberContainerTypeSymbol { IsFileLocal: true }); + Assert.True(cs[2] is SourceMemberContainerTypeSymbol { IsFileLocal: false }); } [Fact] @@ -1274,9 +1274,9 @@ public static void M() { } var namespaceNS = compilation.GetMember("NS"); var cs = namespaceNS.GetMembers("C"); Assert.Equal(3, cs.Length); - Assert.True(cs[0] is SourceMemberContainerTypeSymbol { IsFile: true }); - Assert.True(cs[1] is SourceMemberContainerTypeSymbol { IsFile: true }); - Assert.True(cs[2] is SourceMemberContainerTypeSymbol { IsFile: false }); + Assert.True(cs[0] is SourceMemberContainerTypeSymbol { IsFileLocal: true }); + Assert.True(cs[1] is SourceMemberContainerTypeSymbol { IsFileLocal: true }); + Assert.True(cs[2] is SourceMemberContainerTypeSymbol { IsFileLocal: false }); } [Theory] @@ -1579,10 +1579,10 @@ private void M2(C c) { } // 2 var comp = CreateCompilation(source); comp.VerifyDiagnostics( - // (7,17): error CS9051: File type 'C' cannot be used in a member signature in non-file type 'D'. + // (7,17): error CS9051: File-local type 'C' cannot be used in a member signature in non-file-local type 'D'. // public void M1(C c) { } // 1 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "M1").WithArguments("C", "D").WithLocation(7, 17), - // (8,18): error CS9051: File type 'C' cannot be used in a member signature in non-file type 'D'. + // (8,18): error CS9051: File-local type 'C' cannot be used in a member signature in non-file-local type 'D'. // private void M2(C c) { } // 2 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "M2").WithArguments("C", "D").WithLocation(8, 18)); } @@ -1604,10 +1604,10 @@ class D var comp = CreateCompilation(source); comp.VerifyDiagnostics( - // (7,14): error CS9051: File type 'C' cannot be used in a member signature in non-file type 'D'. + // (7,14): error CS9051: File-local type 'C' cannot be used in a member signature in non-file-local type 'D'. // public C M1() => new C(); // 1 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "M1").WithArguments("C", "D").WithLocation(7, 14), - // (8,15): error CS9051: File type 'C' cannot be used in a member signature in non-file type 'D'. + // (8,15): error CS9051: File-local type 'C' cannot be used in a member signature in non-file-local type 'D'. // private C M2() => new C(); // 2 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "M2").WithArguments("C", "D").WithLocation(8, 15)); } @@ -1632,19 +1632,19 @@ public class E var comp = CreateCompilation(source); comp.VerifyDiagnostics( - // (8,7): error CS9051: File type 'C' cannot be used in a member signature in non-file type 'E'. + // (8,7): error CS9051: File-local type 'C' cannot be used in a member signature in non-file-local type 'E'. // C field; // 1 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "field").WithArguments("C", "E").WithLocation(8, 7), // (8,7): warning CS0169: The field 'E.field' is never used // C field; // 1 Diagnostic(ErrorCode.WRN_UnreferencedField, "field").WithArguments("E.field").WithLocation(8, 7), - // (9,7): error CS9051: File type 'C' cannot be used in a member signature in non-file type 'E'. + // (9,7): error CS9051: File-local type 'C' cannot be used in a member signature in non-file-local type 'E'. // C property { get; set; } // 2 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "property").WithArguments("C", "E").WithLocation(9, 7), - // (10,12): error CS9051: File type 'C' cannot be used in a member signature in non-file type 'E'. + // (10,12): error CS9051: File-local type 'C' cannot be used in a member signature in non-file-local type 'E'. // object this[C c] { get => c; set { } } // 3 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "this").WithArguments("C", "E").WithLocation(10, 12), - // (11,13): error CS9051: File type 'D' cannot be used in a member signature in non-file type 'E'. + // (11,13): error CS9051: File-local type 'D' cannot be used in a member signature in non-file-local type 'E'. // event D @event; // 4 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "@event").WithArguments("D", "E").WithLocation(11, 13), // (11,13): warning CS0067: The event 'E.event' is never used @@ -1673,19 +1673,19 @@ public class E var comp = CreateCompilation(source); comp.VerifyDiagnostics( - // (9,13): error CS9051: File type 'C.Inner' cannot be used in a member signature in non-file type 'E'. + // (9,13): error CS9051: File-local type 'C.Inner' cannot be used in a member signature in non-file-local type 'E'. // C.Inner field; // 1 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "field").WithArguments("C.Inner", "E").WithLocation(9, 13), // (9,13): warning CS0169: The field 'E.field' is never used // C.Inner field; // 1 Diagnostic(ErrorCode.WRN_UnreferencedField, "field").WithArguments("E.field").WithLocation(9, 13), - // (10,13): error CS9051: File type 'C.Inner' cannot be used in a member signature in non-file type 'E'. + // (10,13): error CS9051: File-local type 'C.Inner' cannot be used in a member signature in non-file-local type 'E'. // C.Inner property { get; set; } // 2 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "property").WithArguments("C.Inner", "E").WithLocation(10, 13), - // (11,12): error CS9051: File type 'C.Inner' cannot be used in a member signature in non-file type 'E'. + // (11,12): error CS9051: File-local type 'C.Inner' cannot be used in a member signature in non-file-local type 'E'. // object this[C.Inner inner] { get => inner; set { } } // 3 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "this").WithArguments("C.Inner", "E").WithLocation(11, 12), - // (12,27): error CS9051: File type 'C.InnerDelegate' cannot be used in a member signature in non-file type 'E'. + // (12,27): error CS9051: File-local type 'C.InnerDelegate' cannot be used in a member signature in non-file-local type 'E'. // event C.InnerDelegate @event; // 4 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "@event").WithArguments("C.InnerDelegate", "E").WithLocation(12, 27), // (12,27): warning CS0067: The event 'E.event' is never used @@ -1730,16 +1730,16 @@ public class Inner var comp = CreateCompilation(source); comp.VerifyDiagnostics( - // (24,17): error CS9051: File type 'C.Inner' cannot be used in a member signature in non-file type 'E.Inner'. + // (24,17): error CS9051: File-local type 'C.Inner' cannot be used in a member signature in non-file-local type 'E.Inner'. // C.Inner field; // 1 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "field").WithArguments("C.Inner", "E.Inner").WithLocation(24, 17), - // (25,17): error CS9051: File type 'C.Inner' cannot be used in a member signature in non-file type 'E.Inner'. + // (25,17): error CS9051: File-local type 'C.Inner' cannot be used in a member signature in non-file-local type 'E.Inner'. // C.Inner property { get; set; } // 2 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "property").WithArguments("C.Inner", "E.Inner").WithLocation(25, 17), - // (26,16): error CS9051: File type 'C.Inner' cannot be used in a member signature in non-file type 'E.Inner'. + // (26,16): error CS9051: File-local type 'C.Inner' cannot be used in a member signature in non-file-local type 'E.Inner'. // object this[C.Inner inner] { get => inner; set { } } // 3 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "this").WithArguments("C.Inner", "E.Inner").WithLocation(26, 16), - // (27,31): error CS9051: File type 'C.InnerDelegate' cannot be used in a member signature in non-file type 'E.Inner'. + // (27,31): error CS9051: File-local type 'C.InnerDelegate' cannot be used in a member signature in non-file-local type 'E.Inner'. // event C.InnerDelegate @event; // 4 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "@event").WithArguments("C.InnerDelegate", "E.Inner").WithLocation(27, 31)); } @@ -1758,10 +1758,10 @@ file class C var comp = CreateCompilation(source); comp.VerifyDiagnostics( - // (5,15): error CS9051: File type 'C' cannot be used in a member signature in non-file type 'Del1'. + // (5,15): error CS9051: File-local type 'C' cannot be used in a member signature in non-file-local type 'Del1'. // delegate void Del1(C c); // 1 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "Del1").WithArguments("C", "Del1").WithLocation(5, 15), - // (6,12): error CS9051: File type 'C' cannot be used in a member signature in non-file type 'Del2'. + // (6,12): error CS9051: File-local type 'C' cannot be used in a member signature in non-file-local type 'Del2'. // delegate C Del2(); // 2 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "Del2").WithArguments("C", "Del2").WithLocation(6, 12)); } @@ -1783,10 +1783,10 @@ class D var comp = CreateCompilation(source); comp.VerifyDiagnostics( - // (7,30): error CS9051: File type 'C' cannot be used in a member signature in non-file type 'D'. + // (7,30): error CS9051: File-local type 'C' cannot be used in a member signature in non-file-local type 'D'. // public static D operator +(D d, C c) => d; // 1 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "+").WithArguments("C", "D").WithLocation(7, 30), - // (8,30): error CS9051: File type 'C' cannot be used in a member signature in non-file type 'D'. + // (8,30): error CS9051: File-local type 'C' cannot be used in a member signature in non-file-local type 'D'. // public static C operator -(D d1, D d2) => new C(); // 2 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "-").WithArguments("C", "D").WithLocation(8, 30)); } @@ -1807,7 +1807,7 @@ public D(C c) { } // 1 var comp = CreateCompilation(source); comp.VerifyDiagnostics( - // (7,12): error CS9051: File type 'C' cannot be used in a member signature in non-file type 'D'. + // (7,12): error CS9051: File-local type 'C' cannot be used in a member signature in non-file-local type 'D'. // public D(C c) { } // 1 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "D").WithArguments("C", "D").WithLocation(7, 12)); } @@ -1828,13 +1828,13 @@ class D var comp = CreateCompilation(source); comp.VerifyDiagnostics( - // (7,14): error CS9051: File type 'C' cannot be used in a member signature in non-file type 'D'. + // (7,14): error CS9051: File-local type 'C' cannot be used in a member signature in non-file-local type 'D'. // public C M(C c1, C c2) => c1; // 1, 2, 3 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "M").WithArguments("C", "D").WithLocation(7, 14), - // (7,14): error CS9051: File type 'C' cannot be used in a member signature in non-file type 'D'. + // (7,14): error CS9051: File-local type 'C' cannot be used in a member signature in non-file-local type 'D'. // public C M(C c1, C c2) => c1; // 1, 2, 3 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "M").WithArguments("C", "D").WithLocation(7, 14), - // (7,14): error CS9051: File type 'C' cannot be used in a member signature in non-file type 'D'. + // (7,14): error CS9051: File-local type 'C' cannot be used in a member signature in non-file-local type 'D'. // public C M(C c1, C c2) => c1; // 1, 2, 3 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "M").WithArguments("C", "D").WithLocation(7, 14)); } @@ -1851,13 +1851,13 @@ file class F { } // ok var comp = CreateCompilation(source); comp.VerifyDiagnostics( - // (1,19): error CS9052: File type 'C' cannot use accessibility modifiers. + // (1,19): error CS9052: File-local type 'C' cannot use accessibility modifiers. // public file class C { } // 1 Diagnostic(ErrorCode.ERR_FileTypeNoExplicitAccessibility, "C").WithArguments("C").WithLocation(1, 19), - // (2,21): error CS9052: File type 'D' cannot use accessibility modifiers. + // (2,21): error CS9052: File-local type 'D' cannot use accessibility modifiers. // file internal class D { } // 2 Diagnostic(ErrorCode.ERR_FileTypeNoExplicitAccessibility, "D").WithArguments("D").WithLocation(2, 21), - // (3,20): error CS9052: File type 'E' cannot use accessibility modifiers. + // (3,20): error CS9052: File-local type 'E' cannot use accessibility modifiers. // private file class E { } // 3, 4 Diagnostic(ErrorCode.ERR_FileTypeNoExplicitAccessibility, "E").WithArguments("E").WithLocation(3, 20), // (3,20): error CS1527: Elements defined in a namespace cannot be explicitly declared as private, protected, protected internal, or private protected @@ -1895,13 +1895,13 @@ public class Derived2 : Base { } // 2, 3 var comp = CreateCompilation(source); comp.VerifyDiagnostics( - // (2,7): error CS9053: File type 'Base' cannot be used as a base type of non-file type 'Derived1'. + // (2,7): error CS9053: File-local type 'Base' cannot be used as a base type of non-file-local type 'Derived1'. // class Derived1 : Base { } // 1 Diagnostic(ErrorCode.ERR_FileTypeBase, "Derived1").WithArguments("Base", "Derived1").WithLocation(2, 7), // (3,14): error CS0060: Inconsistent accessibility: base class 'Base' is less accessible than class 'Derived2' // public class Derived2 : Base { } // 2, 3 Diagnostic(ErrorCode.ERR_BadVisBaseClass, "Derived2").WithArguments("Derived2", "Base").WithLocation(3, 14), - // (3,14): error CS9053: File type 'Base' cannot be used as a base type of non-file type 'Derived2'. + // (3,14): error CS9053: File-local type 'Base' cannot be used as a base type of non-file-local type 'Derived2'. // public class Derived2 : Base { } // 2, 3 Diagnostic(ErrorCode.ERR_FileTypeBase, "Derived2").WithArguments("Base", "Derived2").WithLocation(3, 14)); } @@ -1921,7 +1921,7 @@ interface Derived3 : Interface { } // 1 var comp = CreateCompilation(source); comp.VerifyDiagnostics( - // (6,11): error CS9053: File type 'Interface' cannot be used as a base type of non-file type 'Derived3'. + // (6,11): error CS9053: File-local type 'Interface' cannot be used as a base type of non-file-local type 'Derived3'. // interface Derived3 : Interface { } // 1 Diagnostic(ErrorCode.ERR_FileTypeBase, "Derived3").WithArguments("Interface", "Derived3").WithLocation(6, 11)); } @@ -2026,7 +2026,7 @@ partial interface Derived : I2 { } var comp = CreateCompilation(source); comp.VerifyDiagnostics( - // (3,19): error CS9053: File type 'I1' cannot be used as a base type of non-file type 'Derived'. + // (3,19): error CS9053: File-local type 'I1' cannot be used as a base type of non-file-local type 'Derived'. // partial interface Derived : I1 { } // 1 Diagnostic(ErrorCode.ERR_FileTypeBase, "Derived").WithArguments("I1", "Derived").WithLocation(3, 19)); } @@ -2065,7 +2065,7 @@ public void F(I i) { } // 1 var comp = CreateCompilation(source); comp.VerifyDiagnostics( - // (7,17): error CS9051: File type 'I' cannot be used in a member signature in non-file type 'C'. + // (7,17): error CS9051: File-local type 'I' cannot be used in a member signature in non-file-local type 'C'. // public void F(I i) { } // 1 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "F").WithArguments("I", "C").WithLocation(7, 17)); } @@ -2086,7 +2086,7 @@ void I.F(I i) { } var comp = CreateCompilation(source); comp.VerifyDiagnostics( - // (7,12): error CS9051: File type 'I' cannot be used in a member signature in non-file type 'C'. + // (7,12): error CS9051: File-local type 'I' cannot be used in a member signature in non-file-local type 'C'. // void I.F(I i) { } Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "F").WithArguments("I", "C").WithLocation(7, 12)); } @@ -2171,19 +2171,19 @@ unsafe class Program // (1,28): warning CS0649: Field 'S.X' is never assigned to, and will always have its default value 0 // file struct S { public int X; } Diagnostic(ErrorCode.WRN_UnassignedInternalField, "X").WithArguments("S.X", "0").WithLocation(1, 28), - // (5,18): error CS9051: File type 'Container' cannot be used in a member signature in non-file type 'Program'. + // (5,18): error CS9051: File-local type 'Container' cannot be used in a member signature in non-file-local type 'Program'. // Container M1() => new Container(); // 1 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "M1").WithArguments("Container", "Program").WithLocation(5, 18), - // (6,9): error CS9051: File type 'S[]' cannot be used in a member signature in non-file type 'Program'. + // (6,9): error CS9051: File-local type 'S[]' cannot be used in a member signature in non-file-local type 'Program'. // S[] M2() => new S[0]; // 2 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "M2").WithArguments("S[]", "Program").WithLocation(6, 9), - // (7,12): error CS9051: File type '(S, S)' cannot be used in a member signature in non-file type 'Program'. + // (7,12): error CS9051: File-local type '(S, S)' cannot be used in a member signature in non-file-local type 'Program'. // (S, S) M3() => (new S(), new S()); // 3 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "M3").WithArguments("(S, S)", "Program").WithLocation(7, 12), - // (8,8): error CS9051: File type 'S*' cannot be used in a member signature in non-file type 'Program'. + // (8,8): error CS9051: File-local type 'S*' cannot be used in a member signature in non-file-local type 'Program'. // S* M4() => null; // 4 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "M4").WithArguments("S*", "Program").WithLocation(8, 8), - // (9,24): error CS9051: File type 'delegate*' cannot be used in a member signature in non-file type 'Program'. + // (9,24): error CS9051: File-local type 'delegate*' cannot be used in a member signature in non-file-local type 'Program'. // delegate* M5() => null; // 5 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "M5").WithArguments("delegate*", "Program").WithLocation(9, 24)); } @@ -2207,7 +2207,7 @@ void M(T t) where T : C { } // 1 var comp = CreateCompilation(source); comp.VerifyDiagnostics( - // (10,30): error CS9051: File type 'C' cannot be used in a member signature in non-file type 'E.M(T)'. + // (10,30): error CS9051: File-local type 'C' cannot be used in a member signature in non-file-local type 'E.M(T)'. // void M(T t) where T : C { } // 1 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "C").WithArguments("C", "E.M(T)").WithLocation(10, 30)); } @@ -2234,7 +2234,7 @@ file class C { } var comp = CreateCompilation(source); comp.VerifyDiagnostics( - // (7,{{17 + typeKind.Length}}): error CS9051: File type 'C' cannot be used in a member signature in non-file type 'E'. + // (7,{{17 + typeKind.Length}}): error CS9051: File-local type 'C' cannot be used in a member signature in non-file-local type 'E'. // {{typeKind}} E where T : C // 1 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "C").WithArguments("C", "E").WithLocation(7, 17 + typeKind.Length)); } @@ -2282,7 +2282,7 @@ file class C { } var comp = CreateCompilation(source); comp.VerifyDiagnostics( - // (5,36): error CS9051: File type 'C' cannot be used in a member signature in non-file type 'D2'. + // (5,36): error CS9051: File-local type 'C' cannot be used in a member signature in non-file-local type 'D2'. // delegate void D2(T t) where T : C; // 1 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "C").WithArguments("C", "D2").WithLocation(5, 36)); } @@ -2302,16 +2302,16 @@ record struct R2(C c); // 2 var comp = CreateCompilation(new[] { source, IsExternalInitTypeDefinition }); comp.VerifyDiagnostics( - // (3,8): error CS9051: File type 'C' cannot be used in a member signature in non-file type 'R1'. + // (3,8): error CS9051: File-local type 'C' cannot be used in a member signature in non-file-local type 'R1'. // record R1(C c); // 1 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "R1").WithArguments("C", "R1").WithLocation(3, 8), - // (3,8): error CS9051: File type 'C' cannot be used in a member signature in non-file type 'R1'. + // (3,8): error CS9051: File-local type 'C' cannot be used in a member signature in non-file-local type 'R1'. // record R1(C c); // 1 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "R1").WithArguments("C", "R1").WithLocation(3, 8), - // (4,15): error CS9051: File type 'C' cannot be used in a member signature in non-file type 'R2'. + // (4,15): error CS9051: File-local type 'C' cannot be used in a member signature in non-file-local type 'R2'. // record struct R2(C c); // 2 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "R2").WithArguments("C", "R2").WithLocation(4, 15), - // (4,15): error CS9051: File type 'C' cannot be used in a member signature in non-file type 'R2'. + // (4,15): error CS9051: File-local type 'C' cannot be used in a member signature in non-file-local type 'R2'. // record struct R2(C c); // 2 Diagnostic(ErrorCode.ERR_FileTypeDisallowedInSignature, "R2").WithArguments("C", "R2").WithLocation(4, 15) ); @@ -2443,7 +2443,7 @@ public static void Main() var comp = CreateCompilation(source); comp.VerifyDiagnostics( - // (5,16): error CS9054: File type 'Outer.C' must be defined in a top level type; 'Outer.C' is a nested type. + // (5,16): error CS9054: File-local type 'Outer.C' must be defined in a top level type; 'Outer.C' is a nested type. // file class C // 1 Diagnostic(ErrorCode.ERR_FileTypeNested, "C").WithArguments("Outer.C").WithLocation(5, 16), // (15,15): error CS0122: 'Outer.C' is inaccessible due to its protection level @@ -2484,7 +2484,7 @@ static void Main() // (5,15): error CS0117: 'Outer' does not contain a definition for 'C' // Outer.C.M(); // 1 Diagnostic(ErrorCode.ERR_NoSuchMember, "C").WithArguments("Outer", "C").WithLocation(5, 15), - // (5,16): error CS9054: File type 'Outer.C' must be defined in a top level type; 'Outer.C' is a nested type. + // (5,16): error CS9054: File-local type 'Outer.C' must be defined in a top level type; 'Outer.C' is a nested type. // file class C Diagnostic(ErrorCode.ERR_FileTypeNested, "C").WithArguments("Outer.C").WithLocation(5, 16)); } @@ -2581,7 +2581,7 @@ public static void Main() // (1,1): hidden CS8019: Unnecessary using directive. // global using static C; Diagnostic(ErrorCode.HDN_UnusedUsingDirective, "global using static C;").WithLocation(1, 1), - // (1,21): error CS9055: File type 'C' cannot be used in a 'global using static' directive. + // (1,21): error CS9055: File-local type 'C' cannot be used in a 'global using static' directive. // global using static C; Diagnostic(ErrorCode.ERR_GlobalUsingStaticFileType, "C").WithArguments("C").WithLocation(1, 21), // (5,9): error CS0103: The name 'M' does not exist in the current context @@ -2620,7 +2620,7 @@ public static void Main() // (1,1): hidden CS8019: Unnecessary using directive. // global using static Container; Diagnostic(ErrorCode.HDN_UnusedUsingDirective, "global using static Container;").WithLocation(1, 1), - // (1,21): error CS9055: File type 'Container' cannot be used in a 'global using static' directive. + // (1,21): error CS9055: File-local type 'Container' cannot be used in a 'global using static' directive. // global using static Container; Diagnostic(ErrorCode.ERR_GlobalUsingStaticFileType, "Container").WithArguments("Container").WithLocation(1, 21), // (5,9): error CS0103: The name 'M' does not exist in the current context @@ -2791,7 +2791,7 @@ public static void Main() // 'Derived.C' is not actually accessible from 'Program', so we just bind to 'Base.C'. var compilation = CreateCompilation(new[] { source, main }); compilation.VerifyDiagnostics( - // (16,20): error CS9054: File type 'Derived.C' must be defined in a top level type; 'Derived.C' is a nested type. + // (16,20): error CS9054: File-local type 'Derived.C' must be defined in a top level type; 'Derived.C' is a nested type. // new file class C Diagnostic(ErrorCode.ERR_FileTypeNested, "C").WithArguments("Derived.C").WithLocation(16, 20)); @@ -3212,7 +3212,7 @@ class D : C1 { } // 1 var comp = CreateCompilation(source); comp.VerifyDiagnostics( - // (8,7): error CS9053: File type 'C' cannot be used as a base type of non-file type 'D'. + // (8,7): error CS9053: File-local type 'C' cannot be used as a base type of non-file-local type 'D'. // class D : C1 { } // 1 Diagnostic(ErrorCode.ERR_FileTypeBase, "D").WithArguments("NS.C", "NS.D").WithLocation(8, 7)); } @@ -3266,7 +3266,7 @@ public static void M(this string s) { } var comp = CreateSubmission(source1, parseOptions: TestOptions.Script.WithLanguageVersion(LanguageVersion.Preview)); comp.VerifyDiagnostics( - // (5,19): error CS9054: File type 'C1' must be defined in a top level type; 'C1' is a nested type. + // (5,19): error CS9054: File-local type 'C1' must be defined in a top level type; 'C1' is a nested type. // static file class C1 Diagnostic(ErrorCode.ERR_FileTypeNested, "C1").WithArguments("C1").WithLocation(5, 19), // (7,24): error CS1109: Extension methods must be defined in a top level static class; C1 is a nested class @@ -3376,14 +3376,14 @@ file class C { } // 1 // from source var comp = CreateCompilation(source1); comp.VerifyDiagnostics( - // (3,16): error CS9054: File type 'Outer.C' must be defined in a top level type; 'Outer.C' is a nested type. + // (3,16): error CS9054: File-local type 'Outer.C' must be defined in a top level type; 'Outer.C' is a nested type. // file class C { } // 1 Diagnostic(ErrorCode.ERR_FileTypeNested, "C").WithArguments("Outer.C").WithLocation(3, 16)); var sourceMember = comp.GetMember("Outer.C"); Assert.Equal("<>F0__C", sourceMember.MetadataName); var sourceType = comp.GetTypeByMetadataName("Outer.<>F0__C"); - // Note: strictly speaking, it would be reasonable to return the (invalid) nested file type symbol here. + // Note: strictly speaking, it would be reasonable to return the (invalid) nested file-local type symbol here. // However, since we don't actually support nested file types, we don't think we need the API to do the additional lookup // when the requested type is nested, and so we end up giving a null here. Assert.Null(sourceType); @@ -3515,19 +3515,19 @@ void M(C c) var type = (INamedTypeSymbol)model.GetTypeInfo(node.Type!).Type!; Assert.Equal("C@", type.ToTestDisplayString()); Assert.Equal(tree, type.GetSymbol()!.AssociatedSyntaxTree); - Assert.True(type.IsFile); + Assert.True(type.IsFileLocal); var referencingMetadataComp = CreateCompilation("", new[] { comp.ToMetadataReference() }); type = ((Compilation)referencingMetadataComp).GetTypeByMetadataName("<>F0__C")!; Assert.Equal("C@", type.ToTestDisplayString()); Assert.Equal(tree, type.GetSymbol()!.AssociatedSyntaxTree); - Assert.True(type.IsFile); + Assert.True(type.IsFileLocal); var referencingImageComp = CreateCompilation("", new[] { comp.EmitToImageReference() }); type = ((Compilation)referencingImageComp).GetTypeByMetadataName("<>F0__C")!; Assert.Equal("<>F0__C", type.ToTestDisplayString()); Assert.Null(type.GetSymbol()!.AssociatedSyntaxTree); - Assert.False(type.IsFile); + Assert.False(type.IsFileLocal); } [Fact] @@ -3550,7 +3550,7 @@ void M(C c) var type = (INamedTypeSymbol)model.GetTypeInfo(node.Type!).Type!; Assert.Equal("C", type.ToTestDisplayString()); Assert.Null(type.GetSymbol()!.AssociatedSyntaxTree); - Assert.False(type.IsFile); + Assert.False(type.IsFileLocal); } [Fact] @@ -3573,6 +3573,6 @@ void M(C c) var type = (INamedTypeSymbol)model.GetTypeInfo(node.Type!).Type!; Assert.Equal("C@", type.ToTestDisplayString()); Assert.Equal(tree, type.GetSymbol()!.AssociatedSyntaxTree); - Assert.True(type.IsFile); + Assert.True(type.IsFileLocal); } } diff --git a/src/Compilers/CSharp/Test/Syntax/Parsing/FileModifierParsingTests.cs b/src/Compilers/CSharp/Test/Syntax/Parsing/FileModifierParsingTests.cs index 48663a9a18d3a..6f0c7f920f7fd 100644 --- a/src/Compilers/CSharp/Test/Syntax/Parsing/FileModifierParsingTests.cs +++ b/src/Compilers/CSharp/Test/Syntax/Parsing/FileModifierParsingTests.cs @@ -507,7 +507,7 @@ public void FileModifier_11(SyntaxKind typeKeyword) """, expectedBindingDiagnostics: new[] { - // (1,20): error CS9052: File type 'C' cannot use accessibility modifiers. + // (1,20): error CS9052: File-local type 'C' cannot use accessibility modifiers. // public file {{SyntaxFacts.GetText(typeKeyword)}} C { } Diagnostic(ErrorCode.ERR_FileTypeNoExplicitAccessibility, "C").WithArguments("C") }); @@ -540,7 +540,7 @@ public void FileModifier_12(SyntaxKind typeKeyword) """, expectedBindingDiagnostics: new[] { - // (1,19): error CS9052: File type 'C' cannot use accessibility modifiers. + // (1,19): error CS9052: File-local type 'C' cannot use accessibility modifiers. // file public {{SyntaxFacts.GetText(typeKeyword)}} C { } Diagnostic(ErrorCode.ERR_FileTypeNoExplicitAccessibility, "C").WithArguments("C") }); @@ -696,7 +696,7 @@ file class C { } """, expectedBindingDiagnostics: new[] { - // (3,16): error CS9054: File type 'Outer.C' must be defined in a top level type; 'Outer.C' is a nested type. + // (3,16): error CS9054: File-local type 'Outer.C' must be defined in a top level type; 'Outer.C' is a nested type. // file class C { } Diagnostic(ErrorCode.ERR_FileTypeNested, "C").WithArguments("Outer.C").WithLocation(3, 16) }); @@ -2137,7 +2137,7 @@ class C """, expectedBindingDiagnostics: new[] { - // (3,17): error CS9054: File type 'C.X' must be defined in a top level type; 'C.X' is a nested type. + // (3,17): error CS9054: File-local type 'C.X' must be defined in a top level type; 'C.X' is a nested type. // file record X(); Diagnostic(ErrorCode.ERR_FileTypeNested, "X").WithArguments("C.X").WithLocation(3, 17) }); @@ -2235,7 +2235,7 @@ file record X() { } """, expectedBindingDiagnostics: new[] { - // (3,17): error CS9054: File type 'C.X' must be defined in a top level type; 'C.X' is a nested type. + // (3,17): error CS9054: File-local type 'C.X' must be defined in a top level type; 'C.X' is a nested type. // file record X() { } Diagnostic(ErrorCode.ERR_FileTypeNested, "X").WithArguments("C.X").WithLocation(3, 17) }); @@ -2330,7 +2330,7 @@ class C """, expectedBindingDiagnostics: new[] { - // (3,17): error CS9054: File type 'C.X' must be defined in a top level type; 'C.X' is a nested type. + // (3,17): error CS9054: File-local type 'C.X' must be defined in a top level type; 'C.X' is a nested type. // file record X; Diagnostic(ErrorCode.ERR_FileTypeNested, "X").WithArguments("C.X").WithLocation(3, 17) }); diff --git a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt index 17ab31dc4cf39..5ff4e2f3841dd 100644 --- a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt +++ b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt @@ -114,4 +114,4 @@ virtual Microsoft.CodeAnalysis.SymbolVisitor.VisitProperty(M virtual Microsoft.CodeAnalysis.SymbolVisitor.VisitRangeVariable(Microsoft.CodeAnalysis.IRangeVariableSymbol! symbol, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.SymbolVisitor.VisitTypeParameter(Microsoft.CodeAnalysis.ITypeParameterSymbol! symbol, TArgument argument) -> TResult Microsoft.CodeAnalysis.Operations.BinaryOperatorKind.UnsignedRightShift = 25 -> Microsoft.CodeAnalysis.Operations.BinaryOperatorKind -Microsoft.CodeAnalysis.INamedTypeSymbol.IsFile.get -> bool \ No newline at end of file +Microsoft.CodeAnalysis.INamedTypeSymbol.IsFileLocal.get -> bool \ No newline at end of file diff --git a/src/Compilers/Core/Portable/Symbols/INamedTypeSymbol.cs b/src/Compilers/Core/Portable/Symbols/INamedTypeSymbol.cs index f8fab6b35decf..2a6a9ceb1ff8c 100644 --- a/src/Compilers/Core/Portable/Symbols/INamedTypeSymbol.cs +++ b/src/Compilers/Core/Portable/Symbols/INamedTypeSymbol.cs @@ -59,7 +59,7 @@ public interface INamedTypeSymbol : ITypeSymbol /// /// Indicates the type is declared in source and is only visible in the file it is declared in. /// - bool IsFile { get; } + bool IsFileLocal { get; } /// /// Returns collection of names of members declared within this type. diff --git a/src/Compilers/VisualBasic/Portable/Symbols/NamedTypeSymbol.vb b/src/Compilers/VisualBasic/Portable/Symbols/NamedTypeSymbol.vb index 7d30aafb6182c..f53888191d8c1 100644 --- a/src/Compilers/VisualBasic/Portable/Symbols/NamedTypeSymbol.vb +++ b/src/Compilers/VisualBasic/Portable/Symbols/NamedTypeSymbol.vb @@ -1216,7 +1216,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols End Get End Property - Private ReadOnly Property INamedTypeSymbol_IsFile As Boolean Implements INamedTypeSymbol.IsFile + Private ReadOnly Property INamedTypeSymbol_IsFileLocal As Boolean Implements INamedTypeSymbol.IsFileLocal Get Return False End Get diff --git a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/KeywordCompletionProviderTests.cs b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/KeywordCompletionProviderTests.cs index cfbc1cf8ddd02..d47ed942af886 100644 --- a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/KeywordCompletionProviderTests.cs +++ b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/KeywordCompletionProviderTests.cs @@ -726,7 +726,7 @@ file class C { } """; // it might seem like we want to prevent 'file file class', - // but it's likely the user is declaring a file type above an existing file type here. + // but it's likely the user is declaring a file-local type above an existing file-local type here. await VerifyItemExistsAsync(markup, "file"); } diff --git a/src/EditorFeatures/CSharpTest/SymbolKey/SymbolKeyCompilationsTests.cs b/src/EditorFeatures/CSharpTest/SymbolKey/SymbolKeyCompilationsTests.cs index 11acb20fafeb1..b3fcbbf29434d 100644 --- a/src/EditorFeatures/CSharpTest/SymbolKey/SymbolKeyCompilationsTests.cs +++ b/src/EditorFeatures/CSharpTest/SymbolKey/SymbolKeyCompilationsTests.cs @@ -290,7 +290,7 @@ file class C { } } "; // this should result in two entirely separate file symbols. - // note that the IDE can only distinguish file type symbols with the same name when they have distinct file paths. + // note that the IDE can only distinguish file-local type symbols with the same name when they have distinct file paths. // We are OK with this as we will require file types with identical names to have distinct file paths later in the preview. // See https://github.com/dotnet/roslyn/issues/61999 var originalComp = CreateCompilation(new[] { SyntaxFactory.ParseSyntaxTree(src1, path: "file1.cs"), SyntaxFactory.ParseSyntaxTree(src1, path: "file2.cs") }, assemblyName: "Test"); @@ -306,7 +306,7 @@ file class C { } [Fact] public void FileType4() { - // we should be able to distinguish a file type and non-file type when they have the same source name. + // we should be able to distinguish a file-local type and non-file-local type when they have the same source name. var src1 = SyntaxFactory.ParseSyntaxTree(@"using System; namespace N1.N2 diff --git a/src/Features/Core/Portable/MetadataAsSource/AbstractMetadataAsSourceService.WrappedNamedTypeSymbol.cs b/src/Features/Core/Portable/MetadataAsSource/AbstractMetadataAsSourceService.WrappedNamedTypeSymbol.cs index cb8972561e3ef..02a938f0e1094 100644 --- a/src/Features/Core/Portable/MetadataAsSource/AbstractMetadataAsSourceService.WrappedNamedTypeSymbol.cs +++ b/src/Features/Core/Portable/MetadataAsSource/AbstractMetadataAsSourceService.WrappedNamedTypeSymbol.cs @@ -144,7 +144,7 @@ public ImmutableArray ToMinimalDisplayParts(SemanticModel sem public bool IsNativeIntegerType => _symbol.IsNativeIntegerType; - public bool IsFile => _symbol.IsFile; + public bool IsFileLocal => _symbol.IsFileLocal; public INamedTypeSymbol NativeIntegerUnderlyingType => _symbol.NativeIntegerUnderlyingType; diff --git a/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs b/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs index aacfcd25d420d..a8f1d5188fcc7 100644 --- a/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs +++ b/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs @@ -1377,7 +1377,7 @@ public override SyntaxNode WithAccessibility(SyntaxNode declaration, Accessibili { // If user wants to set accessibility for a file-local declaration, we remove file. // Otherwise, code will be in error: - // error CS9052: File type '{0}' cannot use accessibility modifiers. + // error CS9052: File-local type '{0}' cannot use accessibility modifiers. modifiers = modifiers.WithIsFile(false); } diff --git a/src/Workspaces/CSharp/Portable/CodeGeneration/NamedTypeGenerator.cs b/src/Workspaces/CSharp/Portable/CodeGeneration/NamedTypeGenerator.cs index 941fef327976a..63c5af4e9c3ee 100644 --- a/src/Workspaces/CSharp/Portable/CodeGeneration/NamedTypeGenerator.cs +++ b/src/Workspaces/CSharp/Portable/CodeGeneration/NamedTypeGenerator.cs @@ -267,7 +267,7 @@ private static SyntaxTokenList GenerateModifiers( { var tokens = ArrayBuilder.GetInstance(); - if (!namedType.IsFile) + if (!namedType.IsFileLocal) { var defaultAccessibility = destination is CodeGenerationDestination.CompilationUnit or CodeGenerationDestination.Namespace ? Accessibility.Internal diff --git a/src/Workspaces/Core/Portable/CodeGeneration/Symbols/CodeGenerationAbstractNamedTypeSymbol.cs b/src/Workspaces/Core/Portable/CodeGeneration/Symbols/CodeGenerationAbstractNamedTypeSymbol.cs index bc12ff16bfbe4..75b3773b79b43 100644 --- a/src/Workspaces/Core/Portable/CodeGeneration/Symbols/CodeGenerationAbstractNamedTypeSymbol.cs +++ b/src/Workspaces/Core/Portable/CodeGeneration/Symbols/CodeGenerationAbstractNamedTypeSymbol.cs @@ -122,6 +122,6 @@ public override string MetadataName public bool IsSerializable => false; - public bool IsFile => Modifiers.IsFile; + public bool IsFileLocal => Modifiers.IsFile; } } diff --git a/src/Workspaces/Core/Portable/Editing/DeclarationModifiers.cs b/src/Workspaces/Core/Portable/Editing/DeclarationModifiers.cs index b53d401c8b683..bb425fbb78ab3 100644 --- a/src/Workspaces/Core/Portable/Editing/DeclarationModifiers.cs +++ b/src/Workspaces/Core/Portable/Editing/DeclarationModifiers.cs @@ -87,7 +87,7 @@ IMethodSymbol or isExtern: symbol.IsExtern, isAsync: method?.IsAsync == true, isRequired: symbol.IsRequired(), - isFile: (symbol as INamedTypeSymbol)?.IsFile == true); + isFile: (symbol as INamedTypeSymbol)?.IsFileLocal == true); } // Only named types, members of named types, and local functions have modifiers. diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/SymbolKey/SymbolKey.NamedTypeSymbolKey.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/SymbolKey/SymbolKey.NamedTypeSymbolKey.cs index 6b0fee736cd1e..f3c3e8d3f5e41 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/SymbolKey/SymbolKey.NamedTypeSymbolKey.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/SymbolKey/SymbolKey.NamedTypeSymbolKey.cs @@ -16,7 +16,7 @@ public static void Create(INamedTypeSymbol symbol, SymbolKeyWriter visitor) visitor.WriteSymbolKey(symbol.ContainingSymbol); visitor.WriteString(symbol.Name); visitor.WriteInteger(symbol.Arity); - visitor.WriteString(symbol.IsFile + visitor.WriteString(symbol.IsFileLocal ? symbol.DeclaringSyntaxReferences[0].SyntaxTree.FilePath : null); visitor.WriteBoolean(symbol.IsUnboundGenericType); @@ -84,19 +84,19 @@ private static void Resolve( { foreach (var type in container.GetTypeMembers(name, arity)) { - // if this is a 'file' type, then only resolve to a file-type from this same file + // if this is a file-local type, then only resolve to a file-local type from this same file if (filePath != null) { - if (!type.IsFile || + if (!type.IsFileLocal || // note: if we found 'IsFile' returned true, we can assume DeclaringSyntaxReferences is non-empty. type.DeclaringSyntaxReferences[0].SyntaxTree.FilePath != filePath) { continue; } } - else if (type.IsFile) + else if (type.IsFileLocal) { - // since this key lacks a file path it can't match against a 'file' type + // since this key lacks a file path it can't match against a file-local type continue; }