@@ -837,6 +837,87 @@ await VerifyGuidelineDiagnosticAsync(source,
837837 "Parameter order in 'C.M(int, string, params object[])' does not match with the parameter order of the longest overload" ) ;
838838 }
839839
840+ [ Fact ]
841+ internal async Task When_parameter_order_in_overloads_is_consistent_with_CancellationToken_it_must_be_skipped ( )
842+ {
843+ // Arrange
844+ ParsedSourceCode source = new TypeSourceCodeBuilder ( )
845+ . Using ( typeof ( CancellationToken ) . Namespace )
846+ . InGlobalScope ( """
847+ public class C
848+ {
849+ public bool M()
850+ {
851+ return M(CancellationToken.None);
852+ }
853+
854+ public bool M(CancellationToken cancellationToken)
855+ {
856+ return M(string.Empty, cancellationToken);
857+ }
858+
859+ public bool M(string value, CancellationToken cancellationToken)
860+ {
861+ return M(value, -1, cancellationToken);
862+ }
863+
864+ public bool M(string value, int index, CancellationToken cancellationToken)
865+ {
866+ return M(value, index, false, cancellationToken);
867+ }
868+
869+ protected virtual bool M(string value, int index, bool flag, CancellationToken cancellationToken)
870+ {
871+ throw new NotImplementedException();
872+ }
873+ }
874+ """ )
875+ . Build ( ) ;
876+
877+ await VerifyGuidelineDiagnosticAsync ( source ) ;
878+ }
879+
880+ [ Fact ]
881+ internal async Task When_parameter_order_in_overloads_is_not_consistent_with_CancellationToken_it_must_be_reported ( )
882+ {
883+ // Arrange
884+ ParsedSourceCode source = new TypeSourceCodeBuilder ( )
885+ . Using ( typeof ( CancellationToken ) . Namespace )
886+ . InGlobalScope ( """
887+ public class C
888+ {
889+ public bool M()
890+ {
891+ return M(CancellationToken.None);
892+ }
893+
894+ public bool M(CancellationToken cancellationToken)
895+ {
896+ return M(string.Empty, cancellationToken);
897+ }
898+
899+ public bool M(string value, CancellationToken cancellationToken)
900+ {
901+ return M(-1, value, cancellationToken);
902+ }
903+
904+ public bool [|M|](int index, string value, CancellationToken cancellationToken)
905+ {
906+ return M(value, index, false, cancellationToken);
907+ }
908+
909+ protected virtual bool M(string value, int index, bool flag, CancellationToken cancellationToken)
910+ {
911+ throw new NotImplementedException();
912+ }
913+ }
914+ """ )
915+ . Build ( ) ;
916+
917+ await VerifyGuidelineDiagnosticAsync ( source ,
918+ "Parameter order in 'C.M(int, string, CancellationToken)' does not match with the parameter order of the longest overload" ) ;
919+ }
920+
840921 [ Fact ]
841922 internal async Task When_parameter_order_in_overloads_is_consistent_with_optional_parameters_it_must_be_skipped ( )
842923 {
0 commit comments