Merge branch 'release/3.1' into prkrishn/fix-null-ref

This commit is contained in:
Pranav K 2019-09-24 12:39:04 -07:00 committed by GitHub
commit db8cef1ae6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 188 additions and 107 deletions

View File

@ -9,7 +9,7 @@
<!-- Reference base shared framework at incoming dependency flow version, not bundled sdk version. -->
<FrameworkReference
Update="Microsoft.NETCore.App"
Condition="'$(TargetFramework)' == 'netcoreapp3.1'"
Condition="'$(TargetFramework)' == '$(DefaultNetCoreTargetFramework)'"
RuntimeFrameworkVersion="$(MicrosoftNETCoreAppRuntimeVersion)"
TargetingPackVersion="$(MicrosoftNETCoreAppRefPackageVersion)"
/>

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
<StartArguments>-s https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json</StartArguments>
<StartWorkingDirectory>$(MSBuildThisFileDirectory)../../</StartWorkingDirectory>
</PropertyGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>$(DefaultNetCoreTargetFramework)</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">$(TargetFrameworks);net472</TargetFrameworks>
<DefineConstants Condition="'$(TargetFramework)' == 'net472'">$(DefineConstants);BUILD_MSI_TASKS</DefineConstants>
<Optimize>false</Optimize>
@ -16,7 +16,7 @@
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="2.1.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<ItemGroup Condition="'$(TargetFramework)' == '$(DefaultNetCoreTargetFramework)'">
<PackageReference Include="Microsoft.Build.Framework" Version="15.8.166" />
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="15.8.166" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="15.8.166" />

View File

