Skip to content

Commit

Permalink
fix: namespace conflict for VVMW cuasing u# not to compile
Browse files Browse the repository at this point in the history
thanks orels1
  • Loading branch information
DeltaNeverUsed committed Jul 29, 2024
1 parent d8a7094 commit 5c4bfdd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ public class UdonSharpTimerInjector : CSharpSyntaxRewriter {
SyntaxFactory.ParseStatement(
@"{
var fakeSelf = (UdonSharp.UdonSharpBehaviour)GetProgramVariable(UdonSharpProfiler.UdonProfilerConsts.StopwatchSelfKey);
var root = (VRC.SDK3.Data.DataDictionary)fakeSelf.GetProgramVariable(UdonSharpProfiler.UdonProfilerConsts.StopwatchHeapKey);
var parent = (VRC.SDK3.Data.DataDictionary)fakeSelf.GetProgramVariable(UdonSharpProfiler.UdonProfilerConsts.StopwatchHeapParentKey);
var root = (Profiler_Data.DataDictionary)fakeSelf.GetProgramVariable(UdonSharpProfiler.UdonProfilerConsts.StopwatchHeapKey);
var parent = (Profiler_Data.DataDictionary)fakeSelf.GetProgramVariable(UdonSharpProfiler.UdonProfilerConsts.StopwatchHeapParentKey);
var info = new VRC.SDK3.Data.DataDictionary();
var info = new Profiler_Data.DataDictionary();
var name = (string)GetProgramVariable(UdonSharpProfiler.UdonProfilerConsts.StopwatchNameKey);
info.Add(""parent"", parent);
info.Add(""name"", name);
info.Add(""start"", System.Diagnostics.Stopwatch.GetTimestamp());
info.Add(""end"", (long)0);
info.Add(""children"", new VRC.SDK3.Data.DataList());
info.Add(""children"", new Profiler_Data.DataList());
if (VRC.SDKBase.Utilities.IsValid(parent)){
if (Profiler_Utilities.IsValid(parent)){
parent[""children""].DataList.Add(info);
}
else {
Expand All @@ -61,10 +61,10 @@ public class UdonSharpTimerInjector : CSharpSyntaxRewriter {
SyntaxFactory.ParseStatement(
@"{
var fakeSelf = (UdonSharp.UdonSharpBehaviour)GetProgramVariable(UdonSharpProfiler.UdonProfilerConsts.StopwatchSelfKey);
var parent = (VRC.SDK3.Data.DataDictionary)fakeSelf.GetProgramVariable(UdonSharpProfiler.UdonProfilerConsts.StopwatchHeapParentKey);
if (VRC.SDKBase.Utilities.IsValid(parent)) {
var parent = (Profiler_Data.DataDictionary)fakeSelf.GetProgramVariable(UdonSharpProfiler.UdonProfilerConsts.StopwatchHeapParentKey);
if (Profiler_Utilities.IsValid(parent)) {
parent[""end""] = System.Diagnostics.Stopwatch.GetTimestamp();
if (parent.TryGetValue(""parent"", VRC.SDK3.Data.TokenType.DataDictionary, out var value)) {
if (parent.TryGetValue(""parent"", Profiler_Data.TokenType.DataDictionary, out var value)) {
fakeSelf.SetProgramVariable(UdonSharpProfiler.UdonProfilerConsts.StopwatchHeapParentKey, value.DataDictionary);
} else {
fakeSelf.SetProgramVariable(UdonSharpProfiler.UdonProfilerConsts.StopwatchHeapParentKey, null);
Expand All @@ -78,6 +78,18 @@ public override SyntaxNode Visit(SyntaxNode node) {
_root = node as CompilationUnitSyntax;

if (_root != null) {
UsingDirectiveSyntax dataDictAlias = SyntaxFactory.UsingDirective(
SyntaxFactory.NameEquals(SyntaxFactory.IdentifierName("Profiler_Data")),
SyntaxFactory.ParseName("VRC.SDK3.Data"))
.WithTrailingTrivia(SyntaxFactory.ElasticCarriageReturnLineFeed);

UsingDirectiveSyntax utilitiesAlias = SyntaxFactory.UsingDirective(
SyntaxFactory.NameEquals(SyntaxFactory.IdentifierName("Profiler_Utilities")),
SyntaxFactory.ParseName("VRC.SDKBase.Utilities"))
.WithTrailingTrivia(SyntaxFactory.ElasticCarriageReturnLineFeed);

_root = _root.AddUsings(dataDictAlias, utilitiesAlias);

// Inject timing functions into the base classes
var classDeclarations = _root.DescendantNodes().OfType<ClassDeclarationSyntax>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ MonoBehaviour:
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
m_Name: ProfileDataReader
m_Name: ProfilerDataReader
m_EditorClassIdentifier:
serializedUdonProgramAsset: {fileID: 11400000, guid: 53381d2501873294ca1d8593d7cc1990, type: 2}
udonAssembly:
Expand Down
2 changes: 1 addition & 1 deletion Packages/deltaneverused.udonsharpprofiler/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "deltaneverused.udonsharpprofiler",
"displayName": "UdonSharp Profiler",
"version": "0.0.2",
"version": "0.0.3",
"unity": "2022.3",
"description": "Tool for profiling U# scripts",
"vpmDependencies": {
Expand Down

0 comments on commit 5c4bfdd

Please sign in to comment.