private bool AddRuntimeSpecificAssetGroups(string assetType, IEnumerable <RuntimeAssetGroup> assetGroups, bool wroteObjectStart, ref UnifiedJsonWriter jsonWriter) { IEnumerable <RuntimeAssetGroup> groups = assetGroups.Where(g => !string.IsNullOrEmpty(g.Runtime)); if (!wroteObjectStart && groups.Any()) { jsonWriter.WriteStartObject(DependencyContextStrings.RuntimeTargetsPropertyName, escape: false); wroteObjectStart = true; } foreach (RuntimeAssetGroup group in groups) { if (group.RuntimeFiles.Any()) { AddRuntimeSpecificAssets(group.RuntimeFiles, group.Runtime, assetType, ref jsonWriter); } else { // Add a placeholder item // We need to generate a pseudo-path because there could be multiple different asset groups with placeholders // Only the last path segment matters, the rest is basically just a GUID. string pseudoPathFolder = assetType == DependencyContextStrings.RuntimeAssetType ? "lib" : "native"; jsonWriter.WriteStartObject($"runtime/{group.Runtime}/{pseudoPathFolder}/_._"); jsonWriter.WriteString(DependencyContextStrings.RidPropertyName, group.Runtime, escape: false); jsonWriter.WriteString(DependencyContextStrings.AssetTypePropertyName, assetType, escape: false); jsonWriter.WriteEndObject(); } } return(wroteObjectStart); }
private void AddStringPropertyIfNotNull(string name, string value, ref UnifiedJsonWriter jsonWriter) { if (value != null) { jsonWriter.WriteString(name, value, escape: true); } }
private void WriteRuntimeTargetInfo(DependencyContext context, ref UnifiedJsonWriter jsonWriter) { jsonWriter.WriteStartObject(DependencyContextStrings.RuntimeTargetPropertyName, escape: false); if (context.Target.IsPortable) { jsonWriter.WriteString(DependencyContextStrings.RuntimeTargetNamePropertyName, context.Target.Framework, escape: false); } else { jsonWriter.WriteString(DependencyContextStrings.RuntimeTargetNamePropertyName, context.Target.Framework + DependencyContextStrings.VersionSeparator + context.Target.Runtime, escape: false); } jsonWriter.WriteString(DependencyContextStrings.RuntimeTargetSignaturePropertyName, context.Target.RuntimeSignature, escape: false); jsonWriter.WriteEndObject(); }
private void AddRuntimeSpecificAssets(IEnumerable <RuntimeFile> assets, string runtime, string assetType, ref UnifiedJsonWriter jsonWriter) { foreach (RuntimeFile asset in assets) { jsonWriter.WriteStartObject(NormalizePath(asset.Path)); jsonWriter.WriteString(DependencyContextStrings.RidPropertyName, runtime, escape: false); jsonWriter.WriteString(DependencyContextStrings.AssetTypePropertyName, assetType, escape: false); if (asset.AssemblyVersion != null) { jsonWriter.WriteString(DependencyContextStrings.AssemblyVersionPropertyName, asset.AssemblyVersion, escape: false); } if (asset.FileVersion != null) { jsonWriter.WriteString(DependencyContextStrings.FileVersionPropertyName, asset.FileVersion, escape: false); } jsonWriter.WriteEndObject(); } }
private void WriteAssetList(string key, IEnumerable <RuntimeFile> runtimeFiles, ref UnifiedJsonWriter jsonWriter) { jsonWriter.WriteStartObject(key, escape: false); foreach (RuntimeFile runtimeFile in runtimeFiles) { jsonWriter.WriteStartObject(NormalizePath(runtimeFile.Path)); if (runtimeFile.AssemblyVersion != null) { jsonWriter.WriteString(DependencyContextStrings.AssemblyVersionPropertyName, runtimeFile.AssemblyVersion, escape: false); } if (runtimeFile.FileVersion != null) { jsonWriter.WriteString(DependencyContextStrings.FileVersionPropertyName, runtimeFile.FileVersion, escape: false); } jsonWriter.WriteEndObject(); } jsonWriter.WriteEndObject(); }
private void AddDependencies(IEnumerable <Dependency> dependencies, ref UnifiedJsonWriter jsonWriter) { if (!dependencies.Any()) { return; } jsonWriter.WriteStartObject(DependencyContextStrings.DependenciesPropertyName, escape: false); foreach (Dependency dependency in dependencies) { jsonWriter.WriteString(dependency.Name, dependency.Version); } jsonWriter.WriteEndObject(); }
private void WriteLibrary(string key, Library library, ref UnifiedJsonWriter jsonWriter) { jsonWriter.WriteStartObject(key); jsonWriter.WriteString(DependencyContextStrings.TypePropertyName, library.Type, escape: false); jsonWriter.WriteBoolean(DependencyContextStrings.ServiceablePropertyName, library.Serviceable, escape: false); jsonWriter.WriteString(DependencyContextStrings.Sha512PropertyName, library.Hash, escape: false); if (library.Path != null) { jsonWriter.WriteString(DependencyContextStrings.PathPropertyName, library.Path, escape: false); } if (library.HashPath != null) { jsonWriter.WriteString(DependencyContextStrings.HashPathPropertyName, library.HashPath, escape: false); } if (library.RuntimeStoreManifestName != null) { jsonWriter.WriteString(DependencyContextStrings.RuntimeStoreManifestPropertyName, library.RuntimeStoreManifestName, escape: false); } jsonWriter.WriteEndObject(); }
private void AddResourceAssemblies(IEnumerable <ResourceAssembly> resourceAssemblies, ref UnifiedJsonWriter jsonWriter) { if (!resourceAssemblies.Any()) { return; } jsonWriter.WriteStartObject(DependencyContextStrings.ResourceAssembliesPropertyName, escape: false); foreach (ResourceAssembly resourceAssembly in resourceAssemblies) { jsonWriter.WriteStartObject(NormalizePath(resourceAssembly.Path)); jsonWriter.WriteString(DependencyContextStrings.LocalePropertyName, resourceAssembly.Locale, escape: false); jsonWriter.WriteEndObject(); } jsonWriter.WriteEndObject(); }