@ -210,10 +210,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Signal
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Http.Connections.Client", "..\SignalR\clients\csharp\Http.Connections.Client\src\Microsoft.AspNetCore.Http.Connections.Client.csproj", "{F88118E1-6F4A-4F89-B047-5FFD2889B9F0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ignitor", "Ignitor\src\Ignitor.csproj", "{A78CE874-76B7-46FE-8009-1ED5258BA0AA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ignitor.Test", "Ignitor\test\Ignitor.Test.csproj", "{FC2A1EB0-A116-4689-92B7-239B1DCCF4CA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Blazor.HttpClient", "Blazor\Http\src\Microsoft.AspNetCore.Blazor.HttpClient.csproj", "{74D21785-2FAB-4266-B7C4-E311EC8EE0DF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Blazor.HttpClient.Tests", "Blazor\Http\test\Microsoft.AspNetCore.Blazor.HttpClient.Tests.csproj", "{E4C01A3F-D3C1-4639-A6A9-930E918843DD}"
@ -238,7 +234,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.HttpsP
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorServerApp", "Samples\BlazorServerApp\BlazorServerApp.csproj", "{BBF37AF9-8290-4B70-8BA8-0F6017B3B620}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Ignitor", "Ignitor", "{29B5A306-7273-4649-8B04-26234D71ADBD}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Ignitor", "Ignitor", "{BDE2397D-C53A-4783-8B3A-1F54F48A6926}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ignitor", "Ignitor\src\Ignitor.csproj", "{CD0EF85C-4187-4515-A355-E5A0D4485F40}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ignitor.Test", "Ignitor\test\Ignitor.Test.csproj", "{F31E8118-014E-4CCE-8A48-5282F7B9BB3E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -1354,30 +1354,6 @@ Global
{F88118E1-6F4A-4F89-B047-5FFD2889B9F0}.Release|x64.Build.0 = Release|Any CPU
{F88118E1-6F4A-4F89-B047-5FFD2889B9F0}.Release|x86.ActiveCfg = Release|Any CPU
{F88118E1-6F4A-4F89-B047-5FFD2889B9F0}.Release|x86.Build.0 = Release|Any CPU
{A78CE874-76B7-46FE-8009-1ED5258BA0AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A78CE874-76B7-46FE-8009-1ED5258BA0AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A78CE874-76B7-46FE-8009-1ED5258BA0AA}.Debug|x64.ActiveCfg = Debug|Any CPU
{A78CE874-76B7-46FE-8009-1ED5258BA0AA}.Debug|x64.Build.0 = Debug|Any CPU
{A78CE874-76B7-46FE-8009-1ED5258BA0AA}.Debug|x86.ActiveCfg = Debug|Any CPU
{A78CE874-76B7-46FE-8009-1ED5258BA0AA}.Debug|x86.Build.0 = Debug|Any CPU
{A78CE874-76B7-46FE-8009-1ED5258BA0AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A78CE874-76B7-46FE-8009-1ED5258BA0AA}.Release|Any CPU.Build.0 = Release|Any CPU
{A78CE874-76B7-46FE-8009-1ED5258BA0AA}.Release|x64.ActiveCfg = Release|Any CPU
{A78CE874-76B7-46FE-8009-1ED5258BA0AA}.Release|x64.Build.0 = Release|Any CPU
{A78CE874-76B7-46FE-8009-1ED5258BA0AA}.Release|x86.ActiveCfg = Release|Any CPU
{A78CE874-76B7-46FE-8009-1ED5258BA0AA}.Release|x86.Build.0 = Release|Any CPU
{FC2A1EB0-A116-4689-92B7-239B1DCCF4CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FC2A1EB0-A116-4689-92B7-239B1DCCF4CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FC2A1EB0-A116-4689-92B7-239B1DCCF4CA}.Debug|x64.ActiveCfg = Debug|Any CPU
{FC2A1EB0-A116-4689-92B7-239B1DCCF4CA}.Debug|x64.Build.0 = Debug|Any CPU
{FC2A1EB0-A116-4689-92B7-239B1DCCF4CA}.Debug|x86.ActiveCfg = Debug|Any CPU
{FC2A1EB0-A116-4689-92B7-239B1DCCF4CA}.Debug|x86.Build.0 = Debug|Any CPU
{FC2A1EB0-A116-4689-92B7-239B1DCCF4CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FC2A1EB0-A116-4689-92B7-239B1DCCF4CA}.Release|Any CPU.Build.0 = Release|Any CPU
{FC2A1EB0-A116-4689-92B7-239B1DCCF4CA}.Release|x64.ActiveCfg = Release|Any CPU
{FC2A1EB0-A116-4689-92B7-239B1DCCF4CA}.Release|x64.Build.0 = Release|Any CPU
{FC2A1EB0-A116-4689-92B7-239B1DCCF4CA}.Release|x86.ActiveCfg = Release|Any CPU
{FC2A1EB0-A116-4689-92B7-239B1DCCF4CA}.Release|x86.Build.0 = Release|Any CPU
{74D21785-2FAB-4266-B7C4-E311EC8EE0DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{74D21785-2FAB-4266-B7C4-E311EC8EE0DF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{74D21785-2FAB-4266-B7C4-E311EC8EE0DF}.Debug|x64.ActiveCfg = Debug|Any CPU
@ -1486,6 +1462,30 @@ Global
{BBF37AF9-8290-4B70-8BA8-0F6017B3B620}.Release|x64.Build.0 = Release|Any CPU
{BBF37AF9-8290-4B70-8BA8-0F6017B3B620}.Release|x86.ActiveCfg = Release|Any CPU
{BBF37AF9-8290-4B70-8BA8-0F6017B3B620}.Release|x86.Build.0 = Release|Any CPU
{CD0EF85C-4187-4515-A355-E5A0D4485F40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CD0EF85C-4187-4515-A355-E5A0D4485F40}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CD0EF85C-4187-4515-A355-E5A0D4485F40}.Debug|x64.ActiveCfg = Debug|Any CPU
{CD0EF85C-4187-4515-A355-E5A0D4485F40}.Debug|x64.Build.0 = Debug|Any CPU
{CD0EF85C-4187-4515-A355-E5A0D4485F40}.Debug|x86.ActiveCfg = Debug|Any CPU
{CD0EF85C-4187-4515-A355-E5A0D4485F40}.Debug|x86.Build.0 = Debug|Any CPU
{CD0EF85C-4187-4515-A355-E5A0D4485F40}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CD0EF85C-4187-4515-A355-E5A0D4485F40}.Release|Any CPU.Build.0 = Release|Any CPU
{CD0EF85C-4187-4515-A355-E5A0D4485F40}.Release|x64.ActiveCfg = Release|Any CPU
{CD0EF85C-4187-4515-A355-E5A0D4485F40}.Release|x64.Build.0 = Release|Any CPU
{CD0EF85C-4187-4515-A355-E5A0D4485F40}.Release|x86.ActiveCfg = Release|Any CPU
{CD0EF85C-4187-4515-A355-E5A0D4485F40}.Release|x86.Build.0 = Release|Any CPU
{F31E8118-014E-4CCE-8A48-5282F7B9BB3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F31E8118-014E-4CCE-8A48-5282F7B9BB3E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F31E8118-014E-4CCE-8A48-5282F7B9BB3E}.Debug|x64.ActiveCfg = Debug|Any CPU
{F31E8118-014E-4CCE-8A48-5282F7B9BB3E}.Debug|x64.Build.0 = Debug|Any CPU
{F31E8118-014E-4CCE-8A48-5282F7B9BB3E}.Debug|x86.ActiveCfg = Debug|Any CPU
{F31E8118-014E-4CCE-8A48-5282F7B9BB3E}.Debug|x86.Build.0 = Debug|Any CPU
{F31E8118-014E-4CCE-8A48-5282F7B9BB3E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F31E8118-014E-4CCE-8A48-5282F7B9BB3E}.Release|Any CPU.Build.0 = Release|Any CPU
{F31E8118-014E-4CCE-8A48-5282F7B9BB3E}.Release|x64.ActiveCfg = Release|Any CPU
{F31E8118-014E-4CCE-8A48-5282F7B9BB3E}.Release|x64.Build.0 = Release|Any CPU
{F31E8118-014E-4CCE-8A48-5282F7B9BB3E}.Release|x86.ActiveCfg = Release|Any CPU
{F31E8118-014E-4CCE-8A48-5282F7B9BB3E}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -1585,8 +1585,6 @@ Global
{DA137BD4-F7F1-4D53-855F-5EC40CEA36B0} = {2FC10057-7A0A-4E34-8302-879925BC0102}
{0CDAB70B-71DC-43BE-ACB7-AD2EE3541FFB} = {2FC10057-7A0A-4E34-8302-879925BC0102}
{F88118E1-6F4A-4F89-B047-5FFD2889B9F0} = {2FC10057-7A0A-4E34-8302-879925BC0102}
{A78CE874-76B7-46FE-8009-1ED5258BA0AA} = {29B5A306-7273-4649-8B04-26234D71ADBD}
{FC2A1EB0-A116-4689-92B7-239B1DCCF4CA} = {29B5A306-7273-4649-8B04-26234D71ADBD}
{74D21785-2FAB-4266-B7C4-E311EC8EE0DF} = {7260DED9-22A9-4E9D-92F4-5E8A4404DEAF}
{E4C01A3F-D3C1-4639-A6A9-930E918843DD} = {7260DED9-22A9-4E9D-92F4-5E8A4404DEAF}
{DE297C91-B3E9-4C6F-B74D-0AF9EFEBF684} = {A27FF193-195B-4474-8E6C-840B2E339373}
@ -1596,6 +1594,8 @@ Global
{173D84A3-0F37-480F-AC0F-7E2DBBE32B28} = {B0EEB429-4C8C-42AA-8822-3058E7DBC98F}
{4664276D-606A-4BB3-873A-9EE84FB22877} = {2FC10057-7A0A-4E34-8302-879925BC0102}
{BBF37AF9-8290-4B70-8BA8-0F6017B3B620} = {46E4300C-5726-4108-B9A2-18BB94EB26ED}
{CD0EF85C-4187-4515-A355-E5A0D4485F40} = {BDE2397D-C53A-4783-8B3A-1F54F48A6926}
{F31E8118-014E-4CCE-8A48-5282F7B9BB3E} = {BDE2397D-C53A-4783-8B3A-1F54F48A6926}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CC3C47E1-AD1A-4619-9CD3-E08A0148E5CE}

View File

@ -26,17 +26,17 @@
"Components\\test\\Microsoft.AspNetCore.Components.Tests.csproj",
"Forms\\src\\Microsoft.AspNetCore.Components.Forms.csproj",
"Forms\\test\\Microsoft.AspNetCore.Components.Forms.Tests.csproj",
"Samples\\BlazorServer.Sample\\BlazorServer.Sample.csproj",
"Ignitor\\src\\Ignitor.csproj",
"Ignitor\\test\\Ignitor.Test.csproj",
"Samples\\BlazorServerApp\\BlazorServerApp.csproj",
"Server\\src\\Microsoft.AspNetCore.Components.Server.csproj",
"Server\\test\\Microsoft.AspNetCore.Components.Server.Tests.csproj",
"Web\\src\\Microsoft.AspNetCore.Components.Web.csproj",
"Web\\test\\Microsoft.AspNetCore.Components.Web.Tests.csproj",
"test\\E2ETest\\Microsoft.AspNetCore.Components.E2ETests.csproj",
"test\\Ignitor.Test\\Ignitor.Test.csproj",
"test\\testassets\\BasicTestApp\\BasicTestApp.csproj",
"test\\testassets\\Ignitor\\Ignitor.csproj",
"test\\testassets\\TestContentPackage\\TestContentPackage.csproj",
"test\\testassets\\TestServer\\Components.TestServer.csproj"
]
}
}
}

