Cache owner and null-check

Cache owner and null-check

--- AngleSharp/DOM/Html/Basic/HTMLScriptElement.cs
+++ AngleSharp/DOM/Html/Basic/HTMLScriptElement.cs
@@ -147,7 +147,9 @@
         /// </summary>
         internal void Run()
         {
-            if (_load == null)
+            var owner = Owner;
+
+            if (_load == null || owner == null)
                 return;

             if (_load.Exception != null || _load.IsFaulted)
@@ -160,12 +162,12 @@
                 return;

             using (var result = _load.Result)
-                Owner.Options.RunScript(result, CreateOptions(), ScriptLanguage);
+                owner.Options.RunScript(result, CreateOptions(), ScriptLanguage);

             AfterScriptExecute();

             if (Source != null) Load();
-            else Owner.QueueTask(Load);
+            else owner.QueueTask(Load);
         }

         /// <summary>
@@ -174,17 +176,19 @@
         /// </summary>
         internal void Prepare()
         {
-            var options = Owner.Options;
-
-            if (_started)
-                return;
+            var owner = Owner;
+
+            if (_started || owner == null)
+                return;
+
+            var options = owner.Options;

             _wasParserInserted = _parserInserted;
             _parserInserted = false;

             _forceAsync = _wasParserInserted && !IsAsync;

-            if ((String.IsNullOrEmpty(Source) && String.IsNullOrEmpty(Text)) || Owner == null)
+            if ((String.IsNullOrEmpty(Source) && String.IsNullOrEmpty(Text)) || owner == null)
                 return;

             if (options.GetScriptEngine(ScriptLanguage) == null)
@@ -198,7 +202,7 @@

             _started = true;

-            if (!Owner.Options.IsScripting)
+            if (!owner.Options.IsScripting)
                 return;

             var eventAttr = GetAttribute(AttributeNames.Event);
@@ -222,7 +226,7 @@
             {
                 if (src == String.Empty)
                 {
-                    Owner.QueueTask(Error);
+                    owner.QueueTask(Error);
                     return;
                 }

@@ -232,12 +236,12 @@
                 if (requester == null)
                     return;

-                _load = requester.LoadWithCorsAsync(url, CrossOrigin.ToEnum(CorsSetting.None), Owner.Origin, OriginBehavior.Taint);
+                _load = requester.LoadWithCorsAsync(url, CrossOrigin.ToEnum(CorsSetting.None), owner.Origin, OriginBehavior.Taint);

                 if (_parserInserted && !IsAsync)
                 {
                     if (IsDeferred)
-                        Owner.AddScript(this);
+                        owner.AddScript(this);

                     _load.ContinueWith(task => _readyToBeExecuted = true);
                 }
@@ -245,13 +249,13 @@
                 {
                     //The element must be added to the end of the list of scripts that will execute in order as soon as possible associated
                     //with the Document of the script element at the time the prepare a script algorithm started.
-                    Owner.AddScript(this);
+                    owner.AddScript(this);
                 }
                 else
                 {
                     //The element must be added to the set of scripts that will execute as soon as possible of the Document of the
                     //script element at the time the prepare a script algorithm started.
-                    Owner.AddScript(this);
+                    owner.AddScript(this);
                 }
             }
             else if (_parserInserted)


TimePoint - Three -> FiveMillisecondsElapsed (to improve stability)

--- projects/DirectoryWatcherSample/DirectoryWatcherSample.Test/TimePointTest.cs
+++ projects/DirectoryWatcherSample/DirectoryWatcherSample.Test/TimePointTest.cs
@@ -23,14 +23,14 @@
         }

         [TestMethod]
-        public void ThreeMillisecondsElapsed()
+        public void FiveMillisecondsElapsed()
         {
             TimePoint start = TimePoint.Now();

-            Thread.Sleep(3);
+            Thread.Sleep(5);
             TimeSpan elapsed = start.Elapsed();

-            elapsed.TotalMilliseconds.Should().BeApproximately(3.0d, 1.0d);
+            elapsed.TotalMilliseconds.Should().BeApproximately(5.0d, 2.0d);
         }

         [TestMethod]


fix for "No "Assets->Open CSharp project", plugin not working"

--- Assets/Plugins/Editor/RiderUnityIntegration.cs
+++ Assets/Plugins/Editor/RiderUnityIntegration.cs
@@ -63,8 +63,7 @@
           }
           default:
           {
-            Debug.Log(
-              "Please manually update the path to Rider in Unity Preferences -> External Tools -> External Script Editor.");
+            Debug.Log("Please manually update the path to Rider in Unity Preferences -> External Tools -> External Script Editor.");
             break;
           }
         }
@@ -158,7 +157,6 @@

     private static void ActivateWindow()
     {
-      Debug.Log("Attempt to activate window.");
       var process = Process.GetProcesses().FirstOrDefault(b => !b.HasExited && b.ProcessName.Contains("Rider"));
       if (process != null)
       {
@@ -258,11 +256,11 @@
       {
         string content = File.ReadAllText(file);
         const string magicProjectGUID = @"Project(""{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"")";
-          // guid representing C# project
+        // guid representing C# project
         if (!content.Contains(magicProjectGUID))
         {
           string matchGUID = @"Project\(\""\{[A-Z0-9]{8}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{12}\}\""\)";
-            // Unity may put a random guid, which will brake Rider goto
+          // Unity may put a random guid, which will brake Rider goto
           content = Regex.Replace(content, matchGUID, magicProjectGUID);
           File.WriteAllText(file, content);
           isModified = true;
@@ -270,6 +268,18 @@
       }

       Debug.Log(isModified ? "Project was post processed successfully" : "No change necessary in project");
+
+      try
+      {
+        if (slnFiles.Any())
+          EditorPrefs.SetString("kScriptEditorArgs", "\"" + slnFiles.First() + "\"");
+        else
+          EditorPrefs.SetString("kScriptEditorArgs", string.Empty);
+      }
+      catch (Exception e)
+      {
+        Debug.Log("Exception on updating kScriptEditorArgs: " + e.Message);
+      }
     }
   }
 }