Skip to content

Commit d0115a0

Browse files
committed
merge master into branch
2 parents ba2ed9f + 1434f89 commit d0115a0

File tree

12 files changed

+432
-226
lines changed

12 files changed

+432
-226
lines changed

.github/labeler.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#area-azure:
2+
3+
area-blazor:
4+
- src/Components/**/*
5+
6+
#area-commandlinetools:
7+
8+
area-dataprotection:
9+
- src/DataProtection/**/*
10+
11+
#area-grpc:
12+
13+
#area-healthchecks:
14+
15+
area-hosting:
16+
- src/Hosting/**/*
17+
- src/SiteExtensions/**/*
18+
19+
#area-httpclientfactory:
20+
21+
area-identity:
22+
- src/Identity/**/*
23+
24+
area-infrastructure:
25+
- global.json
26+
- .azure/**/*
27+
- .config/**/*
28+
- eng/**/*
29+
30+
area-installers:
31+
- src/Installers/**/*
32+
33+
area-middleware:
34+
- src/Middleware/**/*
35+
36+
area-mvc:
37+
- src/ProjectTemplates/**/*
38+
- src/Razor/**/*
39+
- src/Mvc/**/*
40+
- src/MusicStore/**/*
41+
42+
#area-platform:
43+
44+
area-security:
45+
- src/Security/**/*
46+
47+
area-servers:
48+
- src/Servers/**/*
49+
50+
area-signalr:
51+
- src/SignalR/**/*
52+
53+
#area-websockets:

.github/workflows/labeler.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: "Pull Request Labeler"
2+
on:
3+
- pull_request
4+
5+
jobs:
6+
triage:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/labeler@v2
10+
with:
11+
repo-token: "${{ secrets.GITHUB_TOKEN }}"

docs/ReferenceAssemblies.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ Set `<HasReferenceAssembly>false</HasReferenceAssembly>` in the implementation (
2222

2323
### Regenerate reference assemblies for all projects
2424

25-
Run `.\eng\scripts\GenerateReferenceAssemblies.ps1` from repository root.
25+
Run `.\eng\scripts\GenerateReferenceAssemblies.ps1` from repository root. Make sure you've run `.\restore.cmd` first.

eng/Version.Details.xml

Lines changed: 146 additions & 146 deletions
Large diffs are not rendered by default.

eng/Versions.props

Lines changed: 73 additions & 73 deletions
Large diffs are not rendered by default.

src/Http/Http.Extensions/src/RequestHeaders.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,27 @@ public Uri Referer
279279
}
280280
}
281281

282+
/// <summary>
283+
/// Gets the value of header with <paramref name="name"/>.
284+
/// </summary>
285+
/// <remarks><typeparamref name="T"/> must contain a TryParse method with the signature <code>public static bool TryParse(string, out T)</code>.</remarks>
286+
/// <typeparam name="T">The type of the header.
287+
/// The given type must have a static TryParse method.</typeparam>
288+
/// <param name="name">The name of the header to retrieve.</param>
289+
/// <returns>The value of the header.</returns>
282290
public T Get<T>(string name)
283291
{
284292
return Headers.Get<T>(name);
285293
}
286294

295+
/// <summary>
296+
/// Gets the values of header with <paramref name="name"/>.
297+
/// </summary>
298+
/// <remarks><typeparamref name="T"/> must contain a TryParseList method with the signature <code>public static bool TryParseList(IList&lt;string&gt;, out IList&lt;T&gt;)</code>.</remarks>
299+
/// <typeparam name="T">The type of the header.
300+
/// The given type must have a static TryParseList method.</typeparam>
301+
/// <param name="name">The name of the header to retrieve.</param>
302+
/// <returns>List of values of the header.</returns>
287303
public IList<T> GetList<T>(string name)
288304
{
289305
return Headers.GetList<T>(name);

src/Http/Http.Extensions/src/ResponseHeaders.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,27 @@ public IList<SetCookieHeaderValue> SetCookie
158158
}
159159
}
160160

161+
/// <summary>
162+
/// Gets the value of header with <paramref name="name"/>.
163+
/// </summary>
164+
/// <remarks><typeparamref name="T"/> must contain a TryParse method with the signature <code>public static bool TryParse(string, out T)</code>.</remarks>
165+
/// <typeparam name="T">The type of the header.
166+
/// The given type must have a static TryParse method.</typeparam>
167+
/// <param name="name">The name of the header to retrieve.</param>
168+
/// <returns>The value of the header.</returns>
161169
public T Get<T>(string name)
162170
{
163171
return Headers.Get<T>(name);
164172
}
165173

