From ab0c983db79d21fdc81b1e0bd475a7e0545f5e24 Mon Sep 17 00:00:00 2001 From: Jonghyo Lee Date: Thu, 19 Dec 2024 17:09:12 +0900 Subject: [PATCH] Pages --- .github/workflows/gh-pages.yml | 64 +++++++++++++++++++ .../Bluehill.Analyzers.Pages.csproj | 1 + .../Layout/MainLayout.razor | 2 +- Bluehill.Analyzers.Pages/Pages/BH0001.razor | 33 ++++++++++ Bluehill.Analyzers.Pages/Pages/BH0002.razor | 37 +++++++++++ Bluehill.Analyzers.Pages/Pages/Home.razor | 4 ++ Bluehill.Analyzers.Pages/Pages/Rules.razor | 8 +++ Bluehill.Analyzers.Pages/_Imports.razor | 1 + Bluehill.Analyzers.Pages/packages.lock.json | 10 +++ Bluehill.Analyzers.Pages/wwwroot/index.html | 2 + Bluehill.Analyzers/Resources.Designer.cs | 63 +++++------------- Bluehill.Analyzers/Resources.ko.resx | 6 +- Bluehill.Analyzers/Resources.resx | 6 +- Directory.Packages.props | 1 + 14 files changed, 183 insertions(+), 55 deletions(-) create mode 100644 .github/workflows/gh-pages.yml create mode 100644 Bluehill.Analyzers.Pages/Pages/BH0001.razor create mode 100644 Bluehill.Analyzers.Pages/Pages/BH0002.razor create mode 100644 Bluehill.Analyzers.Pages/Pages/Rules.razor diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml new file mode 100644 index 0000000..f106fba --- /dev/null +++ b/.github/workflows/gh-pages.yml @@ -0,0 +1,64 @@ +name: Deploy GitHub Pages + +on: + # Runs on pushes targeting the default branch + push: + branches: ["main"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + # Build job + build: + runs-on: ubuntu-latest + env: + NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 9.0.x + - name: Cache NuGet + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles('Directory.Packages.props') }} #hash of project files + restore-keys: ${{ runner.os }}-nuget- + - name: Prepare Blazor WASM for GitHub Pages + uses: na1307/blazor-github-pages@v1 + id: prepare + with: + project-path: Bluehill.Analyzers.Pages/Bluehill.Analyzers.Pages.csproj + - name: Setup Pages + uses: actions/configure-pages@v5 + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: ${{ steps.prepare.outputs.wwwroot-path }} + + # Deployment job + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/Bluehill.Analyzers.Pages/Bluehill.Analyzers.Pages.csproj b/Bluehill.Analyzers.Pages/Bluehill.Analyzers.Pages.csproj index fffdce8..e12b659 100644 --- a/Bluehill.Analyzers.Pages/Bluehill.Analyzers.Pages.csproj +++ b/Bluehill.Analyzers.Pages/Bluehill.Analyzers.Pages.csproj @@ -7,6 +7,7 @@ + diff --git a/Bluehill.Analyzers.Pages/Layout/MainLayout.razor b/Bluehill.Analyzers.Pages/Layout/MainLayout.razor index 50b6877..fda4581 100644 --- a/Bluehill.Analyzers.Pages/Layout/MainLayout.razor +++ b/Bluehill.Analyzers.Pages/Layout/MainLayout.razor @@ -1,4 +1,4 @@ @using Bluehill.Blazor.Layout @inherits LayoutComponentBase - + diff --git a/Bluehill.Analyzers.Pages/Pages/BH0001.razor b/Bluehill.Analyzers.Pages/Pages/BH0001.razor new file mode 100644 index 0000000..3a67a51 --- /dev/null +++ b/Bluehill.Analyzers.Pages/Pages/BH0001.razor @@ -0,0 +1,33 @@ +@page "/BH0001" + +

BH0001: Classes without derived types should be sealed

+ +

Classes without derived types should be sealed. Note: Sealed or abstract classes, and static classes are not included in this rule.

+ +

Code with violation

+ + + public class TestClass { + public void TestMethod() { + Console.WriteLine("Test"); + } + } + + public class AnotherClass; + + public class InheritedClass : AnotherClass; + + +

Fixed Code

+ + + public sealed class TestClass { + public void TestMethod() { + Console.WriteLine("Test"); + } + } + + public class AnotherClass; + + public sealed class InheritedClass : AnotherClass; + diff --git a/Bluehill.Analyzers.Pages/Pages/BH0002.razor b/Bluehill.Analyzers.Pages/Pages/BH0002.razor new file mode 100644 index 0000000..0e63514 --- /dev/null +++ b/Bluehill.Analyzers.Pages/Pages/BH0002.razor @@ -0,0 +1,37 @@ +@page "/BH0002" + +

