Skip to content

Commit b75abe0

Browse files
committed
Fix for implicitly abstract interfaces and implicitly sealed structs
1 parent b1d3764 commit b75abe0

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- Interfaces are implicitly abstract, so generated partial interfaces should not be explicitly marked as abstract.
13+
- Structs are implicitly sealed, so generated partial structs should not be explicitly marked as sealed.
14+
1015
## [1.0.1] - 2025-07-27
1116

1217
### Fixed

IncrementalGeneratorExtensions.Content/Datacute/IncrementalGeneratorExtensions/TypeContext.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,12 @@ public static string GetAccessibilityModifier(Accessibility accessibility)
209209
/// Gets the abstract modifier for this type context.
210210
/// </summary>
211211
/// <returns>A string representing the abstract modifier, such as "abstract " or an empty string.</returns>
212-
public string GetAbstractModifier() => GetAbstractModifier(IsAbstract);
212+
public string GetAbstractModifier()
213+
{
214+
if (TypeDeclarationKeyword == "interface")
215+
return ""; // implicitly abstract
216+
return GetAbstractModifier(IsAbstract);
217+
}
213218
/// <summary>
214219
/// Gets the abstract modifier for a given abstract status.
215220
/// </summary>
@@ -221,13 +226,18 @@ public static string GetAccessibilityModifier(Accessibility accessibility)
221226
/// Gets the sealed modifier for this type context.
222227
/// </summary>
223228
/// <returns>A string representing the sealed modifier, such as "sealed " or an empty string.</returns>
224-
public string GetSealedModifier() => GetSealedModifier(IsSealed);
229+
public string GetSealedModifier()
230+
{
231+
if (TypeDeclarationKeyword == "struct" || TypeDeclarationKeyword == "record struct")
232+
return ""; // implicitly sealed
233+
return GetSealedModifier(IsSealed);
234+
}
225235
/// <summary>
226236
/// Gets the sealed modifier for a given sealed status.
227237
/// </summary>
228-
/// <param name="isSealead">The sealed status of the type.</param>
238+
/// <param name="isSealed">The sealed status of the type.</param>
229239
/// <returns>A string representing the sealed modifier, such as "sealed " or an empty string.</returns>
230-
public static string GetSealedModifier(bool isSealead) => isSealead ? "sealed " : "";
240+
public static string GetSealedModifier(bool isSealed) => isSealed ? "sealed " : "";
231241

232242
/// <summary>
233243
/// Gets the type declaration string for a type symbol, determining if it is a record, struct, or class.

0 commit comments

Comments
 (0)