private void RenameMetaFile(FileSystemPath oldPath, FileSystemPath newPath, string extraDetails) { try { myLogger.Info("*** resharper-unity: Meta renamed{2} {0} -> {1}", oldPath, newPath, extraDetails); oldPath.MoveFile(newPath, true); } catch (Exception e) { myLogger.LogException(LoggingLevel.ERROR, e, ExceptionOrigin.Assertion, $"Failed to rename Unity meta file {oldPath} -> {newPath}"); } }
public int Execute() { if (!_symbolsFile.ExistsFile) { Console.Error.WriteLine("PDB file {0} does not exist.", _symbolsFile); return(1); } if (!_sourceDescriptorFile.ExistsFile) { Console.Error.WriteLine("Source descriptor file {0} does not exist.", _sourceDescriptorFile); return(1); } try { DebugInfoType debugInfoType; if (!PdbUtils.TryGetPdbType(_symbolsFile, out debugInfoType)) { throw new Exception("Invalid PDB file " + _symbolsFile); } if (debugInfoType != DebugInfoType.Portable) { throw new Exception(string.Format("Cannot update PDB file ${0}. PDB Type {1} is not supported", _symbolsFile, debugInfoType)); } var sourceDescriptor = ReadSourceDescriptor(_sourceDescriptorFile); if (sourceDescriptor.Documents == null) { throw new Exception(string.Format("Source Link file ${0} is empty", _sourceDescriptorFile)); } var symbolsFile = _symbolsFile.AddSuffix(".original"); _symbolsFile.MoveFile(symbolsFile, true); if (!PortablePdbModifier.AddSourceLink(symbolsFile, _sourceDescriptorFile, _symbolsFile)) { throw new Exception(string.Format("Cannot update PDB file ${0}. Internal error", symbolsFile)); } } catch (Exception e) { Console.Error.WriteLine("Unable to update PDF file {0}: {1} ", _symbolsFile, e.Message); return(1); } return(0); }
private void DeleteMetaFile(FileSystemPath path) { try { if (path.ExistsFile) { #if DEBUG myLogger.Info("*** resharper-unity: Meta removed (ish) {0}", path); path.MoveFile(FileSystemPath.Parse(path + ".deleted"), true); #else myLogger.Info("*** resharper-unity: Meta removed {0}", path); path.DeleteFile(); #endif } } catch (Exception e) { myLogger.LogException(LoggingLevel.ERROR, e, ExceptionOrigin.Assertion, $"Failed to delete Unity meta file {path}"); } }