BH0002: Fields should be at the top of the type definition

+ +

Fields should be at the top of the type definition.

+ +

Code with violation

+ + + public class TestClass { + public TestClass(string name) { + this.name = name; + } + + public void TestMethod() { + Console.WriteLine(name); + } + + private readonly string name; + } + + +

Fixed Code

+ + + public class TestClass { + private readonly string name; + + public TestClass(string name) { + this.name = name; + } + + public void TestMethod() { + Console.WriteLine(name); + } + } + diff --git a/Bluehill.Analyzers.Pages/Pages/Home.razor b/Bluehill.Analyzers.Pages/Pages/Home.razor index ce36560..cfdee0a 100644 --- a/Bluehill.Analyzers.Pages/Pages/Home.razor +++ b/Bluehill.Analyzers.Pages/Pages/Home.razor @@ -3,3 +3,7 @@ Bluehill.Analyzers

Bluehill.Analyzers

+ +

These pages describe the Bluehill.Analyzers analyzer.

+ +

Rules

diff --git a/Bluehill.Analyzers.Pages/Pages/Rules.razor b/Bluehill.Analyzers.Pages/Pages/Rules.razor new file mode 100644 index 0000000..ad52822 --- /dev/null +++ b/Bluehill.Analyzers.Pages/Pages/Rules.razor @@ -0,0 +1,8 @@ +@page "/rules" + +

Rules

+ +
    +
  • BH0001
  • +
  • BH0002
  • +