View File

@ -109,6 +109,11 @@ namespace Microsoft.AspNetCore.Components.Routing
private bool ShouldMatch(string currentUriAbsolute)
{
if (_hrefAbsolute == null)
{
return false;
}
if (EqualsHrefExactlyOrIfTrailingSlashAdded(currentUriAbsolute))
{
return true;

View File

@ -20,6 +20,7 @@
<li><NavLink href="/subdir/WithParameters/Name/Abc/LastName/McDef">With more parameters</NavLink></li>
<li><NavLink href="/subdir/LongPage1">Long page 1</NavLink></li>
<li><NavLink href="/subdir/LongPage2">Long page 2</NavLink></li>
<li><NavLink>Null href never matches</NavLink></li>
</ul>
<button id="do-navigation" @onclick=@(x => NavigationManager.NavigateTo("Other"))>

View File

@ -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/netcoreapp3.1/ -->
<!-- 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>

View File

@ -47,7 +47,8 @@ namespace Microsoft.AspNetCore.Mvc.Analyzers
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,

View File

@ -89,12 +89,17 @@ namespace Microsoft.AspNetCore.Mvc.Analyzers
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;
@ -122,6 +127,26 @@ namespace Microsoft.AspNetCore.Mvc.Analyzers
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" &&
!@namespace.StartsWith("System.", StringComparison.Ordinal);
}
return true;
}
internal static string GetName(in SymbolCache symbolCache, ISymbol symbol)
{
foreach (var attribute in symbol.GetAttributes(symbolCache.IModelNameProvider))

View File

@ -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) { }
}
}

