C#: Add implicit to string usage in constructor.

This commit is contained in:
Michael Nebel
2025-01-13 10:10:50 +01:00
parent d40c1bebbf
commit 77f9f4c532
2 changed files with 11 additions and 4 deletions

View File

@@ -47,6 +47,7 @@ namespace TestVirtualCalls
f_nonvirtual(); // GOOD
f_interface(); // GOOD
((I)this).f_interface(); // GOOD
var x = $"{this}"; // GOOD
// Method access
Action a;
@@ -70,5 +71,10 @@ namespace TestVirtualCalls
e_sealed += f_nonvirtual; // GOOD
e_nonvirtual += f_nonvirtual; // GOOD
}
public override string ToString()
{
return "C";
}
}
}

View File

@@ -1,5 +1,6 @@
| VirtualCallInConstructorOrDestructor.cs:45:13:45:23 | call to method f_virtual | Avoid virtual calls in a constructor or destructor. |
| VirtualCallInConstructorOrDestructor.cs:53:17:53:25 | access to method f_virtual | Avoid virtual calls in a constructor or destructor. |
| VirtualCallInConstructorOrDestructor.cs:59:21:59:29 | access to property p_virtual | Avoid virtual calls in a constructor or destructor. |
| VirtualCallInConstructorOrDestructor.cs:64:17:64:23 | access to indexer | Avoid virtual calls in a constructor or destructor. |
| VirtualCallInConstructorOrDestructor.cs:69:13:69:21 | access to event e_virtual | Avoid virtual calls in a constructor or destructor. |
| VirtualCallInConstructorOrDestructor.cs:50:24:50:27 | call to method ToString | Avoid virtual calls in a constructor or destructor. |
| VirtualCallInConstructorOrDestructor.cs:54:17:54:25 | access to method f_virtual | Avoid virtual calls in a constructor or destructor. |
| VirtualCallInConstructorOrDestructor.cs:60:21:60:29 | access to property p_virtual | Avoid virtual calls in a constructor or destructor. |
| VirtualCallInConstructorOrDestructor.cs:65:17:65:23 | access to indexer | Avoid virtual calls in a constructor or destructor. |
| VirtualCallInConstructorOrDestructor.cs:70:13:70:21 | access to event e_virtual | Avoid virtual calls in a constructor or destructor. |