public static void Run(AssetItem assetItem, ILogger log, AssetAnalysisParameters parameters) { if (assetItem == null) { throw new ArgumentNullException("assetItem"); } if (log == null) { throw new ArgumentNullException("log"); } if (parameters == null) { throw new ArgumentNullException("parameters"); } if (assetItem.Package == null) { throw new InvalidOperationException("AssetItem must belong to an existing package"); } var package = assetItem.Package; // Check that there is no duplicate in assets if (package.Session != null) { var packages = package.FindDependencies(); foreach (var otherPackage in packages) { var existingAsset = otherPackage.Assets.Find(assetItem.Id); if (existingAsset != null) { log.Error("Assets [{0}] with id [{1}] from Package [{2}] is already loaded from package [{3}]", existingAsset.FullPath, existingAsset.Id, package.FullPath, existingAsset.Package.FullPath); } else { existingAsset = otherPackage.Assets.Find(assetItem.Location); if (existingAsset != null) { log.Error("Assets [{0}] with location [{1}] from Package [{2}] is already loaded from package [{3}]", existingAsset.FullPath, existingAsset.Location, package.FullPath, existingAsset.Package.FullPath); } } } } var assetReferences = AssetReferenceAnalysis.Visit(assetItem.Asset); if (package.Session != null && parameters.IsProcessingAssetReferences) { UpdateAssetReferences(assetItem, assetReferences, log, parameters); } // Update paths for asset items if (parameters.IsProcessingUPaths) { // Find where this asset item was previously stored (in a different package for example) CommonAnalysis.UpdatePaths(assetItem, assetReferences.Where(link => link.Reference is UPath), parameters); } }
/// <summary> /// Processes the UPaths on package (but not on assets, use <see cref="ProcessAssets"/> for this) /// </summary> public void ProcessPackageUPaths() { if (package.FullPath == null) { return; } var packageReferenceLinks = AssetReferenceAnalysis.Visit(package); CommonAnalysis.UpdatePaths(package, packageReferenceLinks.Where(link => link.Reference is UPath), Parameters); }
public static void Run(AssetItem assetItem, ILogger log, AssetAnalysisParameters parameters) { if (assetItem == null) { throw new ArgumentNullException(nameof(assetItem)); } if (log == null) { throw new ArgumentNullException(nameof(log)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } if (assetItem.Package == null) { throw new InvalidOperationException("AssetItem must belong to an existing package"); } var package = assetItem.Package; // Check that there is no duplicate in assets if (package.Session != null) { var packages = package.FindDependencies(); foreach (var otherPackage in packages) { var existingAsset = otherPackage.Assets.Find(assetItem.Id); if (existingAsset != null) { log.Error($"Assets [{existingAsset.FullPath}] with id [{existingAsset.Id}] from Package [{package.FullPath}] is already loaded from package [{existingAsset.Package.FullPath}]"); } else { existingAsset = otherPackage.Assets.Find(assetItem.Location); if (existingAsset != null) { log.Error($"Assets [{existingAsset.FullPath}] with location [{existingAsset.Location}] from Package [{package.FullPath}] is already loaded from package [{existingAsset.Package.FullPath}]"); } } } } var assetReferences = AssetReferenceAnalysis.Visit(assetItem.Asset); if (package.Session != null && parameters.IsProcessingAssetReferences) { UpdateAssetReferences(assetItem, assetReferences, log, parameters); } // Update paths for asset items if (parameters.IsProcessingUPaths) { // Find where this asset item was previously stored (in a different package for example) CommonAnalysis.UpdatePaths(assetItem, assetReferences.Where(link => link.Reference is UPath), parameters); // Source hashes are not processed by analysis, we need to manually indicate them to update SourceHashesHelper.UpdateUPaths(assetItem.Asset, assetItem.FullPath.GetParent(), parameters.ConvertUPathTo); } }