From 93c377011976312d999167da149189953b06322d Mon Sep 17 00:00:00 2001 From: Matt Mitchell <mmitche@microsoft.com> Date: Fri, 13 Aug 2021 08:48:47 -0700 Subject: [PATCH] More line ending renormalization (#35301) --- src/Caching/Caching.slnf | 22 +- src/Caching/SqlServer/test/README.md | 32 +-- src/Caching/SqlServer/test/run-db-tests.ps1 | 196 +++++++++--------- .../src/Microsoft.JSInterop.JS.npmproj | 24 +-- .../TagHelpersWebSite/Views/Home/Index.cshtml | 102 ++++----- 5 files changed, 188 insertions(+), 188 deletions(-) diff --git a/src/Caching/Caching.slnf b/src/Caching/Caching.slnf index cd154890e22..ebc2330a777 100644 --- a/src/Caching/Caching.slnf +++ b/src/Caching/Caching.slnf @@ -1,11 +1,11 @@ -{ - "solution": { - "path": "..\\..\\AspNetCore.sln", - "projects": [ - "src\\Caching\\SqlServer\\src\\Microsoft.Extensions.Caching.SqlServer.csproj", - "src\\Caching\\SqlServer\\test\\Microsoft.Extensions.Caching.SqlServer.Tests.csproj", - "src\\Caching\\StackExchangeRedis\\src\\Microsoft.Extensions.Caching.StackExchangeRedis.csproj", - "src\\Caching\\StackExchangeRedis\\test\\Microsoft.Extensions.Caching.StackExchangeRedis.Tests.csproj" - ] - } -} +{ + "solution": { + "path": "..\\..\\AspNetCore.sln", + "projects": [ + "src\\Caching\\SqlServer\\src\\Microsoft.Extensions.Caching.SqlServer.csproj", + "src\\Caching\\SqlServer\\test\\Microsoft.Extensions.Caching.SqlServer.Tests.csproj", + "src\\Caching\\StackExchangeRedis\\src\\Microsoft.Extensions.Caching.StackExchangeRedis.csproj", + "src\\Caching\\StackExchangeRedis\\test\\Microsoft.Extensions.Caching.StackExchangeRedis.Tests.csproj" + ] + } +} diff --git a/src/Caching/SqlServer/test/README.md b/src/Caching/SqlServer/test/README.md index f597779b7fe..5eebe55bd66 100644 --- a/src/Caching/SqlServer/test/README.md +++ b/src/Caching/SqlServer/test/README.md @@ -1,17 +1,17 @@ -# Microsoft.Extensions.Caching.SqlServer Tests - -These tests include functional tests that run against a real SQL Server. Since these are flaky on CI, they should be run manually when changing this code. - -## Pre-requisites - -1. A functional SQL Server, Local DB included with VS is sufficient -1. An empty database named `CacheTestDb` in that SQL Server - -## Running the tests - -1. Install the latest version of the `dotnet-sql-cache` too: `dotnet tool install --global dotnet-sql-cache` (make sure to specify a version if it's a pre-release tool you want!) -1. Run `dotnet sql-cache [connectionstring] dbo CacheTest` - * `[connectionstring]` must be a SQL Connection String **for an empty database named `CacheTestDb` that already exists** - * If using Local DB, this string should work: `"Server=(localdb)\MSSQLLocalDB;Database=CacheTestDb;Trusted_Connection=True;"` -1. Unskip the tests by changing the `SqlServerCacheWithDatabaseTest.SkipReason` field to `null`. +# Microsoft.Extensions.Caching.SqlServer Tests + +These tests include functional tests that run against a real SQL Server. Since these are flaky on CI, they should be run manually when changing this code. + +## Pre-requisites + +1. A functional SQL Server, Local DB included with VS is sufficient +1. An empty database named `CacheTestDb` in that SQL Server + +## Running the tests + +1. Install the latest version of the `dotnet-sql-cache` too: `dotnet tool install --global dotnet-sql-cache` (make sure to specify a version if it's a pre-release tool you want!) +1. Run `dotnet sql-cache [connectionstring] dbo CacheTest` + * `[connectionstring]` must be a SQL Connection String **for an empty database named `CacheTestDb` that already exists** + * If using Local DB, this string should work: `"Server=(localdb)\MSSQLLocalDB;Database=CacheTestDb;Trusted_Connection=True;"` +1. Unskip the tests by changing the `SqlServerCacheWithDatabaseTest.SkipReason` field to `null`. 1. Run the tests. \ No newline at end of file diff --git a/src/Caching/SqlServer/test/run-db-tests.ps1 b/src/Caching/SqlServer/test/run-db-tests.ps1 index 1fc0fb663ce..2c69f92d038 100644 --- a/src/Caching/SqlServer/test/run-db-tests.ps1 +++ b/src/Caching/SqlServer/test/run-db-tests.ps1 @@ -1,98 +1,98 @@ -param( - [Parameter(Mandatory = $false)][string]$ConnectionString = "Server=(localdb)\MSSQLLocalDB;Database=CacheTestDb;Trusted_Connection=True;", - [Parameter(Mandatory = $false)][string]$SchemaName = "dbo", - [Parameter(Mandatory = $false)][string]$TableName = "CacheTest") - -function ExecuteScalar($Connection, $Script) { - $cmd = New-Object System.Data.SqlClient.SqlCommand - $cmd.Connection = $Connection - $cmd.CommandText = $Script - $cmd.ExecuteScalar() -} - -# Check if the database exists -Write-Host "Checking for database..." -$ServerConnectionBuilder = New-Object System.Data.SqlClient.SqlConnectionStringBuilder $ConnectionString - -if (!$ServerConnectionBuilder.InitialCatalog) { - throw "An 'Initial Catalog' or 'Database' value must be provided in the connection string!" -} -$DatabaseName = $ServerConnectionBuilder.InitialCatalog - -if (!$ServerConnectionBuilder.DataSource -eq "(localdb)\MSSQLLocalDB") { - Write-Warning "This script is really only designed for running against your local instance of SQL Local DB. Continue at your own risk!" -} - -$ServerConnectionBuilder.Remove("Initial Catalog") | Out-Null; -$ServerConnection = New-Object System.Data.SqlClient.SqlConnection $ServerConnectionBuilder.ConnectionString -$ServerConnection.Open(); - -# Yes, this is SQL Injectable, but you're using it on your local machine with the intent of connecting to your local db. -$dbid = ExecuteScalar $ServerConnection "SELECT database_id FROM sys.databases WHERE Name = '$DatabaseName'" -if (!$dbid) { - Write-Host "Database not found, creating..." - - # Create the database - ExecuteScalar $ServerConnection "CREATE DATABASE $DatabaseName" -} - -# Close the server connection -$ServerConnection.Close() - -# Check for the table -$DbConnection = New-Object System.Data.SqlClient.SqlConnection $ConnectionString -$DbConnection.Open(); -$tableid = ExecuteScalar $DbConnection "SELECT object_id FROM sys.objects WHERE type = 'U' AND name = '$TableName'" -if ($tableid) { - Write-Host "Table exists, dropping it..." - ExecuteScalar $DbConnection "DROP TABLE $TableName" -} - -$DbConnection.Close() - -# Fill the database with sql cache goodies -dotnet sql-cache create $ConnectionString $SchemaName $TableName - -# Set environment variables and launch tests -$oldConnectionString = $env:SQLCACHETESTS_ConnectionString -$oldSchemaName = $env:SQLCACHETESTS_SchemaName -$oldTableName = $env:SQLCACHETESTS_TableName -$oldEnabled = $env:SQLCACHETESTS_ENABLED -try { - $env:SQLCACHETESTS_ConnectionString = $ConnectionString - $env:SQLCACHETESTS_SchemaName = $SchemaName - $env:SQLCACHETESTS_TableName = $TableName - $env:SQLCACHETESTS_ENABLED = "1" - - Write-Host "Launching Tests..." - dotnet test "$PSScriptRoot/Microsoft.Extensions.Caching.SqlServer.Tests.csproj" -} -finally { - if ($oldConnectionString) { - $env:SQLCACHETESTS_ConnectionString = $oldConnectionString - } - else { - Remove-Item env:\SQLCACHETESTS_ConnectionString - } - - if ($oldSchemaName) { - $env:SQLCACHETESTS_SchemaName = $oldSchemaName - } - else { - Remove-Item env:\SQLCACHETESTS_SchemaName - } - - if ($oldTableName) { - $env:SQLCACHETESTS_TableName = $oldTableName - } - else { - Remove-Item env:\SQLCACHETESTS_TableName - } - - if ($oldEnabled) { - $env:SQLCACHETESTS_ENABLED = $oldEnabled - } - else { - Remove-Item env:\SQLCACHETESTS_ENABLED - } -} +param( + [Parameter(Mandatory = $false)][string]$ConnectionString = "Server=(localdb)\MSSQLLocalDB;Database=CacheTestDb;Trusted_Connection=True;", + [Parameter(Mandatory = $false)][string]$SchemaName = "dbo", + [Parameter(Mandatory = $false)][string]$TableName = "CacheTest") + +function ExecuteScalar($Connection, $Script) { + $cmd = New-Object System.Data.SqlClient.SqlCommand + $cmd.Connection = $Connection + $cmd.CommandText = $Script + $cmd.ExecuteScalar() +} + +# Check if the database exists +Write-Host "Checking for database..." +$ServerConnectionBuilder = New-Object System.Data.SqlClient.SqlConnectionStringBuilder $ConnectionString + +if (!$ServerConnectionBuilder.InitialCatalog) { + throw "An 'Initial Catalog' or 'Database' value must be provided in the connection string!" +} +$DatabaseName = $ServerConnectionBuilder.InitialCatalog + +if (!$ServerConnectionBuilder.DataSource -eq "(localdb)\MSSQLLocalDB") { + Write-Warning "This script is really only designed for running against your local instance of SQL Local DB. Continue at your own risk!" +} + +$ServerConnectionBuilder.Remove("Initial Catalog") | Out-Null; +$ServerConnection = New-Object System.Data.SqlClient.SqlConnection $ServerConnectionBuilder.ConnectionString +$ServerConnection.Open(); + +# Yes, this is SQL Injectable, but you're using it on your local machine with the intent of connecting to your local db. +$dbid = ExecuteScalar $ServerConnection "SELECT database_id FROM sys.databases WHERE Name = '$DatabaseName'" +if (!$dbid) { + Write-Host "Database not found, creating..." + + # Create the database + ExecuteScalar $ServerConnection "CREATE DATABASE $DatabaseName" +} + +# Close the server connection +$ServerConnection.Close() + +# Check for the table +$DbConnection = New-Object System.Data.SqlClient.SqlConnection $ConnectionString +$DbConnection.Open(); +$tableid = ExecuteScalar $DbConnection "SELECT object_id FROM sys.objects WHERE type = 'U' AND name = '$TableName'" +if ($tableid) { + Write-Host "Table exists, dropping it..." + ExecuteScalar $DbConnection "DROP TABLE $TableName" +} + +$DbConnection.Close() + +# Fill the database with sql cache goodies +dotnet sql-cache create $ConnectionString $SchemaName $TableName + +# Set environment variables and launch tests +$oldConnectionString = $env:SQLCACHETESTS_ConnectionString +$oldSchemaName = $env:SQLCACHETESTS_SchemaName +$oldTableName = $env:SQLCACHETESTS_TableName +$oldEnabled = $env:SQLCACHETESTS_ENABLED +try { + $env:SQLCACHETESTS_ConnectionString = $ConnectionString + $env:SQLCACHETESTS_SchemaName = $SchemaName + $env:SQLCACHETESTS_TableName = $TableName + $env:SQLCACHETESTS_ENABLED = "1" + + Write-Host "Launching Tests..." + dotnet test "$PSScriptRoot/Microsoft.Extensions.Caching.SqlServer.Tests.csproj" +} +finally { + if ($oldConnectionString) { + $env:SQLCACHETESTS_ConnectionString = $oldConnectionString + } + else { + Remove-Item env:\SQLCACHETESTS_ConnectionString + } + + if ($oldSchemaName) { + $env:SQLCACHETESTS_SchemaName = $oldSchemaName + } + else { + Remove-Item env:\SQLCACHETESTS_SchemaName + } + + if ($oldTableName) { + $env:SQLCACHETESTS_TableName = $oldTableName + } + else { + Remove-Item env:\SQLCACHETESTS_TableName + } + + if ($oldEnabled) { + $env:SQLCACHETESTS_ENABLED = $oldEnabled + } + else { + Remove-Item env:\SQLCACHETESTS_ENABLED + } +} diff --git a/src/JSInterop/Microsoft.JSInterop.JS/src/Microsoft.JSInterop.JS.npmproj b/src/JSInterop/Microsoft.JSInterop.JS/src/Microsoft.JSInterop.JS.npmproj index 589b7e1c5a7..a0f637aba69 100644 --- a/src/JSInterop/Microsoft.JSInterop.JS/src/Microsoft.JSInterop.JS.npmproj +++ b/src/JSInterop/Microsoft.JSInterop.JS/src/Microsoft.JSInterop.JS.npmproj @@ -1,12 +1,12 @@ -<Project> - <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Directory.Build.props))\Directory.Build.props" /> - - <PropertyGroup> - <PackageId>@microsoft/dotnet-js-interop</PackageId> - <IsPackable>true</IsPackable> - <IsTestProject>false</IsTestProject> - <IsShipping>true</IsShipping> - </PropertyGroup> - - <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Directory.Build.targets))\Directory.Build.targets" /> -</Project> +<Project> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Directory.Build.props))\Directory.Build.props" /> + + <PropertyGroup> + <PackageId>@microsoft/dotnet-js-interop</PackageId> + <IsPackable>true</IsPackable> + <IsTestProject>false</IsTestProject> + <IsShipping>true</IsShipping> + </PropertyGroup> + + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Directory.Build.targets))\Directory.Build.targets" /> +</Project> diff --git a/src/Mvc/test/WebSites/TagHelpersWebSite/Views/Home/Index.cshtml b/src/Mvc/test/WebSites/TagHelpersWebSite/Views/Home/Index.cshtml index 52d62c30ee6..56326dbbc54 100644 --- a/src/Mvc/test/WebSites/TagHelpersWebSite/Views/Home/Index.cshtml +++ b/src/Mvc/test/WebSites/TagHelpersWebSite/Views/Home/Index.cshtml @@ -1,52 +1,52 @@ -@using TagHelpersWebSite.Models -@using Microsoft.AspNetCore.Mvc.Razor - -@model WebsiteContext -@{ - ViewBag.Title = "Home Page"; -} - -@addTagHelper *, TagHelpersWebSite - -@section css { - <style condition="!Model.Approved"> - h1 { - color:red; - font-size:2em; - } - </style> -} - -@functions { - public void RenderTemplate(string title, Func<string, HelperResult> template) - { - Output.WriteLine("<br /><p><em>Rendering Template:</em></p>"); - var helperResult = template(title); - helperResult.WriteTo(Output, HtmlEncoder); - } -} - -<div condition="!Model.Approved"> - <p>This website has <strong surround="em">not</strong> been approved yet. Visit www.contoso.com for <strong make-pretty="false">more</strong> information.</p> -</div> - -<div> - <h3>Current Tag Cloud from Tag Helper</h3> - <tag-cloud count="Model.TagsToShow" surround="div" /> - <h3>Current Tag Cloud from ViewComponentHelper:</h3> - <section bold>@await Component.InvokeAsync("Tags", new { count = 15 })</section> - @{ - RenderTemplate( - "Tag Cloud from Template: ", - @<div condition="true"><h3>@item</h3><tag-cloud count="Model.TagsToShow"></tag-cloud></div>); - } -</div> - -<div> - <h3>Dictionary Valued Model Expression</h3> - <div prefix-test1="@Model.TagsToShow" prefix-test2="@Model.Version.Build"></div> -</div> - -@section footerContent { - <p condition="Model.Approved" bold surround="section">© @Model.CopyrightYear - My ASP.NET Application</p> +@using TagHelpersWebSite.Models +@using Microsoft.AspNetCore.Mvc.Razor + +@model WebsiteContext +@{ + ViewBag.Title = "Home Page"; +} + +@addTagHelper *, TagHelpersWebSite + +@section css { + <style condition="!Model.Approved"> + h1 { + color:red; + font-size:2em; + } + </style> +} + +@functions { + public void RenderTemplate(string title, Func<string, HelperResult> template) + { + Output.WriteLine("<br /><p><em>Rendering Template:</em></p>"); + var helperResult = template(title); + helperResult.WriteTo(Output, HtmlEncoder); + } +} + +<div condition="!Model.Approved"> + <p>This website has <strong surround="em">not</strong> been approved yet. Visit www.contoso.com for <strong make-pretty="false">more</strong> information.</p> +</div> + +<div> + <h3>Current Tag Cloud from Tag Helper</h3> + <tag-cloud count="Model.TagsToShow" surround="div" /> + <h3>Current Tag Cloud from ViewComponentHelper:</h3> + <section bold>@await Component.InvokeAsync("Tags", new { count = 15 })</section> + @{ + RenderTemplate( + "Tag Cloud from Template: ", + @<div condition="true"><h3>@item</h3><tag-cloud count="Model.TagsToShow"></tag-cloud></div>); + } +</div> + +<div> + <h3>Dictionary Valued Model Expression</h3> + <div prefix-test1="@Model.TagsToShow" prefix-test2="@Model.Version.Build"></div> +</div> + +@section footerContent { + <p condition="Model.Approved" bold surround="section">© @Model.CopyrightYear - My ASP.NET Application</p> } \ No newline at end of file -- GitLab