Skip to content

Commit c6ff655

Browse files
author
msftbot[bot]
authored
Merge pull request #46033 from dotnet/merges/master-to-master-vs-deps
Merge master to master-vs-deps
2 parents 874902b + 8d4a80b commit c6ff655

34 files changed

+523
-274
lines changed

eng/Version.Details.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
<Uri>https://github.com/dotnet/arcade</Uri>
88
<Sha>ed69753a3ffbdaa08365252c710d57a64d17f859</Sha>
99
</Dependency>
10-
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="3.8.0-1.20353.1">
10+
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="3.8.0-1.20361.1">
1111
<Uri>https://github.com/dotnet/roslyn</Uri>
12-
<Sha>09f75b83754732a74e0815976b80ecffd94c0dde</Sha>
12+
<Sha>f24d2c5c98211908ab90d6f1f42e7592411d6058</Sha>
1313
</Dependency>
1414
</ToolsetDependencies>
1515
</Dependencies>

eng/Versions.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</MajorVersion>
2424
<MinorVersion>
2525
</MinorVersion>
26-
<MicrosoftNetCompilersToolsetVersion>3.8.0-1.20353.1</MicrosoftNetCompilersToolsetVersion>
26+
<MicrosoftNetCompilersToolsetVersion>3.8.0-1.20361.1</MicrosoftNetCompilersToolsetVersion>
2727
</PropertyGroup>
2828
<PropertyGroup>
2929
<!-- Versions used by several individual references below -->

