static AsmDefConfigFile() { Json = JObject.Parse(new NPath("asmdefs.json").MakeAbsolute().ReadAllText()); UnityProjectPath = Json["UnityProjectPath"].Value <string>(); ProjectName = Json["ProjectName"].Value <string>(); UnityCompilationPipelineAssemblyPath = Json["CompilationPipelineAssemblyPath"].Value <string>(); BuildSettingsFileVersion = Json["BuildSettingsFileVersion"].Value <int>(); // asmrefs have to be created first, because they're used during construction of the asmdef description foreach (var asmref in Json["asmrefs"].Values <JObject>()) { var path = asmref["FullPath"].Value <string>().ToNPath(); var desc = new AsmRefDescription(path, asmref["PackageSource"].Value <string>()); _pathsToAsmRefDescription[path] = desc; } // then the Guid mapping has to be set up foreach (var asmdef in Json["asmdefs"].Values <JObject>()) { var name = asmdef["AsmdefName"].Value <string>(); GuidsToAsmDefNames[asmdef["Guid"].Value <string>()] = name; } // finally we can create the AsmDefDescriptions foreach (var asmdef in Json["asmdefs"].Values <JObject>()) { var name = asmdef["AsmdefName"].Value <string>(); var desc = new AsmDefDescription(asmdef["FullPath"].Value <string>(), asmdef["PackageSource"].Value <string>()); _namesToAsmDefDescription[name] = desc; } }
public static AsmRefDescription AsmRefDescriptionFor(NPath path) { if (_pathsToAsmRefDescription.TryGetValue(path, out var result)) { return(result); } var jobject = Json["asmrefs"].Values <JObject>().FirstOrDefault(o => o["FullPath"].Value <string>().ToNPath() == path); if (jobject == null) { return(null); } result = new AsmRefDescription(jobject["FullPath"].Value <string>(), jobject["PackageSource"].Value <string>()); _pathsToAsmRefDescription[path] = result; return(result); }