Repository navigation
Keep type parameters when implementing properties of a generic class (v10.x) - #5044
Merged
rockfordlhotka merged 3 commits intoNov 20, 2026
Merged
Conversation
…class (v10.x) Backport of the main fix, plus the base class lookup the reporter worked around by renaming their base class. - The generated partial declaration repeats the class's type parameters (names only; a partial declaration may omit constraints). Before, a generic PersonBase<T> got "partial class PersonBase", a different type. - The hint name of a generic class gets an arity suffix (PersonBase_1.g.cs) so Foo and Foo<T> don't collide. Non-generic hint names are unchanged. - A property whose type is a type parameter (T, T?) is generated with that type; it used to be written with an empty type. - The base class used to choose GetProperty/SetProperty/LoadProperty/ ReadProperty is the nearest Csla base class through any intermediate base classes. Before, only the direct base class's name was checked, so nothing was generated unless that name contained "BusinessBase", "ReadOnlyBase" or "CommandBase". When no Csla base class is found, the direct base class's name is used, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ators (v10.x) AutoImplementProperties generator: - Hint names include the namespace and containing types (Sales.Order.g.cs), so same-named classes in different namespaces no longer collide and abort the generator. Existing snapshots are renamed accordingly. - A class nested in other types is generated inside partial declarations of its containing types, with their type parameters. - [CslaImplementPropertiesInterface<T>] binds an interface declared in another file with that file's semantic model instead of throwing. - Array property types are displayed from the array symbol, so jagged and multi-dimensional arrays keep every rank; keyword identifiers such as @Class are escaped. - One CslaBaseClasses map chooses the property methods. A class whose base chain has no CSLA base class gets nothing generated, instead of code calling methods its base class doesn't have. AutoSerialization generator: - A generic [AutoSerializable] type, and one nested in a generic type, keeps its type parameters; hint names use the arity. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…er members - Generic types' hint names use '-' before the arity (Test.Foo-1.g.cs), which can't occur in an identifier, so Foo<T> no longer shares a hint name with a class named Foo_1, as a target or a containing type, in both the property and serialization generators. - The serialization generator writes members typed as a type parameter (T, T?, T[]) with that type instead of an empty one, and displays array types from the array symbol. - Tests for the hint-name collisions and for type-parameter members of a generic [AutoSerializable] class. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rockfordlhotka
deleted the
issue-5042/v10-cslaimplementproperties-generic-types
branch
November 20, 2026 19:51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Backports #5043 to
v10.xfor 10.3.0.[CslaImplementProperties]and[CslaImplementPropertiesInterface<T>]on a generic partial class such asPersonBase<T>generatedpartial class PersonBase, a separate non-generic type, so the partial properties were never implemented.partial class PersonBase<T>). It writes names only; constraints and type-parameter attributes are left out, which a partial declaration allows.PersonBase-1.g.cs), soFooandFoo<T>don't collide. (The review follow-ups below also add the namespace to every hint name.)T,T?) is generated with that type. Before, it was written with an empty type.GetProperty/SetProperty/LoadProperty/ReadPropertyis now the nearestCslabase class, found through any intermediate base classes. Before, only the direct base class's name was checked forBusinessBase,ReadOnlyBaseorCommandBase, which is why renamingPersonBasetoPersonBusinessBaseworked around the bug in the issue.mainalready has this lookup.Review follow-ups
Sales.Order.g.cs,Test.Outer-1.Line.g.cs). Before, same-named classes in different namespaces madeAddSourcethrow, and the generator produced nothing for the whole project. Existing snapshots are renamed only; their content is unchanged.[CslaImplementProperties]class nested in other types is generated inside partial declarations of those types, with their type parameters.T[][]andint[,]keep every rank. Keyword identifiers such as@classare escaped.[AutoSerializable]had the same bug: a generic type, or one nested in a generic type, lost its type parameters. It now keeps them, members typed as a type parameter (T,T?,T[]) are serialized with that type, and its hint names use the arity.T?,T[], jagged and multi-dimensional arrays,@class), nested-in-generic, same name in different namespaces, an interface in another file, and generic[AutoSerializable]types. All fail without the fixes.-before the arity (Foo-1).-can't occur in an identifier, soFoo<T>no longer collides with a class namedFoo_1, as the target or as a containing type.[CslaImplementPropertiesInterface<T>]binds an interface declared in another file with that file's semantic model. Before, it threw.CslaBaseClassesmap, as on main. A class with no CSLA base class in its chain now gets nothing generated. Before, it got code callingGetProperty/SetProperty, which its base class doesn't have.Test plan
string/T?properties;PairandPair<TKey, TValue>in one compilation; an intermediate base class whose name doesn't contain the CSLA base class's name; and a generic class with[CslaImplementPropertiesInterface<T>]Csla.Generator.AutoImplementProperties.CSharp.Testspasses with the .NET 10 SDK (78 tests), andCsla.Generator.AutoSerialization.CSharp.Tests(99 tests)csla.test.slnsuite passes locally (TestCategory!=SkipOnCIServer)Backport for #5042 (main fix: #5043)
🤖 Generated with Claude Code