From 87cadeae1ed389718643ee3e8935c62001653ba9 Mon Sep 17 00:00:00 2001 From: Bartosz Klonowski Date: Fri, 17 Jan 2025 22:08:18 +0100 Subject: [PATCH 1/3] Move cs1502 code snippet to cs1503 --- .../compiler-messages/cs1502.md | 22 --------------- docs/csharp/misc/cs1503.md | 27 ++++++++++++++++--- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/docs/csharp/language-reference/compiler-messages/cs1502.md b/docs/csharp/language-reference/compiler-messages/cs1502.md index ee494cef258b0..efec4bb8b22aa 100644 --- a/docs/csharp/language-reference/compiler-messages/cs1502.md +++ b/docs/csharp/language-reference/compiler-messages/cs1502.md @@ -23,25 +23,3 @@ The best overloaded method match for 'name' has some invalid arguments - If appropriate, cast any mismatched parameters to match the type that the method is expecting. - If appropriate, define another overloaded version of the method to match the parameter types that are being sent. - - The following sample generates CS1502: - -```csharp -// CS1502.cs -namespace x -{ - public class a - { - public a(char i) - // try the following constructor instead - // public a(int i) - { - } - - public static void Main() - { - a aa = new a(2222); // CS1502 - } - } -} -``` diff --git a/docs/csharp/misc/cs1503.md b/docs/csharp/misc/cs1503.md index 8a38e766db74b..f7df2baa53e58 100644 --- a/docs/csharp/misc/cs1503.md +++ b/docs/csharp/misc/cs1503.md @@ -10,6 +10,27 @@ ms.assetid: 65e4c63d-928d-49f5-8fac-8e113b07e128 --- # Compiler Error CS1503 -Argument 'number' cannot convert from TypeA to TypeB - - The type of one argument in a method does not match the type that was passed when the class was instantiated. This error typically appears along with CS1502. See [CS1502](../language-reference/compiler-messages/cs1502.md) for a discussion of how to resolve this error. +Argument 'argument' cannot convert from TypeA to TypeB + +The type of one argument in a method does not match the type that was passed when the class was instantiated. This error typically appears along with CS1502. See [CS1502](../language-reference/compiler-messages/cs1502.md) for a discussion of how to resolve this error. + +The following sample generates CS1503: + +```csharp +namespace x +{ + public class a + { + public a(char i) + // try the following constructor instead + // public a(int i) + { + } + + public static void Main() + { + a aa = new a(2222); // CS1503 + } + } +} +``` From dafcee0e960ba2e88d64cb9766644e9c0fb4cfb8 Mon Sep 17 00:00:00 2001 From: Bartosz Klonowski Date: Tue, 21 Jan 2025 17:14:21 +0100 Subject: [PATCH 2/3] Remove CS1502 and redirect to CS1503 --- .openpublishing.redirection.csharp.json | 4 +++ .../compiler-messages/cs1502.md | 25 ------------------- docs/csharp/language-reference/toc.yml | 2 +- docs/csharp/misc/cs1503.md | 4 ++- 4 files changed, 8 insertions(+), 27 deletions(-) delete mode 100644 docs/csharp/language-reference/compiler-messages/cs1502.md diff --git a/.openpublishing.redirection.csharp.json b/.openpublishing.redirection.csharp.json index 7b12bcb3e04cb..90a8e143cd5be 100644 --- a/.openpublishing.redirection.csharp.json +++ b/.openpublishing.redirection.csharp.json @@ -1826,6 +1826,10 @@ "source_path_from_root": "/docs/csharp/misc/cs1007.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/overload-resolution" }, + { + "source_path_from_root": "/docs/csharp/language-reference/compiler-messages/cs1502.md", + "redirect_url": "/dotnet/csharp/misc/cs1503.md" + }, { "source_path_from_root": "/docs/csharp/misc/cs1510.md", "redirect_url": "/dotnet/csharp/language-reference/compiler-messages/ref-modifiers-errors" diff --git a/docs/csharp/language-reference/compiler-messages/cs1502.md b/docs/csharp/language-reference/compiler-messages/cs1502.md deleted file mode 100644 index efec4bb8b22aa..0000000000000 --- a/docs/csharp/language-reference/compiler-messages/cs1502.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -description: "Compiler Error CS1502" -title: "Compiler Error CS1502" -ms.date: 07/20/2015 -f1_keywords: - - "CS1502" -helpviewer_keywords: - - "CS1502" -ms.assetid: f302f00a-5fe1-4e42-b91c-f185d6311671 ---- -# Compiler Error CS1502 - -The best overloaded method match for 'name' has some invalid arguments - - This error occurs when the argument types being passed to the method do not match the parameter types of that method. If the called method is overloaded, then none of the overloaded versions has a signature that matches the argument types being passed. - - To resolve this problem, do one of the following: - -- Double-check the types of the arguments being passed. Make sure that they match the arguments of the method being called. - -- If appropriate, convert any mismatched parameters using the class. - -- If appropriate, cast any mismatched parameters to match the type that the method is expecting. - -- If appropriate, define another overloaded version of the method to match the parameter types that are being sent. diff --git a/docs/csharp/language-reference/toc.yml b/docs/csharp/language-reference/toc.yml index 1e4ef81c0dec8..9aaea86ee02e4 100644 --- a/docs/csharp/language-reference/toc.yml +++ b/docs/csharp/language-reference/toc.yml @@ -1471,7 +1471,7 @@ items: - name: CS1113 href: ../misc/cs1113.md - name: CS1502 - href: ./compiler-messages/cs1502.md + href: ../misc/cs1503.md - name: CS1503 href: ../misc/cs1503.md - name: CS1504 diff --git a/docs/csharp/misc/cs1503.md b/docs/csharp/misc/cs1503.md index f7df2baa53e58..e81bb52135c68 100644 --- a/docs/csharp/misc/cs1503.md +++ b/docs/csharp/misc/cs1503.md @@ -4,15 +4,17 @@ title: "Compiler Error CS1503" ms.date: 07/20/2015 f1_keywords: - "CS1503" + - "CS1502" helpviewer_keywords: - "CS1503" + - "CS1502" ms.assetid: 65e4c63d-928d-49f5-8fac-8e113b07e128 --- # Compiler Error CS1503 Argument 'argument' cannot convert from TypeA to TypeB -The type of one argument in a method does not match the type that was passed when the class was instantiated. This error typically appears along with CS1502. See [CS1502](../language-reference/compiler-messages/cs1502.md) for a discussion of how to resolve this error. +The type of one argument in a method does not match the type that was passed when the class was instantiated. The following sample generates CS1503: From 77d91074ade1d4314b77ec7c7d2d769330fbd26e Mon Sep 17 00:00:00 2001 From: Bill Wagner Date: Tue, 21 Jan 2025 11:21:54 -0500 Subject: [PATCH 3/3] Update .openpublishing.redirection.csharp.json --- .openpublishing.redirection.csharp.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.openpublishing.redirection.csharp.json b/.openpublishing.redirection.csharp.json index 90a8e143cd5be..cd854aa2d8684 100644 --- a/.openpublishing.redirection.csharp.json +++ b/.openpublishing.redirection.csharp.json @@ -1828,7 +1828,7 @@ }, { "source_path_from_root": "/docs/csharp/language-reference/compiler-messages/cs1502.md", - "redirect_url": "/dotnet/csharp/misc/cs1503.md" + "redirect_url": "/dotnet/csharp/misc/cs1503" }, { "source_path_from_root": "/docs/csharp/misc/cs1510.md",