Skip to content

Commit b7d3777

Browse files
authored
Reinstate supplemental API remarks (System.Runtime) (#12699)
1 parent 13e187a commit b7d3777

38 files changed

Lines changed: 1150 additions & 65 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Library</OutputType>
5+
<TargetFramework>net10.0</TargetFramework>
6+
</PropertyGroup>
7+
8+
</Project>

snippets/csharp/System.Runtime.CompilerServices/InternalsVisibleToAttribute/Overview/assembly1.cs renamed to snippets/csharp/System.Runtime.CompilerServices/InternalsVisibleToAttribute/Overview/Friend/assembly1.cs

File renamed without changes.

snippets/csharp/System.Runtime.CompilerServices/InternalsVisibleToAttribute/Overview/friend1.cs renamed to snippets/csharp/System.Runtime.CompilerServices/InternalsVisibleToAttribute/Overview/Friend/friend1.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static void Main()
2626
// C:\Program Files\
2727
// </Snippet2>
2828

29-
public class FileUtilities
29+
public class FileUtilities1
3030
{
3131
internal static string AppendDirectorySeparator(string dir)
3232
{
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// <Snippet6>
2+
using System;
3+
4+
public class Example1
5+
{
6+
public static void Main()
7+
{
8+
String s = "The Sign of the Four";
9+
//Console.WriteLine(Utilities.StringUtilities.StringLib.IsFirstLetterUpperCase(s));
10+
}
11+
}
12+
// </Snippet6>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.Runtime.CompilerServices;
3+
4+
// <Snippet3>
5+
[assembly:InternalsVisibleTo("Friend1a")]
6+
[assembly:InternalsVisibleTo("Friend1b")]
7+
// </Snippet3>
8+
9+
public class StringUtilities
10+
{
11+
internal string ToTitleCase(string value)
12+
{
13+
string retval = null;
14+
for (int ctr = 0; ctr < value.Length; ctr++)
15+
if (ctr == 0)
16+
retval += Char.ToUpper(value[ctr]);
17+
else if (ctr > 0 && Char.IsWhiteSpace(value[ctr - 1]))
18+
retval += Char.ToUpper(value[ctr]);
19+
else
20+
retval += value[ctr];
21+
return retval;
22+
}
23+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.Runtime.CompilerServices;
3+
4+
// <Snippet4>
5+
[assembly:InternalsVisibleTo("Friend2a"),
6+
InternalsVisibleTo("Friend2b")]
7+
// </Snippet4>
8+
9+
namespace Utilities
10+
{
11+
public class StringUtilities1
12+
{
13+
internal static string ToTitleCase(string value)
14+
{
15+
string retval = null;
16+
for (int ctr = 0; ctr < value.Length; ctr++)
17+
if (ctr == 0)
18+
retval += Char.ToUpper(value[ctr]);
19+
else if (ctr > 0 && Char.IsWhiteSpace(value[ctr - 1]))
20+
retval += Char.ToUpper(value[ctr]);
21+
else
22+
retval += value[ctr];
23+
return retval;
24+
}
25+
}
26+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Library</OutputType>
5+
<TargetFramework>net10.0</TargetFramework>
6+
</PropertyGroup>
7+
8+
</Project>

snippets/csharp/System.Runtime.CompilerServices/InternalsVisibleToAttribute/Overview/utilitylib.cs renamed to snippets/csharp/System.Runtime.CompilerServices/InternalsVisibleToAttribute/Overview/UtilityLib/utilitylib.cs

File renamed without changes.

snippets/csharp/System.Runtime.CompilerServices/InternalsVisibleToAttribute/Overview/friend2.cs

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// <Snippet1>
2+
using System;
3+
using System.Runtime.CompilerServices;
4+
5+
public class Example
6+
{
7+
public static void Main()
8+
{
9+
Console.WriteLine("{0,-18} {1,6} {2,18:N0} {3,6} {4,18:N0}\n",
10+
"", "Var 1", "Hash Code", "Var 2", "Hash Code");
11+
12+
// Get hash codes of two different strings.
13+
String sc1 = "String #1";
14+
String sc2 = "String #2";
15+
ShowHashCodes("sc1", sc1, "sc2", sc2);
16+
17+
// Get hash codes of two identical non-interned strings.
18+
String s1 = "This string";
19+
String s2 = String.Format("{0} {1}", "This", "string");
20+
ShowHashCodes("s1", s1, "s2", s2);
21+
22+
// Get hash codes of two (evidently concatenated) strings.
23+
String si1 = "This is a string!";
24+
String si2 = "This " + "is " + "a " + "string!";
25+
ShowHashCodes("si1", si1, "si2", si2);
26+
}
27+
28+
private static void ShowHashCodes(String var1, Object value1,
29+
String var2, Object value2)
30+
{
31+
Console.WriteLine("{0,-18} {1,6} {2,18:X8} {3,6} {4,18:X8}",
32+
"Obj.GetHashCode", var1, value1.GetHashCode(),
33+
var2, value2.GetHashCode());
34+
35+
Console.WriteLine("{0,-18} {1,6} {2,18:X8} {3,6} {4,18:X8}\n",
36+
"RTH.GetHashCode", var1, RuntimeHelpers.GetHashCode(value1),
37+
var2, RuntimeHelpers.GetHashCode(value2));
38+
}
39+
}
40+
// The example displays output similar to the following:
41+
// Var 1 Hash Code Var 2 Hash Code
42+
//
43+
// Obj.GetHashCode sc1 94EABD27 sc2 94EABD24
44+
// RTH.GetHashCode sc1 02BF8098 sc2 00BB8560
45+
//
46+
// Obj.GetHashCode s1 29C5A397 s2 29C5A397
47+
// RTH.GetHashCode s1 0297B065 s2 03553390
48+
//
49+
// Obj.GetHashCode si1 941BCEA5 si2 941BCEA5
50+
// RTH.GetHashCode si1 01FED012 si2 01FED012
51+
// </Snippet1>

0 commit comments

Comments
 (0)