Merge pull request #372 from aspnet/release/2.1

Remove BOM from json files (#369)
This commit is contained in:
Jass Bagga 2018-03-19 10:11:28 -07:00 committed by GitHub
commit 0b58328143
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 75 additions and 16 deletions

View File

@ -1,4 +1,4 @@
{
{
"Logging": {
"LogLevel": {
"Default": "Debug",

View File

@ -1,4 +1,4 @@
{
{
"Logging": {
"LogLevel": {
"Default": "Debug",

View File

@ -1,4 +1,4 @@
{
{
"Logging": {
"LogLevel": {
"Default": "Debug",

View File

@ -1,4 +1,4 @@
{
{
"Logging": {
"LogLevel": {
"Default": "Debug",

View File

@ -1,4 +1,4 @@
{
{
////#if (IndividualB2CAuth)
// "AzureAdB2C": {
// "Instance": "https:////login.microsoftonline.com/tfp/",

View File

@ -1,4 +1,4 @@
{
{
"Logging": {
"LogLevel": {
"Default": "Debug",

View File

@ -1,4 +1,4 @@
{
{
////#if (IndividualB2CAuth)
// "AzureAdB2C": {
// "Instance": "https:////login.microsoftonline.com/tfp/",

View File

@ -1,4 +1,4 @@
{
{
"Logging": {
"LogLevel": {
"Default": "Debug",

View File

@ -1,4 +1,4 @@
{
{
"Logging": {
"LogLevel": {
"Default": "Warning"

View File

@ -1,4 +1,4 @@
{
{
"Logging": {
"LogLevel": {
"Default": "Debug",

View File

@ -1,4 +1,4 @@
{
{
////#if (IndividualB2CAuth)
// "AzureAdB2C": {
// "Instance": "https:////login.microsoftonline.com/tfp/",

View File

@ -1,4 +1,4 @@
{
{
"Logging": {
"LogLevel": {
"Default": "Debug",

View File

@ -1,4 +1,4 @@
{
{
"Logging": {
"LogLevel": {
"Default": "Warning"

View File

@ -1,4 +1,4 @@
{
{
"Logging": {
"LogLevel": {
"Default": "Debug",

View File

@ -1,4 +1,4 @@
{
{
"Logging": {
"LogLevel": {
"Default": "Debug",

View File

@ -1,4 +1,4 @@
{
{
"Logging": {
"LogLevel": {
"Default": "Debug",

View File

@ -0,0 +1,59 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.IO;
using Xunit;
using Xunit.Abstractions;
namespace Templates.Test
{
public class ByteOrderMarkTest
{
private readonly ITestOutputHelper _output;
public ByteOrderMarkTest(ITestOutputHelper output)
{
_output = output;
}
[Theory]
[InlineData(@"\Microsoft.AspNetCore.SpaTemplates\content")]
[InlineData(@"\Microsoft.DotNet.Web.ProjectTemplates\content")]
[InlineData(@"\Microsoft.DotNet.Web.Spa.ProjectTemplates\content")]
public void CheckForByteOrderMarkSpaTemplates(string path)
{
var currentDirectory = Directory.GetCurrentDirectory();
var srcDirectory = Path.GetFullPath(Path.Combine(currentDirectory, @"..\..\..\..\..\src"));
var directories = Directory.GetDirectories(srcDirectory + path, "*Sharp");
var filesWithBOMCharactersPresent = false;
foreach (var directory in directories)
{
var files = Directory.GetFiles(directory, "*.json");
foreach (var file in files)
{
var filePath = Path.GetFullPath(file);
var fileStream = new FileStream(filePath, FileMode.Open);
var bytes = new byte[3];
fileStream.Read(bytes, 0, 3);
// Check for UTF8 BOM 0xEF,0xBB,0xBF
if (bytes[0] == 0xEF && bytes[1] == 0xBB && bytes[2] == 0xBF)
{
_output.WriteLine($"File {filePath} has UTF-8 BOM characters.");
filesWithBOMCharactersPresent = true;
}
// Check for UTF16 BOM 0xFF, 0xFE
if (bytes[0] == 0xFF && bytes[1] == 0xFE)
{
_output.WriteLine($"File {filePath} has UTF-16 BOM characters.");
filesWithBOMCharactersPresent = true;
}
}
}
Assert.False(filesWithBOMCharactersPresent);
}
}
}