View File

@ -95,6 +95,30 @@ namespace Microsoft.AspNetCore.Mvc.Analyzers
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()
{

View File

@ -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

View File

@ -7,7 +7,7 @@
<div class="main">
<div class="top-row px-4">
<LoginDisplay />
<a href="https://docs.microsoft.com/en-us/aspnet/" target="_blank">About</a>
<a href="https://docs.microsoft.com/aspnet/" target="_blank">About</a>
</div>
<div class="content px-4">

View File

@ -6,7 +6,7 @@
<div class="main">
<div class="top-row px-4">
<a href="https://docs.microsoft.com/en-us/aspnet/" target="_blank">About</a>
<a href="https://docs.microsoft.com/aspnet/" target="_blank">About</a>
</div>
<div class="content px-4">

View File

@ -36,7 +36,7 @@ namespace Templates.Test
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/netcoreapp3.1/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();
@ -93,7 +93,7 @@ namespace Templates.Test
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/netcoreapp3.1/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();

View File

@ -22,10 +22,19 @@ namespace Templates.Test
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);
@ -36,7 +45,7 @@ namespace Templates.Test
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/netcoreapp3.1/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();

View File

@ -58,7 +58,7 @@ namespace Templates.Test.Helpers
var arguments = published ? $"exec {dllPath}" : "run";
Process = ProcessEx.Run(output, workingDirectory, DotNetMuxer.MuxerPathOrDefault(), arguments, envVars: environmentVariables);
if(hasListeningUri)
if (hasListeningUri)
{
ListeningUri = GetListeningUri(output);
}
@ -108,7 +108,7 @@ namespace Templates.Test.Helpers
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();
@ -141,7 +141,7 @@ namespace Templates.Test.Helpers
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!");
@ -149,6 +149,28 @@ namespace Templates.Test.Helpers
}
}
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
@ -190,7 +212,7 @@ namespace Templates.Test.Helpers
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)
@ -204,7 +226,7 @@ namespace Templates.Test.Helpers
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}'.");
}

