Skip to content

Instantly share code, notes, and snippets.

@multinerd
Last active June 4, 2018 14:25
Show Gist options
  • Save multinerd/d6a2d7e922b1e563ed0098194ad0f322 to your computer and use it in GitHub Desktop.
Save multinerd/d6a2d7e922b1e563ed0098194ad0f322 to your computer and use it in GitHub Desktop.

Developement Checklist

App.xaml(.cs)

  1. Override OnStartup and OnExit.
  • Create TempDirectory (if needed)
  • Implement InstanceChecker to prevent multiple instances of an application from running.
  • Setup CrashReporter events and handlers
        public static TempDirectoryHelper TempDirectory = new TempDirectoryHelper("APPLICATION_NAME");

        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            
            if (!Debugger.IsAttached)
            {
                if (InstanceChecker.IsAppRunning(Process.GetCurrentProcess(), true))
                    Current.Shutdown(0);
                
                // Attach Crash Reporter events
                AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
                Current.DispatcherUnhandledException += DispatcherOnUnhandledException;
                TaskScheduler.UnobservedTaskException += TaskSchedulerOnUnobservedTaskException;
                System.Windows.Forms.Application.ThreadException += Application_ThreadException;
            }
            
            // Prism Bootstrapper
            var bootstrapper = new Bootstrapper();
            bootstrapper.Run();
        }

        protected override void OnExit(ExitEventArgs e)
        {
            InstanceChecker.Cleanup();
            base.OnExit(e);
        }
        
        #region Crash Reporter

        private void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
        {
            ReportCrash(e.Exception);
            //Environment.Exit(0);
        }

        private void TaskSchedulerOnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
        {
            ReportCrash(e.Exception);
            //Environment.Exit(0);
        }

        private void DispatcherOnUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            ReportCrash(e.Exception);
            //Environment.Exit(0);
        }

        private static void CurrentDomainOnUnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            ReportCrash((Exception)e.ExceptionObject);
            //Environment.Exit(0);
        }

        private static void ReportCrash(Exception exception, string developerMessage = "")
        {
            var crashReport = new CrashReport
            {
                FromEmail = "FROM",
                ToEmail = "TO",

                UserName = "USERNAME",
                Password = "PASSWORD",
                SmtpHost = "SMTPHOST",
                Port = PORT,
                EnableSSL = true,

                IncludeScreenshot = true,
                CaptureType = CaptureType.Screen,
                DeveloperMessage = developerMessage,
                Exception = exception,
            };
            crashReport.Send(exception);
        }

        #endregion
  1. Edit .csproj file.
<Target Name="BeforePublish">
	<Error Condition="'$(DebugSymbols)' == 'true'" Text="Hey dumbass, dont publish using debug configurations!!" />
</Target>

Development Checklist

Custom Build Scripts

  1. Generate a constants file by grabbing identifiers from storyboards in a project. Link
sbconstants ${SRCROOT}/${PROJECT}/Constants.swift --swift
  1. Flag TODOs, FIXMEs & WARNINGs
TAGS="TODO:|FIXME:|WARNING:"
echo "searching ${SRCROOT} for ${TAGS}"
find "${SRCROOT}" \( -name "*.swift" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).*\$" | perl -p -e "s/($TAGS)/ warning: \$1/"
  1. SwiftLint Link
if which swiftlint >/dev/null; then
swiftlint
else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi

Documentations

  1. Jazzy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment