← back to index

S8380 — Return types named "partial" should be escaped with "@"

Language: C#  |  Type: CODE_SMELL  |  Severity: Critical

Tags: breaking-change, csharp14

Using partial as a return type identifier will cause a compilation error when upgrading to C# 14.

Why is this an issue?

In C# 14, partial in a return type position is always treated as a modifier, even when a type named partial is in scope. This causes compilation errors in code that previously compiled successfully.

The issue specifically affects method declarations where a custom type named partial is used as the return type. Other uses of the partial type (such as in variable declarations or constructor calls) are not affected by this change.

What is the potential impact?

This breaking change will cause compilation failures when upgrading existing codebases to C# 14. The compilation error prevents the application from building, requiring immediate attention to fix the syntax.

While this is not a runtime issue, it can block development and deployment processes until resolved. The fix is straightforward but must be applied to all affected method declarations.

How to fix it

Add the @ prefix before partial when used as a return type. This tells the compiler to treat partial as an identifier rather than a modifier. Alternatively, rename the type to avoid the conflict.

Code examples

Noncompliant code example

class C
{
    partial F() => new partial(); // Noncompliant
}

class partial { }

Compliant solution

class C
{
    @partial F() => new partial();
}

class partial { }

Noncompliant code example

class C
{
    partial F() => new partial(); // Noncompliant
}

class partial { }

Compliant solution

class C
{
    PartialItem F() => new PartialItem();
}

class PartialItem { }

Resources

Documentation