diff --git a/Bluehill.Analyzers.Pages/_Imports.razor b/Bluehill.Analyzers.Pages/_Imports.razor index 04533a8..95d20f0 100644 --- a/Bluehill.Analyzers.Pages/_Imports.razor +++ b/Bluehill.Analyzers.Pages/_Imports.razor @@ -8,3 +8,4 @@ @using Microsoft.JSInterop @using Bluehill.Analyzers.Pages @using Bluehill.Analyzers.Pages.Layout +@using HighlightBlazor diff --git a/Bluehill.Analyzers.Pages/packages.lock.json b/Bluehill.Analyzers.Pages/packages.lock.json index 4efe405..32698ee 100644 --- a/Bluehill.Analyzers.Pages/packages.lock.json +++ b/Bluehill.Analyzers.Pages/packages.lock.json @@ -18,6 +18,16 @@ "Microsoft.AspNetCore.Components.WebAssembly": "8.0.11" } }, + "HighlightBlazor": { + "type": "Direct", + "requested": "[0.1.10, )", + "resolved": "0.1.10", + "contentHash": "Se6/AvDiBm8K0k+rWVxP/nFnkmjqBTEOuFowAiAHum0zYZw/q18jZNc6gKviFvDaLeXjXNzzn+qIjrLT3udgIA==", + "dependencies": { + "Microsoft.AspNetCore.Components": "3.1.19", + "Microsoft.AspNetCore.Components.Web": "3.1.19" + } + }, "Microsoft.AspNetCore.Components.WebAssembly": { "type": "Direct", "requested": "[9.0.0, )", diff --git a/Bluehill.Analyzers.Pages/wwwroot/index.html b/Bluehill.Analyzers.Pages/wwwroot/index.html index 09b845d..817bb73 100644 --- a/Bluehill.Analyzers.Pages/wwwroot/index.html +++ b/Bluehill.Analyzers.Pages/wwwroot/index.html @@ -9,6 +9,8 @@ + + diff --git a/Bluehill.Analyzers/Resources.Designer.cs b/Bluehill.Analyzers/Resources.Designer.cs index db9c864..5f75bdf 100644 --- a/Bluehill.Analyzers/Resources.Designer.cs +++ b/Bluehill.Analyzers/Resources.Designer.cs @@ -1,10 +1,9 @@ //------------------------------------------------------------------------------ // -// 이 코드는 도구를 사용하여 생성되었습니다. -// 런타임 버전:4.0.30319.42000 +// This code was generated by a tool. // -// 파일 내용을 변경하면 잘못된 동작이 발생할 수 있으며, 코드를 다시 생성하면 -// 이러한 변경 내용이 손실됩니다. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. // //------------------------------------------------------------------------------ @@ -12,46 +11,32 @@ namespace Bluehill.Analyzers { using System; - /// - /// 지역화된 문자열 등을 찾기 위한 강력한 형식의 리소스 클래스입니다. - /// - // 이 클래스는 ResGen 또는 Visual Studio와 같은 도구를 통해 StronglyTypedResourceBuilder - // 클래스에서 자동으로 생성되었습니다. - // 멤버를 추가하거나 제거하려면 .ResX 파일을 편집한 다음 /str 옵션을 사용하여 ResGen을 - // 다시 실행하거나 VS 프로젝트를 다시 빌드하십시오. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { - private static global::System.Resources.ResourceManager resourceMan; + private static System.Resources.ResourceManager resourceMan; - private static global::System.Globalization.CultureInfo resourceCulture; + private static System.Globalization.CultureInfo resourceCulture; - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal Resources() { } - /// - /// 이 클래스에서 사용하는 캐시된 ResourceManager 인스턴스를 반환합니다. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + internal static System.Resources.ResourceManager ResourceManager { get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Bluehill.Analyzers.Resources", typeof(Resources).Assembly); + if (object.Equals(null, resourceMan)) { + System.Resources.ResourceManager temp = new System.Resources.ResourceManager("Bluehill.Analyzers.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } - /// - /// 이 강력한 형식의 리소스 클래스를 사용하여 모든 리소스 조회에 대해 현재 스레드의 CurrentUICulture 속성을 - /// 재정의합니다. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + internal static System.Globalization.CultureInfo Culture { get { return resourceCulture; } @@ -60,54 +45,36 @@ internal Resources() { } } - /// - /// Types without derived types should be sealed.과(와) 유사한 지역화된 문자열을 찾습니다. - /// internal static string BH0001AnalyzerDescription { get { return ResourceManager.GetString("BH0001AnalyzerDescription", resourceCulture); } } - /// - /// No types are derived from type '{0}'과(와) 유사한 지역화된 문자열을 찾습니다. - /// internal static string BH0001AnalyzerMessageFormat { get { return ResourceManager.GetString("BH0001AnalyzerMessageFormat", resourceCulture); } } - /// - /// Types without derived types should be sealed과(와) 유사한 지역화된 문자열을 찾습니다. - /// internal static string BH0001AnalyzerTitle { get { return ResourceManager.GetString("BH0001AnalyzerTitle", resourceCulture); } } - /// - /// Fields should be at the top of the type definition.과(와) 유사한 지역화된 문자열을 찾습니다. - /// internal static string BH0002AnalyzerDescription { get { return ResourceManager.GetString("BH0002AnalyzerDescription", resourceCulture); } } - /// - /// '{0}' is not at the top of the type definition과(와) 유사한 지역화된 문자열을 찾습니다. - /// internal static string BH0002AnalyzerMessageFormat { get { return ResourceManager.GetString("BH0002AnalyzerMessageFormat", resourceCulture); } } - /// - /// Fields should be at the top of the type definition과(와) 유사한 지역화된 문자열을 찾습니다. - /// internal static string BH0002AnalyzerTitle { get { return ResourceManager.GetString("BH0002AnalyzerTitle", resourceCulture); diff --git a/Bluehill.Analyzers/Resources.ko.resx b/Bluehill.Analyzers/Resources.ko.resx index e715668..568ef09 100644 --- a/Bluehill.Analyzers/Resources.ko.resx +++ b/Bluehill.Analyzers/Resources.ko.resx @@ -118,15 +118,15 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - 파생 형식이 없는 형식은 봉인되어야 합니다. + 파생 형식이 없는 클래스는 봉인되어야 합니다. An optional longer localizable description of the diagnostic. - '{0}' 형식에서 파생된 형식이 없음 + '{0}' 클래스에서 파생된 형식이 없음 The format-able message the diagnostic displays. - 파생 형식이 없는 형식은 봉인되어야 함 + 파생 형식이 없는 클래스는 봉인되어야 함 The title of the diagnostic. diff --git a/Bluehill.Analyzers/Resources.resx b/Bluehill.Analyzers/Resources.resx index 5191a9a..762a43c 100644 --- a/Bluehill.Analyzers/Resources.resx +++ b/Bluehill.Analyzers/Resources.resx @@ -118,15 +118,15 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - Types without derived types should be sealed. + Classes without derived types should be sealed. An optional longer localizable description of the diagnostic. - No types are derived from type '{0}' + No types are derived from class '{0}' The format-able message the diagnostic displays. - Types without derived types should be sealed + Classes without derived types should be sealed The title of the diagnostic. diff --git a/Directory.Packages.props b/Directory.Packages.props index b1ff52f..7879f3a 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -7,6 +7,7 @@ +