From 0e1ab99e2524c430a6b1fc43339e1c5c8a3590c2 Mon Sep 17 00:00:00 2001 From: Justin Baur <136baur@gmail.com> Date: Thu, 13 May 2021 17:14:56 -0400 Subject: [PATCH] Cleanup Projects (#1324) * Update bitwarden_license projects * Added tests to verify resource names * Remove unneeded assembly attributes * Standardized namespace * Remove .GetTypeInfo() --- bitwarden-server.sln | 9 +++++- bitwarden_license/src/Portal/Portal.csproj | 3 -- .../src/Portal/Properties/AssemblyInfo.cs | 1 - bitwarden_license/src/Sso/Sso.csproj | 3 -- src/Core/Properties/AssemblyInfo.cs | 1 - test/Core.Test/Models/CipherTests.cs | 4 +-- test/Core.Test/Resources/VerifyResources.cs | 29 +++++++++++++++++++ test/Icons.Test/Icons.Test.csproj | 21 ++++++++++++++ test/Icons.Test/Resources/VerifyResources.cs | 21 ++++++++++++++ 9 files changed, 81 insertions(+), 11 deletions(-) create mode 100644 test/Core.Test/Resources/VerifyResources.cs create mode 100644 test/Icons.Test/Icons.Test.csproj create mode 100644 test/Icons.Test/Resources/VerifyResources.cs diff --git a/bitwarden-server.sln b/bitwarden-server.sln index 8401f1855..0ae64a7f2 100644 --- a/bitwarden-server.sln +++ b/bitwarden-server.sln @@ -15,6 +15,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution .gitignore = .gitignore build.sh = build.sh .github\workflows\build.yml = .github\workflows\build.yml + Directory.Build.props = Directory.Build.props dotnet-tools.json = dotnet-tools.json LICENSE.txt = LICENSE.txt LICENSE_AGPL.txt = LICENSE_AGPL.txt @@ -22,7 +23,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution NuGet.Config = NuGet.Config README.md = README.md SECURITY.md = SECURITY.md - Directory.Build.props = Directory.Build.props EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core", "src\Core\Core.csproj", "{3973D21B-A692-4B60-9B70-3631C057423A}" @@ -61,6 +61,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Portal", "bitwarden_license EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sso", "bitwarden_license\src\Sso\Sso.csproj", "{4866AF64-6640-4C65-A662-A31E02FF9064}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Icons.Test", "test\Icons.Test\Icons.Test.csproj", "{C7BA2255-C1B1-4789-8BB9-C27540DA6FB8}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -137,6 +139,10 @@ Global {4866AF64-6640-4C65-A662-A31E02FF9064}.Debug|Any CPU.Build.0 = Debug|Any CPU {4866AF64-6640-4C65-A662-A31E02FF9064}.Release|Any CPU.ActiveCfg = Release|Any CPU {4866AF64-6640-4C65-A662-A31E02FF9064}.Release|Any CPU.Build.0 = Release|Any CPU + {C7BA2255-C1B1-4789-8BB9-C27540DA6FB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C7BA2255-C1B1-4789-8BB9-C27540DA6FB8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C7BA2255-C1B1-4789-8BB9-C27540DA6FB8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C7BA2255-C1B1-4789-8BB9-C27540DA6FB8}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -159,6 +165,7 @@ Global {860DE301-0B3E-4717-9C21-A9B4C3C2B121} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84F} {BA852F18-852F-4154-973B-77D577B8CA04} = {4FDB6543-F68B-4202-9EA6-7FEA984D2D0A} {4866AF64-6640-4C65-A662-A31E02FF9064} = {4FDB6543-F68B-4202-9EA6-7FEA984D2D0A} + {C7BA2255-C1B1-4789-8BB9-C27540DA6FB8} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {E01CBF68-2E20-425F-9EDB-E0A6510CA92F} diff --git a/bitwarden_license/src/Portal/Portal.csproj b/bitwarden_license/src/Portal/Portal.csproj index 8e1112c05..cf861a8ff 100644 --- a/bitwarden_license/src/Portal/Portal.csproj +++ b/bitwarden_license/src/Portal/Portal.csproj @@ -1,9 +1,6 @@  - 1.41.2 - netcoreapp3.1 - Bit.Portal bitwarden-Portal diff --git a/bitwarden_license/src/Portal/Properties/AssemblyInfo.cs b/bitwarden_license/src/Portal/Properties/AssemblyInfo.cs index 884022547..5a4afc68d 100644 --- a/bitwarden_license/src/Portal/Properties/AssemblyInfo.cs +++ b/bitwarden_license/src/Portal/Properties/AssemblyInfo.cs @@ -2,4 +2,3 @@ using Microsoft.Extensions.Localization; [assembly: ResourceLocation("Resources")] -[assembly: RootNamespace("Bit.Portal")] diff --git a/bitwarden_license/src/Sso/Sso.csproj b/bitwarden_license/src/Sso/Sso.csproj index 826aff2bf..6f29b203c 100644 --- a/bitwarden_license/src/Sso/Sso.csproj +++ b/bitwarden_license/src/Sso/Sso.csproj @@ -1,9 +1,6 @@  - 1.41.2 - netcoreapp3.1 - Bit.Sso bitwarden-Sso diff --git a/src/Core/Properties/AssemblyInfo.cs b/src/Core/Properties/AssemblyInfo.cs index 4c45d9af2..5a4afc68d 100644 --- a/src/Core/Properties/AssemblyInfo.cs +++ b/src/Core/Properties/AssemblyInfo.cs @@ -2,4 +2,3 @@ using Microsoft.Extensions.Localization; [assembly: ResourceLocation("Resources")] -[assembly: RootNamespace("Bit.Core")] diff --git a/test/Core.Test/Models/CipherTests.cs b/test/Core.Test/Models/CipherTests.cs index dfc9f9e99..06fe15f68 100644 --- a/test/Core.Test/Models/CipherTests.cs +++ b/test/Core.Test/Models/CipherTests.cs @@ -1,9 +1,9 @@ -using Bit.Core.Models.Table; +using Bit.Core.Models.Table; using Bit.Core.Test.AutoFixture.CipherFixtures; using Newtonsoft.Json; using Xunit; -namespace Core.Test.Models +namespace Bit.Core.Test.Models { public class CipherTests { diff --git a/test/Core.Test/Resources/VerifyResources.cs b/test/Core.Test/Resources/VerifyResources.cs new file mode 100644 index 000000000..898b0f196 --- /dev/null +++ b/test/Core.Test/Resources/VerifyResources.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using Bit.Core.Utilities; +using Xunit; + +namespace Bit.Core.Test.Resources +{ + public class VerifyResources + { + [Theory] + [MemberData(nameof(GetResources))] + public void Resource_FoundAndReadable(string resourceName) + { + var assembly = typeof(CoreHelpers).Assembly; + + using (var resource = assembly.GetManifestResourceStream(resourceName)) + { + Assert.NotNull(resource); + Assert.True(resource.CanRead); + } + } + + public static IEnumerable GetResources() + { + yield return new[] { "Bit.Core.licensing.cer" }; + yield return new[] { "Bit.Core.MailTemplates.Handlebars.AddedCredit.html.hbs" }; + yield return new[] { "Bit.Core.MailTemplates.Handlebars.Layouts.Basic.html.hbs" }; + } + } +} diff --git a/test/Icons.Test/Icons.Test.csproj b/test/Icons.Test/Icons.Test.csproj new file mode 100644 index 000000000..3a985166a --- /dev/null +++ b/test/Icons.Test/Icons.Test.csproj @@ -0,0 +1,21 @@ + + + + false + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + diff --git a/test/Icons.Test/Resources/VerifyResources.cs b/test/Icons.Test/Resources/VerifyResources.cs new file mode 100644 index 000000000..d8265d940 --- /dev/null +++ b/test/Icons.Test/Resources/VerifyResources.cs @@ -0,0 +1,21 @@ +using System.Reflection; +using Xunit; + +namespace Bit.Icons.Test.Resources +{ + public class VerifyResources + { + [Theory] + [InlineData("Bit.Icons.Resources.public_suffix_list.dat")] + public void Resources_FoundAndReadable(string resourceName) + { + var assembly = typeof(Program).Assembly; + + using (var resource = assembly.GetManifestResourceStream(resourceName)) + { + Assert.NotNull(resource); + Assert.True(resource.CanRead); + } + } + } +}