174+
/// <summary>
175+
/// Gets the values of header with <paramref name="name"/>.
176+
/// </summary>
177+
/// <remarks><typeparamref name="T"/> must contain a TryParseList method with the signature <code>public static bool TryParseList(IList&lt;string&gt;, out IList&lt;T&gt;)</code>.</remarks>
178+
/// <typeparam name="T">The type of the header.
179+
/// The given type must have a static TryParseList method.</typeparam>
180+
/// <param name="name">The name of the header to retrieve.</param>
181+
/// <returns>List of values of the header.</returns>
166182
public IList<T> GetList<T>(string name)
167183
{
168184
return Headers.GetList<T>(name);
@@ -208,4 +224,4 @@ public void AppendList<T>(string name, IList<T> values)
208224
Headers.AppendList<T>(name, values);
209225
}
210226
}
211-
}
227+
}

src/Mvc/Mvc.DataAnnotations/src/DataAnnotationsMetadataProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ internal static bool HasNullableAttribute(IEnumerable<object> attributes, out bo
481481
// See: https://github.com/dotnet/roslyn/blob/master/docs/features/nullable-reference-types.md#annotations
482482
if (nullableAttribute.GetType().GetField(NullableFlagsFieldName) is FieldInfo field &&
483483
field.GetValue(nullableAttribute) is byte[] flags &&
484-
flags.Length >= 0 &&
484+
flags.Length > 0 &&
485485
flags[0] == 1) // First element is the property/parameter type.
486486
{
487487
isNullable = true;

src/Mvc/Mvc.ViewFeatures/src/RazorComponents/StaticComponentRenderer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public async Task<IEnumerable<string>> PrerenderComponentAsync(
5252
// all components have rendered.
5353
throw new InvalidOperationException("A navigation command was attempted during prerendering after the server already started sending the response. " +
5454
"Navigation commands can not be issued during server-side prerendering after the response from the server has started. Applications must buffer the" +
55-
"reponse and avoid using features like FlushAsync() before all components on the page have been rendered to prevent failed navigation commands.", navigationException);
55+
"response and avoid using features like FlushAsync() before all components on the page have been rendered to prevent failed navigation commands.", navigationException);
5656
}
5757

5858
httpContext.Response.Redirect(navigationException.Location);

src/Mvc/Mvc.ViewFeatures/test/RazorComponents/ComponentRendererTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
@@ -473,8 +473,8 @@ public async Task UriHelperRedirect_ThrowsInvalidOperationException_WhenResponse
473473
}));
474474

475475
Assert.Equal("A navigation command was attempted during prerendering after the server already started sending the response. " +
476-
"Navigation commands can not be issued during server-side prerendering after the response from the server has started. Applications must buffer the" +
477-
"reponse and avoid using features like FlushAsync() before all components on the page have been rendered to prevent failed navigation commands.",
476+
"Navigation commands can not be issued during server-side prerendering after the response from the server has started. Applications must buffer the" +
477+
"response and avoid using features like FlushAsync() before all components on the page have been rendered to prevent failed navigation commands.",
478478
exception.Message);
479479
}
480480

src/SignalR/common/SignalR.Common/test/Internal/Protocol/JsonHubProtocolTestsBase.cs

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,50 @@ public void ReadCaseInsensitivePropertiesByDefault()
312312
}, streamItemMessage.Item);
313313
}
314314

315+
public static IDictionary<string, MessageSizeTestData> MessageSizeData => new[]
316+
{
317+
new MessageSizeTestData("InvocationMessage_WithoutInvocationId", new InvocationMessage("Target", new object[] { 1 }), 45),
318+
new MessageSizeTestData("InvocationMessage_WithInvocationId", new InvocationMessage("1", "Target", new object[] { 1 }), 64),
319+
new MessageSizeTestData("InvocationMessage_WithInvocationIdAndStreamId", new InvocationMessage("1", "Target", new object[] { 1 }, new string[] { "2" }), 82),
320+
321+
new MessageSizeTestData("CloseMessage_Empty", CloseMessage.Empty, 11),
322+
new MessageSizeTestData("CloseMessage_WithError", new CloseMessage("error"), 27),
323+
324+
new MessageSizeTestData("StreamItemMessage_WithNullItem", new StreamItemMessage("1", null), 42),
325+
new MessageSizeTestData("StreamItemMessage_WithItem", new StreamItemMessage("1", 1), 39),
326+
327+
new MessageSizeTestData("CompletionMessage_Empty", CompletionMessage.Empty("1"), 30),
328+
new MessageSizeTestData("CompletionMessage_WithResult", CompletionMessage.WithResult("1", 1), 41),
329+
new MessageSizeTestData("CompletionMessage_WithError", CompletionMessage.WithError("1", "error"), 46),
330+
331+
new MessageSizeTestData("StreamInvocationMessage", new StreamInvocationMessage("1", "target", Array.Empty<object>()), 63),
332+
new MessageSizeTestData("StreamInvocationMessage_WithStreamId", new StreamInvocationMessage("1", "target", Array.Empty<object>(), new [] { "2" }), 81),
333+
334+
new MessageSizeTestData("CancelInvocationMessage", new CancelInvocationMessage("1"), 30),
335+
336+
new MessageSizeTestData("PingMessage", PingMessage.Instance, 11),
337+
}.ToDictionary(t => t.Name);
338+
339+
public static IEnumerable<object[]> MessageSizeDataNames => MessageSizeData.Keys.Select(name => new object[] { name });
340+
341+
[Theory]
342+
[MemberData(nameof(MessageSizeDataNames))]
343+
public void VerifyMessageSize(string testDataName)
344+
{
345+
var testData = MessageSizeData[testDataName];
346+
347+
var writer = MemoryBufferWriter.Get();
348+
try
349+
{
350+
JsonHubProtocol.WriteMessage(testData.Message, writer);
351+
Assert.Equal(testData.Size, writer.Length);
352+
}
353+
finally
354+
{
355+
MemoryBufferWriter.Return(writer);
356+
}
357+
}
358+
315359
public static string Frame(string input)
316360
{
317361
var data = Encoding.UTF8.GetBytes(input);
@@ -345,5 +389,21 @@ public JsonProtocolTestData(string name, HubMessage message, bool useCamelCase,
345389

346390
public override string ToString() => Name;
347391
}
392+
393+
public class MessageSizeTestData
394+
{
395+
public string Name { get; }
396+
public HubMessage Message { get; }
397+
public int Size { get; }
398+
399+
public MessageSizeTestData(string name, HubMessage message, int size)
400+
{
401+
Name = name;
402+
Message = message;
403+
Size = size;
404+
}
405+
406+
public override string ToString() => Name;
407+
}
348408
}
349409
}

