File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,13 @@ public static void ProcessMemberDeclarations(
8686 // If the target class is sealed, make protected members private and remove the virtual modifier
8787 sealedMemberDeclarations = annotatedMemberDeclarations . Select ( static member =>
8888 {
89+ // Constructors become public for sealed types
90+ if ( member is ConstructorDeclarationSyntax )
91+ {
92+ return member . ReplaceModifier ( SyntaxKind . ProtectedKeyword , SyntaxKind . PublicKeyword ) ;
93+ }
94+
95+ // Other members become private
8996 return
9097 member
9198 . ReplaceModifier ( SyntaxKind . ProtectedKeyword , SyntaxKind . PrivateKeyword )
Original file line number Diff line number Diff line change @@ -228,4 +228,36 @@ protected virtual partial void OnDeactivated()
228228 OnDeactivatedResult = true ;
229229 }
230230 }
231+
232+ [ TestMethod ]
233+ public void Test_ObservableRecipientAttribute_SealedPersonWithCustomOnActivatedAndOnDeactivated ( )
234+ {
235+ SealedPersonWithCustomOnActivatedAndOnDeactivated model = new ( ) ;
236+
237+ model . IsActive = true ;
238+
239+ Assert . IsTrue ( model . OnActivatedResult ) ;
240+
241+ model . IsActive = false ;
242+
243+ Assert . IsTrue ( model . OnDeactivatedResult ) ;
244+ }
245+
246+ [ ObservableRecipient ]
247+ public sealed partial class SealedPersonWithCustomOnActivatedAndOnDeactivated : ObservableObject
248+ {
249+ public bool OnActivatedResult { get ; private set ; }
250+
251+ public bool OnDeactivatedResult { get ; private set ; }
252+
253+ private partial void OnActivated ( )
254+ {
255+ OnActivatedResult = true ;
256+ }
257+
258+ private partial void OnDeactivated ( )
259+ {
260+ OnDeactivatedResult = true ;
261+ }
262+ }
231263}
You can’t perform that action at this time.
0 commit comments