com.wallstop-studios.dxmessaging 3.1.0 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +326 -0
- package/Editor/Analyzers/BaseCallLogMessageParser.cs.meta +3 -3
- package/Editor/Analyzers/BaseCallReportAggregator.cs.meta +3 -3
- package/Editor/Analyzers/DxMessagingConsoleHarvester.cs +8 -8
- package/Editor/Analyzers/DxMessagingConsoleHarvester.cs.meta +3 -3
- package/Editor/CustomEditors/MessageAwareComponentFallbackEditor.cs +171 -13
- package/Editor/CustomEditors/MessageAwareComponentFallbackEditor.cs.meta +3 -3
- package/Editor/CustomEditors/MessageAwareComponentInspectorOverlay.cs +391 -96
- package/Editor/CustomEditors/MessageAwareComponentInspectorOverlay.cs.meta +3 -3
- package/Editor/CustomEditors/MessageAwareComponentInspectorView.cs +279 -0
- package/Editor/CustomEditors/MessageAwareComponentInspectorView.cs.meta +11 -0
- package/Editor/DxMessagingEditorPalette.cs +66 -0
- package/Editor/DxMessagingEditorPalette.cs.meta +11 -0
- package/Editor/DxMessagingEditorTheme.cs +200 -0
- package/Editor/DxMessagingEditorTheme.cs.meta +11 -0
- package/Editor/DxMessagingMenu.cs.meta +3 -3
- package/Editor/DxMessagingSceneBuildProcessor.cs.meta +3 -3
- package/Editor/Icons/dxmessaging-icon-256.png +0 -0
- package/Editor/Icons/dxmessaging-icon-256.png.meta +156 -0
- package/Editor/Icons/dxmessaging-icon-32.png +0 -0
- package/Editor/Icons/dxmessaging-icon-32.png.meta +156 -0
- package/Editor/Icons/dxmessaging-icon-48.png +0 -0
- package/Editor/Icons/dxmessaging-icon-48.png.meta +156 -0
- package/Editor/Icons.meta +8 -0
- package/Editor/Settings/DxMessagingBaseCallIgnoreSync.cs +2 -3
- package/Editor/Settings/DxMessagingBaseCallIgnoreSync.cs.meta +3 -3
- package/Editor/Settings/DxMessagingSettingsProvider.cs +368 -33
- package/Editor/SetupCscRsp.cs +232 -163
- package/Editor/Testing/MessagingComponentEditorHarness.cs +11 -4
- package/Editor/Theme/DxMessagingTheme.uss +255 -0
- package/Editor/Theme/DxMessagingTheme.uss.meta +11 -0
- package/Editor/Theme/DxTokens.uss +90 -0
- package/Editor/Theme/DxTokens.uss.meta +11 -0
- package/Editor/Theme.meta +8 -0
- package/Editor/Windows/DxMessagingFlowGraphWindow.cs +5513 -0
- package/Editor/Windows/DxMessagingFlowGraphWindow.cs.meta +11 -0
- package/Editor/Windows/DxMessagingMessageMonitorWindow.cs +2288 -0
- package/Editor/Windows/DxMessagingMessageMonitorWindow.cs.meta +11 -0
- package/Editor/Windows.meta +8 -0
- package/README.md +84 -35
- package/Runtime/Analyzers.meta +8 -0
- package/Runtime/AssemblyInfo.cs +1 -0
- package/Runtime/Core/Attributes/DxIgnoreMissingBaseCallAttribute.cs.meta +3 -3
- package/Runtime/Core/Diagnostics/MessageEmissionData.cs +29 -1
- package/Runtime/Core/DxMessagingStaticState.cs.meta +3 -3
- package/Runtime/Core/Extensions/MessageBusExtensions.cs.meta +3 -3
- package/Runtime/Core/Extensions/MessageExtensions.cs +4 -5
- package/Runtime/Core/Extensions/MessageExtensions.cs.meta +3 -3
- package/Runtime/Core/Helper/MessageCache.cs +56 -23
- package/Runtime/Core/IMessage.cs.meta +3 -3
- package/Runtime/Core/InstanceId.cs.meta +3 -3
- package/Runtime/Core/Internal/FlatDispatch.cs +32 -0
- package/Runtime/Core/Internal/TypedSlots.cs +45 -7
- package/Runtime/Core/MessageBus/DiagnosticsTarget.cs.meta +3 -3
- package/Runtime/Core/MessageBus/GlobalMessageBusProvider.cs.meta +3 -3
- package/Runtime/Core/MessageBus/IMessageBus.cs +63 -28
- package/Runtime/Core/MessageBus/IMessageBus.cs.meta +3 -3
- package/Runtime/Core/MessageBus/IMessageBusProvider.cs.meta +3 -3
- package/Runtime/Core/MessageBus/IMessageRegistrationBuilder.cs.meta +3 -3
- package/Runtime/Core/MessageBus/MessageBus.cs +1135 -626
- package/Runtime/Core/MessageBus/MessageBus.cs.meta +3 -3
- package/Runtime/Core/MessageBus/MessageBusRebindMode.cs.meta +3 -3
- package/Runtime/Core/MessageBus/MessageBusRegistration.cs +207 -0
- package/Runtime/Core/MessageBus/MessageBusRegistration.cs.meta +11 -0
- package/Runtime/Core/MessageBus/MessageRegistrationBuilder.cs.meta +3 -3
- package/Runtime/Core/MessageBus/MessagingRegistration.cs.meta +3 -3
- package/Runtime/Core/MessageBus/RegistrationLog.cs +25 -12
- package/Runtime/Core/MessageBus/RegistrationLog.cs.meta +3 -3
- package/Runtime/Core/MessageHandler.cs +1886 -1082
- package/Runtime/Core/MessageHandler.cs.meta +3 -3
- package/Runtime/Core/MessageRegistrationHandle.cs +19 -5
- package/Runtime/Core/MessageRegistrationHandle.cs.meta +3 -3
- package/Runtime/Core/MessageRegistrationToken.cs +1932 -895
- package/Runtime/Core/MessageRegistrationToken.cs.meta +3 -3
- package/Runtime/Core/Messages/IBroadcastMessage.cs.meta +3 -3
- package/Runtime/Core/Messages/ITargetedMessage.cs.meta +3 -3
- package/Runtime/Core/Messages/IUntargetedMessage.cs.meta +3 -3
- package/Runtime/Core/Messages/SourcedStringMessage.cs.meta +3 -3
- package/Runtime/Core/MessagingDebug.cs.meta +3 -3
- package/Runtime/Unity/CurrentGlobalMessageBusProvider.cs.meta +3 -3
- package/Runtime/Unity/DxMessagingRuntimeInitializer.cs.meta +3 -3
- package/Runtime/Unity/InitialGlobalMessageBusProvider.cs.meta +3 -3
- package/Runtime/Unity/Integrations/Reflex/ReflexRegistrationInstaller.cs.meta +3 -3
- package/Runtime/Unity/Integrations/VContainer/VContainerRegistrationExtensions.cs.meta +3 -3
- package/Runtime/Unity/Integrations/Zenject/ZenjectRegistrationInstaller.cs.meta +3 -3
- package/Runtime/Unity/MessageAwareComponent.cs.meta +3 -3
- package/Runtime/Unity/MessageBusProviderHandle.cs.meta +3 -3
- package/Runtime/Unity/MessagingComponent.cs.meta +3 -3
- package/Runtime/Unity/MessagingComponentInstaller.cs.meta +3 -3
- package/Runtime/Unity/ScriptableMessageBusProvider.cs.meta +3 -3
- package/Samples~/DI/Reflex/SampleInstaller.cs.meta +3 -3
- package/Samples~/DI/VContainer/SampleLifetimeScope.cs.meta +3 -3
- package/Samples~/DI/Zenject/SampleInstaller.cs.meta +3 -3
- package/Samples~/Diagnostics Tooling Exerciser/DiagnosticsToolingExerciser.cs +173 -0
- package/Samples~/Diagnostics Tooling Exerciser/DiagnosticsToolingExerciser.cs.meta +11 -0
- package/Samples~/Diagnostics Tooling Exerciser/DiagnosticsToolingExerciser.unity +424 -0
- package/Samples~/Diagnostics Tooling Exerciser/DiagnosticsToolingExerciser.unity.meta +7 -0
- package/Samples~/Diagnostics Tooling Exerciser/DiagnosticsToolingReceiver.cs +185 -0
- package/Samples~/Diagnostics Tooling Exerciser/DiagnosticsToolingReceiver.cs.meta +11 -0
- package/Samples~/Diagnostics Tooling Exerciser/Messages.cs +46 -0
- package/Samples~/Diagnostics Tooling Exerciser/Messages.cs.meta +11 -0
- package/Samples~/Diagnostics Tooling Exerciser/README.md +53 -0
- package/Samples~/Diagnostics Tooling Exerciser/README.md.meta +7 -0
- package/Samples~/Diagnostics Tooling Exerciser/WallstopStudios.DxMessaging.DiagnosticsToolingExerciser.Sample.asmdef +13 -0
- package/Samples~/Diagnostics Tooling Exerciser/WallstopStudios.DxMessaging.DiagnosticsToolingExerciser.Sample.asmdef.meta +7 -0
- package/Samples~/Diagnostics Tooling Exerciser.meta +8 -0
- package/Samples~/Mini Combat/Boot.cs.meta +3 -3
- package/Samples~/Mini Combat/Enemy.cs.meta +3 -3
- package/Samples~/Mini Combat/Messages.cs.meta +3 -3
- package/Samples~/Mini Combat/Player.cs.meta +3 -3
- package/Samples~/Mini Combat/README.md +1 -1
- package/Samples~/Mini Combat/UIOverlay.cs.meta +3 -3
- package/Samples~/Mini Combat/Walkthrough.md +3 -3
- package/Samples~/UI Buttons + Inspector/DiagnosticsEnabler.cs.meta +3 -3
- package/Samples~/UI Buttons + Inspector/Messages.cs.meta +3 -3
- package/Samples~/UI Buttons + Inspector/MessagingObserver.cs.meta +3 -3
- package/Samples~/UI Buttons + Inspector/UIButtonEmitter.cs.meta +3 -3
- package/SourceGenerators/Directory.Build.props +5 -5
- package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxAutoConstructorGenerator.cs.meta +3 -3
- package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.csproj +12 -11
- package/docs/images/DxMessaging-banner.svg +79 -0
- package/docs/images/DxMessaging-banner.svg.meta +53 -0
- package/docs/images.meta +8 -0
- package/docs.meta +8 -0
- package/package.json +17 -5
- /package/{Editor → Runtime}/Analyzers/Microsoft.CodeAnalysis.CSharp.dll +0 -0
- /package/{Editor → Runtime}/Analyzers/Microsoft.CodeAnalysis.CSharp.dll.meta +0 -0
- /package/{Editor → Runtime}/Analyzers/Microsoft.CodeAnalysis.dll +0 -0
- /package/{Editor → Runtime}/Analyzers/Microsoft.CodeAnalysis.dll.meta +0 -0
- /package/{Editor → Runtime}/Analyzers/System.Collections.Immutable.dll +0 -0
- /package/{Editor → Runtime}/Analyzers/System.Collections.Immutable.dll.meta +0 -0
- /package/{Editor → Runtime}/Analyzers/System.Reflection.Metadata.dll +0 -0
- /package/{Editor → Runtime}/Analyzers/System.Reflection.Metadata.dll.meta +0 -0
- /package/{Editor → Runtime}/Analyzers/System.Runtime.CompilerServices.Unsafe.dll +0 -0
- /package/{Editor → Runtime}/Analyzers/System.Runtime.CompilerServices.Unsafe.dll.meta +0 -0
- /package/{Editor → Runtime}/Analyzers/WallstopStudios.DxMessaging.Analyzer.dll +0 -0
- /package/{Editor → Runtime}/Analyzers/WallstopStudios.DxMessaging.Analyzer.dll.meta +0 -0
- /package/{Editor → Runtime}/Analyzers/WallstopStudios.DxMessaging.SourceGenerators.dll +0 -0
- /package/{Editor → Runtime}/Analyzers/WallstopStudios.DxMessaging.SourceGenerators.dll.meta +0 -0
package/Editor/SetupCscRsp.cs
CHANGED
|
@@ -5,12 +5,9 @@ namespace DxMessaging.Editor
|
|
|
5
5
|
using System;
|
|
6
6
|
using System.Collections.Generic;
|
|
7
7
|
using System.IO;
|
|
8
|
-
using System.Linq;
|
|
9
|
-
using System.Security.Cryptography;
|
|
10
8
|
using DxMessaging.Editor.Settings;
|
|
11
9
|
using UnityEditor;
|
|
12
10
|
using UnityEngine;
|
|
13
|
-
using Object = UnityEngine.Object;
|
|
14
11
|
|
|
15
12
|
[InitializeOnLoad]
|
|
16
13
|
public static class SetupCscRsp
|
|
@@ -22,57 +19,55 @@ namespace DxMessaging.Editor
|
|
|
22
19
|
)
|
|
23
20
|
.Replace("\\", "/");
|
|
24
21
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
// Older package versions copied the analyzer + Roslyn runtime DLLs into the consumer
|
|
23
|
+
// project here so the source generator applied project-wide. The generator now ships
|
|
24
|
+
// under the package's Runtime/Analyzers folder (Unity scopes it natively to the runtime
|
|
25
|
+
// assembly and everything that references it, including the predefined Assembly-CSharp),
|
|
26
|
+
// so this in-project copy is redundant and is removed on upgrade.
|
|
27
|
+
internal const string LegacyAnalyzerCopyFolder =
|
|
28
|
+
"Assets/Plugins/Editor/WallstopStudios.DxMessaging";
|
|
30
29
|
|
|
31
|
-
private
|
|
30
|
+
private const string LegacySourceGeneratorDllName =
|
|
32
31
|
"WallstopStudios.DxMessaging.SourceGenerators.dll";
|
|
33
32
|
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
// Released 2.x legacy folders predate the companion analyzer DLL, so the source generator
|
|
34
|
+
// is the required package-owned marker. Unknown DLLs still make the folder unsafe.
|
|
35
|
+
private static readonly HashSet<string> RequiredLegacyAnalyzerCopyDlls = new(
|
|
36
|
+
StringComparer.OrdinalIgnoreCase
|
|
37
|
+
)
|
|
38
|
+
{
|
|
39
|
+
LegacySourceGeneratorDllName,
|
|
40
|
+
};
|
|
38
41
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
// copy loop below silently skips any name that isn't on disk.
|
|
43
|
-
private static readonly string[] RequiredDllNames =
|
|
42
|
+
private static readonly HashSet<string> KnownLegacyAnalyzerCopyDlls = new(
|
|
43
|
+
StringComparer.OrdinalIgnoreCase
|
|
44
|
+
)
|
|
44
45
|
{
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
LegacySourceGeneratorDllName,
|
|
47
|
+
"WallstopStudios.DxMessaging.Analyzer.dll",
|
|
47
48
|
"Microsoft.CodeAnalysis.dll",
|
|
48
49
|
"Microsoft.CodeAnalysis.CSharp.dll",
|
|
49
|
-
"System.
|
|
50
|
-
"System.Reflection.Metadata.dll",
|
|
51
|
-
"System.Runtime.CompilerServices.Unsafe.dll",
|
|
50
|
+
"System.Buffers.dll",
|
|
52
51
|
"System.Collections.Immutable.dll",
|
|
53
52
|
"System.Memory.dll",
|
|
54
|
-
"System.Buffers.dll",
|
|
55
|
-
"System.Threading.Tasks.Extensions.dll",
|
|
56
53
|
"System.Numerics.Vectors.dll",
|
|
54
|
+
"System.Reflection.Metadata.dll",
|
|
55
|
+
"System.Runtime.CompilerServices.Unsafe.dll",
|
|
57
56
|
"System.Text.Encoding.CodePages.dll",
|
|
57
|
+
"System.Text.Encodings.Web.dll",
|
|
58
|
+
"System.Threading.Tasks.Extensions.dll",
|
|
58
59
|
};
|
|
59
60
|
|
|
60
|
-
|
|
61
|
-
// pipeline picks them up as analyzer/source-generator hosts. Other DLLs in the same folder
|
|
62
|
-
// (Roslyn runtime, immutable collections) are plain Editor-only plugin DLLs.
|
|
63
|
-
private static readonly HashSet<string> AnalyzerLabeledDllNames = new(
|
|
64
|
-
StringComparer.OrdinalIgnoreCase
|
|
65
|
-
)
|
|
66
|
-
{
|
|
67
|
-
SourceGeneratorDllName,
|
|
68
|
-
AnalyzerDllName,
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
private static readonly HashSet<string> DllNames = new(StringComparer.OrdinalIgnoreCase);
|
|
61
|
+
private static bool loggedSkippedLegacyAnalyzerCopyCleanup;
|
|
72
62
|
|
|
73
63
|
static SetupCscRsp()
|
|
74
64
|
{
|
|
75
|
-
|
|
65
|
+
// Backstop only: the primary removal happens pre-compile in LegacyAnalyzerCopyCleanup.
|
|
66
|
+
// This catches projects whose legacy copy predates the upgrade and triggers no import.
|
|
67
|
+
ScheduleSetupStep(
|
|
68
|
+
() => TryRemoveLegacyAnalyzerCopy(),
|
|
69
|
+
"remove redundant in-project analyzer copy"
|
|
70
|
+
);
|
|
76
71
|
ScheduleSetupStep(EnsureCscRsp, "clean csc.rsp analyzer entries");
|
|
77
72
|
ScheduleAdditionalFileForIgnoreListSync();
|
|
78
73
|
}
|
|
@@ -104,147 +99,186 @@ namespace DxMessaging.Editor
|
|
|
104
99
|
}
|
|
105
100
|
}
|
|
106
101
|
|
|
107
|
-
|
|
102
|
+
/// <summary>
|
|
103
|
+
/// Deletes the redundant in-project analyzer copy that older package versions deployed to
|
|
104
|
+
/// <see cref="LegacyAnalyzerCopyFolder"/>. The source generator now ships under the
|
|
105
|
+
/// package's <c>Runtime/Analyzers</c> folder and applies automatically, so the copy is no
|
|
106
|
+
/// longer needed -- and, critically, leaving it in place makes BOTH copies generate into
|
|
107
|
+
/// every DxMessaging-referencing assembly, emitting each member twice (CS0102). Removing it
|
|
108
|
+
/// is therefore an upgrade requirement, not just cleanup.
|
|
109
|
+
/// </summary>
|
|
110
|
+
/// <remarks>
|
|
111
|
+
/// Called from <see cref="LegacyAnalyzerCopyCleanup"/> (an <c>AssetPostprocessor</c>) so the
|
|
112
|
+
/// removal lands during the asset import that PRECEDES script compilation -- before the two
|
|
113
|
+
/// copies can both feed the compiler -- and again from the <c>[InitializeOnLoad]</c> static
|
|
114
|
+
/// constructor as a post-compile backstop. Idempotent (a no-op once the folder is gone) and
|
|
115
|
+
/// conservative: it leaves the folder untouched if it holds anything other than the analyzer
|
|
116
|
+
/// DLLs this package deployed there. Returns <c>true</c> only when it actually deleted the
|
|
117
|
+
/// folder.
|
|
118
|
+
/// </remarks>
|
|
119
|
+
internal static bool TryRemoveLegacyAnalyzerCopy()
|
|
120
|
+
{
|
|
121
|
+
if (!AssetDatabase.IsValidFolder(LegacyAnalyzerCopyFolder))
|
|
122
|
+
{
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// The only shape this package ever created here is a flat set of analyzer / Roslyn
|
|
127
|
+
// DLLs plus their auto-generated .meta sidecars. Inspect the on-disk folder and bail
|
|
128
|
+
// out if a consumer repurposed it for anything else.
|
|
129
|
+
string absoluteFolder = Path.GetFullPath(
|
|
130
|
+
Path.Combine(Application.dataPath, "..", LegacyAnalyzerCopyFolder)
|
|
131
|
+
);
|
|
132
|
+
if (!Directory.Exists(absoluteFolder))
|
|
133
|
+
{
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// A real subdirectory means a consumer repurposed this folder for their own content;
|
|
138
|
+
// preserve it. The package only ever wrote a flat set of analyzer DLLs here, so the
|
|
139
|
+
// safe-to-remove check below sees only files (a subfolder named "x.dll" can never be
|
|
140
|
+
// mistaken for a DLL).
|
|
141
|
+
string[] files = Directory.GetFiles(absoluteFolder);
|
|
142
|
+
if (Directory.GetDirectories(absoluteFolder).Length > 0)
|
|
143
|
+
{
|
|
144
|
+
LogSkippedLegacyAnalyzerCopyCleanupIfNeeded(files);
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (!IsLegacyAnalyzerCopySafeToRemove(files))
|
|
149
|
+
{
|
|
150
|
+
LogSkippedLegacyAnalyzerCopyCleanupIfNeeded(files);
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (AssetDatabase.DeleteAsset(LegacyAnalyzerCopyFolder))
|
|
155
|
+
{
|
|
156
|
+
Debug.Log(
|
|
157
|
+
"DxMessaging: removed the redundant in-project analyzer copy at "
|
|
158
|
+
+ LegacyAnalyzerCopyFolder
|
|
159
|
+
+ ". The source generator now ships under the package's Runtime/Analyzers "
|
|
160
|
+
+ "folder and applies automatically; nothing needs to live under Assets."
|
|
161
|
+
);
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
private static void LogSkippedLegacyAnalyzerCopyCleanupIfNeeded(IEnumerable<string> files)
|
|
108
169
|
{
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
170
|
+
if (
|
|
171
|
+
loggedSkippedLegacyAnalyzerCopyCleanup
|
|
172
|
+
|| !ContainsKnownLegacyAnalyzerCopyEntry(files)
|
|
112
173
|
)
|
|
113
174
|
{
|
|
114
|
-
|
|
115
|
-
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
loggedSkippedLegacyAnalyzerCopyCleanup = true;
|
|
179
|
+
Debug.LogWarning(
|
|
180
|
+
"DxMessaging: found a legacy in-project analyzer copy at "
|
|
181
|
+
+ LegacyAnalyzerCopyFolder
|
|
182
|
+
+ " but did not remove it because the folder contains content outside "
|
|
183
|
+
+ "the exact known package payload or is missing the required "
|
|
184
|
+
+ "DxMessaging source-generator DLL. Move consumer-owned files out of that folder, "
|
|
185
|
+
+ "then delete the stale DxMessaging analyzer DLLs manually to avoid "
|
|
186
|
+
+ "double-loading analyzers."
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/// <summary>
|
|
191
|
+
/// True when the legacy analyzer-copy folder contains the first-party source generator and
|
|
192
|
+
/// every entry is one of the exact analyzer/dependency DLLs this package deployed there or
|
|
193
|
+
/// a matching <c>.dll.meta</c> sidecar. A subfolder, a foreign DLL, or any other file makes
|
|
194
|
+
/// this false so the folder is preserved rather than deleted.
|
|
195
|
+
/// </summary>
|
|
196
|
+
internal static bool IsLegacyAnalyzerCopySafeToRemove(IEnumerable<string> folderEntries)
|
|
197
|
+
{
|
|
198
|
+
HashSet<string> presentRequiredDlls = new(StringComparer.OrdinalIgnoreCase);
|
|
199
|
+
HashSet<string> seenEntryNames = new(StringComparer.OrdinalIgnoreCase);
|
|
200
|
+
foreach (string entry in folderEntries ?? Array.Empty<string>())
|
|
201
|
+
{
|
|
202
|
+
if (string.IsNullOrEmpty(entry))
|
|
116
203
|
{
|
|
117
204
|
continue;
|
|
118
205
|
}
|
|
119
206
|
|
|
120
|
-
|
|
207
|
+
string name = GetLegacyAnalyzerCopyEntryName(entry);
|
|
208
|
+
if (string.IsNullOrEmpty(name) || !seenEntryNames.Add(name))
|
|
121
209
|
{
|
|
122
|
-
|
|
123
|
-
DllNames.Add(dllName);
|
|
210
|
+
return false;
|
|
124
211
|
}
|
|
125
|
-
}
|
|
126
212
|
|
|
127
|
-
|
|
128
|
-
{
|
|
129
|
-
if (DllNames.Contains(requiredDllName))
|
|
213
|
+
if (name.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
|
|
130
214
|
{
|
|
215
|
+
if (!KnownLegacyAnalyzerCopyDlls.Contains(name))
|
|
216
|
+
{
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (RequiredLegacyAnalyzerCopyDlls.Contains(name))
|
|
221
|
+
{
|
|
222
|
+
presentRequiredDlls.Add(name);
|
|
223
|
+
}
|
|
224
|
+
|
|
131
225
|
continue;
|
|
132
226
|
}
|
|
133
227
|
|
|
134
|
-
|
|
228
|
+
if (name.EndsWith(".dll.meta", StringComparison.OrdinalIgnoreCase))
|
|
135
229
|
{
|
|
136
|
-
|
|
230
|
+
string dllName = name.Substring(0, name.Length - ".meta".Length);
|
|
231
|
+
if (!KnownLegacyAnalyzerCopyDlls.Contains(dllName))
|
|
137
232
|
{
|
|
138
|
-
|
|
139
|
-
if (!File.Exists(sourceFile))
|
|
140
|
-
{
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const string pluginsDirectory =
|
|
145
|
-
"Assets/Plugins/Editor/WallstopStudios.DxMessaging/";
|
|
146
|
-
string outputAsset = $"{pluginsDirectory}{requiredDllName}";
|
|
147
|
-
if (!Directory.Exists(pluginsDirectory))
|
|
148
|
-
{
|
|
149
|
-
Directory.CreateDirectory(pluginsDirectory);
|
|
150
|
-
AssetDatabase.Refresh();
|
|
151
|
-
}
|
|
152
|
-
bool needsCopy = FilesDiffer(sourceFile, outputAsset);
|
|
153
|
-
if (needsCopy)
|
|
154
|
-
{
|
|
155
|
-
File.Copy(sourceFile, outputAsset, true);
|
|
156
|
-
AssetDatabase.ImportAsset(outputAsset);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (AnalyzerLabeledDllNames.Contains(requiredDllName))
|
|
160
|
-
{
|
|
161
|
-
Object loadedDll = AssetDatabase.LoadMainAssetAtPath(outputAsset);
|
|
162
|
-
if (loadedDll != null)
|
|
163
|
-
{
|
|
164
|
-
string[] existingLabels = AssetDatabase.GetLabels(loadedDll);
|
|
165
|
-
if (!existingLabels.Contains("RoslynAnalyzer"))
|
|
166
|
-
{
|
|
167
|
-
List<string> newLabels = existingLabels.ToList();
|
|
168
|
-
newLabels.Add("RoslynAnalyzer");
|
|
169
|
-
AssetDatabase.SetLabels(loadedDll, newLabels.ToArray());
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (AssetImporter.GetAtPath(outputAsset) is PluginImporter importer)
|
|
175
|
-
{
|
|
176
|
-
bool importerDirty = false;
|
|
177
|
-
|
|
178
|
-
// A RoslynAnalyzer-labeled DLL must be EXCLUDED from every
|
|
179
|
-
// build platform, including the Editor, so Unity treats it as a
|
|
180
|
-
// C# compiler analyzer rather than a managed precompiled
|
|
181
|
-
// assembly. The same-named DLL is importable from two locations
|
|
182
|
-
// (the package's own Editor/Analyzers copy and this Assets
|
|
183
|
-
// copy); if either is an Editor-enabled precompiled assembly,
|
|
184
|
-
// Unity 2021 aborts with "Multiple precompiled assemblies with
|
|
185
|
-
// the same name". The Roslyn runtime dependencies in the same
|
|
186
|
-
// folder already ship Editor-disabled and never collide -- this
|
|
187
|
-
// converges the analyzer DLLs onto that proven-safe shape.
|
|
188
|
-
// NOTE: SetExcludeFromAnyPlatform is a no-op once
|
|
189
|
-
// CompatibleWithAnyPlatform is false, so the Editor platform is
|
|
190
|
-
// disabled through the effective SetCompatibleWithEditor API.
|
|
191
|
-
if (importer.GetCompatibleWithAnyPlatform())
|
|
192
|
-
{
|
|
193
|
-
importer.SetCompatibleWithAnyPlatform(false);
|
|
194
|
-
importerDirty = true;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
if (importer.GetCompatibleWithEditor())
|
|
198
|
-
{
|
|
199
|
-
importer.SetCompatibleWithEditor(false);
|
|
200
|
-
importerDirty = true;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
if (importerDirty || needsCopy)
|
|
204
|
-
{
|
|
205
|
-
importer.SaveAndReimport();
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
DllNames.Add(requiredDllName);
|
|
210
|
-
break;
|
|
211
|
-
}
|
|
212
|
-
catch (Exception ex)
|
|
213
|
-
{
|
|
214
|
-
DxMessagingEditorLog.LogError(
|
|
215
|
-
$"Failed to copy {requiredDllName} to Assets.",
|
|
216
|
-
ex
|
|
217
|
-
);
|
|
233
|
+
return false;
|
|
218
234
|
}
|
|
235
|
+
|
|
236
|
+
continue;
|
|
219
237
|
}
|
|
220
|
-
}
|
|
221
238
|
|
|
222
|
-
|
|
223
|
-
{
|
|
224
|
-
AssetDatabase.Refresh();
|
|
239
|
+
return false;
|
|
225
240
|
}
|
|
241
|
+
|
|
242
|
+
return presentRequiredDlls.Count == RequiredLegacyAnalyzerCopyDlls.Count;
|
|
226
243
|
}
|
|
227
244
|
|
|
228
|
-
private static
|
|
245
|
+
private static string GetLegacyAnalyzerCopyEntryName(string entry)
|
|
229
246
|
{
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
247
|
+
string normalizedEntry = entry.Replace("\\", "/");
|
|
248
|
+
int lastSeparator = normalizedEntry.LastIndexOf('/');
|
|
249
|
+
return lastSeparator >= 0
|
|
250
|
+
? normalizedEntry.Substring(lastSeparator + 1)
|
|
251
|
+
: normalizedEntry;
|
|
252
|
+
}
|
|
234
253
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
254
|
+
private static bool ContainsKnownLegacyAnalyzerCopyEntry(IEnumerable<string> folderEntries)
|
|
255
|
+
{
|
|
256
|
+
foreach (string entry in folderEntries ?? Array.Empty<string>())
|
|
238
257
|
{
|
|
239
|
-
|
|
258
|
+
if (string.IsNullOrEmpty(entry))
|
|
259
|
+
{
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
string name = GetLegacyAnalyzerCopyEntryName(entry);
|
|
264
|
+
if (KnownLegacyAnalyzerCopyDlls.Contains(name))
|
|
265
|
+
{
|
|
266
|
+
return true;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
if (!name.EndsWith(".dll.meta", StringComparison.OrdinalIgnoreCase))
|
|
270
|
+
{
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
string dllName = name.Substring(0, name.Length - ".meta".Length);
|
|
275
|
+
if (KnownLegacyAnalyzerCopyDlls.Contains(dllName))
|
|
276
|
+
{
|
|
277
|
+
return true;
|
|
278
|
+
}
|
|
240
279
|
}
|
|
241
280
|
|
|
242
|
-
|
|
243
|
-
using FileStream destinationStream = File.OpenRead(destinationPath);
|
|
244
|
-
using SHA256 sha256 = SHA256.Create();
|
|
245
|
-
byte[] sourceHash = sha256.ComputeHash(sourceStream);
|
|
246
|
-
byte[] destinationHash = sha256.ComputeHash(destinationStream);
|
|
247
|
-
return !sourceHash.AsSpan().SequenceEqual(destinationHash);
|
|
281
|
+
return false;
|
|
248
282
|
}
|
|
249
283
|
|
|
250
284
|
/// <summary>
|
|
@@ -252,9 +286,12 @@ namespace DxMessaging.Editor
|
|
|
252
286
|
/// </summary>
|
|
253
287
|
/// <remarks>
|
|
254
288
|
/// DxMessaging analyzers are activated solely through the RoslynAnalyzer-labeled
|
|
255
|
-
/// <c>
|
|
256
|
-
///
|
|
257
|
-
///
|
|
289
|
+
/// DLLs shipped under the package's <c>Runtime/Analyzers</c> folder, which Unity
|
|
290
|
+
/// scopes to the runtime assembly and every assembly that references it (including
|
|
291
|
+
/// the predefined Assembly-CSharp). A stray <c>-a:</c> registration here (for
|
|
292
|
+
/// example, one left behind by an older package version that copied analyzers into
|
|
293
|
+
/// the project) double-loads the source generator, and registering dependency DLLs
|
|
294
|
+
/// as analyzers makes Unity's compiler path fragile, so this method strips them.
|
|
258
295
|
/// </remarks>
|
|
259
296
|
private static void EnsureCscRsp()
|
|
260
297
|
{
|
|
@@ -262,8 +299,7 @@ namespace DxMessaging.Editor
|
|
|
262
299
|
{
|
|
263
300
|
if (!File.Exists(RspFilePath))
|
|
264
301
|
{
|
|
265
|
-
|
|
266
|
-
AssetDatabase.ImportAsset("csc.rsp");
|
|
302
|
+
return;
|
|
267
303
|
}
|
|
268
304
|
|
|
269
305
|
string rspContent = File.ReadAllText(RspFilePath);
|
|
@@ -375,12 +411,6 @@ namespace DxMessaging.Editor
|
|
|
375
411
|
{
|
|
376
412
|
try
|
|
377
413
|
{
|
|
378
|
-
if (!File.Exists(RspFilePath))
|
|
379
|
-
{
|
|
380
|
-
File.WriteAllText(RspFilePath, string.Empty);
|
|
381
|
-
AssetDatabase.ImportAsset("csc.rsp");
|
|
382
|
-
}
|
|
383
|
-
|
|
384
414
|
string sidecarRelativePath = DxMessagingBaseCallIgnoreSync.SidecarAssetPath;
|
|
385
415
|
string projectRoot = Path.GetFullPath(Path.Combine(Application.dataPath, ".."))
|
|
386
416
|
.Replace("\\", "/");
|
|
@@ -388,6 +418,22 @@ namespace DxMessaging.Editor
|
|
|
388
418
|
.Replace("\\", "/");
|
|
389
419
|
|
|
390
420
|
bool sidecarExists = File.Exists(sidecarAbsolutePath);
|
|
421
|
+
if (!File.Exists(RspFilePath))
|
|
422
|
+
{
|
|
423
|
+
if (!sidecarExists)
|
|
424
|
+
{
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
File.WriteAllText(
|
|
429
|
+
RspFilePath,
|
|
430
|
+
FormatAdditionalFileArgument(sidecarRelativePath) + Environment.NewLine
|
|
431
|
+
);
|
|
432
|
+
AssetDatabase.ImportAsset("csc.rsp");
|
|
433
|
+
Debug.Log("Updated csc.rsp additionalfile entries.");
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
|
|
391
437
|
string[] newLines = SynchronizeAdditionalFileForIgnoreListLines(
|
|
392
438
|
File.ReadAllLines(RspFilePath),
|
|
393
439
|
sidecarRelativePath,
|
|
@@ -630,5 +676,28 @@ namespace DxMessaging.Editor
|
|
|
630
676
|
return arguments;
|
|
631
677
|
}
|
|
632
678
|
}
|
|
679
|
+
|
|
680
|
+
/// <summary>
|
|
681
|
+
/// Removes the legacy in-project analyzer copy (via
|
|
682
|
+
/// <see cref="SetupCscRsp.TryRemoveLegacyAnalyzerCopy"/>) during the asset import that PRECEDES
|
|
683
|
+
/// script compilation. This is the primary upgrade path: deleting the redundant copy before the
|
|
684
|
+
/// compiler runs prevents it and the package's Runtime/Analyzers copy from both generating into
|
|
685
|
+
/// the same assembly (which would emit each member twice -- CS0102). It is a cheap no-op in the
|
|
686
|
+
/// steady state: once the folder is gone, <c>AssetDatabase.IsValidFolder</c> short-circuits on
|
|
687
|
+
/// every subsequent import.
|
|
688
|
+
/// </summary>
|
|
689
|
+
internal sealed class LegacyAnalyzerCopyCleanup : AssetPostprocessor
|
|
690
|
+
{
|
|
691
|
+
// Classic four-argument signature so this compiles on every supported Unity (2021.3+).
|
|
692
|
+
private static void OnPostprocessAllAssets(
|
|
693
|
+
string[] importedAssets,
|
|
694
|
+
string[] deletedAssets,
|
|
695
|
+
string[] movedAssets,
|
|
696
|
+
string[] movedFromAssetPaths
|
|
697
|
+
)
|
|
698
|
+
{
|
|
699
|
+
SetupCscRsp.TryRemoveLegacyAnalyzerCopy();
|
|
700
|
+
}
|
|
701
|
+
}
|
|
633
702
|
}
|
|
634
703
|
#endif
|
|
@@ -19,7 +19,10 @@ namespace DxMessaging.Editor.Testing
|
|
|
19
19
|
private static readonly MessageEmissionData[] EmptyEmissions =
|
|
20
20
|
Array.Empty<MessageEmissionData>();
|
|
21
21
|
|
|
22
|
-
internal static MessagingComponentInspectorState Capture(
|
|
22
|
+
internal static MessagingComponentInspectorState Capture(
|
|
23
|
+
MessagingComponent component,
|
|
24
|
+
bool resolveSerializedProviderBus = true
|
|
25
|
+
)
|
|
23
26
|
{
|
|
24
27
|
if (component == null)
|
|
25
28
|
{
|
|
@@ -43,7 +46,10 @@ namespace DxMessaging.Editor.Testing
|
|
|
43
46
|
.Select(pair => CreateListenerView(pair.Key, pair.Value))
|
|
44
47
|
.ToList();
|
|
45
48
|
|
|
46
|
-
ProviderDiagnosticsView providerDiagnostics = CreateProviderDiagnostics(
|
|
49
|
+
ProviderDiagnosticsView providerDiagnostics = CreateProviderDiagnostics(
|
|
50
|
+
component,
|
|
51
|
+
resolveSerializedProviderBus
|
|
52
|
+
);
|
|
47
53
|
|
|
48
54
|
return new MessagingComponentInspectorState(
|
|
49
55
|
globalDiagnosticsEnabled,
|
|
@@ -80,7 +86,8 @@ namespace DxMessaging.Editor.Testing
|
|
|
80
86
|
}
|
|
81
87
|
|
|
82
88
|
internal static ProviderDiagnosticsView CreateProviderDiagnostics(
|
|
83
|
-
MessagingComponent component
|
|
89
|
+
MessagingComponent component,
|
|
90
|
+
bool resolveSerializedProviderBus = true
|
|
84
91
|
)
|
|
85
92
|
{
|
|
86
93
|
bool autoConfigure = component.AutoConfigureSerializedProviderOnAwake;
|
|
@@ -91,7 +98,7 @@ namespace DxMessaging.Editor.Testing
|
|
|
91
98
|
bool serializedProviderMissingWarning = autoConfigure && !hasSerializedProvider;
|
|
92
99
|
|
|
93
100
|
bool serializedProviderNullBusWarning = false;
|
|
94
|
-
if (hasSerializedProvider)
|
|
101
|
+
if (hasSerializedProvider && resolveSerializedProviderBus)
|
|
95
102
|
{
|
|
96
103
|
IMessageBus resolvedBus = component.SerializedProviderHandle.ResolveBus();
|
|
97
104
|
serializedProviderNullBusWarning = resolvedBus == null;
|