Skip to content

Commit a4cfd58

Browse files
authored
Format codes based on .editorconfig, Part 1 (#2865)
1 parent 89cda2c commit a4cfd58

File tree

80 files changed

+556
-551
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+556
-551
lines changed

core/assembly/MetadataLoadContext/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.IO;
33
using System.Collections.Generic;
44
using System.Reflection;

core/console-apps/HelloMsBuild/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ static void Main(string[] args)
99
Console.WriteLine("Hello World!");
1010
}
1111
}
12-
}
12+
}

core/console-apps/fibonacci-msbuild/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ static int FibonacciNumber(int n)
3939
return a;
4040
}
4141
}
42-
}
42+
}

core/diagnostics/DiagnosticScenarios/Controllers/DiagnosticScenarios.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ public class DiagScenarioController : ControllerBase
2121
[Route("deadlock/")]
2222
public ActionResult<string> deadlock()
2323
{
24-
(new System.Threading.Thread(() => {
24+
(new System.Threading.Thread(() =>
25+
{
2526
DeadlockFunc();
2627
})).Start();
2728

@@ -30,7 +31,8 @@ public ActionResult<string> deadlock()
3031
var threads = new Thread[300];
3132
for (int i = 0; i < 300; i++)
3233
{
33-
(threads[i] = new Thread(() => {
34+
(threads[i] = new Thread(() =>
35+
{
3436
lock (o1) { Thread.Sleep(100); }
3537
})).Start();
3638
}
@@ -47,7 +49,8 @@ private void DeadlockFunc()
4749
{
4850
lock (o1)
4951
{
50-
(new Thread(() => {
52+
(new Thread(() =>
53+
{
5154
lock (o2) { Monitor.Enter(o1); }
5255
})).Start();
5356

core/diagnostics/DiagnosticScenarios/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Threading.Tasks;

core/diagnostics/DiagnosticScenarios/Startup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Threading.Tasks;

core/encoding/cyrillic-to-latin/cs/ConsoleModule.cs

Lines changed: 75 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -4,90 +4,90 @@
44

55
class ConsoleModule
66
{
7-
static void Main()
8-
{
9-
string[] args = Environment.GetCommandLineArgs();
7+
static void Main()
8+
{
9+
string[] args = Environment.GetCommandLineArgs();
1010

11-
// Get command line arguments.
12-
if (args.Length != 3 || String.IsNullOrWhiteSpace(args[1]) || String.IsNullOrWhiteSpace(args[2]))
13-
{
14-
Console.WriteLine("There must be a source and a destination file.");
15-
ShowSyntax();
16-
return;
17-
}
11+
// Get command line arguments.
12+
if (args.Length != 3 || String.IsNullOrWhiteSpace(args[1]) || String.IsNullOrWhiteSpace(args[2]))
13+
{
14+
Console.WriteLine("There must be a source and a destination file.");
15+
ShowSyntax();
16+
return;
17+
}
1818

19-
string source = args[1];
20-
string destination = args[2];
19+
string source = args[1];
20+
string destination = args[2];
2121

22-
if(!File.Exists(source))
23-
{
24-
Console.WriteLine("The source file does not exist.");
25-
return;
26-
}
22+
if (!File.Exists(source))
23+
{
24+
Console.WriteLine("The source file does not exist.");
25+
return;
26+
}
2727

28-
try
29-
{
30-
using (var sr = new StreamReader(source))
31-
{
32-
// Check whether destination file exists and exit if it should not be overwritten.
33-
if (File.Exists(destination))
28+
try
29+
{
30+
using (var sr = new StreamReader(source))
3431
{
35-
Console.Write("The destination file {1} '{0}'{1}exists. Overwrite it? (Y/N) ",
36-
source, Environment.NewLine);
37-
ConsoleKeyInfo keyPressed = Console.ReadKey(true);
38-
if (Char.ToUpper(keyPressed.KeyChar) == 'Y' | Char.ToUpper(keyPressed.KeyChar) == 'N')
39-
{
40-
Console.WriteLine(keyPressed.KeyChar);
41-
if (Char.ToUpper(keyPressed.KeyChar) == 'N')
42-
return;
43-
}
44-
}
45-
using (var sw = new StreamWriter(destination, false, System.Text.Encoding.UTF8))
46-
{
47-
// Instantiate the encoder
48-
Encoding encoding = Encoding.GetEncoding("us-ascii", new CyrillicToRomanFallback(), new DecoderExceptionFallback());
49-
// This is an encoding operation, so we only need to get the encoder.
50-
Encoder encoder = encoding.GetEncoder();
51-
Decoder decoder = encoding.GetDecoder();
32+
// Check whether destination file exists and exit if it should not be overwritten.
33+
if (File.Exists(destination))
34+
{
35+
Console.Write("The destination file {1} '{0}'{1}exists. Overwrite it? (Y/N) ",
36+
source, Environment.NewLine);
37+
ConsoleKeyInfo keyPressed = Console.ReadKey(true);
38+
if (Char.ToUpper(keyPressed.KeyChar) == 'Y' | Char.ToUpper(keyPressed.KeyChar) == 'N')
39+
{
40+
Console.WriteLine(keyPressed.KeyChar);
41+
if (Char.ToUpper(keyPressed.KeyChar) == 'N')
42+
return;
43+
}
44+
}
45+
using (var sw = new StreamWriter(destination, false, System.Text.Encoding.UTF8))
46+
{
47+
// Instantiate the encoder
48+
Encoding encoding = Encoding.GetEncoding("us-ascii", new CyrillicToRomanFallback(), new DecoderExceptionFallback());
49+
// This is an encoding operation, so we only need to get the encoder.
50+
Encoder encoder = encoding.GetEncoder();
51+
Decoder decoder = encoding.GetDecoder();
5252

53-
// Define buffer to read characters
54-
char[] buffer = new char[100];
55-
int charsRead;
53+
// Define buffer to read characters
54+
char[] buffer = new char[100];
55+
int charsRead;
5656

57-
do
58-
{
59-
// Read next 100 characters from input stream.
60-
charsRead = sr.ReadBlock(buffer, 0, buffer.Length);
57+
do
58+
{
59+
// Read next 100 characters from input stream.
60+
charsRead = sr.ReadBlock(buffer, 0, buffer.Length);
6161

62-
// Encode characters.
63-
int byteCount = encoder.GetByteCount(buffer, 0, charsRead, false);
64-
byte[] bytes = new byte[byteCount];
65-
int bytesWritten = encoder.GetBytes(buffer, 0, charsRead, bytes, 0, false);
62+
// Encode characters.
63+
int byteCount = encoder.GetByteCount(buffer, 0, charsRead, false);
64+
byte[] bytes = new byte[byteCount];
65+
int bytesWritten = encoder.GetBytes(buffer, 0, charsRead, bytes, 0, false);
6666

67-
// Decode characters back to Unicode and write to a UTF-8-encoded file.
68-
char[] charsToWrite = new char[decoder.GetCharCount(bytes, 0, byteCount)];
69-
decoder.GetChars(bytes, 0, bytesWritten, charsToWrite, 0);
70-
sw.Write(charsToWrite);
71-
} while (charsRead == buffer.Length);
67+
// Decode characters back to Unicode and write to a UTF-8-encoded file.
68+
char[] charsToWrite = new char[decoder.GetCharCount(bytes, 0, byteCount)];
69+
decoder.GetChars(bytes, 0, bytesWritten, charsToWrite, 0);
70+
sw.Write(charsToWrite);
71+
} while (charsRead == buffer.Length);
72+
}
7273
}
73-
}
74-
}
75-
catch (DirectoryNotFoundException e)
76-
{
77-
Console.WriteLine($"Invalid directory: {e.Message}");
78-
return;
79-
}
80-
catch (IOException e)
81-
{
82-
Console.WriteLine($"I/O exception: {e.Message}");
83-
return;
84-
}
85-
}
74+
}
75+
catch (DirectoryNotFoundException e)
76+
{
77+
Console.WriteLine($"Invalid directory: {e.Message}");
78+
return;
79+
}
80+
catch (IOException e)
81+
{
82+
Console.WriteLine($"I/O exception: {e.Message}");
83+
return;
84+
}
85+
}
8686

87-
private static void ShowSyntax()
88-
{
89-
Console.WriteLine("\nSyntax: CyrillicToRoman <source> <destination>");
90-
Console.WriteLine(" where <source> = source filename");
91-
Console.WriteLine(" <destination> = destination filename\n");
92-
}
87+
private static void ShowSyntax()
88+
{
89+
Console.WriteLine("\nSyntax: CyrillicToRoman <source> <destination>");
90+
Console.WriteLine(" where <source> = source filename");
91+
Console.WriteLine(" <destination> = destination filename\n");
92+
}
9393
}

0 commit comments

Comments
 (0)