Skip to content

Commit 0b58328

Browse files
authored
Merge pull request #372 from aspnet/release/2.1
Remove BOM from json files (#369)
2 parents b96c8ca + 79b4caf commit 0b58328

File tree

17 files changed

+75
-16
lines changed

17 files changed

+75
-16
lines changed

src/Microsoft.AspNetCore.SpaTemplates/content/Aurelia-CSharp/appsettings.Development.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
"Logging": {
33
"LogLevel": {
44
"Default": "Debug",

src/Microsoft.AspNetCore.SpaTemplates/content/Knockout-CSharp/appsettings.Development.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
"Logging": {
33
"LogLevel": {
44
"Default": "Debug",

src/Microsoft.AspNetCore.SpaTemplates/content/Vue-CSharp/appsettings.Development.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
"Logging": {
33
"LogLevel": {
44
"Default": "Debug",

src/Microsoft.DotNet.Web.ProjectTemplates/content/RazorPagesWeb-CSharp/appsettings.Development.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
"Logging": {
33
"LogLevel": {
44
"Default": "Debug",

src/Microsoft.DotNet.Web.ProjectTemplates/content/RazorPagesWeb-CSharp/appsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
////#if (IndividualB2CAuth)
33
// "AzureAdB2C": {
44
// "Instance": "https:////login.microsoftonline.com/tfp/",

src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/appsettings.Development.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
"Logging": {
33
"LogLevel": {
44
"Default": "Debug",

src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/appsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
////#if (IndividualB2CAuth)
33
// "AzureAdB2C": {
44
// "Instance": "https:////login.microsoftonline.com/tfp/",

src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-FSharp/appsettings.Development.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
"Logging": {
33
"LogLevel": {
44
"Default": "Debug",

src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-FSharp/appsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
"Logging": {
33
"LogLevel": {
44
"Default": "Warning"

src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/appsettings.Development.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
"Logging": {
33
"LogLevel": {
44
"Default": "Debug",

src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/appsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
////#if (IndividualB2CAuth)
33
// "AzureAdB2C": {
44
// "Instance": "https:////login.microsoftonline.com/tfp/",

src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-FSharp/appsettings.Development.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
"Logging": {
33
"LogLevel": {
44
"Default": "Debug",

src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-FSharp/appsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
"Logging": {
33
"LogLevel": {
44
"Default": "Warning"

src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/Angular-CSharp/appsettings.Development.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
"Logging": {
33
"LogLevel": {
44
"Default": "Debug",

src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/React-CSharp/appsettings.Development.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
"Logging": {
33
"LogLevel": {
44
"Default": "Debug",

src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/appsettings.Development.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
"Logging": {
33
"LogLevel": {
44
"Default": "Debug",
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System.IO;
5+
using Xunit;
6+
using Xunit.Abstractions;
7+
8+
namespace Templates.Test
9+
{
10+
public class ByteOrderMarkTest
11+
{
12+
private readonly ITestOutputHelper _output;
13+
14+
public ByteOrderMarkTest(ITestOutputHelper output)
15+
{
16+
_output = output;
17+
}
18+
19+
[Theory]
20+
[InlineData(@"\Microsoft.AspNetCore.SpaTemplates\content")]
21+
[InlineData(@"\Microsoft.DotNet.Web.ProjectTemplates\content")]
22+
[InlineData(@"\Microsoft.DotNet.Web.Spa.ProjectTemplates\content")]
23+
public void CheckForByteOrderMarkSpaTemplates(string path)
24+
{
25+
var currentDirectory = Directory.GetCurrentDirectory();
26+
var srcDirectory = Path.GetFullPath(Path.Combine(currentDirectory, @"..\..\..\..\..\src"));
27+
var directories = Directory.GetDirectories(srcDirectory + path, "*Sharp");
28+
29+
var filesWithBOMCharactersPresent = false;
30+
foreach (var directory in directories)
31+
{
32+
var files = Directory.GetFiles(directory, "*.json");
33+
foreach (var file in files)
34+
{
35+
var filePath = Path.GetFullPath(file);
36+
var fileStream = new FileStream(filePath, FileMode.Open);
37+
38+
var bytes = new byte[3];
39+
fileStream.Read(bytes, 0, 3);
40+
41+
// Check for UTF8 BOM 0xEF,0xBB,0xBF
42+
if (bytes[0] == 0xEF && bytes[1] == 0xBB && bytes[2] == 0xBF)
43+
{
44+
_output.WriteLine($"File {filePath} has UTF-8 BOM characters.");
45+
filesWithBOMCharactersPresent = true;
46+
}
47+
// Check for UTF16 BOM 0xFF, 0xFE
48+
if (bytes[0] == 0xFF && bytes[1] == 0xFE)
49+
{
50+
_output.WriteLine($"File {filePath} has UTF-16 BOM characters.");
51+
filesWithBOMCharactersPresent = true;
52+
}
53+
}
54+
}
55+
56+
Assert.False(filesWithBOMCharactersPresent);
57+
}
58+
}
59+
}

0 commit comments

Comments
 (0)