From 359ccd567802d31a2e230ab7f52a3be22f376c09 Mon Sep 17 00:00:00 2001 From: Yuchen Ji Date: Tue, 5 Apr 2022 16:19:11 +0800 Subject: [PATCH] Fix null warning, cleanup --- GC-local-server-rewrite/common/CertificateHelper.cs | 4 +--- GC-local-server-rewrite/common/DatabaseHelper.cs | 2 +- GC-local-server-rewrite/common/PathHelper.cs | 10 ++++++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/GC-local-server-rewrite/common/CertificateHelper.cs b/GC-local-server-rewrite/common/CertificateHelper.cs index 261fbba..cd2b16f 100644 --- a/GC-local-server-rewrite/common/CertificateHelper.cs +++ b/GC-local-server-rewrite/common/CertificateHelper.cs @@ -1,7 +1,5 @@ -using System.Diagnostics; -using System.Security.Cryptography; +using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; -using System.Text; using CertificateManager; using CertificateManager.Models; using Microsoft.Extensions.DependencyInjection; diff --git a/GC-local-server-rewrite/common/DatabaseHelper.cs b/GC-local-server-rewrite/common/DatabaseHelper.cs index 2499ee3..7c95eda 100644 --- a/GC-local-server-rewrite/common/DatabaseHelper.cs +++ b/GC-local-server-rewrite/common/DatabaseHelper.cs @@ -2,7 +2,7 @@ namespace GCLocalServerRewrite.common; -public class DatabaseHelper +public static class DatabaseHelper { /// /// Static method to allow local data services to initialise their associated database conveniently. diff --git a/GC-local-server-rewrite/common/PathHelper.cs b/GC-local-server-rewrite/common/PathHelper.cs index 5026d69..39b9624 100644 --- a/GC-local-server-rewrite/common/PathHelper.cs +++ b/GC-local-server-rewrite/common/PathHelper.cs @@ -1,8 +1,9 @@ using System.Diagnostics; +using Swan; namespace GCLocalServerRewrite.common; -public class PathHelper +public static class PathHelper { /// /// Gets the local path of html/static files. @@ -32,7 +33,12 @@ public class PathHelper return parentFullName; #else - return assemblyPath; + if (assemblyPath != null) + { + return assemblyPath; + } + + throw SelfCheck.Failure("Cannot get assembly path!"); #endif } }