private static void UpdateSchema(string assemblyPath, CompilerMessage[] messages) { var asset = ProjectUtility.GetProjectAsset <TypeFieldSchema>(); if (asset != null) { asset.UpdateSchema(assemblyPath); ProjectUtility.UpdateProjectAsset(asset); } }
public void OnBeginAnalysis(AssemblyDefinition assemblyDefinition) { this.assembly = assemblyDefinition.FullName; if (cache == null) { cache = ProjectUtility.GetProjectAsset <SerializableMemberCache>(); } if (cache != null) { filterData = cache.typeFields.Select(field => (field: field.IsCreated ? field.Value : null, filter: new TypeFilter(field.Value?.GetCustomAttributes <TypeFilterAttribute>()?.ToArray()))) .Where(obj => obj.field != null && obj.field.GetCustomAttribute <HideInInspector>() == null && obj.filter.filterAttributes.Length > 0) .Select(obj => new TypeAnalysisData(obj.field, obj.filter)).ToList(); } updateCacheForAssembly = false; }
public static void Decompose(this Type type, Func <Type, FieldInfo, FieldInfo, string, string, TypeDecompositionOptions, bool> onDecomposition, TypeDecompositionOptions options = default) { if (!type.IsValueType) { throw new ArgumentException("Type must be Value Type.", nameof(type)); } if (onDecomposition == null) { throw new ArgumentException("No onDecomposition Callback detected.", nameof(onDecomposition)); } var schema = ProjectUtility.GetOrCreateProjectAsset <TypeFieldSchema>(); foreach (var field in type.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance).Where(field => field.GetCustomAttribute <HideInInspector>() == null)) { Decompose(field, null, JoinPath(options.initialPath, field.Name), string.Empty, onDecomposition, options); } }
public List <SerializableType> CollectSerializableTypes(FieldInfo fieldInfo) { var field = new SerializableField(fieldInfo); var cache = ProjectUtility.GetOrCreateProjectAsset <SerializableMemberCache>(); if (!cache.types.TryGetValue(field.FullName, out List <SerializableType> result)) { result = new List <SerializableType>(); foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { var output = new List <SerializableType>(); foreach (var type in assembly.GetTypes()) { if (type.GetCustomAttribute <HideInInspector>() == null && IsValid(type)) { output.Add(type); } } if (!output.IsEmpty()) { if (!cache.assemblyData.TryGetValue(assembly.FullName, out var data)) { data = new SerializableMemberCache.AssemblyData(); cache.assemblyData[assembly.FullName] = data; } data.types[field.FullName] = output; result.AddRange(output); } } if (!cache.typeFields.Contains(field)) { cache.typeFields.Add(field); } ProjectUtility.UpdateProjectAsset(cache); return(result); } else { return(result.Where(r => r.IsCreated && IsValid(r)).ToList()); } }
public void OnEndAnalysis(AssemblyDefinition assemblyDefinition) { if (cache == null) { cache = ProjectUtility.GetProjectAsset <SerializableMemberCache>(); } if (cache != null) { if (updateCacheForAssembly) { cache.assemblyData[assembly] = new SerializableMemberCache.AssemblyData { types = filterData.Where(fd => !fd.filteredTypes.IsEmpty()).ToDictionary(d => d.FullName, d => d.filteredTypes) }; } else { cache.assemblyData.Remove(assembly); } ProjectUtility.UpdateProjectAsset(cache); } }