private bool TryGetValue(object obj, object[] indices, out object value) { try { value = this.targetProperty.GetValue(obj, indices); return(true); } catch (Exception e) { if (e is TargetInvocationException) { e = e.InnerException; } if (indices != null && indices.Length > 0) { Logs.Editor.WriteError( "An error occurred trying to get property {0}.{1}[{2}]: {3}", LogFormat.Type(this.targetProperty.DeclaringType), this.targetProperty.Name, indices.ToString(", "), LogFormat.Exception(e)); } else { Logs.Editor.WriteError( "An error occurred trying to get property {0}.{1}: {2}", LogFormat.Type(this.targetProperty.DeclaringType), this.targetProperty.Name, LogFormat.Exception(e)); } value = null; return(false); } }
private PackageUpdateSchedule PrepareUpdateSchedule() { // Load existing update schedule in order to extend it string updateFilePath = this.env.UpdateFilePath; PackageUpdateSchedule updateSchedule = null; if (File.Exists(updateFilePath)) { try { updateSchedule = PackageUpdateSchedule.Load(updateFilePath); } catch (Exception exception) { updateSchedule = null; Logs.Editor.WriteError("Error parsing existing package update schedule '{0}': {1}", Path.GetFileName(updateFilePath), LogFormat.Exception(exception)); } } // If none existed yet, create a fresh update schedule if (updateSchedule == null) { updateSchedule = new PackageUpdateSchedule(); } return(updateSchedule); }
private static void ArchiveOldLogfile() { try { // If there is an existing logfile, archive it for diagnostic purposes FileInfo prevLogfile = new FileInfo(DualityEditorApp.EditorLogfilePath); if (prevLogfile.Exists) { if (!Directory.Exists(DualityEditorApp.EditorPrevLogfileDir)) { Directory.CreateDirectory(DualityEditorApp.EditorPrevLogfileDir); } string timestampToken = prevLogfile.LastWriteTimeUtc.ToString("yyyy-MM-dd-T-HH-mm-ss"); string prevLogfileName = string.Format(DualityEditorApp.EditorPrevLogfileName, timestampToken); string prevLogFilePath = Path.Combine(DualityEditorApp.EditorPrevLogfileDir, prevLogfileName); prevLogfile.MoveTo(prevLogFilePath); } } catch (Exception e) { Logs.Core.WriteWarning("Unable to archive old logfile: {0}", LogFormat.Exception(e)); } }
private MemberInfo ReadMemberInfo(ObjectHeader header) { MemberInfo result = null; try { if (header.DataType == DataType.Type) { string typeString = this.reader.ReadString(); Type type = this.ResolveType(typeString, header.ObjectId); result = (type != null) ? type.GetTypeInfo() : null; } else { string memberString = this.reader.ReadString(); result = this.ResolveMember(memberString, header.ObjectId); } } catch (Exception e) { result = null; this.LocalLog.WriteError( "An error occurred in deserializing MemberInfo object Id {0} of type '{1}': {2}", header.ObjectId, LogFormat.Type(header.DataType.ToActualType()), LogFormat.Exception(e)); } // Prepare object reference this.idManager.Inject(result, header.ObjectId); return(result); }
private static System.Collections.IEnumerable PackageOperationThread(ProcessingBigTaskDialog.WorkerInterface workerInterface) { PackageOperationData data = workerInterface.Data as PackageOperationData; workerInterface.Progress = -1.0f; if (data.Package.Version != null) { workerInterface.StateDesc = string.Format("Package '{0}', Version {1}...", data.Package.Id, data.Package.Version); } else { workerInterface.StateDesc = string.Format("Package '{0}'...", data.Package.Id); } yield return(null); try { data.Operation(data); } catch (Exception e) { Logs.Editor.WriteError("An error occurred while processing Package '{0}', Version {1}: {2}", data.Package.Id, data.Package.Version, LogFormat.Exception(e)); workerInterface.Error = e; } yield break; }
/// <summary> /// Logs an error that occurred during <see cref="Duality.Serialization.ISerializeExplicit">custom deserialization</see>. /// </summary> /// <param name="objId">The object id of the affected object.</param> /// <param name="serializeType">The <see cref="System.Type"/> of the affected object.</param> /// <param name="e">The <see cref="System.Exception"/> that occurred.</param> protected void LogCustomDeserializationError(uint objId, TypeInfo serializeType, Exception e) { this.log.WriteError( "An error occurred in custom deserialization in object Id {0} of type '{1}': {2}", objId, LogFormat.Type(serializeType), LogFormat.Exception(e)); }
private void OnDispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) { try { Logs.Editor.WriteError(LogFormat.Exception(e.Exception)); } catch (Exception) { /* Ensure we're not causing any further exception by logging... */ } }
private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) { try { Logs.Editor.WriteError(LogFormat.Exception(e.Exception)); } catch (Exception) { /* Ensure we're not causing any further exception by logging... */ } }
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { try { Logs.Editor.WriteError(LogFormat.Exception(e.ExceptionObject as Exception)); } catch (Exception) { /* Ensure we're not causing any further exception by logging... */ } }
private static IEnumerable SynchronizePackages(ProcessingBigTaskDialog.WorkerInterface workerInterface) { PackageManager manager = workerInterface.Data as PackageManager; // Set the working state and yield, so the UI can update properly in case we're in the main thread workerInterface.Progress = 0.0f; workerInterface.StateDesc = GeneralRes.TaskPrepareInfo; yield return(null); // Retrieve all registered Duality packages and sort them so we don't accidentally install an old dependency LocalPackage[] packagesToVerify = manager.LocalSetup.Packages.ToArray(); manager.OrderByDependencies(packagesToVerify); yield return(null); // Uninstall all "shadow" Duality packages that are installed, but not registered Logs.Editor.Write("Removing unregistered packages..."); Logs.Editor.PushIndent(); manager.UninstallNonRegisteredPackages(); Logs.Editor.PopIndent(); yield return(null); // Iterate over previously reigstered local packages and verify / install them. Logs.Editor.Write("Verifying registered packages..."); Logs.Editor.PushIndent(); foreach (LocalPackage package in packagesToVerify) { // Update the task dialog's UI if (package.Version != null) { workerInterface.StateDesc = string.Format("Package '{0}', Version {1}...", package.Id, package.Version); } else { workerInterface.StateDesc = string.Format("Package '{0}'...", package.Id); } workerInterface.Progress += 0.5f / packagesToVerify.Length; yield return(null); // Verify / Install the local package as needed try { manager.VerifyPackage(package); } catch (Exception e) { Logs.Editor.WriteError("An error occurred verifying Package '{0}', Version {1}: {2}", package.Id, package.Version, LogFormat.Exception(e)); } workerInterface.Progress += 0.5f / packagesToVerify.Length; yield return(null); } Logs.Editor.PopIndent(); yield break; }
/// <summary> /// Compiles the shader. This is done automatically when loading the shader /// or attaching it to a <see cref="DrawTechnique"/>. /// </summary> public void Compile() { Logs.Core.Write("Compiling {0} shader '{1}'...", this.Type, this.FullName); Logs.Core.PushIndent(); if (string.IsNullOrEmpty(this.source)) { Logs.Core.PopIndent(); throw new InvalidOperationException("Can't compile a shader without any source code specified."); } if (this.native == null) { this.native = CoheeApp.GraphicsBackend.CreateShaderPart(); } // Preprocess the source code to include builtin shader functions string processedSource = null; ShaderFieldInfo[] fields = null; try { ShaderSourceBuilder builder = new ShaderSourceBuilder(); string typeConditional = string.Format("SHADERTYPE_{0}", this.Type).ToUpperInvariant(); builder.SetConditional(typeConditional, true); builder.SetMainChunk(this.source); foreach (string sharedChunk in CommonSourceChunks) { builder.AddSharedChunk(sharedChunk); } processedSource = builder.Build(); fields = builder.Fields.ToArray(); } catch (Exception e) { Logs.Core.WriteError("Failed to preprocess shader:{1}{0}", LogFormat.Exception(e), Environment.NewLine); } // Load the shader on the backend side if (processedSource != null) { try { this.native.LoadSource(processedSource, this.Type); } catch (Exception e) { Logs.Core.WriteError("Failed to compile shader:{1}{0}", LogFormat.Exception(e), Environment.NewLine); } } this.fields = fields; this.compiled = true; Logs.Core.PopIndent(); }
private ExportInputAssignment SelectImporter(AssetExportEnvironment env) { if (!env.IsPrepareStep) { throw new ArgumentException( "The specified export environment must be configured as a preparation environment.", "env"); } // Find an importer to handle some or all of the unhandled input files List <ExportInputAssignment> candidates = new List <ExportInputAssignment>(); foreach (IAssetImporter importer in AssetManager.Importers) { env.ResetAcquiredData(); try { importer.PrepareExport(env); } catch (Exception ex) { Logs.Editor.WriteError("An error occurred in the preparation step of '{1}': {0}", LogFormat.Exception(ex), LogFormat.Type(importer.GetType())); continue; } if (env.IsHandled) { candidates.Add(new ExportInputAssignment { Importer = importer, ExpectedOutput = env.OutputPaths.ToArray() }); } } // If multiple importers intend to handle the same files, resolve conflicts if (candidates.Count > 1) { ExportInputAssignment[] conflictingAssignments = candidates.ToArray(); int selectedIndex = this.ResolveMappingConflict(env.Input, conflictingAssignments); if (selectedIndex == -1) { return(default(ExportInputAssignment)); } else { return(conflictingAssignments[selectedIndex]); } } return(candidates.FirstOrDefault()); }
/// <summary> /// Initializes duality but does not yet run it. /// </summary> /// <param name="launcherArgs"></param> public DualityLauncher(LauncherArgs launcherArgs = null) { if (launcherArgs == null) { launcherArgs = new LauncherArgs(); } System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.InvariantCulture; // Set up console logging this.AddGlobalOutput(new ConsoleLogOutput()); // Set up file logging try { StreamWriter logfileWriter = new StreamWriter("logfile.txt"); logfileWriter.AutoFlush = true; this.disposables.Push(logfileWriter); this.AddGlobalOutput(new TextWriterLogOutput(logfileWriter)); } catch (Exception e) { Logs.Core.WriteWarning("Text Logfile unavailable: {0}", LogFormat.Exception(e)); } // Set up a global exception handler to log errors AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; // Write initial log message before actually booting Duality Logs.Core.Write("Running DualityLauncher with flags: {1}{0}", Environment.NewLine, launcherArgs); // Initialize the Duality core DualityApp.Init( DualityApp.ExecutionEnvironment.Launcher, DualityApp.ExecutionContext.Game, new DefaultAssemblyLoader(), launcherArgs); // Open up a new window WindowOptions options = new WindowOptions { Size = DualityApp.UserData.Instance.WindowSize, ScreenMode = launcherArgs.IsDebugging ? ScreenMode.Window : DualityApp.UserData.Instance.WindowMode, RefreshMode = launcherArgs.IsProfiling ? RefreshMode.NoSync : DualityApp.UserData.Instance.WindowRefreshMode, Title = DualityApp.AppData.Instance.AppName, SystemCursorVisible = launcherArgs.IsDebugging || DualityApp.UserData.Instance.SystemCursorVisible }; this.window = DualityApp.OpenWindow(options); }
/// <summary> /// Applies this PrefabLinks change list to its GameObject. This will restore /// all deliberate modifications (made in the editor) of the GameObjects Properties /// after linking it to the Prefab. /// </summary> public void ApplyChanges() { if (this.changes == null || this.changes.Count == 0) { return; } for (int i = 0; i < this.changes.Count; i++) { GameObject targetObj = this.obj.GetChildAtIndexPath(this.changes[i].childIndex); object target; if (this.changes[i].componentType != null) { target = targetObj.GetComponent(this.changes[i].componentType); } else { target = targetObj; } if (this.changes[i].prop != null && target != null) { object applyVal = null; try { CloneType cloneType = CloneProvider.GetCloneType(this.changes[i].prop.PropertyType); if (cloneType.Type.IsValueType || cloneType.DefaultCloneBehavior != CloneBehavior.ChildObject) { applyVal = this.changes[i].val; } else { applyVal = this.changes[i].val.DeepClone(); } this.changes[i].prop.SetValue(target, applyVal, null); } catch (Exception e) { Logs.Core.WriteError( "Error applying PrefabLink changes in {0}, property {1}:\n{2}", this.obj.FullName, this.changes[i].prop.Name, LogFormat.Exception(e)); } } else { this.changes.RemoveAt(i); i--; continue; } } }
public PackageManager(PackageManagerEnvironment workEnvironment, PackageSetup packageSetup) { // If no external package setup is provided, load it from the config file if (packageSetup == null) { string configFilePath = workEnvironment.ConfigFilePath; if (!File.Exists(configFilePath)) { packageSetup = new PackageSetup(); packageSetup.Save(configFilePath); } else { try { packageSetup = PackageSetup.Load(configFilePath); } catch (Exception e) { Logs.Editor.WriteError( "Failed to load PackageManager config file '{0}': {1}", configFilePath, LogFormat.Exception(e)); } } } // Assign work environment and package setup to work with this.env = workEnvironment; this.setup = packageSetup; // Create internal package management objects IPackageRepository[] repositories = this.setup.RepositoryUrls .Select(x => this.CreateRepository(x)) .Where(x => x != null) .ToArray(); this.repository = new AggregateRepository(repositories); this.manager = new NuGet.PackageManager(this.repository, this.env.RepositoryPath); this.manager.PackageInstalling += this.manager_PackageInstalling; this.manager.PackageInstalled += this.manager_PackageInstalled; this.manager.PackageUninstalled += this.manager_PackageUninstalled; this.cache = new PackageCache( this.repository, repositories.OfType <LocalPackageRepository>().Any()); this.logger = new PackageManagerLogger(); this.manager.Logger = this.logger; this.dependencyWalker = new PackageDependencyWalker(this.GetPackage); // Retrieve information about local packages this.RetrieveLocalPackageInfo(); }
private void ReadHeader() { long initialPos = this.reader.BaseStream.Position; try { byte length = this.reader.ReadByte(); if (length != HeaderId.Length) { throw new Exception("Header ID does not match."); } string headerId = System.Text.Encoding.UTF8.GetString(this.reader.ReadBytes(HeaderId.Length), 0, HeaderId.Length); if (headerId != HeaderId) { throw new Exception("Header ID does not match."); } this.dataVersion = this.reader.ReadUInt16(); if (this.dataVersion < MinVersion) { throw new NotSupportedException(string.Format("Binary data version {0} is below minimum version {1}", this.dataVersion, MinVersion)); } // Create "Safe zone" for additional data long lastPos = this.reader.BaseStream.Position; long offset = this.reader.ReadInt64(); try { // --[ Insert reading additional data here ]-- // If we read the object properly and aren't where we're supposed to be, something went wrong if (this.reader.BaseStream.Position != lastPos + offset) { throw new Exception(string.Format("Wrong dataset offset: '{0}' instead of expected value '{1}'.", offset, this.reader.BaseStream.Position - lastPos)); } } catch (Exception e) { // If anything goes wrong, assure the stream position is valid and points to the next data entry this.reader.BaseStream.Seek(lastPos + offset, SeekOrigin.Begin); this.LocalLog.WriteError("Error reading header at '{0:X8}'-'{1:X8}': {2}", lastPos, lastPos + offset, LogFormat.Exception(e)); } } catch (Exception e) { this.reader.BaseStream.Seek(initialPos, SeekOrigin.Begin); this.LocalLog.WriteError("Error reading header: {0}", LogFormat.Exception(e)); } }
public override void Perform(Prefab prefab) { try { CreateGameObjectAction undoRedoAction = new CreateGameObjectAction(null, prefab.Instantiate()); UndoRedoManager.Do(undoRedoAction); DualityEditorApp.Select(this, new ObjectSelection(undoRedoAction.Result)); } catch (Exception exception) { Logs.Editor.WriteError("An error occurred instanciating Prefab {1}: {0}", LogFormat.Exception(exception), prefab != null ? prefab.Path : "null"); } }
/// <summary> /// Retrieves all capability values from the currently active graphics context. /// </summary> public void RetrieveFromAPI() { // Reset all values to default / undefined so we'll end up with only the values we successfully retrieved this.Reset(); // Accessing OpenGL functionality requires context. Don't get confused by AccessViolationExceptions, fail better instead. GraphicsContext.Assert(); // Retrieve raw values from OpenGL try { GraphicsBackend.CheckOpenGLErrors(); this.glVersionString = GL.GetString(StringName.Version); this.glVendor = GL.GetString(StringName.Vendor); this.glRenderer = GL.GetString(StringName.Renderer); this.glslVersionString = GL.GetString(StringName.ShadingLanguageVersion); GraphicsBackend.CheckOpenGLErrors(); } catch (Exception e) { Logs.Core.WriteWarning( "Unable to determine OpenGL base specs: {0}", LogFormat.Exception(e)); } // Retrieve extended / in-depth specs from OpenGL try { GraphicsBackend.CheckOpenGLErrors(); GL.GetInteger(GetPName.MaxTextureSize, out this.maxTextureSize); GL.GetInteger(GetPName.MaxTextureImageUnits, out this.maxTextureBindings); GL.GetInteger(GetPName.MaxRenderbufferSize, out this.maxRenderTargetSize); GraphicsBackend.CheckOpenGLErrors(); } catch (Exception e) { Logs.Core.WriteWarning( "Unable to determine OpenGL extended specs: {0}", LogFormat.Exception(e)); } // Parse raw values such as version strings for higher level info this.TryParseVersionString(this.glVersionString, out this.glVersion); this.TryParseVersionString(this.glslVersionString, out this.glslVersion); // Translate some of the GL-specific attributes to the generalized base class ones this.apiVersion = this.glslVersion; }
public override void Perform(Scene scene) { string lastPath = Scene.CurrentPath; try { Scene.SwitchTo(scene); } catch (Exception exception) { Logs.Editor.WriteError("An error occurred while switching from Scene {1} to Scene {2}: {0}", LogFormat.Exception(exception), lastPath, scene != null ? scene.Path : "null"); } }
/// <summary> /// Renders the <see cref="Duality.Resources.Font"/> using the specified system font family. /// </summary> private FontData RenderGlyphs(FontFamily fontFamily, float emSize, FontStyle style, FontCharSet extendedSet, bool antialiasing, bool monospace) { // Determine System.Drawing font style SysDrawFontStyle systemStyle = SysDrawFontStyle.Regular; if (style.HasFlag(FontStyle.Bold)) { systemStyle |= SysDrawFontStyle.Bold; } if (style.HasFlag(FontStyle.Italic)) { systemStyle |= SysDrawFontStyle.Italic; } // Create a System.Drawing font SysDrawFont internalFont = null; if (fontFamily != null) { try { internalFont = new SysDrawFont(fontFamily, emSize, systemStyle); } catch (Exception e) { Logs.Editor.WriteError( "Failed to create System Font '{1} {2}, {3}' for rendering Duality Font glyphs: {0}", LogFormat.Exception(e), fontFamily.Name, emSize, style); } } // If creating the font failed, fall back to a default one if (internalFont == null) { internalFont = new SysDrawFont(FontFamily.GenericMonospace, emSize, systemStyle); } // Render the font's glyphs using (internalFont) { return(this.RenderGlyphs( internalFont, FontCharSet.Default.MergedWith(extendedSet), antialiasing, monospace)); } }
private static void WorkerThreadProc(object args) { WorkerInterface workInterface = args as WorkerInterface; workInterface.Error = null; workInterface.Progress = 0.0f; try { // All work is performed here. if (!workInterface.parent.MainThreadRequired) { var taskEnumerator = workInterface.Task(workInterface).GetEnumerator(); while (taskEnumerator.MoveNext()) { } } // All work is actually performed in the main thread. else { // Wait a little so the main thread has time for drawing the GUI. Thread.Sleep(20); // Perform task on the main thread - which is necessary because OpenGL and friends don't like multithreading. // In order to keep the GUI updated, the task is split into chunks. After each chunk, GUI events can be processed. var taskEnumerator = workInterface.Task(workInterface).GetEnumerator(); DateTime lastCheck = DateTime.Now; while ((bool)workInterface.TargetForm.Invoke((Func <bool>)taskEnumerator.MoveNext)) { TimeSpan lastTime = DateTime.Now - lastCheck; // Wait a little so the main thread has time for drawing the GUI. if (lastTime.TotalMilliseconds > 1000.0f) { Thread.Sleep(20); lastCheck = DateTime.Now; } } } // Assume the task finished completely workInterface.Progress = 1.0f; } catch (Exception e) { Logs.Editor.WriteError("Failed to perform task: {0}", LogFormat.Exception(e)); workInterface.Error = e; } }
private void LoadDockPanelData(XElement dockPanelState) { Logs.Editor.Write("Loading DockPanel data..."); Logs.Editor.PushIndent(); using (MemoryStream dockPanelDataStream = new MemoryStream(Encoding.Default.GetBytes(dockPanelState.ToString()))) { try { this.MainDockPanel.LoadFromXml(dockPanelDataStream, DeserializeDockContent); } catch (Exception e) { Logs.Editor.WriteError("Cannot load DockPanel data: {0}", LogFormat.Exception(e)); } } Logs.Editor.PopIndent(); }
private void WriteObjectData(XElement element, object obj) { // Null? Empty Element. if (obj == null) { return; } // Retrieve type data ObjectHeader header = this.PrepareWriteObject(obj); if (header == null) { return; } // Write data type header if (header.DataType != DataType.Unknown) { element.SetAttributeValue("dataType", header.DataType.ToString()); } if (header.IsObjectTypeRequired && !string.IsNullOrEmpty(header.TypeString)) { element.SetAttributeValue("type", header.TypeString); } if (header.IsObjectIdRequired && header.ObjectId != 0) { element.SetAttributeValue("id", XmlConvert.ToString(header.ObjectId)); } // Write object try { this.idManager.PushIdLevel(); this.WriteObjectBody(element, obj, header); } catch (Exception e) { // Log the error this.LocalLog.WriteError("Error writing object: {0}", LogFormat.Exception(e)); } finally { this.idManager.PopIdLevel(); } }
private static void CreateLogfile() { if (logfileOutput != null || logfileWriter != null) { CloseLogfile(); } try { logfileWriter = new StreamWriter(DualityEditorApp.EditorLogfilePath); logfileWriter.AutoFlush = true; logfileOutput = new TextWriterLogOutput(logfileWriter); Logs.AddGlobalOutput(logfileOutput); } catch (Exception e) { Logs.Core.WriteWarning("Unable to create logfile: {0}", LogFormat.Exception(e)); } }
/// <summary> /// Starts applying any pending package updates and returns true when it is required /// to shut down the current editor instance in order to complete them. /// </summary> /// <param name="restartEditor"> /// Whether the current editor instance should be restarted after the update has been applied. /// </param> /// <returns></returns> public bool ApplyUpdate(bool restartEditor = true) { if (!File.Exists(this.env.UpdateFilePath)) { return(false); } Logs.Editor.Write("Applying package update..."); Logs.Editor.PushIndent(); try { // Manually perform update operations on the updater itself try { Logs.Editor.Write("Preparing updater..."); PackageUpdateSchedule schedule = this.PrepareUpdateSchedule(); schedule.ApplyUpdaterChanges(this.env.UpdaterExecFilePath); this.SaveUpdateSchedule(schedule); } catch (Exception e) { Logs.Editor.WriteError( "Can't update '{0}', because an error occurred: {1}", this.env.UpdaterExecFilePath, LogFormat.Exception(e)); return(false); } // Run the updater application Logs.Editor.Write("Running updater..."); Process.Start(this.env.UpdaterExecFilePath, string.Format("\"{0}\" \"{1}\" \"{2}\"", this.env.UpdateFilePath, restartEditor ? typeof(DualityEditorApp).Assembly.Location : "", restartEditor ? Environment.CurrentDirectory : "")); } finally { Logs.Editor.PopIndent(); } return(true); }
public static bool BuildSolutionFile(string solutionFile, string configuration) { try { return(_BuildSolutionFile(solutionFile, configuration)); } catch (FileNotFoundException e) { // This will be caught when the binding redirect from the old .Net MsBuild to the new VS MsBuild failed. Logs.Editor.WriteError("An error occurred while attempting to build a VS solution file: {0}{1}{1}This error usually means the binding redirect from the old .Net 4.0 MsBuild to the new Visual Studio MsBuild failed. To fix this, upgrade to any version of Visual Studio 2013.", LogFormat.Exception(e), Environment.NewLine); return(false); } catch (Exception e) { Logs.Editor.WriteError("An error occurred while attempting to build a VS solution file: {0}", LogFormat.Exception(e)); return(false); } }
/// <summary> /// Uses a (seekable, random access) Stream to detect the serializer that can handle it. /// </summary> /// <param name="stream"></param> /// <returns></returns> public static Type Detect(Stream stream) { if (!stream.CanRead || !stream.CanSeek) { throw new ArgumentException("The specified Stream needs to be readable, seekable and provide random-access functionality."); } if (stream.Length == 0) { throw new InvalidOperationException("The specified stream must not be empty."); } IList <Serializer> tempSerializers = TempCheckSerializers; for (int i = tempSerializers.Count - 1; i >= 0; i--) { Serializer serializer = tempSerializers[i]; long oldPos = stream.Position; try { if (serializer.MatchesStreamFormat(stream)) { return(serializer.GetType()); } } catch (Exception e) { Logs.Core.WriteError( "An error occurred while asking {0} whether it matched the format of a certain Stream: {1}", LogFormat.Type(serializer.GetType()), LogFormat.Exception(e)); } finally { stream.Seek(oldPos, SeekOrigin.Begin); } } return(null); }
private static void WorkerThreadProc(object args) { WorkerInterface workInterface = args as WorkerInterface; bool fullRestart = false; try { // Reload plugins the regular way. PerformPluginReload(workInterface, ref fullRestart); } catch (Exception e) { // If we failed for an unknown reason, let's try a full restart instead. if (!fullRestart) { Logs.Editor.WriteError("Failed reloading plugins during runtime: {0}", LogFormat.Exception(e)); Logs.Editor.Write("Trying full restart..."); try { // Try again, with a forced full restart fullRestart = true; PerformPluginReload(workInterface, ref fullRestart); } catch (Exception e2) { // Failed anyway? Log the error and stop. Logs.Editor.WriteError(LogFormat.Exception(e2)); workInterface.Error = e2; } } // If even a full restart has failed, log the error and stop right there. else { Logs.Editor.WriteError(LogFormat.Exception(e)); workInterface.Error = e; } } }
private static System.Collections.IEnumerable PackageUpdateAllThread(ProcessingBigTaskDialog.WorkerInterface workerInterface) { PackageManager manager = workerInterface.Data as PackageManager; workerInterface.Progress = 0.0f; workerInterface.StateDesc = GeneralRes.TaskPrepareInfo; yield return(null); // Determine which packages need to be updated PackageInfo[] updatePackages = manager.GetUpdatablePackages().ToArray(); // Sort packages by their dependencies so we don't accidentally install multiple versions manager.OrderByDependencies(updatePackages); // Start the updating process foreach (PackageInfo package in updatePackages) { workerInterface.Progress += 1.0f / updatePackages.Length; workerInterface.StateDesc = string.Format("Package '{0}'...", package.Id); yield return(null); try { manager.UpdatePackage(package.Name); } catch (Exception e) { Logs.Editor.WriteError("An error occurred while updating Package '{0}', Version {1}: {2}", package.Id, package.Version, LogFormat.Exception(e)); workerInterface.Error = e; } } workerInterface.Progress = 1.0f; yield break; }
private bool RunImporter(AssetExportEnvironment env, ExportInputAssignment assignment, IList <string> outputPathCollection) { try { assignment.Importer.Export(env); // Get a list on properly registered output Resources and report warnings on the rest foreach (string outputPath in env.OutputPaths) { FileEventManager.FlagPathEditorModified(outputPath); if (!assignment.ExpectedOutput.Contains(outputPath)) { Logs.Editor.WriteWarning( "AssetImporter '{0}' created an unpredicted output file: '{1}'. " + Environment.NewLine + "This may cause problems in the Asset Management system, especially during Asset re-import. " + Environment.NewLine + "Please fix the implementation of the PrepareExport method so it properly calls AddOutputPath for each predicted output file.", LogFormat.Type(assignment.Importer.GetType()), outputPath); } else { outputPathCollection.Add(outputPath); } } } catch (Exception ex) { Logs.Editor.WriteError("An error occurred while trying to export Resource '{2}' using '{1}': {0}", LogFormat.Exception(ex), LogFormat.Type(assignment.Importer.GetType()), env.Input); return(false); } return(true); }