src/SignalR/common/SignalR.Common/test/Internal/Protocol/MessagePackHubProtocolTests.cs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,5 +195,55 @@ public void WriteMessages(string testDataName)
195195

196196
TestWriteMessages(testData);
197197
}
198+
199+
public static IDictionary<string, MessageSizeTestData> MessageSizeData => new[]
200+
{
201+
new MessageSizeTestData("InvocationMessage_WithoutInvocationId", new InvocationMessage("Target", new object[] { 1 }), 15),
202+
new MessageSizeTestData("InvocationMessage_WithInvocationId", new InvocationMessage("1", "Target", new object[] { 1 }), 16),
203+
new MessageSizeTestData("InvocationMessage_WithInvocationIdAndStreamId", new InvocationMessage("1", "Target", new object[] { 1 }, new string[] { "2" }), 18),
204+
205+
new MessageSizeTestData("CloseMessage_Empty", CloseMessage.Empty, 4),
206+
new MessageSizeTestData("CloseMessage_WithError", new CloseMessage("error"), 9),
207+
208+
new MessageSizeTestData("StreamItemMessage_WithNullItem", new StreamItemMessage("1", null), 7),
209+
new MessageSizeTestData("StreamItemMessage_WithItem", new StreamItemMessage("1", 1), 7),
210+
211+
new MessageSizeTestData("CompletionMessage_Empty", CompletionMessage.Empty("1"), 7),
212+
new MessageSizeTestData("CompletionMessage_WithResult", CompletionMessage.WithResult("1", 1), 8),
213+
new MessageSizeTestData("CompletionMessage_WithError", CompletionMessage.WithError("1", "error"), 13),
214+
215+
new MessageSizeTestData("StreamInvocationMessage", new StreamInvocationMessage("1", "target", Array.Empty<object>()), 15),
216+
new MessageSizeTestData("StreamInvocationMessage_WithStreamId", new StreamInvocationMessage("1", "target", Array.Empty<object>(), new [] { "2" }), 17),
217+
218+
new MessageSizeTestData("CancelInvocationMessage", new CancelInvocationMessage("1"), 6),
219+
220+
new MessageSizeTestData("PingMessage", PingMessage.Instance, 3),
221+
}.ToDictionary(t => t.Name);
222+
223+
public static IEnumerable<object[]> MessageSizeDataNames => MessageSizeData.Keys.Select(name => new object[] { name });
224+
225+
[Theory]
226+
[MemberData(nameof(MessageSizeDataNames))]
227+
public void VerifyMessageSize(string testDataName)
228+
{
229+
var testData = MessageSizeData[testDataName];
230+
Assert.Equal(testData.Size, Write(testData.Message).Length);
231+
}
232+
233+
public class MessageSizeTestData
234+
{
235+
public string Name { get; }
236+
public HubMessage Message { get; }
237+
public int Size { get; }
238+
239+
public MessageSizeTestData(string name, HubMessage message, int size)
240+
{
241+
Name = name;
242+
Message = message;
243+
Size = size;
244+
}
245+
246+
public override string ToString() => Name;
247+
}
198248
}
199249
}

0 commit comments

Comments
 (0)