Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/update #12

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/actionlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Lint workflow files
on:
push:
branches:
- master
- main
paths:
- .github/workflows/**
pull_request:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build
on:
push:
branches:
- master
- main
pull_request:
types: [ opened, synchronize, reopened ] # Same as default

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/template-cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name: Template Cleanup
on:
push:
branches:
- master
- main

jobs:

Expand Down Expand Up @@ -66,6 +66,7 @@ jobs:
.github/template-cleanup \
.github/workflows/template-cleanup.yml \
.github/CODEOWNERS \
.github/pull_request_template.md \
LICENSE

# Commit modified files
Expand Down
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.PHONY: help
help: ## Display this help screen
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'

.PHONY: all
all: build copy ## Build and Copy

.PHONY: build
build: ## Build csproj
rm -rf output
dotnet build --no-incremental RoslynAnalyzerTemplate/RoslynAnalyzerTemplate.csproj --output output --configuration Release

.PHONY: copy
copy: ## Copy dll file to Unity Project
rm -f RoslynAnalyzerTemplate.Unity/Assets/Plugins/RoslynAnalyzerTemplate/RoslynAnalyzerTemplate.dll*
cp output/RoslynAnalyzerTemplate.dll RoslynAnalyzerTemplate.Unity/Assets/Plugins/RoslynAnalyzerTemplate/RoslynAnalyzerTemplate.dll
91 changes: 91 additions & 0 deletions RoslynAnalyzerTemplate.Unity/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore
#
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/
/[Uu]ser[Ss]ettings/

# MemoryCaptures can get excessive in size.
# They also could contain extremely sensitive data
/[Mm]emoryCaptures/

# Recordings can get excessive in size
/[Rr]ecordings/

# Uncomment this line if you wish to ignore the asset store tools plugin
# /[Aa]ssets/AssetStoreTools*

# Autogenerated Jetbrains Rider plugin
/[Aa]ssets/Plugins/Editor/JetBrains*

# Visual Studio cache directory
.vs/

# Gradle cache directory
.gradle/

# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
*.mdb
*.opendb
*.VC.db

# Unity3D generated meta files
*.pidb.meta
*.pdb.meta
*.mdb.meta

# Unity3D generated file on crash reports
sysinfo.txt

# Builds
*.apk
*.aab
*.unitypackage
*.app

# Crashlytics generated file
crashlytics-build.properties

# Packed Addressables
/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin*
/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/i[Oo][Ss]*

# Temporary auto-generated Android Assets
/[Aa]ssets/[Ss]treamingAssets/aa.meta
/[Aa]ssets/[Ss]treamingAssets/aa/*

# Rider
.idea/

# Ignore temporaries from GameCI
/[Aa]rtifacts/
/[Cc]odeCoverage/

# Build Artifacts
i[Oo][Ss][Oo]utput/
[Aa]ndroid[Oo]utput/

# UPM Samples
/[Aa]ssets/[Ss]amples/
/[Aa]ssets/[Ss]amples.meta

# macOS Finder file that stores custom folder attributes
.DS_Store
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using UnityEditor;

namespace Editor
{
public class AnalyzerDllModifier : AssetPostprocessor
{
private readonly string _analyzerDLLPath =
$"Assets/Plugins/{Constants.AnalyzerName}/{Constants.AnalyzerName}.dll";

private const string RoslynAnalyzerLabel = "RoslynAnalyzer";

private void OnPreprocessAsset()
{
if (assetPath != _analyzerDLLPath)
{
return;
}

var importer = AssetImporter.GetAtPath(assetPath) as PluginImporter;
if (importer == null)
{
return;
}

if (!importer.importSettingsMissing)
{
return;
}

importer.SetCompatibleWithAnyPlatform(false);
AssetDatabase.SetLabels(importer, new[] { RoslynAnalyzerLabel });
}
}
}
10 changes: 10 additions & 0 deletions RoslynAnalyzerTemplate.Unity/Assets/Editor/Constants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) 2020-2024 DeNA Co., Ltd.
// This software is released under the MIT License.

namespace Editor
{
public static class Constants
{
public const string AnalyzerName = "RoslynAnalyzerTemplate";
}
}
24 changes: 24 additions & 0 deletions RoslynAnalyzerTemplate.Unity/Assets/Editor/PackageExporter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Linq;
using UnityEditor;

namespace Editor
{
public class PackageExporter
{
[MenuItem("Tools/ExportPackage")]
private static void Export()
{
var analyzerPluginPath = $"Assets/Plugins/{Constants.AnalyzerName}/";
var exportPath = $"./{Constants.AnalyzerName}.unitypackage";

var assetPathNames = AssetDatabase.FindAssets("", new[] { analyzerPluginPath })
.Select(AssetDatabase.GUIDToAssetPath)
.ToArray();

AssetDatabase.ExportPackage(
assetPathNames,
exportPath,
ExportPackageOptions.IncludeDependencies);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright (c) 2020-2024 DeNA Co., Ltd.
// This software is released under the MIT License.

using System.Reflection;

[assembly: AssemblyDescription(
"Suppress warning 'Assembly for Assembly Definition File will not be compiled, because it has no scripts associated with it.'")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "DefaultAssembly",
"rootNamespace": "",
"references": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "com.default.analyzer",
"displayName": "RoslynAnalyzerTemplate",
"version": "0.1.0",
"unity": "2021.1",
"unityRelease": "2f1",
"author": {
"name": ""
}
}
Loading
Loading