From c7273674c428f308ec110f1d5dfd256e35a78a7c Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Wed, 15 Sep 2021 08:36:05 -0700 Subject: [PATCH 1/5] Adding basic doc comments for System.Math.Sign, System.Math.SinCos, and System.MathF.SinCos --- xml/System/Math.xml | 63 ++++++++++++++++++++++++++++++++++++++------ xml/System/MathF.xml | 26 +++++++++++++++--- 2 files changed, 77 insertions(+), 12 deletions(-) diff --git a/xml/System/Math.xml b/xml/System/Math.xml index 925366cb7be..c12fd38ad91 100644 --- a/xml/System/Math.xml +++ b/xml/System/Math.xml @@ -7036,10 +7036,39 @@ The following example demonstrates how to use the - To be added. - To be added. - To be added. - To be added. + A signed number. + Returns an integer that indicates the sign of a native sized signed integer. + A number that indicates the sign of , as shown in the following table. + + Return value + + Meaning + + -1 + + is less than zero. + + 0 + + is equal to zero. + + 1 + + is greater than zero. + + + + method to determine the sign of an value and display it to the console. + + :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/math.sign/CPP/sign.cpp" id="Snippet1"::: + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/math.sign/CS/sign.cs" interactive="try-dotnet" id="Snippet1"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/math.sign/VB/sign.vb" id="Snippet1"::: + + ]]> + @@ -7317,10 +7346,28 @@ The following example demonstrates how to use the - To be added. - To be added. - To be added. - To be added. + An angle, measured in radians. + Returns the sine and cosine of the specified angle. + The sine and cosine of . If is equal to , , or , this method returns . + + /180 to convert degrees to radians. + + This method calls into the underlying C runtime, and the exact result or valid input range may differ between different operating systems or architectures. + + + +## Examples + The following example uses to evaluate certain trigonometric identities for selected angles. + + :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Math.SinCos/CPP/sincos.cpp" id="Snippet1"::: + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Math.SinCos/CS/sincos.cs" interactive="try-dotnet" id="Snippet1"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Math.SinCos/VB/sincos.vb" id="Snippet1"::: + + ]]> + diff --git a/xml/System/MathF.xml b/xml/System/MathF.xml index 510002cb4c6..077eab04271 100644 --- a/xml/System/MathF.xml +++ b/xml/System/MathF.xml @@ -2097,10 +2097,28 @@ If the value of the `x` argument is - To be added. - To be added. - To be added. - To be added. + An angle, measured in radians. + Returns the sine and cosine of the specified angle. + The sine and cosine of . If is equal to , , or , this method returns . + + /180 to convert degrees to radians. + + This method calls into the underlying C runtime, and the exact result or valid input range may differ between different operating systems or architectures. + + + +## Examples + The following example uses to evaluate certain trigonometric identities for selected angles. + + :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.MathF.SinCos/CPP/sincos.cpp" id="Snippet1"::: + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.MathF.SinCos/CS/sincos.cs" interactive="try-dotnet" id="Snippet1"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.MathF.SinCos/VB/sincos.vb" id="Snippet1"::: + + ]]> + From 6f78b672b67aa41c0042cc42a7c32ceed31929b1 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Wed, 15 Sep 2021 09:09:10 -0700 Subject: [PATCH 2/5] Updating the samples to cover Sign(IntPtr) and SinCos(double) --- .../VS_Snippets_CLR/math.sign/CS/sign.cs | 3 ++ .../system.Math.SinCos/CS/sincos.cs | 29 ++++++++++++++++++- xml/System/Math.xml | 4 --- xml/System/MathF.xml | 9 ------ 4 files changed, 31 insertions(+), 14 deletions(-) diff --git a/samples/snippets/csharp/VS_Snippets_CLR/math.sign/CS/sign.cs b/samples/snippets/csharp/VS_Snippets_CLR/math.sign/CS/sign.cs index 2063a16e727..7014ac48f04 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/math.sign/CS/sign.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/math.sign/CS/sign.cs @@ -15,6 +15,7 @@ public static void Main() float xSingle1 = 0.0f; double xDouble1 = 6.0; Decimal xDecimal1 = -7m; + nint xIntPtr1 = 8; // The following type is not CLS-compliant. sbyte xSbyte1 = -101; @@ -27,6 +28,7 @@ public static void Main() Console.WriteLine(str, "Single ", xSingle1, Test(Math.Sign(xSingle1))); Console.WriteLine(str, "Double ", xDouble1, Test(Math.Sign(xDouble1))); Console.WriteLine(str, "Decimal", xDecimal1, Test(Math.Sign(xDecimal1))); + Console.WriteLine(str, "IntPtr", xIntPtr1, Test(Math.Sign(xIntPtr1))); Console.WriteLine($"{nl}The following type is not CLS-compliant."); Console.WriteLine(str, "SByte ", xSbyte1, Test(Math.Sign(xSbyte1))); @@ -53,6 +55,7 @@ public static string Test(int compare) Single : 0 is equal to zero. Double : 6 is greater than zero. Decimal: -7 is less than zero. +IntPtr: 8 is greater than zero. The following type is not CLS-compliant. SByte : -101 is less than zero. diff --git a/samples/snippets/csharp/VS_Snippets_CLR_System/system.Math.SinCos/CS/sincos.cs b/samples/snippets/csharp/VS_Snippets_CLR_System/system.Math.SinCos/CS/sincos.cs index 79c2e74e9bd..5238597b2c6 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR_System/system.Math.SinCos/CS/sincos.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR_System/system.Math.SinCos/CS/sincos.cs @@ -9,7 +9,7 @@ public static void Main() { Console.WriteLine( "This example of trigonometric " + - "Math.Sin( double ) and Math.Cos( double )\n" + + "Math.Sin( double ), Math.Cos( double ), and Math.SinCos( double )\n" + "generates the following output.\n" ); Console.WriteLine( "Convert selected values for X to radians \n" + @@ -17,6 +17,7 @@ public static void Main() Console.WriteLine( " sin^2(X) + cos^2(X) == 1\n" + " sin(2 * X) == 2 * sin(X) * cos(X)" ); Console.WriteLine( " cos(2 * X) == cos^2(X) - sin^2(X)" ); + Console.WriteLine( " cos(2 * X) == cos^2(X) - sin^2(X)" ); UseSineCosine(15.0); UseSineCosine(30.0); @@ -30,6 +31,32 @@ public static void Main() UseTwoAngles(15.0, 30.0); UseTwoAngles(30.0, 45.0); + + Console.WriteLine( + "\nWhen you have calls to sin(X) and cos(X) they \n" + + "can be replaced with a single call to sincos(x):" ); + + UseCombinedSinCosine(15.0); + UseCombinedSinCosine(30.0); + UseCombinedSinCosine(45.0); + } + + // Evaluate trigonometric identities with a given angle. + static void UseCombinedSineCosine(double degrees) + { + double angle = Math.PI * degrees / 180.0; + (double sinAngle, double cosAngle) = Math.SinCos(angle); + + // Evaluate sin^2(X) + cos^2(X) == 1. + Console.WriteLine( + "\n Math.SinCos({0} deg) == ({1:E16}, {2:E16})", + degrees, sinAngle, cosAngle); + Console.WriteLine( + "(double sin, double cos) = Math.SinCos({0} deg)", + degrees ); + Console.WriteLine( + "sin^2 + cos^2 == {0:E16}", + sinAngle * sinAngle + cosAngle * cosAngle ); } // Evaluate trigonometric identities with a given angle. diff --git a/xml/System/Math.xml b/xml/System/Math.xml index c12fd38ad91..38d226beb0e 100644 --- a/xml/System/Math.xml +++ b/xml/System/Math.xml @@ -7063,9 +7063,7 @@ The following example demonstrates how to use the method to determine the sign of an value and display it to the console. - :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/math.sign/CPP/sign.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/math.sign/CS/sign.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/math.sign/VB/sign.vb" id="Snippet1"::: ]]> @@ -7362,9 +7360,7 @@ The following example demonstrates how to use the to evaluate certain trigonometric identities for selected angles. - :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Math.SinCos/CPP/sincos.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Math.SinCos/CS/sincos.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Math.SinCos/VB/sincos.vb" id="Snippet1"::: ]]> diff --git a/xml/System/MathF.xml b/xml/System/MathF.xml index 077eab04271..155b39df463 100644 --- a/xml/System/MathF.xml +++ b/xml/System/MathF.xml @@ -2108,15 +2108,6 @@ If the value of the `x` argument is to evaluate certain trigonometric identities for selected angles. - - :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.MathF.SinCos/CPP/sincos.cpp" id="Snippet1"::: - :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.MathF.SinCos/CS/sincos.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.MathF.SinCos/VB/sincos.vb" id="Snippet1"::: - ]]> From 6fa1a60df873dc0be6ef3a8549bd9c1b2dc1f652 Mon Sep 17 00:00:00 2001 From: carlossanlop Date: Wed, 15 Sep 2021 12:10:13 -0700 Subject: [PATCH 3/5] Add required csproj files --- .../VS_Snippets_CLR/math.sign/System.Math.Sign.csproj | 8 ++++++++ .../system.Math.SinCos/System.Math.SinCos.csproj | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 samples/snippets/csharp/VS_Snippets_CLR/math.sign/System.Math.Sign.csproj create mode 100644 samples/snippets/csharp/VS_Snippets_CLR_System/system.Math.SinCos/System.Math.SinCos.csproj diff --git a/samples/snippets/csharp/VS_Snippets_CLR/math.sign/System.Math.Sign.csproj b/samples/snippets/csharp/VS_Snippets_CLR/math.sign/System.Math.Sign.csproj new file mode 100644 index 00000000000..41f1d5ad4b2 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CLR/math.sign/System.Math.Sign.csproj @@ -0,0 +1,8 @@ + + + + Exe + net6.0 + + + diff --git a/samples/snippets/csharp/VS_Snippets_CLR_System/system.Math.SinCos/System.Math.SinCos.csproj b/samples/snippets/csharp/VS_Snippets_CLR_System/system.Math.SinCos/System.Math.SinCos.csproj new file mode 100644 index 00000000000..41f1d5ad4b2 --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CLR_System/system.Math.SinCos/System.Math.SinCos.csproj @@ -0,0 +1,8 @@ + + + + Exe + net6.0 + + + From f2802352e8f3036beb830d5f3ea0ceb647b31d96 Mon Sep 17 00:00:00 2001 From: Carlos Sanchez <1175054+carlossanlop@users.noreply.github.com> Date: Wed, 15 Sep 2021 14:25:27 -0700 Subject: [PATCH 4/5] fix typo --- .../VS_Snippets_CLR_System/system.Math.SinCos/CS/sincos.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/snippets/csharp/VS_Snippets_CLR_System/system.Math.SinCos/CS/sincos.cs b/samples/snippets/csharp/VS_Snippets_CLR_System/system.Math.SinCos/CS/sincos.cs index 5238597b2c6..a1b83851afb 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR_System/system.Math.SinCos/CS/sincos.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR_System/system.Math.SinCos/CS/sincos.cs @@ -36,9 +36,9 @@ public static void Main() "\nWhen you have calls to sin(X) and cos(X) they \n" + "can be replaced with a single call to sincos(x):" ); - UseCombinedSinCosine(15.0); - UseCombinedSinCosine(30.0); - UseCombinedSinCosine(45.0); + UseCombinedSineCosine(15.0); + UseCombinedSineCosine(30.0); + UseCombinedSineCosine(45.0); } // Evaluate trigonometric identities with a given angle. From 819a46dd3041343761e64787f803b679b4b33a13 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Mar 2022 20:03:58 +0000 Subject: [PATCH 5/5] Bump System.Reflection.Metadata Bumps [System.Reflection.Metadata](https://github.com/dotnet/runtime) from 5.0.0 to 6.0.1. - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/compare/v5.0.0...v6.0.1) --- updated-dependencies: - dependency-name: System.Reflection.Metadata dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .../metadatareader/MetadataReaderSnippets.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/snippets/csharp/api/system.reflection.metadata/metadatareader/MetadataReaderSnippets.csproj b/samples/snippets/csharp/api/system.reflection.metadata/metadatareader/MetadataReaderSnippets.csproj index 1763ae3474b..4abc160460e 100644 --- a/samples/snippets/csharp/api/system.reflection.metadata/metadatareader/MetadataReaderSnippets.csproj +++ b/samples/snippets/csharp/api/system.reflection.metadata/metadatareader/MetadataReaderSnippets.csproj @@ -6,7 +6,7 @@ - +