View File

@ -134,7 +134,7 @@ namespace Templates.Test
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/netcoreapp3.1/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);

View File

@ -25,11 +25,14 @@ namespace Templates.Test
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);
@ -48,7 +51,7 @@ namespace Templates.Test
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/netcoreapp3.1/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();
@ -98,8 +101,7 @@ namespace Templates.Test
[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);
@ -116,7 +118,7 @@ namespace Templates.Test
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/netcoreapp3.1/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();

View File

@ -33,7 +33,7 @@ namespace Templates.Test
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/netcoreapp3.1/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();
@ -52,7 +52,7 @@ namespace Templates.Test
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/netcoreapp3.1/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();

View File

@ -26,8 +26,7 @@ namespace Templates.Test
public ITestOutputHelper Output { get; }
[Fact]
[Flaky("https://github.com/aspnet/AspNetCore-Internal/issues/2327", FlakyOn.All)]
public async Task RazorPagesTemplate_NoAuthImplAsync()
public async Task RazorPagesTemplate_NoAuth()
{
Project = await ProjectFactory.GetOrCreateProject("razorpagesnoauth", Output);
@ -45,7 +44,7 @@ namespace Templates.Test
Assert.True(0 == publishResult.ExitCode, ErrorMessages.GetFailedProcessMessage("publish", Project, createResult));
// 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/netcoreapp3.1/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();
@ -95,10 +94,9 @@ namespace Templates.Test
}
[Theory]
[Flaky("https://github.com/aspnet/AspNetCore-Internal/issues/2335", FlakyOn.All)]
[InlineData(false)]
[InlineData(true)]
public async Task RazorPagesTemplate_IndividualAuthImplAsync(bool useLocalDB)
public async Task RazorPagesTemplate_IndividualAuth(bool useLocalDB)
{
Project = await ProjectFactory.GetOrCreateProject("razorpagesindividual" + (useLocalDB ? "uld" : ""), Output);
@ -115,7 +113,7 @@ namespace Templates.Test
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/netcoreapp3.1/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();

View File

@ -76,7 +76,7 @@ namespace Templates.Test.SpaTemplateTest
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/netcoreapp3.1/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.
using var buildResult = await Project.RunDotNetBuildAsync();

View File

@ -22,10 +22,13 @@ namespace Templates.Test
public Project Project { get; set; }
[Theory]
[InlineData(null)]
[InlineData("F#")]
public async Task WebApiTemplateAsync(string languageOverride)
[Fact]
public async Task WebApiTemplateFSharp() => await WebApiTemplateCore(languageOverride: "F#");
[Fact]
public async Task WebApiTemplateCSharp() => await WebApiTemplateCore(languageOverride: null);
private async Task WebApiTemplateCore(string languageOverride)
{
Project = await FactoryFixture.GetOrCreateProject("webapi" + (languageOverride == "F#" ? "fsharp" : "csharp"), Output);
@ -36,7 +39,7 @@ namespace Templates.Test
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/netcoreapp3.1/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();

View File

@ -32,7 +32,7 @@ namespace Templates.Test
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/netcoreapp3.1/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();

View File

@ -51,7 +51,7 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
// Start timer
StartTimer();
// For an unpublished application the dllroot points pre-built dlls like projectdir/bin/debug/netcoreapp3.1/
// For an unpublished application the dllroot points pre-built dlls like projectdir/bin/debug/netcoreappX.Y/
// and contentRoot points to the project directory so you get things like static assets.
// For a published app both point to the publish directory.
var dllRoot = CheckIfPublishIsRequired();

View File

@ -155,7 +155,8 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal.Transports
var memory = _application.Output.GetMemory();
var receiveResult = await socket.ReceiveAsync(memory, token);
// Need to check again for netcoreapp3.1 because a close can happen between a 0-byte read and the actual read
// Need to check again for netcoreapp3.0 and later because a close can happen between a 0-byte read and the actual read
if (receiveResult.MessageType == WebSocketMessageType.Close)
{
return;

View File

@ -134,7 +134,7 @@ namespace Microsoft.DotNet.OpenApi.Add.Tests
Assert.Single(openApiRefs);
}
[Fact (Skip = "https://github.com/aspnet/AspNetCore/pull/13571/#issuecomment-531466801")]
[Fact]
public async Task OpenApi_Add_NSwagTypeScript()
{
var project = CreateBasicProject(withOpenApi: true);
@ -155,20 +155,9 @@ namespace Microsoft.DotNet.OpenApi.Add.Tests
Assert.Contains("<PackageReference Include=\"NSwag.ApiDescription.Client\" Version=\"", content);
Assert.Contains($"<OpenApiReference Include=\"{nswagJsonFile}\" CodeGenerator=\"NSwagTypeScript\" />", content);
}
// Build project and make sure it compiles
using var buildProc = ProcessEx.Run(_outputHelper, _tempDir.Root, "dotnet", "build");
await buildProc.Exited;
Assert.True(buildProc.ExitCode == 0, $"Build failed: {buildProc.Output}");
// Run project and make sure it doesn't crash
using var runProc = ProcessEx.Run(_outputHelper, _tempDir.Root, "dotnet", "run");
Thread.Sleep(100);
Assert.False(runProc.HasExited, $"Run failed with: {runProc.Output}");
}
[Fact (Skip = "https://github.com/aspnet/AspNetCore/pull/13571/#issuecomment-531466801")]
[Fact]
public async Task OpenApi_Add_FromJson()
{
var project = CreateBasicProject(withOpenApi: true);
@ -189,16 +178,6 @@ namespace Microsoft.DotNet.OpenApi.Add.Tests
Assert.Contains("<PackageReference Include=\"NSwag.ApiDescription.Client\" Version=\"", content);
Assert.Contains($"<OpenApiReference Include=\"{nswagJsonFile}\"", content);
}
// Build project and make sure it compiles
var buildProc = ProcessEx.Run(_outputHelper, _tempDir.Root, "dotnet", "build");
await buildProc.Exited;
Assert.True(buildProc.ExitCode == 0, $"Build failed: {buildProc.Output}");
// Run project and make sure it doesn't crash
using var runProc = ProcessEx.Run(_outputHelper, _tempDir.Root, "dotnet", "run");
Thread.Sleep(100);
Assert.False(runProc.HasExited, $"Run failed with: {runProc.Output}");
}
[Fact]