File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -232,9 +232,48 @@ public override bool VisitMethodDecl(Method method)
232
232
return true ;
233
233
}
234
234
235
+ if ( method . IsCopyConstructor )
236
+ {
237
+ if ( ! CheckNonDeletedCopyConstructor ( method ) )
238
+ return false ;
239
+ }
240
+
235
241
return base . VisitMethodDecl ( method ) ;
236
242
}
237
243
244
+ private static bool CheckNonDeletedCopyConstructor ( Method method )
245
+ {
246
+ if ( method . IsDeleted )
247
+ {
248
+ method . ExplicitlyIgnore ( ) ;
249
+
250
+ Diagnostics . Debug (
251
+ "Copy constructor '{0}' was ignored due to being deleted" ,
252
+ method . QualifiedOriginalName ) ;
253
+
254
+ return false ;
255
+ }
256
+
257
+ //Check if base class has an implicitly deleted copy constructor
258
+ var baseClass = ( method . Namespace as Class ) . Bases . FirstOrDefault ( ) ? . Class ;
259
+ if ( baseClass != null )
260
+ {
261
+ var baseCopyCtor = baseClass . Methods . Find ( m => m . IsCopyConstructor ) ;
262
+ if ( baseCopyCtor == null || baseCopyCtor . IsDeleted )
263
+ {
264
+ method . ExplicitlyIgnore ( ) ;
265
+
266
+ Diagnostics . Debug (
267
+ "Copy constructor '{0}' was ignored due to implicitly deleted base copy constructor '{1}'" ,
268
+ method . QualifiedOriginalName , baseClass . Name ) ;
269
+
270
+ return false ;
271
+ }
272
+ }
273
+
274
+ return true ;
275
+ }
276
+
238
277
bool CheckIgnoredBaseOverridenMethod ( Method method )
239
278
{
240
279
var @class = method . Namespace as Class ;
You can’t perform that action at this time.
0 commit comments