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(
86
86
// If the target class is sealed, make protected members private and remove the virtual modifier
87
87
sealedMemberDeclarations = annotatedMemberDeclarations . Select ( static member =>
88
88
{
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
89
96
return
90
97
member
91
98
. ReplaceModifier ( SyntaxKind . ProtectedKeyword , SyntaxKind . PrivateKeyword )
Original file line number Diff line number Diff line change @@ -228,4 +228,36 @@ protected virtual partial void OnDeactivated()
228
228
OnDeactivatedResult = true ;
229
229
}
230
230
}
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
+ }
231
263
}
You can’t perform that action at this time.
0 commit comments