Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ var symbolInfo = semanticModel.GetSymbolInfo(expression);
- **Cancellation**: Always thread `CancellationToken` through async operations
- **MEF Lifecycle**: Use `[ImportingConstructor]` with obsolete attribute for MEF v2 compatibility
- **PROTOTYPE Comments**: Only used to track follow-up work in feature branches and are disallowed in main branch
- **Code Formatting**: Avoid trailing spaces and blank lines (lines with only whitespace). Ensure all lines either have content or are completely empty.

## Common Gotchas

Expand Down
3 changes: 3 additions & 0 deletions src/Compilers/CSharp/Portable/CSharpResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -6567,6 +6567,9 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<data name="ERR_UnexpectedArgumentList" xml:space="preserve">
<value>Unexpected argument list.</value>
</data>
<data name="ERR_UnexpectedArgumentListInBaseTypeWithoutParameterList" xml:space="preserve">
<value>Cannot pass arguments to the base type without a parameter list on the type declaration. Consider adding an empty parameter list to '{0}'.</value>
</data>
<data name="ERR_UnexpectedOrMissingConstructorInitializerInRecord" xml:space="preserve">
<value>A constructor declared in a type with parameter list must have 'this' constructor initializer.</value>
</data>
Expand Down
1 change: 1 addition & 0 deletions src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2435,6 +2435,7 @@ internal enum ErrorCode
HDN_RedundantPatternStackGuard = 9337,

ERR_BadVisBaseType = 9338,
ERR_UnexpectedArgumentListInBaseTypeWithoutParameterList = 9339,

// Note: you will need to do the following after adding errors:
// 1) Update ErrorFacts.IsBuildOnlyDiagnostic (src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs)
Expand Down
1 change: 1 addition & 0 deletions src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2543,6 +2543,7 @@ or ErrorCode.HDN_RedundantPattern
or ErrorCode.WRN_RedundantPattern
or ErrorCode.HDN_RedundantPatternStackGuard
or ErrorCode.ERR_BadVisBaseType
or ErrorCode.ERR_UnexpectedArgumentListInBaseTypeWithoutParameterList
=> false,
};
#pragma warning restore CS8524 // The switch expression does not handle some values of its input type (it is not exhaustive) involving an unnamed enum value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal partial class SourceNamedTypeSymbol
private ImmutableArray<NamedTypeSymbol> _lazyInterfaces;

/// <summary>
/// Gets the BaseType of this type. If the base type could not be determined, then
/// Gets the BaseType of this type. If the base type could not be determined, then
/// an instance of ErrorType is returned. If this kind of type does not have a base type
/// (for example, interfaces), null is returned. Also the special class System.Object
/// always has a BaseType of null.
Expand Down Expand Up @@ -638,10 +638,24 @@ private Tuple<NamedTypeSymbol, ImmutableArray<NamedTypeSymbol>> MakeOneDeclaredB

void checkPrimaryConstructorBaseType(BaseTypeSyntax baseTypeSyntax, TypeSymbol baseType)
{
if (baseTypeSyntax is PrimaryConstructorBaseTypeSyntax primaryConstructorBaseType &&
(TypeKind != TypeKind.Class || baseType.TypeKind == TypeKind.Interface || ((TypeDeclarationSyntax)decl.SyntaxReference.GetSyntax()).ParameterList is null))
if (baseTypeSyntax is PrimaryConstructorBaseTypeSyntax primaryConstructorBaseType)
{
diagnostics.Add(ErrorCode.ERR_UnexpectedArgumentList, primaryConstructorBaseType.ArgumentList.Location);
var typeDecl = (TypeDeclarationSyntax)decl.SyntaxReference.GetSyntax();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Consider inlining: ... && decl.SyntaxReference.GetSyntax() is TypeDeclarationSyntax { ParameterList: null }. That way we don't compute it when the earlier conditions aren't met


// Check if this is a class inheriting from a class but missing a parameter list
if (TypeKind == TypeKind.Class &&
baseType.TypeKind != TypeKind.Interface &&
typeDecl.ParameterList is null)
{
diagnostics.Add(ErrorCode.ERR_UnexpectedArgumentListInBaseTypeWithoutParameterList,
primaryConstructorBaseType.ArgumentList.Location,
this.Name);
}
// Other cases where argument lists are not allowed
else if (TypeKind != TypeKind.Class || baseType.TypeKind == TypeKind.Interface)
{
diagnostics.Add(ErrorCode.ERR_UnexpectedArgumentList, primaryConstructorBaseType.ArgumentList.Location);
}
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading