Skip to content

[automated] Merge branch 'release/3.1' => 'master' #14249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Sep 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
308 changes: 154 additions & 154 deletions eng/Version.Details.xml

Large diffs are not rendered by default.

154 changes: 77 additions & 77 deletions eng/Versions.props

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions eng/scripts/ci-source-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ set -euo pipefail
scriptroot="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
reporoot="$(dirname "$(dirname "$scriptroot")")"

export DotNetBuildFromSource='true'

# Build repo tasks
# Build repo tasks
"$reporoot/eng/common/build.sh" --restore --build --ci --configuration Release /p:ProjectToBuild=$reporoot/eng/tools/RepoTasks/RepoTasks.csproj

# Build projects
export DotNetBuildFromSource='true'

# Build projects
"$reporoot/eng/common/build.sh" --restore --build --pack "$@"
2 changes: 1 addition & 1 deletion src/Framework/src/Microsoft.AspNetCore.App.Runtime.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ This package is an internal implementation of the .NET Core SDK and is not meant
<BaseRuntimeVersionFileName>aspnetcore_base_runtime.version</BaseRuntimeVersionFileName>
<BaseRuntimeVersionFileOutputPath>$(InstallersOutputPath)$(BaseRuntimeVersionFileName)</BaseRuntimeVersionFileOutputPath>

<!-- NuGet appends target framework to this value. Example: runtimes/win-x64/lib/netcoreapp5.0/ -->
<!-- NuGet appends target framework to this value. Example: runtimes/win-x64/lib/netcoreappX.Y/ -->
<BuildOutputTargetFolder>runtimes/$(RuntimeIdentifier)/lib/</BuildOutputTargetFolder>
<!-- We still need the native path to these assets though for the RuntimeList.xml manifest -->
<ManagedAssetsPackagePath>$(BuildOutputTargetFolder)$(DefaultNetCoreTargetFramework)</ManagedAssetsPackagePath>
Expand Down
3 changes: 2 additions & 1 deletion src/Mvc/Mvc.Analyzers/src/DiagnosticDescriptors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public static class DiagnosticDescriptors
new DiagnosticDescriptor(
"MVC1004",
"Rename model bound parameter.",
"Property on type '{0}' has the same name as parameter '{1}'. This may result in incorrect model binding. Consider renaming the parameter or using a model binding attribute to override the name.",
"Property on type '{0}' has the same name as parameter '{1}'. This may result in incorrect model binding. " +
"Consider renaming the parameter or the property to avoid conflicts. If the type '{0}' has a custom type converter or custom model binder, you can suppress this message.",
"Naming",
DiagnosticSeverity.Warning,
isEnabledByDefault: true,
Expand Down
27 changes: 26 additions & 1 deletion src/Mvc/Mvc.Analyzers/src/TopLevelParameterNameAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,17 @@ internal static bool IsProblematicParameter(in SymbolCache symbolCache, IParamet
return false;
}

if (SpecifiesModelType(symbolCache, parameter))
if (SpecifiesModelType(in symbolCache, parameter))
{
// Ignore parameters that specify a model type.
return false;
}

if (!IsComplexType(parameter.Type))
{
return false;
}

var parameterName = GetName(symbolCache, parameter);

var type = parameter.Type;
Expand Down Expand Up @@ -122,6 +127,26 @@ internal static bool IsProblematicParameter(in SymbolCache symbolCache, IParamet
return false;
}

private static bool IsComplexType(ITypeSymbol type)
{
// This analyzer should not apply to simple types. In MVC, a simple type is any type that has a type converter that returns true for TypeConverter.CanConvertFrom(typeof(string)).
// Unfortunately there isn't a Roslyn way of determining if a TypeConverter exists for a given symbol or if the converter allows string conversions.
// https://github.com/dotnet/corefx/blob/v3.0.0-preview8.19405.3/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.cs#L103-L141
// provides a list of types that have built-in converters.
// We'll use a simpler heuristic in the analyzer: A type is simple if it's a value type or if it's in the "System.*" namespace hierarchy.

var @namespace = type.ContainingNamespace?.ToString();
if (@namespace != null)
{
// Things in the System.* namespace hierarchy don't count as complex types. This workarounds
// the problem of discovering type converters on types in mscorlib.
return @namespace != "System" &&
[email protected]("System.", StringComparison.Ordinal);
}

return true;
}

internal static string GetName(in SymbolCache symbolCache, ISymbol symbol)
{
foreach (var attribute in symbol.GetAttributes(symbolCache.IModelNameProvider))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System;

namespace Microsoft.AspNetCore.Mvc.Analyzers.TopLevelParameterNameAnalyzerTestFiles
{
public class IsProblematicParameter_ReturnsFalse_ForSimpleTypes
{
public void ActionMethod(DateTime date, DateTime? day, Uri absoluteUri, Version majorRevision, DayOfWeek sunday) { }
}
}
24 changes: 24 additions & 0 deletions src/Mvc/Mvc.Analyzers/test/TopLevelParameterNameAnalyzerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,30 @@ public async Task IsProblematicParameter_ReturnsFalse_ForParametersWithCustomMod
Assert.False(result);
}

// Test for https://github.com/aspnet/AspNetCore/issues/6945
[Fact]
public async Task IsProblematicParameter_ReturnsFalse_ForSimpleTypes()
{
var testName = nameof(IsProblematicParameter_ReturnsFalse_ForSimpleTypes);
var testSource = MvcTestSource.Read(GetType().Name, testName);
var project = DiagnosticProject.Create(GetType().Assembly, new[] { testSource.Source });

var compilation = await project.GetCompilationAsync();

var modelType = compilation.GetTypeByMetadataName($"Microsoft.AspNetCore.Mvc.Analyzers.TopLevelParameterNameAnalyzerTestFiles.{testName}");
var method = (IMethodSymbol)modelType.GetMembers("ActionMethod").First();

Assert.True(TopLevelParameterNameAnalyzer.SymbolCache.TryCreate(compilation, out var symbolCache));

Assert.Collection(
method.Parameters,
p => Assert.False(TopLevelParameterNameAnalyzer.IsProblematicParameter(symbolCache, p)),
p => Assert.False(TopLevelParameterNameAnalyzer.IsProblematicParameter(symbolCache, p)),
p => Assert.False(TopLevelParameterNameAnalyzer.IsProblematicParameter(symbolCache, p)),
p => Assert.False(TopLevelParameterNameAnalyzer.IsProblematicParameter(symbolCache, p)),
p => Assert.False(TopLevelParameterNameAnalyzer.IsProblematicParameter(symbolCache, p)));
}

[Fact]
public async Task IsProblematicParameter_IgnoresStaticProperties()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
<a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage">Hello @User.Identity.Name!</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/LogOut">Logout</a>
<form class="form-inline" asp-area="Identity" asp-page="/Account/Logout" asp-route-returnUrl="/" method="post">
<button type="submit" class="nav-link btn btn-link text-dark">Logout</button>
</form>
</li>
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"name": "ASP.NET Core Web App",
"generatorVersions": "[1.0.0.0-*)",
"description": "A project template for creating an ASP.NET Core application with example ASP.NET Razor Pages content",
"description": "A project template for creating an ASP.NET Core application with example ASP.NET Core Razor Pages content",
"groupIdentity": "Microsoft.Web.RazorPages",
"precedence": "5000",
"identity": "Microsoft.Web.RazorPages.CSharp.3.0",
Expand Down
4 changes: 2 additions & 2 deletions src/ProjectTemplates/test/BlazorServerTemplateTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public async Task BlazorServerTemplateWorks_NoAuth()
Assert.True(0 == publishResult.ExitCode, ErrorMessages.GetFailedProcessMessage("publish", Project, publishResult));

// Run dotnet build after publish. The reason is that one uses Config = Debug and the other uses Config = Release
// The output from publish will go into bin/Release/netcoreapp5.0/publish and won't be affected by calling build
// The output from publish will go into bin/Release/netcoreappX.Y/publish and won't be affected by calling build
// later, while the opposite is not true.

var buildResult = await Project.RunDotNetBuildAsync();
Expand Down Expand Up @@ -93,7 +93,7 @@ public async Task BlazorServerTemplateWorks_IndividualAuth(bool useLocalDB)
Assert.True(0 == publishResult.ExitCode, ErrorMessages.GetFailedProcessMessage("publish", Project, publishResult));

// Run dotnet build after publish. The reason is that one uses Config = Debug and the other uses Config = Release
// The output from publish will go into bin/Release/netcoreapp5.0/publish and won't be affected by calling build
// The output from publish will go into bin/Release/netcoreappX.Y/publish and won't be affected by calling build
// later, while the opposite is not true.

var buildResult = await Project.RunDotNetBuildAsync();
Expand Down
19 changes: 14 additions & 5 deletions src/ProjectTemplates/test/EmptyWebTemplateTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,19 @@ public EmptyWebTemplateTest(ProjectFactoryFixture projectFactory, ITestOutputHel

public ITestOutputHelper Output { get; }

[Theory]
[InlineData(null)]
[InlineData("F#")]
public async Task EmptyWebTemplateAsync(string languageOverride)
[Fact]
public async Task EmptyWebTemplateCSharp()
{
await EmtpyTemplateCore(languageOverride: null);
}

[Fact]
public async Task EmptyWebTemplateFSharp()
{
await EmtpyTemplateCore("F#");
}

private async Task EmtpyTemplateCore(string languageOverride)
{
Project = await ProjectFactory.GetOrCreateProject("empty" + (languageOverride == "F#" ? "fsharp" : "csharp"), Output);

Expand All @@ -42,7 +51,7 @@ public async Task EmptyWebTemplateAsync(string languageOverride)
Assert.True(0 == publishResult.ExitCode, ErrorMessages.GetFailedProcessMessage("publish", Project, publishResult));

// Run dotnet build after publish. The reason is that one uses Config = Debug and the other uses Config = Release
// The output from publish will go into bin/Release/netcoreapp5.0/publish and won't be affected by calling build
// The output from publish will go into bin/Release/netcoreappX.Y/publish and won't be affected by calling build
// later, while the opposite is not true.

var buildResult = await Project.RunDotNetBuildAsync();
Expand Down
32 changes: 27 additions & 5 deletions src/ProjectTemplates/test/Helpers/AspNetProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public AspNetProcess(

var arguments = published ? $"exec {dllPath}" : "run";
Process = ProcessEx.Run(output, workingDirectory, DotNetMuxer.MuxerPathOrDefault(), arguments, envVars: environmentVariables);
if(hasListeningUri)
if (hasListeningUri)
{
ListeningUri = GetListeningUri(output);
}
Expand Down Expand Up @@ -108,7 +108,7 @@ public async Task ContainsLinks(Page page)
HttpMethod.Get,
new Uri(ListeningUri, page.Url));

var response = await _httpClient.SendAsync(request);
var response = await RequestWithRetries(client => client.SendAsync(request), _httpClient);

Assert.Equal(HttpStatusCode.OK, response.StatusCode);
var parser = new HtmlParser();
Expand Down Expand Up @@ -141,14 +141,36 @@ public async Task ContainsLinks(Page page)
Assert.True(string.Equals(anchor.Href, expectedLink), $"Expected next link to be {expectedLink} but it was {anchor.Href}.");
var result = await RetryHelper.RetryRequest(async () =>
{
return await _httpClient.GetAsync(anchor.Href);
return await RequestWithRetries(client => client.GetAsync(anchor.Href), _httpClient);
}, logger: NullLogger.Instance);

Assert.True(IsSuccessStatusCode(result), $"{anchor.Href} is a broken link!");
}
}
}

private async Task<T> RequestWithRetries<T>(Func<HttpClient, Task<T>> requester, HttpClient client, int retries = 3, TimeSpan initialDelay = default)
{
var currentDelay = initialDelay == default ? TimeSpan.FromSeconds(30) : initialDelay;
for (int i = 0; i <= retries; i++)
{
try
{
return await requester(client);
}
catch (Exception)
{
if (i == retries)
{
throw;
}
await Task.Delay(currentDelay);
currentDelay *= 2;
}
}
throw new InvalidOperationException("Max retries reached.");
}

private Uri GetListeningUri(ITestOutputHelper output)
{
// Wait until the app is accepting HTTP requests
Expand Down Expand Up @@ -190,7 +212,7 @@ public Task AssertNotFound(string requestUrl)

internal Task<HttpResponseMessage> SendRequest(string path)
{
return _httpClient.GetAsync(new Uri(ListeningUri, path));
return RequestWithRetries(client => client.GetAsync(new Uri(ListeningUri, path)), _httpClient);
}

public async Task AssertStatusCode(string requestUrl, HttpStatusCode statusCode, string acceptContentType = null)
Expand All @@ -204,7 +226,7 @@ public async Task AssertStatusCode(string requestUrl, HttpStatusCode statusCode,
request.Headers.Add("Accept", acceptContentType);
}

var response = await _httpClient.SendAsync(request);
var response = await RequestWithRetries(client => client.SendAsync(request), _httpClient);
Assert.True(statusCode == response.StatusCode, $"Expected {requestUrl} to have status '{statusCode}' but it was '{response.StatusCode}'.");
}