eng/config/PublishData.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,12 @@
185185
"vsBranch": "master",
186186
"vsMajorVersion": 16
187187
},
188-
"features/dotnetFormat": {
188+
"features/UsedAssemblyReferences": {
189189
"nugetKind": [ "Shipping", "NonShipping" ],
190-
"version": "3.3.*",
190+
"version": "3.8.*",
191191
"nuget": [ "https://dotnet.myget.org/F/roslyn/api/v2/package" ],
192192
"vsix": [ "https://dotnet.myget.org/F/roslyn/vsix/upload" ],
193-
"channels": [ "dotnetFormat" ],
193+
"channels": [ "UsedAssemblyReferences" ],
194194
"vsBranch": "master",
195195
"vsMajorVersion": 16
196196
},

src/Compilers/Core/CommandLine/BuildProtocol.cs

Lines changed: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,12 @@ public static BuildRequest Create(RequestLanguage language,
8282
{
8383
Debug.Assert(!string.IsNullOrWhiteSpace(compilerHash), "CompilerHash is required to send request to the build server");
8484

85-
Log("Creating BuildRequest");
86-
Log($"Working directory: {workingDirectory}");
87-
Log($"Temp directory: {tempDirectory}");
88-
Log($"Lib directory: {libDirectory ?? "null"}");
89-
Log($"Compiler hash: {compilerHash}");
85+
Log($@"
86+
Creating BuildRequest
87+
Working directory: {workingDirectory}
88+
Temp directory: {tempDirectory}
89+
Lib directory: {libDirectory ?? null}
90+
Compiler hash: {compilerHash}");
9091

9192
var requestLength = args.Count + 1 + (libDirectory == null ? 0 : 1);
9293
var requestArgs = new List<Argument>(requestLength);
@@ -108,7 +109,6 @@ public static BuildRequest Create(RequestLanguage language,
108109
for (int i = 0; i < args.Count; ++i)
109110
{
110111
var arg = args[i];
111-
Log($"argument[{i}] = {arg}");
112112
requestArgs.Add(new Argument(ArgumentId.CommandLineArgument, i, arg));
113113
}
114114

@@ -118,7 +118,7 @@ public static BuildRequest Create(RequestLanguage language,
118118
public static BuildRequest CreateShutdown()
119119
{
120120
var requestArgs = new[] { new Argument(ArgumentId.Shutdown, argumentIndex: 0, value: "") };
121-
return new BuildRequest(BuildProtocolConstants.ProtocolVersion, RequestLanguage.CSharpCompile, GetCommitHash(), requestArgs);
121+
return new BuildRequest(BuildProtocolConstants.ProtocolVersion, RequestLanguage.CSharpCompile, GetCommitHash() ?? "", requestArgs);
122122
}
123123

124124
/// <summary>
@@ -127,19 +127,17 @@ public static BuildRequest CreateShutdown()
127127
/// The total request size must be less than 1MB.
128128
/// </summary>
129129
/// <returns>null if the Request was too large, the Request otherwise.</returns>
130-
public static async Task<BuildRequest?> ReadAsync(Stream inStream, CancellationToken cancellationToken)
130+
public static async Task<BuildRequest> ReadAsync(Stream inStream, CancellationToken cancellationToken)
131131
{
132132
// Read the length of the request
133133
var lengthBuffer = new byte[4];
134-
Log("Reading length of request");
135134
await ReadAllAsync(inStream, lengthBuffer, 4, cancellationToken).ConfigureAwait(false);
136135
var length = BitConverter.ToInt32(lengthBuffer, 0);
137136

138137
// Back out if the request is > 1MB
139138
if (length > 0x100000)
140139
{
141-
Log("Request is over 1MB in length, cancelling read.");
142-
return null;
140+
throw new ArgumentException("Request is over 1MB in length");
143141
}
144142

145143
cancellationToken.ThrowIfCancellationRequested();
@@ -150,7 +148,6 @@ public static BuildRequest CreateShutdown()
150148

151149
cancellationToken.ThrowIfCancellationRequested();
152150

153-
Log("Parsing request");
154151
// Parse the request into the Request data structure.
155152
using (var reader = new BinaryReader(new MemoryStream(requestBuffer), Encoding.Unicode))
156153
{
@@ -182,8 +179,6 @@ public static BuildRequest CreateShutdown()
182179
using (var memoryStream = new MemoryStream())
183180
using (var writer = new BinaryWriter(memoryStream, Encoding.Unicode))
184181
{
185-
// Format the request.
186-
Log("Formatting request");
187182
writer.Write(ProtocolVersion);
188183
writer.Write((uint)Language);
189184
writer.Write(CompilerHash);
@@ -203,17 +198,12 @@ public static BuildRequest CreateShutdown()
203198
// Back out if the request is > 1 MB
204199
if (memoryStream.Length > 0x100000)
205200
{
206-
Log("Request is over 1MB in length, cancelling write");
207-
throw new ArgumentOutOfRangeException();
201+
throw new ArgumentOutOfRangeException("Request is over 1MB in length");
208202
}
209203

210-
// Send the request to the server
211-
Log("Writing length of request.");
212204
await outStream.WriteAsync(BitConverter.GetBytes(length), 0, 4,
213205
cancellationToken).ConfigureAwait(false);
214206

215-
Log("Writing request of size {0}", length);
216-
// Write the request
217207
memoryStream.Position = 0;
218208
await memoryStream.CopyToAsync(outStream, bufferSize: length, cancellationToken: cancellationToken).ConfigureAwait(false);
219209
}
@@ -311,8 +301,6 @@ public async Task WriteAsync(Stream outStream,
311301
using (var memoryStream = new MemoryStream())
312302
using (var writer = new BinaryWriter(memoryStream, Encoding.Unicode))
313303
{
314-
// Format the response
315-
Log("Formatting Response");
316304
writer.Write((int)Type);
317305

318306
AddResponseBody(writer);
@@ -325,16 +313,13 @@ public async Task WriteAsync(Stream outStream,
325313
// Write the length of the response
326314
int length = checked((int)memoryStream.Length);
327315

328-
Log("Writing response length");
329316
// There is no way to know the number of bytes written to
330317
// the pipe stream. We just have to assume all of them are written.
331318
await outStream.WriteAsync(BitConverter.GetBytes(length),
332319
0,
333320
4,
334321
cancellationToken).ConfigureAwait(false);
335322

336-
// Write the response
337-
Log("Writing response of size {0}", length);
338323
memoryStream.Position = 0;
339324
await memoryStream.CopyToAsync(outStream, bufferSize: length, cancellationToken: cancellationToken).ConfigureAwait(false);
340325
}
@@ -350,14 +335,12 @@ await outStream.WriteAsync(BitConverter.GetBytes(length),
350335
/// <returns></returns>
351336
public static async Task<BuildResponse> ReadAsync(Stream stream, CancellationToken cancellationToken = default(CancellationToken))
352337
{
353-
Log("Reading response length");
354338
// Read the response length
355339
var lengthBuffer = new byte[4];
356340
await ReadAllAsync(stream, lengthBuffer, 4, cancellationToken).ConfigureAwait(false);
357341
var length = BitConverter.ToUInt32(lengthBuffer, 0);
358342

359343
// Read the response
360-
Log("Reading response of length {0}", length);
361344
var responseBuffer = new byte[length];
362345
await ReadAllAsync(stream,
363346
responseBuffer,
@@ -381,7 +364,7 @@ await ReadAllAsync(stream,
381364
case ResponseType.Shutdown:
382365
return ShutdownBuildResponse.Create(reader);
383366
case ResponseType.Rejected:
384-
return new RejectedBuildResponse();
367+
return RejectedBuildResponse.Create(reader);
385368
default:
386369
throw new InvalidOperationException("Received invalid response type from server.");
387370
}
@@ -505,13 +488,30 @@ protected override void AddResponseBody(BinaryWriter writer) { }
505488

506489
internal sealed class RejectedBuildResponse : BuildResponse
507490
{
491+
public string Reason;
492+
508493
public override ResponseType Type => ResponseType.Rejected;
509494

495+
public RejectedBuildResponse(string reason)
496+
{
497+
Reason = reason;
498+
}
499+
510500
/// <summary>
511501
/// AnalyzerInconsistency has no body.
512502
/// </summary>
513503
/// <param name="writer"></param>
514-
protected override void AddResponseBody(BinaryWriter writer) { }
504+
protected override void AddResponseBody(BinaryWriter writer)
505+
{
506+
WriteLengthPrefixedString(writer, Reason);
507+
}
508+
509+
public static RejectedBuildResponse Create(BinaryReader reader)
510+
{
511+
var reason = ReadLengthPrefixedString(reader);
512+
Debug.Assert(reason is object);
513+
return new RejectedBuildResponse(reason);
514+
}
515515
}
516516

517517
// The id numbers below are just random. It's useful to use id numbers
@@ -592,14 +592,13 @@ public static void WriteLengthPrefixedString(BinaryWriter writer, string? value)
592592
/// Reads the value of <see cref="CommitHashAttribute.Hash"/> of the assembly <see cref="BuildRequest"/> is defined in
593593
/// </summary>
594594
/// <returns>The hash value of the current assembly or an empty string</returns>
595-
public static string GetCommitHash()
595+
public static string? GetCommitHash()
596596
{
597597
var hashAttributes = typeof(BuildRequest).Assembly.GetCustomAttributes<CommitHashAttribute>();
598598
var hashAttributeCount = hashAttributes.Count();
599599
if (hashAttributeCount != 1)
600600
{
601-
Log($"Error reading CommitHashAttribute. Exactly 1 attribute is required, found {hashAttributeCount}");
602-
return string.Empty;
601+
return null;
603602
}
604603
return hashAttributes.Single().Hash;
605604
}
@@ -616,21 +615,16 @@ internal static async Task ReadAllAsync(
616615
int totalBytesRead = 0;
617616
do
618617
{
619-
Log("Attempting to read {0} bytes from the stream",
620-
count - totalBytesRead);
621618
int bytesRead = await stream.ReadAsync(buffer,
622619
totalBytesRead,
623620
count - totalBytesRead,
624621
cancellationToken).ConfigureAwait(false);
625622
if (bytesRead == 0)
626623
{
627-
Log("Unexpected -- read 0 bytes from the stream.");
628624
throw new EndOfStreamException("Reached end of stream before end of read.");
629625
}
630-
Log("Read {0} bytes", bytesRead);
631626
totalBytesRead += bytesRead;
632627
} while (totalBytesRead < count);
633-
Log("Finished read");
634628
}
635629
}
636630
}

src/Compilers/Server/VBCSCompiler/CompilerRequestHandler.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,27 +96,22 @@ public bool TryCreateCompiler(RunRequest request, out CommonCompiler compiler)
9696

9797
public BuildResponse RunCompilation(RunRequest request, CancellationToken cancellationToken)
9898
{
99-
Log($"CurrentDirectory = '{request.CurrentDirectory}'");
100-
Log($"LIB = '{request.LibDirectory}'");
101-
for (int i = 0; i < request.Arguments.Length; ++i)
102-
{
103-
Log($"Argument[{i}] = '{request.Arguments[i]}'");
104-
}
99+
Log($@"
100+
Run Compilation
101+
CurrentDirectory = '{request.CurrentDirectory}
102+
LIB = '{request.LibDirectory}'");
105103

106104
// Compiler server must be provided with a valid temporary directory in order to correctly
107105
// isolate signing between compilations.
108106
if (string.IsNullOrEmpty(request.TempDirectory))
109107
{
110-
Log($"Rejecting build due to missing temp directory");
111-
return new RejectedBuildResponse();
108+
return new RejectedBuildResponse("Missing temp directory");
112109
}
113110

114111
CommonCompiler compiler;
115112
if (!TryCreateCompiler(request, out compiler))
116113
{
117-
// We can't do anything with a request we don't know about.
118-
Log($"Got request with id '{request.Language}'");
119-
return new RejectedBuildResponse();
114+
return new RejectedBuildResponse($"Cannot create compiler for language id {request.Language}");
120115
}
121116

122117
bool utf8output = compiler.Arguments.Utf8Output;
@@ -125,11 +120,16 @@ public BuildResponse RunCompilation(RunRequest request, CancellationToken cancel
125120
return new AnalyzerInconsistencyBuildResponse();
126121
}
127122

128-
Log($"****Running {request.Language} compiler...");
123+
Log($"Begin {request.Language} compiler run");
129124
TextWriter output = new StringWriter(CultureInfo.InvariantCulture);
130125
int returnCode = compiler.Run(output, cancellationToken);
131-
Log($"****{request.Language} Compilation complete.\r\n****Return code: {returnCode}\r\n****Output:\r\n{output.ToString()}\r\n");
132-
return new CompletedBuildResponse(returnCode, utf8output, output.ToString());
126+
var outputString = output.ToString();
127+
Log(@$"
128+
End {request.Language} Compilation complete.
129+
Return code: {returnCode}
130+
Output:
131+
{outputString}");
132+
return new CompletedBuildResponse(returnCode, utf8output, outputString);
133133
}
134134
}
135135
}

src/Compilers/Server/VBCSCompiler/NamedPipeClientConnection.cs

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ public void Close()
112112
// The client connection failing to close isn't fatal to the server process. It is simply a client
113113
// for which we can no longer communicate and that's okay because the Close method indicates we are
114114
// done with the client already.
115-
var msg = string.Format($"Pipe {LoggingIdentifier}: Error closing pipe.");
116-
CompilerServerLogger.LogException(e, msg);
115+
CompilerServerLogger.LogException(e, $"Pipe {LoggingIdentifier}: Error closing pipe.");
117116
}
118117
}
119118

@@ -124,14 +123,12 @@ public void Close()
124123
BuildRequest request;
125124
try
126125
{
127-
Log("Begin reading request.");
128126
request = await BuildRequest.ReadAsync(_stream, cancellationToken).ConfigureAwait(false);
129127
ValidateBuildRequest(request);
130-
Log("End reading request.");
131128
}
132129
catch (Exception e)
133130
{
134-
LogException(e, "Error reading build request.");
131+
CompilerServerLogger.LogException(e, "Error reading build request.");
135132
return new ConnectionData(CompletionReason.CompilationNotStarted);
136133
}
137134

@@ -149,7 +146,7 @@ public void Close()
149146
}
150147
else if (!allowCompilationRequests)
151148
{
152-
return await HandleRejectedRequestAsync(cancellationToken).ConfigureAwait(false);
149+
return await HandleRejectedRequestAsync("Compilation requests not allowed at this time", cancellationToken).ConfigureAwait(false);
153150
}
154151
else
155152
{
@@ -181,10 +178,8 @@ private async Task<ConnectionData> HandleCompilationRequestAsync(BuildRequest re
181178

182179
try
183180
{
184-
Log("Begin writing response.");
185181
await response.WriteAsync(_stream, cancellationToken).ConfigureAwait(false);
186182
reason = CompletionReason.CompilationCompleted;
187-
Log("End writing response.");
188183
}
189184
catch
190185
{
@@ -216,9 +211,9 @@ private async Task<ConnectionData> HandleIncorrectHashRequestAsync(CancellationT
216211
return new ConnectionData(CompletionReason.CompilationNotStarted);
217212
}
218213

219-
private async Task<ConnectionData> HandleRejectedRequestAsync(CancellationToken cancellationToken)
214+
private async Task<ConnectionData> HandleRejectedRequestAsync(string reason, CancellationToken cancellationToken)
220215
{
221-
var response = new RejectedBuildResponse();
216+
var response = new RejectedBuildResponse(reason);
222217
await response.WriteAsync(_stream, cancellationToken).ConfigureAwait(false);
223218
return new ConnectionData(CompletionReason.CompilationNotStarted);
224219
}
@@ -266,29 +261,14 @@ private Task<BuildResponse> ServeBuildRequestAsync(BuildRequest buildRequest, Ca
266261
{
267262
Func<BuildResponse> func = () =>
268263
{
269-
// Do the compilation
270-
Log("Begin compilation");
271-
272264
var request = BuildProtocolUtil.GetRunRequest(buildRequest);
273265
var response = _compilerServerHost.RunCompilation(request, cancellationToken);
274-
275-
Log("End compilation");
276266
return response;
277267
};
278268

279269
var task = new Task<BuildResponse>(func, cancellationToken, TaskCreationOptions.LongRunning);
280270
task.Start();
281271
return task;
282272
}
283-
284-
private void Log(string message)
285-
{
286-
CompilerServerLogger.Log("Client {0}: {1}", _loggingIdentifier, message);
287-
}
288-
289-
private void LogException(Exception e, string message)
290-
{
291-
CompilerServerLogger.LogException(e, string.Format("Client {0}: {1}", _loggingIdentifier, message));
292-
}
293273
}
294274
}

0 commit comments

Comments
 (0)