diff --git a/Avalonia_Apps/AvlnSamples/Avln_IntegrationTestApp/Pages/ScreensPage.axaml.cs b/Avalonia_Apps/AvlnSamples/Avln_IntegrationTestApp/Pages/ScreensPage.axaml.cs index a9348f86e..2390a911b 100644 --- a/Avalonia_Apps/AvlnSamples/Avln_IntegrationTestApp/Pages/ScreensPage.axaml.cs +++ b/Avalonia_Apps/AvlnSamples/Avln_IntegrationTestApp/Pages/ScreensPage.axaml.cs @@ -27,6 +27,6 @@ private void ScreenRefresh_Click(object? sender, RoutedEventArgs e) ScreenWorkArea.Text = screen?.WorkingArea.ToString(); ScreenScaling.Text = screen?.Scaling.ToString(CultureInfo.InvariantCulture); ScreenOrientation.Text = screen?.CurrentOrientation.ToString(); - ScreenSameReference.Text = ReferenceEquals(lastScreen, screen).ToString(); + ScreenSameReference.Text = (lastScreen == screen).ToString(); } } diff --git a/Avalonia_Apps/AvlnSamples/Avln_RenderDemo/Pages/CustomSkiaPage.cs b/Avalonia_Apps/AvlnSamples/Avln_RenderDemo/Pages/CustomSkiaPage.cs index 991c3afc9..bf05567e9 100644 --- a/Avalonia_Apps/AvlnSamples/Avln_RenderDemo/Pages/CustomSkiaPage.cs +++ b/Avalonia_Apps/AvlnSamples/Avln_RenderDemo/Pages/CustomSkiaPage.cs @@ -25,7 +25,7 @@ public CustomSkiaPage() _noSkia = new GlyphRun(Typeface.Default.GlyphTypeface, 12, text.AsMemory(), glyphs); } - class CustomDrawOp : ICustomDrawOperation + class CustomDrawOp : ICustomDrawOperation, IEquatable { private readonly IImmutableGlyphRunReference _noSkia; @@ -42,7 +42,10 @@ public void Dispose() public Rect Bounds { get; } public bool HitTest(Point p) => false; - public bool Equals(ICustomDrawOperation other) => false; + public bool Equals(ICustomDrawOperation? other) => other is CustomDrawOp; + public bool Equals(CustomDrawOp? other) => other is not null; + public override bool Equals(object? obj) => obj is CustomDrawOp other && Equals(other); + public override int GetHashCode() => Bounds.GetHashCode(); static Stopwatch St = Stopwatch.StartNew(); public void Render(ImmediateDrawingContext context) { @@ -62,8 +65,8 @@ public void Render(ImmediateDrawingContext context) new SKColor(0, 255, 255) }; - var sx = Animate(100, 2, 10); - var sy = Animate(1000, 5, 15); + _ = Animate(100, 2, 10); + _ = Animate(1000, 5, 15); var lightPosition = new SKPoint( (float)(Bounds.Width / 2 + Math.Cos(St.Elapsed.TotalSeconds) * Bounds.Width / 4), (float)(Bounds.Height / 2 + Math.Sin(St.Elapsed.TotalSeconds) * Bounds.Height / 4)); diff --git a/CSharpBible/ConsoleApps/Display_Test/Models/DisplayTest.cs b/CSharpBible/ConsoleApps/Display_Test/Models/DisplayTest.cs index 56ab51916..9dfa85ae0 100644 --- a/CSharpBible/ConsoleApps/Display_Test/Models/DisplayTest.cs +++ b/CSharpBible/ConsoleApps/Display_Test/Models/DisplayTest.cs @@ -37,10 +37,10 @@ public void DisplayTest3(IRandom random) for (int j = 0; j < display2.ScreenBuffer.Length; j++) { - int r = (int)Math.Round(1.25 + 0.25 * random.NextDouble() + Math.Sin((j % 10 - i * 0.4) * -0.6) * 1.5); - int g = (int)Math.Round(1.25 + 0.25 * random.NextDouble() + Math.Sin((j / 10 + (j % 10) / 2 + i * 0.4) * 0.6) * 1.5); - int b = (int)Math.Round(1.25 + 0.25 * random.NextDouble() + Math.Sin((j / 10 - (j % 10) / 2 - i * 0.4) * 0.6) * 1.5); - display2.PutPixel((j / 10), (j % 10), (byte)(r * 64), (byte)(g * 64), (byte)(b * 64)); + byte r = (byte)Math.Clamp(Math.Round(1.25 + 0.25 * random.NextDouble() + Math.Sin((j % 10 - i * 0.4) * -0.6) * 1.5) * 64, 0, 255); + byte g = (byte)Math.Clamp(Math.Round(1.25 + 0.25 * random.NextDouble() + Math.Sin((j / 10 + (j % 10) / 2 + i * 0.4) * 0.6) * 1.5) * 64, 0, 255); + byte b = (byte)Math.Clamp(Math.Round(1.25 + 0.25 * random.NextDouble() + Math.Sin((j / 10 - (j % 10) / 2 - i * 0.4) * 0.6) * 1.5) * 64, 0, 255); + display2.PutPixel((j / 10), (j % 10), r, g, b); } display3.ScreenBuffer[i / 2 + (((i + 1) / 2) % 2) * 50] = ConsoleColor.Green; diff --git a/CSharpBible/ConsoleApps/TestConsole/View/TestConsoleForm.cs b/CSharpBible/ConsoleApps/TestConsole/View/TestConsoleForm.cs index b54525bb2..0041bd8a7 100644 --- a/CSharpBible/ConsoleApps/TestConsole/View/TestConsoleForm.cs +++ b/CSharpBible/ConsoleApps/TestConsole/View/TestConsoleForm.cs @@ -269,13 +269,13 @@ private void pictureBox1_MouseClick(object sender, MouseEventArgs e) private void pictureBox1_Paint(object sender, PaintEventArgs e) { Font f =new Font("Consolas",14); - var fh=f.GetHeight(e.Graphics)-1; - var fw = fh/2-1; + var fh = f.GetHeight(e.Graphics) - 1; + var fw = fh / 2 - 1; for (int i = 0; i < ScreenBuffer.Length; i++) { - e.Graphics.FillRectangle(new SolidBrush(ccolors[(int)ScreenBuffer[i].bgr]), (i % ConsoleSize.Width) * fw+2, (i / ConsoleSize.Width) * fh, fw, fh); + e.Graphics.FillRectangle(new SolidBrush(ccolors[(int)ScreenBuffer[i].bgr]), (i % ConsoleSize.Width) * fw + 2, (i / ConsoleSize.Width) * fh, fw, fh); Brush brush = new SolidBrush(ccolors[(int)ScreenBuffer[i].fgr]); - e.Graphics.DrawString($"{ScreenBuffer[i].ch}", f, brush, (i % ConsoleSize.Width) * fw-2, (i / ConsoleSize.Width) * fh); + e.Graphics.DrawString($"{ScreenBuffer[i].ch}", f, brush, (i % ConsoleSize.Width) * fw - 2, (i / ConsoleSize.Width) * fh); } lastUpdate = DateTime.Now; } diff --git a/CSharpBible/ConsoleApps/WaveFuncCol/Models/WFCModel.cs b/CSharpBible/ConsoleApps/WaveFuncCol/Models/WFCModel.cs index dc2d0e0a8..bd3a6f800 100644 --- a/CSharpBible/ConsoleApps/WaveFuncCol/Models/WFCModel.cs +++ b/CSharpBible/ConsoleApps/WaveFuncCol/Models/WFCModel.cs @@ -209,10 +209,10 @@ public void DisplayTest3(IRandom rnd) for (int j = 0; j < D2SBuffer().Length; j++) { - int r = (int)Math.Round(1.25 + 0.5 * rnd.NextDouble() + Math.Sin((j % D2Width - i * 0.4) * -0.6) * 1.5); - int g = (int)Math.Round(1.25 + 0.5 * rnd.NextDouble() + Math.Sin((j / D2Width + j % D2Width / 2 + i * 0.4) * 0.6) * 1.5); - int b = (int)Math.Round(1.25 + 0.5 * rnd.NextDouble() + Math.Sin((j / D2Width - j % D2Width / 2 - i * 0.4) * 0.6) * 1.5); - D2PutPixelC(j / D2Width, j % D2Width, (byte)(r * 64), (byte)(g * 64), (byte)(b * 64)); + byte r = (byte)Math.Clamp(Math.Round(1.25 + 0.5 * rnd.NextDouble() + Math.Sin((j % D2Width - i * 0.4) * -0.6) * 1.5) * 64, 0, 255); + byte g = (byte)Math.Clamp(Math.Round(1.25 + 0.5 * rnd.NextDouble() + Math.Sin((j / D2Width + j % D2Width / 2 + i * 0.4) * 0.6) * 1.5) * 64, 0, 255); + byte b = (byte)Math.Clamp(Math.Round(1.25 + 0.5 * rnd.NextDouble() + Math.Sin((j / D2Width - j % D2Width / 2 - i * 0.4) * 0.6) * 1.5) * 64, 0, 255); + D2PutPixelC(j / D2Width, j % D2Width, r, g, b); } D3SBuffer()[i / 2 + (i + 1) / 2 % 2 * 50] = ConsoleColor.Green; diff --git a/CSharpBible/Games/AsteroidsModernEngine.Tests/Services/GameWorldTests.cs b/CSharpBible/Games/AsteroidsModernEngine.Tests/Services/GameWorldTests.cs index 6e00b31e4..444827b07 100644 --- a/CSharpBible/Games/AsteroidsModernEngine.Tests/Services/GameWorldTests.cs +++ b/CSharpBible/Games/AsteroidsModernEngine.Tests/Services/GameWorldTests.cs @@ -150,9 +150,10 @@ public void Collision_ShipWithAsteroid_ResetsWorld() // move ship away from center gw.Ship.Position = new(104, 98); // place an asteroid at ship - var (asteroids, _) = GetSimLists(gw); + var (asteroids, bullets) = GetSimLists(gw); asteroids.Clear(); asteroids.Add(new Asteroid { Position = gw.Ship.Position, Velocity = Vector2.Zero, Radius = 20 }); + _ = bullets; gw.Update(_input, _time, _sound); _sound.Received().PlayBang(); diff --git a/CSharpBible/Games/Game_BaseTests/Model/FieldTests.cs b/CSharpBible/Games/Game_BaseTests/Model/FieldTests.cs index 654778089..a02bd9305 100644 --- a/CSharpBible/Games/Game_BaseTests/Model/FieldTests.cs +++ b/CSharpBible/Games/Game_BaseTests/Model/FieldTests.cs @@ -33,14 +33,18 @@ namespace Game.Model.Tests; [TestClass()] public class FieldTests { + public override bool Equals(object? obj) => ReferenceEquals(this, obj); + + public override int GetHashCode() => base.GetHashCode(); + #region Properties /// /// The test field /// /// -#pragma warning disable CS8618 // Ein Non-Nullable-Feld muss beim Beenden des Konstruktors einen Wert ungleich NULL enthalten. Erwägen Sie die Deklaration als Nullable. +#pragma warning disable CS8618 // Ein Non-Nullable-Feld muss beim Beenden des Konstruktors einen Wert ungleich NULL enthalten. Erw�gen Sie die Deklaration als Nullable. private Field testField; -#pragma warning restore CS8618 // Ein Non-Nullable-Feld muss beim Beenden des Konstruktors einen Wert ungleich NULL enthalten. Erwägen Sie die Deklaration als Nullable. +#pragma warning restore CS8618 // Ein Non-Nullable-Feld muss beim Beenden des Konstruktors einen Wert ungleich NULL enthalten. Erw�gen Sie die Deklaration als Nullable. /// /// The result data /// diff --git a/CSharpBible/Games/Game_BaseTests/Model/Playfield2DTests.cs b/CSharpBible/Games/Game_BaseTests/Model/Playfield2DTests.cs index f5334357d..1d1e33891 100644 --- a/CSharpBible/Games/Game_BaseTests/Model/Playfield2DTests.cs +++ b/CSharpBible/Games/Game_BaseTests/Model/Playfield2DTests.cs @@ -13,6 +13,10 @@ namespace Game.Model.Tests; [TestClass] public class Playfield2DTests { + public override bool Equals(object? obj) => ReferenceEquals(this, obj); + + public override int GetHashCode() => base.GetHashCode(); + #pragma warning disable CS8618 private Playfield2D _pf; #pragma warning restore CS8618 diff --git a/CSharpBible/Games/Snake_Base/Models/Snake.cs b/CSharpBible/Games/Snake_Base/Models/Snake.cs index 67881e69a..2bf2dbf85 100644 --- a/CSharpBible/Games/Snake_Base/Models/Snake.cs +++ b/CSharpBible/Games/Snake_Base/Models/Snake.cs @@ -166,7 +166,7 @@ public class Snake : NotificationObjectAdv /// The sn body /// /// - private List _snBody = new List(); + private readonly List _snBody = new List(); /// /// The sn tail /// diff --git a/CSharpBible/SomeThing/Statistic4/Program.cs b/CSharpBible/SomeThing/Statistic4/Program.cs index 951226858..617e047a5 100644 --- a/CSharpBible/SomeThing/Statistic4/Program.cs +++ b/CSharpBible/SomeThing/Statistic4/Program.cs @@ -131,8 +131,8 @@ void Run(int[] prog) if (arg < 0 || arg >= templates.Length) throw new IndexOutOfRangeException($"Template index {arg} out of range."); string tmpl = templates[arg]; - Console.Write(string.Format(CultureInfo.InvariantCulture, tmpl, lastObj)); - System.Diagnostics.Debug.Write(string.Format(CultureInfo.InvariantCulture, tmpl, lastObj)); + Console.WriteLine(string.Format(CultureInfo.InvariantCulture, tmpl, lastObj)); + System.Diagnostics.Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, tmpl, lastObj)); } else { diff --git a/GenFreeWin/Druck/Druck/ATo.cs b/GenFreeWin/Druck/Druck/ATo.cs index 0ba19adef..094637062 100644 --- a/GenFreeWin/Druck/Druck/ATo.cs +++ b/GenFreeWin/Druck/Druck/ATo.cs @@ -1901,7 +1901,7 @@ public void ATperles() } Text1 = Pername + "\t"; Text1 = Text1 + VNam + "\t"; - if ((Gebdat.Trim() != "") | (Gebdat2.Trim() != "")) + if ((Gebdat.Trim() != "") || (Gebdat2.Trim() != "")) { Text1 += "* \t"; } @@ -1910,7 +1910,7 @@ public void ATperles() Text1 += " \t"; } Text1 = Text1 + Gebdat + "\t" + Gebdat2 + "\t"; - if ((Sterdat.Trim() != "") | (sterdat2.Trim() != "")) + if ((Sterdat.Trim() != "") || (sterdat2.Trim() != "")) { Text1 += "+ \t"; } diff --git a/GenFreeWin/Druck/Druck/Module2.cs b/GenFreeWin/Druck/Druck/Module2.cs index 0cb8c599c..183082772 100644 --- a/GenFreeWin/Druck/Druck/Module2.cs +++ b/GenFreeWin/Druck/Druck/Module2.cs @@ -711,7 +711,7 @@ public static void Bildaus(string BiKe, string Form) num = 2; text = ""; text2 = ""; - if ((Modul1.DAus[115] == "1") | (Modul1.DAus[116] == "1")) + if ((Modul1.DAus[115] == "1") || (Modul1.DAus[116] == "1")) { DataModul.DB_PictureTable.Index = "Perkenn"; if (BiKe == "P") @@ -729,9 +729,9 @@ public static void Bildaus(string BiKe, string Form) goto IL_0aa3; IL_0231: // <========== 3 num = 27; - if ((Modul1.DAus[116] == "1") | (Modul1.DAus[115] == "1")) + if ((Modul1.DAus[116] == "1") || (Modul1.DAus[115] == "1")) { - if (((DataModul.DB_PictureTable.Fields[PictureFields.Beschreibung].Value == "Personenbild") | (DataModul.DB_PictureTable.Fields[PictureFields.Beschreibung].Value == "Familienbild")).AsBool()) + if (((DataModul.DB_PictureTable.Fields[PictureFields.Beschreibung].Value == "Personenbild") || (DataModul.DB_PictureTable.Fields[PictureFields.Beschreibung].Value == "Familienbild")).AsBool()) { text3 = text3.Replace("#", ""); fileStream2 = new FileStream(text3, FileMode.Open); @@ -817,7 +817,7 @@ public static void Bildaus(string BiKe, string Form) } if (left2 == "Ahnen") { - if ((text.Trim() != "") | (text2.Trim() != "")) + if ((text.Trim() != "") || (text2.Trim() != "")) { MyProject.Forms.Ahnen.Anz[0].SelectedText = "\n"; MyProject.Forms.Ahnen.Anz[0].Paste(); @@ -906,7 +906,7 @@ public static void Bildaus(string BiKe, string Form) text3 = text3.Replace("#", ""); if (!Information.IsDBNull(DataModul.DB_PictureTable.Fields[PictureFields.Beschreibung].Value)) { - if (!((DataModul.DB_PictureTable.Fields[PictureFields.Beschreibung].Value == "Personenbild") | (DataModul.DB_PictureTable.Fields[PictureFields.Beschreibung].Value == "Familienbild")).AsBool()) + if (!((DataModul.DB_PictureTable.Fields[PictureFields.Beschreibung].Value == "Personenbild") || (DataModul.DB_PictureTable.Fields[PictureFields.Beschreibung].Value == "Familienbild")).AsBool()) { if (!(DataModul.DB_PictureTable.Fields[PictureFields.Beschreibung].AsString() == "Personenbild")) { diff --git a/GenFreeWin/Druck/Druck/Views/Anzeige.cs b/GenFreeWin/Druck/Druck/Views/Anzeige.cs index c1ef3c0e6..331d95780 100644 --- a/GenFreeWin/Druck/Druck/Views/Anzeige.cs +++ b/GenFreeWin/Druck/Druck/Views/Anzeige.cs @@ -291,7 +291,7 @@ private void Befehl_Click(object eventSender, EventArgs eventArgs) { RichTextBox1[4].SelectedText = ("Nr.: " + DataModul.DB_QuTable.Fields[QuFields._12].AsString()); } - if ((Operators.CompareString(DataModul.DB_QuTable.Fields[QuFields._11].AsString().Trim(), "", TextCompare: false) != 0) | (Operators.CompareString(DataModul.DB_QuTable.Fields[QuFields._12].AsString().Trim(), "", TextCompare: false) != 0)) + if ((Operators.CompareString(DataModul.DB_QuTable.Fields[QuFields._11].AsString().Trim(), "", TextCompare: false) != 0) || (Operators.CompareString(DataModul.DB_QuTable.Fields[QuFields._12].AsString().Trim(), "", TextCompare: false) != 0)) { RichTextBox1[4].SelectedText = "\n"; } @@ -450,7 +450,7 @@ private void Befehl_7_Click() RichTextBox1[(short)i].Visible = false; } RichTextBox1[0].Visible = true; - if ((Listnam == 130) | (Listnam == 119)) + if ((Listnam == 130) || (Listnam == 119)) { Befehl[0].Visible = false; Befehl[6].Visible = false; @@ -1107,7 +1107,7 @@ private void Button1_Click(object sender, EventArgs e) Aufhoer = " Jahr: " + Strings.Mid((num10 - 10000).AsString(), 2, 4); } Bezeichnung8.Text = "Einträge sortieren"; - if (iListArt < 400 | iListArt > 1000) + if (iListArt < 400 || iListArt > 1000) { Listnam = (short)iListArt; Bezeichnung1.Text = "Sortierte Personenliste nach" + text4; @@ -2082,7 +2082,10 @@ static void GetListArtTexts(int iListArt, out string text3, out string text4) { text4 = " kirchl. Heiratsregister"; } - else text4 = text4; + else + { + // Preserve the current value explicitly; this branch is part of the learning exercise. + } } void Handle_ListArt_101f(int iListArt, byte b2, int num9, int num10) { @@ -2352,7 +2355,7 @@ private void WriteFamilyList(ref int num, int iListArt, ref string text, ref int Datmit = 1; } _Modul1.Instance.Famles(); - if ((_Modul1.Instance.Family.Mann > 0) | (_Modul1.Instance.Family.Frau > 0)) + if ((_Modul1.Instance.Family.Mann > 0) || (_Modul1.Instance.Family.Frau > 0)) { _Modul1.Instance.Famdatles(_Modul1.Instance.FamInArb, out var asFamDates3); if (asFamDates3[iListArt - 500] == "") @@ -2481,7 +2484,7 @@ private void WriteFamilyList(ref int num, int iListArt, ref string text, ref int DataModul.Link.GetPersonFam(persInArb, ELinkKennz.lkChild, out _Modul1.Instance.FamInArb); Datmit = 2; _Modul1.Instance.Famles(); - if ((_Modul1.Instance.Family.Mann > 0) | (_Modul1.Instance.Family.Frau > 0) + if ((_Modul1.Instance.Family.Mann > 0) || (_Modul1.Instance.Family.Frau > 0) && _Modul1.Instance.Aus[51] == "Y") { if (b6 == 1) @@ -2625,7 +2628,7 @@ private void WriteList401(RichTextBox richTextBox1_0, Ausw ausw, ref int famInAr Datmit = 1; } _Modul1.Instance.Famles(); - if ((_Modul1.Instance.Family.Mann > 0) | (_Modul1.Instance.Family.Frau > 0)) + if ((_Modul1.Instance.Family.Mann > 0) || (_Modul1.Instance.Family.Frau > 0)) { persInArb = _Modul1.Instance.Family.Mann; if (_Modul1.Instance.Family.Mann > 0) @@ -2756,7 +2759,7 @@ private void WriteList401(RichTextBox richTextBox1_0, Ausw ausw, ref int famInAr } DataModul.Link.GetPersonFam(persInArb, ELinkKennz.lkChild, out _Modul1.Instance.FamInArb); _Modul1.Instance.Famles(); - if ((_Modul1.Instance.Family.Mann > 0) | (_Modul1.Instance.Family.Frau > 0)) + if ((_Modul1.Instance.Family.Mann > 0) || (_Modul1.Instance.Family.Frau > 0)) { if (ausw_opt3_0) { @@ -2887,7 +2890,7 @@ private void WritePersonList(int iListArt, RichTextBox richTextBox1_0, int persI DataModul.DSB_SortTable.Index = "Sort"; DataModul.DSB_SortTable.Seek(">=", " "); IZahl = 0; - if ((Listnam == 130) | (Listnam == 119)) + if ((Listnam == 130) || (Listnam == 119)) { Befehl[0].Visible = false; Befehl[6].Visible = false; @@ -3425,7 +3428,7 @@ private void WritePersonList(int iListArt, RichTextBox richTextBox1_0, int persI this.PerPos = 2; if (_Modul1.Instance.Aus[51] == "Y") { - if ((_Modul1.Instance.Family.Mann > 0) | (_Modul1.Instance.Family.Frau > 0)) + if ((_Modul1.Instance.Family.Mann > 0) || (_Modul1.Instance.Family.Frau > 0)) { if (ausw_opt3_0) { @@ -3743,7 +3746,7 @@ private void WritePersonList(int iListArt, RichTextBox richTextBox1_0, int persI if (_Modul1.Instance.Aus[51] == "Y") { _Modul1.Instance.Famles(); - if ((_Modul1.Instance.Family.Mann > 0) | (_Modul1.Instance.Family.Frau > 0)) + if ((_Modul1.Instance.Family.Mann > 0) || (_Modul1.Instance.Family.Frau > 0)) { if (Strings.Mid(richTextBox1_0.Text, richTextBox1_0.SelectionStart, 1) != ".") { @@ -4710,7 +4713,7 @@ private void Write_Kopf(RichTextBox richTextBox1_0) } richTextBox1_0.SelectedText = sBez + "\n"; richTextBox1_0.SelectionFont = fntRegular; - if ((Anfang != "") | (Aufhoer != "")) + if ((Anfang != "") || (Aufhoer != "")) { if (Anfang != "") { @@ -4837,7 +4840,7 @@ public void Personles() { richTextBox1_0.SelectedText = ", Sippe " + _Modul1.Instance.Kont[5]; } - if (ausw.Kontroll[10].Checked | ausw.Kontroll[11].Checked) + if (ausw.Kontroll[10].Checked || ausw.Kontroll[11].Checked) { WriteNachnr(richTextBox1_0); } diff --git a/GenFreeWin/GenFreeBaseTests/Data/IndexDefTests.cs b/GenFreeWin/GenFreeBaseTests/Data/IndexDefTests.cs index a7f6d4676..31b8fc2d5 100644 --- a/GenFreeWin/GenFreeBaseTests/Data/IndexDefTests.cs +++ b/GenFreeWin/GenFreeBaseTests/Data/IndexDefTests.cs @@ -10,13 +10,13 @@ public class IndexDefTests { private ITableDef td; private IndexDef testClass; - private List _ix; + private readonly List _ix = new(); [TestInitialize] public void Init() { td = Substitute.For(); - td.Indexes.Returns(_ix = new List()); + td.Indexes.Returns(_ix); testClass = new IndexDef(td, "Name", "sField", true, false); } diff --git a/GenFreeWin/GenFreeData/GenFree/Data/CPerson.cs b/GenFreeWin/GenFreeData/GenFree/Data/CPerson.cs index 88654a542..d837f9590 100644 --- a/GenFreeWin/GenFreeData/GenFree/Data/CPerson.cs +++ b/GenFreeWin/GenFreeData/GenFree/Data/CPerson.cs @@ -83,7 +83,7 @@ public int ValidateID(int persInArb, short schalt, int MaxPersID, T tOKRes, F var dB_PersonTable = Seek(persInArb, out bool xBreak); var i = 0; while (xBreak - | (dB_PersonTable?.Fields[PersonFields.Pruefen]).AsString().Trim() == "G") + || (dB_PersonTable?.Fields[PersonFields.Pruefen]).AsString().Trim() == "G") { if (persInArb < 1) { diff --git a/GenFreeWin/GenFreeWin/Gen_FreeWin/ViewModels/OrtsVerViewModel.cs b/GenFreeWin/GenFreeWin/Gen_FreeWin/ViewModels/OrtsVerViewModel.cs index dd20f9112..e04655935 100644 --- a/GenFreeWin/GenFreeWin/Gen_FreeWin/ViewModels/OrtsVerViewModel.cs +++ b/GenFreeWin/GenFreeWin/Gen_FreeWin/ViewModels/OrtsVerViewModel.cs @@ -651,7 +651,7 @@ public void CalculateCoordinates() [RelayCommand] public void ApplyCoordinates() { - if (!((TextBox23_Text.Trim() == "") | (TextBox27_Text.Trim() == ""))) + if (!string.IsNullOrWhiteSpace(TextBox23_Text) && !string.IsNullOrWhiteSpace(TextBox27_Text)) { edtLat1_Text = TextBox23_Text; edtLat2_Text = TextBox24_Text; @@ -2124,7 +2124,7 @@ public void CloseDistancePanel() partial void OnLabel27_TextChanged(string value) { - if ((Label29_Text != "") & (Label28_Text != "") & (Label30_Text != "") & (Label31_Text != "")) + if (!string.IsNullOrWhiteSpace(Label29_Text) && !string.IsNullOrWhiteSpace(Label28_Text) && !string.IsNullOrWhiteSpace(Label30_Text) && !string.IsNullOrWhiteSpace(Label31_Text)) { var instance = Strings.Split(value, "\n"); var instance2 = Strings.Split(Label32_Text, "\n"); @@ -2137,7 +2137,7 @@ partial void OnLabel27_TextChanged(string value) partial void OnLabel32_TextChanged(string value) { - if ((Label29_Text != "") & (Label28_Text != "") & (Label30_Text != "") & (Label31_Text != "")) + if (!string.IsNullOrWhiteSpace(Label29_Text) && !string.IsNullOrWhiteSpace(Label28_Text) && !string.IsNullOrWhiteSpace(Label30_Text) && !string.IsNullOrWhiteSpace(Label31_Text)) { var instance = Strings.Split(Label27_Text, "\n"); var instance2 = Strings.Split(value, "\n"); diff --git a/GenFreeWin/GenFreeWin/Gen_FreeWin/ViewModels/RahmenViewModel.cs b/GenFreeWin/GenFreeWin/Gen_FreeWin/ViewModels/RahmenViewModel.cs index 3bb3b1f97..1c7573533 100644 --- a/GenFreeWin/GenFreeWin/Gen_FreeWin/ViewModels/RahmenViewModel.cs +++ b/GenFreeWin/GenFreeWin/Gen_FreeWin/ViewModels/RahmenViewModel.cs @@ -1145,7 +1145,7 @@ private void Do4(out int num10, ref string text2, out string Persex) Modul1.Kont[97] = iAhn.AsString(); Modul1.Person.SetFullSurname(Modul1.BuildFullSurName(Modul1.Person)); Modul1_LiText = new string(' ', 80); - if (Modul1.Person.FullSurName != "" | Modul1.Person.Givennames != "") + if (!string.IsNullOrWhiteSpace(Modul1.Person.FullSurName) || !string.IsNullOrWhiteSpace(Modul1.Person.Givennames)) { StringType.MidStmtStr(ref Modul1_LiText, 1, 60, "" + Modul1.sDatu.Right(6) + " " + Modul1.Person.Givennames + " " + Modul1.Person.FullSurName.TrimEnd()); } @@ -1202,7 +1202,7 @@ private void Do5(ref string text2, int ubg) Modul1.Person_ReadNames(persInArb, Modul1.Person); Modul1.Kont[10] = Modul1.Ancesters_GetPersonData(iPerNr, out int iAhn, out Modul1_Kont20); Modul1.Kont[97] = iAhn.AsString(); - if (Modul1.Person.SurName != "" | Modul1.Person.Givennames != "") + if (!string.IsNullOrWhiteSpace(Modul1.Person.SurName) || !string.IsNullOrWhiteSpace(Modul1.Person.Givennames)) { StringType.MidStmtStr(ref Modul1_LiText, 1, 60, "" + Modul1.sDatu.Right(6) + " " + Modul1.Person.Givennames + " " + Modul1.Person.SurName.ToUpper().TrimEnd()); } @@ -1972,7 +1972,7 @@ public void Ramentextspeich() { Modul1.FamInArb = Familie.Default.iFamNr; DataModul.DB_FamilyTable.Edit(); - if (View.Height != 365 & View.frmFrame1.Tag.AsInt() == (int)EUserText.tMarrWitness) + if (View.Height != 365 && View.frmFrame1.Tag.AsInt() == (int)EUserText.tMarrWitness) { DataModul.DB_FamilyTable.Fields[FamilyFields.Bem2].Value = View.RTB.Text; } diff --git a/GenFreeWin/GenFreeWin/Gen_FreeWin/Views/Fehlerli.cs b/GenFreeWin/GenFreeWin/Gen_FreeWin/Views/Fehlerli.cs index c6e30bf9a..e772327ca 100644 --- a/GenFreeWin/GenFreeWin/Gen_FreeWin/Views/Fehlerli.cs +++ b/GenFreeWin/GenFreeWin/Gen_FreeWin/Views/Fehlerli.cs @@ -1785,13 +1785,13 @@ private void Button5_Click(object sender, EventArgs e) IEventData Event = null; while (++num7 <= 507) { - if (!(num7 == 500 & !CheckBox6.Checked) - && !(num7 == 501 & !CheckBox5.Checked) - && !(num7 == 502 & !CheckBox7.Checked) - && !(num7 == 503 & !CheckBox8.Checked) - && !(num7 == 504 & !CheckBox9.Checked) - && !(num7 == 505 & !CheckBox10.Checked) - && !(num7 == 507 & !CheckBox11.Checked) + if ((num7 != 500 || CheckBox6.Checked) + && (num7 != 501 || CheckBox5.Checked) + && (num7 != 502 || CheckBox7.Checked) + && (num7 != 503 || CheckBox8.Checked) + && (num7 != 504 || CheckBox9.Checked) + && (num7 != 505 || CheckBox10.Checked) + && (num7 != 507 || CheckBox11.Checked) && DataModul.Event.ReadData((EEventArt)num7, I1, out Event, 0)) { break; diff --git a/GenFreeWin/GenFreeWin/Gen_FreeWin/Views/FrmEreignis.cs b/GenFreeWin/GenFreeWin/Gen_FreeWin/Views/FrmEreignis.cs index d80d7c67b..3ecdcb627 100644 --- a/GenFreeWin/GenFreeWin/Gen_FreeWin/Views/FrmEreignis.cs +++ b/GenFreeWin/GenFreeWin/Gen_FreeWin/Views/FrmEreignis.cs @@ -2468,7 +2468,7 @@ private void TextBox1_KeyUp1(object sender, KeyEventArgs e) IL_0ea8: num = 228; ListBox2.Visible = false; - if (TextBox18.Visible & TextBox4.Text.Trim() != "") + if (TextBox18.Visible && !string.IsNullOrWhiteSpace(TextBox4.Text)) { TextBox18.Enabled = true; _ = TextBox18.Focus(); diff --git a/GenFreeWin/VBUnObfusicator/Models/Scanner/CodeBlock.cs b/GenFreeWin/VBUnObfusicator/Models/Scanner/CodeBlock.cs index 3eadb31f1..99bfd7b2d 100644 --- a/GenFreeWin/VBUnObfusicator/Models/Scanner/CodeBlock.cs +++ b/GenFreeWin/VBUnObfusicator/Models/Scanner/CodeBlock.cs @@ -31,6 +31,10 @@ namespace VBUnObfusicator.Models.Scanner; /// public class CodeBlock : ICodeBlock { + public override bool Equals(object? obj) => ReferenceEquals(this, obj); + + public override int GetHashCode() => base.GetHashCode(); + /// /// The parent /// diff --git a/JC-AMS/Core/Core/SGraphics.cs b/JC-AMS/Core/Core/SGraphics.cs index 8541a4efa..4c500f256 100644 --- a/JC-AMS/Core/Core/SGraphics.cs +++ b/JC-AMS/Core/Core/SGraphics.cs @@ -270,7 +270,6 @@ public static bool DrawAGVArrowHead(Graphics Gr, Brush Brush, Pen Pen, PointF Pt Pt3, SMath2.ToPoint(PtDest) }; - double Len = Length; PtDest = SMath2.PointVectorToPoint(PtDest, Angle, Length * 2.0); Pt2.X = (int)((double)PtDest.X - Math.Cos((Angle + 20.0) * Math.PI / 180.0) * (double)Length * 2.0); Pt2.Y = (int)((double)PtDest.Y - Math.Sin((Angle + 20.0) * Math.PI / 180.0) * (double)Length * 2.0); diff --git a/JC-AMS/Core/Core/SGraphics2.cs b/JC-AMS/Core/Core/SGraphics2.cs index f0260722d..31fbac3c7 100644 --- a/JC-AMS/Core/Core/SGraphics2.cs +++ b/JC-AMS/Core/Core/SGraphics2.cs @@ -130,7 +130,7 @@ public static void WriteToXML(this Pen pen, XmlWriter writer, bool xFull = false if (xFull) { writer.WriteStartElement(pen.GetType().Name); sPrefix = "";EntryState = WriteState.Element; } writer.WriteAttributeString(sPrefix+nameof(pen.Width), pen.Width.ToString("0.00",CultureInfo.InvariantCulture)); writer.WriteAttributeString(sPrefix + nameof(pen.PenType), ((int)pen.PenType).ToString()); - pen.Color.WriteToXML(writer,xFull | EntryState== WriteState.Element, sPrefix + "Color."); + pen.Color.WriteToXML(writer, xFull || EntryState == WriteState.Element, sPrefix + "Color."); if (xFull) writer.WriteEndElement(); } diff --git a/JC-AMS/Core/Core/System/CStation.cs b/JC-AMS/Core/Core/System/CStation.cs index a72efc533..ea0f4f7ed 100644 --- a/JC-AMS/Core/Core/System/CStation.cs +++ b/JC-AMS/Core/Core/System/CStation.cs @@ -7,7 +7,7 @@ // Last Modified On : 10-17-2022 // *********************************************************************** // -// Copyright © JC-Soft 2008-2015 +// Copyright � JC-Soft 2008-2015 // // // *********************************************************************** @@ -150,7 +150,12 @@ private void OnChangeIdStation(long oldId, long newId, string name) if (oldId > 0) RemoveStation(oldId); if (newId > 0) - Stations[newId] = this; + { + lock (Stations) + { + Stations[newId] = this; + } + } } /// @@ -161,13 +166,16 @@ private void OnChangeIdStation(long oldId, long newId, string name) /// public static CStation GetStation(long idStation) { - return Stations.ContainsKey(idStation) ? Stations[idStation]:null; + lock (Stations) + { + return Stations.TryGetValue(idStation, out CStation station) ? station : null; + } } /// - /// Füllt eine mit den Daten auf, die zum Serialisieren des Zielobjekts erforderlich sind. + /// F�llt eine mit den Daten auf, die zum Serialisieren des Zielobjekts erforderlich sind. /// - /// Die mit Daten zu füllende . + /// Die mit Daten zu f�llende . /// Das Ziel (siehe ) dieser Serialisierung. /// public void GetObjectData(SerializationInfo info, StreamingContext context) @@ -186,7 +194,7 @@ public void GetObjectData(SerializationInfo info, StreamingContext context) /// /// Diese Methode ist reserviert und sollte nicht verwendet werden. - /// Bei der Implementierung der -Schnittstelle sollte von dieser Methode ( in Visual Basic) zurückgegeben werden. Wenn die Angabe eines benutzerdefinierten Schemas erforderlich ist, sollten Sie stattdessen das das auf die Klasse anwenden. + /// Bei der Implementierung der -Schnittstelle sollte von dieser Methode ( in Visual Basic) zur�ckgegeben werden. Wenn die Angabe eines benutzerdefinierten Schemas erforderlich ist, sollten Sie stattdessen das das auf die Klasse anwenden. /// /// Ein zur Beschreibung der XML-Darstellung des Objekts, das von der -Methode erstellt und von der -Methode verwendet wird. /// diff --git a/TestStatements/TestStatements/DataTypes/Formating.cs b/TestStatements/TestStatements/DataTypes/Formating.cs index 65c319104..93cb9de24 100644 --- a/TestStatements/TestStatements/DataTypes/Formating.cs +++ b/TestStatements/TestStatements/DataTypes/Formating.cs @@ -7,7 +7,7 @@ // Last Modified On : 09-09-2022 // *********************************************************************** // -// Copyright © JC-Soft 2020 +// Copyright � JC-Soft 2020 // // // *********************************************************************** diff --git a/Transpiler_pp/TranspilerLib/Models/Scanner/CodeBlock.cs b/Transpiler_pp/TranspilerLib/Models/Scanner/CodeBlock.cs index 1f22846a0..bc1e88961 100644 --- a/Transpiler_pp/TranspilerLib/Models/Scanner/CodeBlock.cs +++ b/Transpiler_pp/TranspilerLib/Models/Scanner/CodeBlock.cs @@ -40,6 +40,10 @@ namespace TranspilerLib.Models.Scanner; /// public class CodeBlock : ICodeBlock { + public override bool Equals(object? obj) => ReferenceEquals(this, obj); + + public override int GetHashCode() => base.GetHashCode(); + #region Properties /// @@ -438,4 +442,3 @@ public bool Equals(ICodeBlock? other) return this == other; } } -