Expand Down
2 changes: 1 addition & 1 deletion src/ProjectTemplates/test/IdentityUIPackageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public async Task IdentityUIPackage_WorksWithDifferentOptions(IDictionary<string
Assert.True(0 == publishResult.ExitCode, ErrorMessages.GetFailedProcessMessage("publish", Project, publishResult));

// Run dotnet build after publish. The reason is that one uses Config = Debug and the other uses Config = Release
// The output from publish will go into bin/Release/netcoreapp5.0/publish and won't be affected by calling build
// The output from publish will go into bin/Release/netcoreappX.Y/publish and won't be affected by calling build
// later, while the opposite is not true.

var buildResult = await Project.RunDotNetBuildAsync(packageOptions: packageOptions);
Expand Down
20 changes: 11 additions & 9 deletions src/ProjectTemplates/test/MvcTemplateTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ public MvcTemplateTest(ProjectFactoryFixture projectFactory, ITestOutputHelper o
public ProjectFactoryFixture ProjectFactory { get; }
public ITestOutputHelper Output { get; }

[Theory]
[InlineData(null)]
[InlineData("F#")]
[Flaky("https://github.com/aspnet/AspNetCore-Internal/issues/2267", FlakyOn.All)]
public async Task MvcTemplate_NoAuthImplAsync(string languageOverride)
[Fact(Skip = "https://github.com/aspnet/AspNetCore/issues/14022")]
public async Task MvcTemplate_NoAuthFSharp() => await MvcTemplateCore(languageOverride: "F#");

[Fact]
public async Task MvcTemplate_NoAuthCSharp() => await MvcTemplateCore(languageOverride: null);


private async Task MvcTemplateCore(string languageOverride)
{
Project = await ProjectFactory.GetOrCreateProject("mvcnoauth" + (languageOverride == "F#" ? "fsharp" : "csharp"), Output);

Expand All @@ -54,7 +57,7 @@ public async Task MvcTemplate_NoAuthImplAsync(string languageOverride)
Assert.True(0 == publishResult.ExitCode, ErrorMessages.GetFailedProcessMessage("publish", Project, publishResult));

// Run dotnet build after publish. The reason is that one uses Config = Debug and the other uses Config = Release
// The output from publish will go into bin/Release/netcoreapp5.0/publish and won't be affected by calling build
// The output from publish will go into bin/Release/netcoreappX.Y/publish and won't be affected by calling build
// later, while the opposite is not true.

var buildResult = await Project.RunDotNetBuildAsync();
Expand Down Expand Up @@ -104,8 +107,7 @@ public async Task MvcTemplate_NoAuthImplAsync(string languageOverride)
[Theory]
[InlineData(true)]
[InlineData(false)]
[Flaky("https://github.com/aspnet/AspNetCore-Internal/issues/2267", FlakyOn.All)]
public async Task MvcTemplate_IndividualAuthImplAsync(bool useLocalDB)
public async Task MvcTemplate_IndividualAuth(bool useLocalDB)
{
Project = await ProjectFactory.GetOrCreateProject("mvcindividual" + (useLocalDB ? "uld" : ""), Output);

Expand All @@ -122,7 +124,7 @@ public async Task MvcTemplate_IndividualAuthImplAsync(bool useLocalDB)
Assert.True(0 == publishResult.ExitCode, ErrorMessages.GetFailedProcessMessage("publish", Project, publishResult));

// Run dotnet build after publish. The reason is that one uses Config = Debug and the other uses Config = Release
// The output from publish will go into bin/Release/netcoreapp5.0/publish and won't be affected by calling build
// The output from publish will go into bin/Release/netcoreappX.Y/publish and won't be affected by calling build
// later, while the opposite is not true.

var buildResult = await Project.RunDotNetBuildAsync();
Expand Down
4 changes: 2 additions & 2 deletions src/ProjectTemplates/test/RazorClassLibraryTemplateTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public async Task RazorClassLibraryTemplate_WithViews_Async()
Assert.True(0 == publishResult.ExitCode, ErrorMessages.GetFailedProcessMessage("publish", Project, publishResult));

// Run dotnet build after publish. The reason is that one uses Config = Debug and the other uses Config = Release
// The output from publish will go into bin/Release/netcoreapp5.0/publish and won't be affected by calling build
// The output from publish will go into bin/Release/netcoreappX.Y/publish and won't be affected by calling build
// later, while the opposite is not true.

var buildResult = await Project.RunDotNetBuildAsync();
Expand All @@ -52,7 +52,7 @@ public async Task RazorClassLibraryTemplateAsync()
Assert.True(0 == publishResult.ExitCode, ErrorMessages.GetFailedProcessMessage("publish", Project, publishResult));

// Run dotnet build after publish. The reason is that one uses Config = Debug and the other uses Config = Release
// The output from publish will go into bin/Release/netcoreapp5.0/publish and won't be affected by calling build
// The output from publish will go into bin/Release/netcoreappX.Y/publish and won't be affected by calling build
// later, while the opposite is not true.

var buildResult = await Project.RunDotNetBuildAsync();
Expand Down
Loading