microsoft/SWE-Sharp-Bench huggingface dataset:
Repository: ardalis/CleanArchitecture

Issue:
Attempting to create a new project through the API results in an error regarding the 'CreateProjectDTO' interface.
<!-- ⚠️⚠️ Do Not Delete This! bug_report_template ⚠️⚠️ -->
<!-- 🔎 Search existing issues to avoid creating duplicates. -->
It's not possible to create a new project using the endpoint `[POST]/api/Projects`.
When trying, it gives an error: `Could not create an instance of type Clean.Architecture.Web.ApiModels.CreateProjectDTO. Type is an interface or abstract class and cannot be instantiated. Path 'name', line 2, position 9.`
![image](https://user-images.githubusercontent.com/4308648/235479002-f7865f0d-8a6d-43e4-9931-a045ceae50ba.png)

![image](https://user-images.githubusercontent.com/4308648/235478859-5259c8f3-e2be-4ecf-998f-3003e741b650.png)

![image](https://user-images.githubusercontent.com/4308648/235477952-2d846910-391b-470f-8b8e-cb4517abd24a.png)




Hints:

Patch:
diff --git a/src/Clean.Architecture.Web/ApiModels/ProjectDTO.cs b/src/Clean.Architecture.Web/ApiModels/ProjectDTO.cs
index 373e25fdb..c5342328c 100644
--- a/src/Clean.Architecture.Web/ApiModels/ProjectDTO.cs
+++ b/src/Clean.Architecture.Web/ApiModels/ProjectDTO.cs
@@ -15,7 +15,7 @@ public ProjectDTO(int id, string name, List<ToDoItemDTO>? items = null) : base(n
 // Creation DTOs should not include an ID if the ID will be generated by the back end
 public class CreateProjectDTO
 {
-  protected CreateProjectDTO(string name)
+  public CreateProjectDTO(string name)
   {
     Name = name;
   }


Test patch:
diff --git a/tests/Clean.Architecture.FunctionalTests/ControllerApis/ApiProjectsControllerList.cs b/tests/Clean.Architecture.FunctionalTests/ControllerApis/ApiProjectsControllerList.cs
index f8d5de85c..df65af509 100644
--- a/tests/Clean.Architecture.FunctionalTests/ControllerApis/ApiProjectsControllerList.cs
+++ b/tests/Clean.Architecture.FunctionalTests/ControllerApis/ApiProjectsControllerList.cs
@@ -1,6 +1,8 @@
-﻿using Ardalis.HttpClientTestExtensions;
+﻿using System.Text;
+using Ardalis.HttpClientTestExtensions;
 using Clean.Architecture.Web;
 using Clean.Architecture.Web.ApiModels;
+using Newtonsoft.Json;
 using Xunit;
 
 namespace Clean.Architecture.FunctionalTests.ControllerApis;
@@ -23,4 +25,13 @@ public async Task ReturnsOneProject()
     Assert.Single(result);
     Assert.Contains(result, i => i.Name == SeedData.TestProject1.Name);
   }
+
+  [Fact]
+  public async Task CreateProject()
+  {
+    string projectName = "Test Project 2";
+    var result = await _client.PostAndDeserializeAsync<ProjectDTO>("/api/projects", new StringContent(JsonConvert.SerializeObject(new CreateProjectDTO(projectName)), Encoding.UTF8, "application/json"));
+    Assert.NotNull(result);
+    Assert.Equal(projectName, result.Name);
+  }
 }
Repository: spectreconsole/spectre.console

Issue:
Prompt text is erased upon backspace when the prompt text is a secret and its mask is null.
**Describe the bug**
Prompt text is erased upon backspace when the prompt text is a secret and its mask is null.

**To Reproduce**
Create secret Prompt with a null mask. Show the Prompt. Enter a few characters, then backspace. The prompt text will be deleted.

**Expected behavior**
Prompt text deletion should stop after the ultimate character of the prompt text.




Hints:

Patch:
diff --git a/src/Spectre.Console/Extensions/AnsiConsoleExtensions.Input.cs b/src/Spectre.Console/Extensions/AnsiConsoleExtensions.Input.cs
index f5299adde..7769e33a5 100644
--- a/src/Spectre.Console/Extensions/AnsiConsoleExtensions.Input.cs
+++ b/src/Spectre.Console/Extensions/AnsiConsoleExtensions.Input.cs
@@ -53,7 +53,11 @@ internal static async Task<string> ReadLine(this IAnsiConsole console, Style? st
                 if (text.Length > 0)
                 {
                     text = text.Substring(0, text.Length - 1);
-                    console.Write("\b \b");
+
+                    if (mask != null)
+                    {
+                        console.Write("\b \b");
+                    }
                 }
 
                 continue;


Test patch:
diff --git a/test/Spectre.Console.Tests/Expectations/Prompts/Text/SecretValueBackspaceNullMask.Output.verified.txt b/test/Spectre.Console.Tests/Expectations/Prompts/Text/SecretValueBackspaceNullMask.Output.verified.txt
new file mode 100644
index 000000000..473c6d87b
--- /dev/null
+++ b/test/Spectre.Console.Tests/Expectations/Prompts/Text/SecretValueBackspaceNullMask.Output.verified.txt
@@ -0,0 +1,1 @@
+﻿Favorite fruit? 
diff --git a/test/Spectre.Console.Tests/Unit/Prompts/TextPromptTests.cs b/test/Spectre.Console.Tests/Unit/Prompts/TextPromptTests.cs
index 52d26e7d5..c358b9be3 100644
--- a/test/Spectre.Console.Tests/Unit/Prompts/TextPromptTests.cs
+++ b/test/Spectre.Console.Tests/Unit/Prompts/TextPromptTests.cs
@@ -248,6 +248,25 @@ public Task Should_Choose_Masked_Default_Value_If_Nothing_Is_Entered_And_Prompt_
         return Verifier.Verify(console.Output);
     }
 
+    [Fact]
+    [Expectation("SecretValueBackspaceNullMask")]
+    public Task Should_Not_Erase_Prompt_Text_On_Backspace_If_Prompt_Is_Secret_And_Mask_Is_Null()
+    {
+        // Given
+        var console = new TestConsole();
+        console.Input.PushText("Bananas");
+        console.Input.PushKey(ConsoleKey.Backspace);
+        console.Input.PushKey(ConsoleKey.Enter);
+
+        // When
+        console.Prompt(
+            new TextPrompt<string>("Favorite fruit?")
+                .Secret(null));
+
+        // Then
+        return Verifier.Verify(console.Output);
+    }
+
     [Fact]
     [Expectation("SecretDefaultValueCustomMask")]
     public Task Should_Choose_Custom_Masked_Default_Value_If_Nothing_Is_Entered_And_Prompt_Is_Secret_And_Mask_Is_Custom()
Repository: MessagePack-CSharp/MessagePack-CSharp

Issue:
MsgPack013 should not report diagnostics on abstract classes
The following class declaration produced an MsgPack013 diagnostic:

```cs
public abstract class Deserializer : IMessagePackFormatter<object?>
```

This doesn't make sense though because as an abstract type, the resolver could never use it anyway.

`MsgPack009` also mis-fires by counting abstract classes as bona fide formatters.


Hints:

Patch:
diff --git a/src/MessagePack.SourceGenerator/CodeAnalysis/AnalyzerOptions.cs b/src/MessagePack.SourceGenerator/CodeAnalysis/AnalyzerOptions.cs
index 4d8567fef..4832023ec 100644
--- a/src/MessagePack.SourceGenerator/CodeAnalysis/AnalyzerOptions.cs
+++ b/src/MessagePack.SourceGenerator/CodeAnalysis/AnalyzerOptions.cs
@@ -218,6 +218,12 @@ public record FormatterDescriptor(QualifiedNamedTypeName Name, string? InstanceP
     /// <returns><see langword="true"/> if <paramref name="type"/> represents a formatter.</returns>
     public static bool TryCreate(INamedTypeSymbol type, [NotNullWhen(true)] out FormatterDescriptor? formatter)
     {
+        if (type.IsAbstract)
+        {
+            formatter = null;
+            return false;
+        }
+
         var formattedTypes =
             AnalyzerUtilities.SearchTypeForFormatterImplementations(type)
             .Select(i => new FormattableType(i, type.ContainingAssembly))


Test patch:
diff --git a/tests/MessagePack.SourceGenerator.Tests/MsgPack00xAnalyzerTests.cs b/tests/MessagePack.SourceGenerator.Tests/MsgPack00xAnalyzerTests.cs
index 54d8dda01..b35682b7a 100644
--- a/tests/MessagePack.SourceGenerator.Tests/MsgPack00xAnalyzerTests.cs
+++ b/tests/MessagePack.SourceGenerator.Tests/MsgPack00xAnalyzerTests.cs
@@ -908,4 +908,27 @@ public class Derived : Base
 
         await VerifyCS.VerifyAnalyzerAsync(test);
     }
+
+    [Fact]
+    public async Task AbstractFormatterDoesNotAttractAttention()
+    {
+        string test = /* lang=c#-test */ """
+            using MessagePack;
+            using MessagePack.Formatters;
+
+            public abstract class AbstractFormatter1 : IMessagePackFormatter<object>
+            {
+                public abstract void Serialize(ref MessagePackWriter writer, object value, MessagePackSerializerOptions options);
+                public abstract object Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options);
+            }
+
+            public abstract class AbstractFormatter2 : IMessagePackFormatter<object>
+            {
+                public abstract void Serialize(ref MessagePackWriter writer, object value, MessagePackSerializerOptions options);
+                public abstract object Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options);
+            }
+            """;
+
+        await VerifyCS.VerifyAnalyzerAsync(test);
+    }
 }
Repository: dotnet/BenchmarkDotNet

Issue:
msbuild binlog for the benchmark projects gets cleaned up too, making diagnosis of build impossible
If you use `--generateBinLog` for wasm benchmarks, you get:

```
/home/helixbot/work/B78C09A9/p/dotnet/dotnet  restore --packages "/home/helixbot/work/B78C09A9/w/BCE609B9/e/performance/artifacts/packages" /p:UseSharedCompilation=false /p:BuildInParallel=false /m:1 /p:Deterministic=true /p:Optimize=true
  -bl:8b197aae-5d64-4019-b6f4-46946d02dc65-restore.binlog

in /home/helixbot/work/B78C09A9/w/BCE609B9/e/performance/artifacts/bin/for-running/MicroBenchmarks/8b197aae-5d64-4019-b6f4-46946d02dc65
```

The binlog gets generated in `/home/helixbot/work/B78C09A9/w/BCE609B9/e/performance/artifacts/bin/for-running/MicroBenchmarks/8b197aae-5d64-4019-b6f4-46946d02dc65`, but that is getting cleaned up at the end, thus it is not retrievable later for diagnosis.

It would be useful to maybe use some path in `artifacts` which does not get removed for these files.

cc @adamsitnik


Hints:
And related to that, a command line parameter to skip the cleanup would be useful too.

Patch:
diff --git a/src/BenchmarkDotNet/ConsoleArguments/ConfigParser.cs b/src/BenchmarkDotNet/ConsoleArguments/ConfigParser.cs
index e4b730aca3..17a01e87d5 100644
--- a/src/BenchmarkDotNet/ConsoleArguments/ConfigParser.cs
+++ b/src/BenchmarkDotNet/ConsoleArguments/ConfigParser.cs
@@ -250,6 +250,9 @@ private static IConfig CreateConfig(CommandLineOptions options, IConfig globalCo
             config.WithOption(ConfigOptions.ApplesToApples, options.ApplesToApples);
             config.WithOption(ConfigOptions.Resume, options.Resume);
 
+            if (config.Options.IsSet(ConfigOptions.GenerateMSBuildBinLog))
+                config.Options |= ConfigOptions.KeepBenchmarkFiles;
+
             if (options.MaxParameterColumnWidth.HasValue)
                 config.WithSummaryStyle(SummaryStyle.Default.WithMaxParameterColumnWidth(options.MaxParameterColumnWidth.Value));
 


Test patch:
diff --git a/tests/BenchmarkDotNet.Tests/ConfigParserTests.cs b/tests/BenchmarkDotNet.Tests/ConfigParserTests.cs
index a0d5c57c3a..427b7d00ce 100644
--- a/tests/BenchmarkDotNet.Tests/ConfigParserTests.cs
+++ b/tests/BenchmarkDotNet.Tests/ConfigParserTests.cs
@@ -291,7 +291,7 @@ public void DotNetCliParsedCorrectly(string tfm)
         [InlineData(ConfigOptions.StopOnFirstError, "--stopOnFirstError")]
         [InlineData(ConfigOptions.DisableLogFile, "--disableLogFile" )]
         [InlineData(ConfigOptions.LogBuildOutput, "--logBuildOutput")]
-        [InlineData(ConfigOptions.GenerateMSBuildBinLog, "--generateBinLog")]
+        [InlineData(ConfigOptions.GenerateMSBuildBinLog | ConfigOptions.KeepBenchmarkFiles, "--generateBinLog")]
         [InlineData(
             ConfigOptions.JoinSummary |
             ConfigOptions.KeepBenchmarkFiles |
Repository: App-vNext/Polly

Issue:
Replace Moq
Given recent developments with Moq as of version 4.20.0, we should remove it and replace with another library.

[NSubstitue](https://nsubstitute.github.io/) seems like a good _substitue_.

I'm going to work on this today unless someone has any strong opinions about an alternative library to use in its place.



Hints:
Are there any plans to fork the Moq? 
Maybe in the meantime, we can freeze the versions and wait for some "official forked package".

I have not used NSubstitute personally, so I can't comment on that. It seems some folks find it cleaner compared to Moq. 

If the switch is straightforward, we can get away with that.



 
There is already an issue for creating a migration tool: https://github.com/nsubstitute/NSubstitute/issues/720

I would probably wait and see in this case, how it develops. The latest version of Moq no longer has that dependency, so I would say it's not immediate concern.
Thanks for the link, I'll bear that in mind for the future. I have however just finished locally converting the code over 😅

Patch:
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 3a5e431dfd0..ce5b24e4b09 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -22,7 +22,7 @@
     <PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
     <PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
     <PackageVersion Include="MinVer" Version="4.3.0" />
-    <PackageVersion Include="Moq" Version="4.18.4" />
+    <PackageVersion Include="NSubstitute" Version="5.0.0" />
     <PackageVersion Include="Polly" Version="$(PollyVersion)" />
     <PackageVersion Include="Polly.Core" Version="$(PollyVersion)" />
     <PackageVersion Include="Polly.Extensions" Version="$(PollyVersion)" />
diff --git a/eng/Test.targets b/eng/Test.targets
index 2c270eac370..a8baacb3403 100644
--- a/eng/Test.targets
+++ b/eng/Test.targets
@@ -15,7 +15,7 @@
     <PackageReference Include="FluentAssertions" />
     <PackageReference Include="GitHubActionsTestLogger" />
     <PackageReference Include="Microsoft.NET.Test.Sdk" />
-    <PackageReference Include="Moq" />
+    <PackageReference Include="NSubstitute" />
     <PackageReference Include="ReportGenerator" PrivateAssets="all" />
     <PackageReference Include="xunit" />
     <PackageReference Include="xunit.runner.visualstudio" PrivateAssets="all" />


Test patch:
Repository: SixLabors/ImageSharp

Issue:
Missing API : `ExifProfile.CreateThumbnail<TPixel>()` 
### ImageSharp version

2.0.0

### Other ImageSharp packages and versions

na

### Environment (Operating system, version and so on)

na

### .NET Framework version

na

### Description

`ExifProfile.CreateThumbnail<TPixel>()` is missing its non-generic overload forcing people to know/understand pixel formats

See this stack overflow question demonstrating that it can cause confusion when pixel formats are unknown to them
https://stackoverflow.com/questions/71095559/how-do-i-extract-a-jpegs-exif-thumbnail-using-imagesharp/71095796

### Steps to Reproduce

na

### Images

_No response_


Hints:

Patch:
diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs
index e0ab8ecf95..665e4753a7 100644
--- a/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs
+++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs
@@ -121,6 +121,14 @@ public IReadOnlyList<IExifValue> Values
             }
         }
 
+        /// <summary>
+        /// Returns the thumbnail in the EXIF profile when available.
+        /// </summary>
+        /// <returns>
+        /// The <see cref="Image"/>.
+        /// </returns>
+        public Image CreateThumbnail() => this.CreateThumbnail<Rgba32>();
+
         /// <summary>
         /// Returns the thumbnail in the EXIF profile when available.
         /// </summary>


Test patch:
diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifProfileTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifProfileTests.cs
index a859852279..1668b7a125 100644
--- a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifProfileTests.cs
+++ b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifProfileTests.cs
@@ -354,10 +354,15 @@ public void Values()
 
             TestProfile(profile);
 
-            using Image<Rgba32> thumbnail = profile.CreateThumbnail<Rgba32>();
+            using Image thumbnail = profile.CreateThumbnail();
             Assert.NotNull(thumbnail);
             Assert.Equal(256, thumbnail.Width);
             Assert.Equal(170, thumbnail.Height);
+
+            using Image<Rgba32> genericThumbnail = profile.CreateThumbnail<Rgba32>();
+            Assert.NotNull(genericThumbnail);
+            Assert.Equal(256, genericThumbnail.Width);
+            Assert.Equal(170, genericThumbnail.Height);
         }
 
         [Fact]
Repository: AvaloniaUI/Avalonia

Issue:
Wrapped RTL text has extra bottom padding
### Describe the bug

![image](https://github.com/AvaloniaUI/Avalonia/assets/5063478/7fb3ad43-57ee-4609-a371-625a01220e56)

Looks like space for one more line is allocated.

### To Reproduce

https://github.com/kerams/font2

### Expected behavior

LTR and RTL wrapped text have the same height.

### Avalonia version

11.2.999-cibuild0049152-alpha

### OS

Windows, Android

### Additional context

_No response_


Hints:

Patch:
diff --git a/src/Avalonia.Base/Media/TextFormatting/BidiReorderer.cs b/src/Avalonia.Base/Media/TextFormatting/BidiReorderer.cs
index 85fea48edb8..0612ecf8e02 100644
--- a/src/Avalonia.Base/Media/TextFormatting/BidiReorderer.cs
+++ b/src/Avalonia.Base/Media/TextFormatting/BidiReorderer.cs
@@ -169,7 +169,7 @@ private static sbyte GetRunBidiLevel(TextRun run, FlowDirection flowDirection, s
 
             if (run is TextEndOfLine)
             {
-                return defaultLevel;
+                return 0;
             }
 
             if(previousLevel is not null)


Test patch:
diff --git a/tests/Avalonia.Skia.UnitTests/Media/TextFormatting/TextFormatterTests.cs b/tests/Avalonia.Skia.UnitTests/Media/TextFormatting/TextFormatterTests.cs
index 83c5fc377c8..5ff0a45e390 100644
--- a/tests/Avalonia.Skia.UnitTests/Media/TextFormatting/TextFormatterTests.cs
+++ b/tests/Avalonia.Skia.UnitTests/Media/TextFormatting/TextFormatterTests.cs
@@ -156,11 +156,15 @@ public void Should_Format_TextLine_With_Non_Text_TextRuns_RightToLeft()
 
                 Assert.Equal(14, textLine.Length);
 
-                var second = textLine.TextRuns[1] as ShapedTextRun;
+                var first = textLine.TextRuns[0] as ShapedTextRun;
 
-                Assert.NotNull(second);
+                var last = textLine.TextRuns[4] as TextEndOfParagraph;
 
-                Assert.Equal("Hello".AsMemory(), second.Text);
+                Assert.NotNull(first);
+
+                Assert.NotNull(last);
+
+                Assert.Equal("Hello".AsMemory(), first.Text);
             }
         }
Repository: AvaloniaUI/Avalonia

Issue:
Add Matrix.Rotate(angle, x, y) overload
### Is your feature request related to a problem? Please describe.

This is not a standard css transformation, but a frequently used in svg. 

### Describe the solution you'd like

as described. 

### Describe alternatives you've considered

_No response_

### Additional context

_No response_


Hints:

Patch:
diff --git a/src/Avalonia.Base/Matrix.cs b/src/Avalonia.Base/Matrix.cs
index a72710ffd4a..5f5aab4f47f 100644
--- a/src/Avalonia.Base/Matrix.cs
+++ b/src/Avalonia.Base/Matrix.cs
@@ -214,6 +214,21 @@ public static Matrix CreateRotation(double radians)
             return new Matrix(cos, sin, -sin, cos, 0, 0);
         }
 
+        /// <summary>
+        /// Creates a rotation matrix using the given rotation in radians around center point. 
+        /// </summary>
+        /// <param name="radians">The amount of rotation, in radians. </param>
+        /// <param name="center">The location of center point. </param>
+        /// <returns></returns>
+        public static Matrix CreateRotation(double radians, Point center)
+        {
+            var cos = Math.Cos(radians);
+            var sin = Math.Sin(radians);
+            var x = center.X;
+            var y = center.Y;
+            return new Matrix(cos, sin, -sin, cos, x * (1.0 - cos) + y * sin, y * (1.0 - cos) - x * sin);
+        }
+
         /// <summary>
         /// Creates a skew matrix from the given axis skew angles in radians.
         /// </summary>


Test patch:
diff --git a/tests/Avalonia.Base.UnitTests/MatrixTests.cs b/tests/Avalonia.Base.UnitTests/MatrixTests.cs
index d111c142581..9fccdf25fce 100644
--- a/tests/Avalonia.Base.UnitTests/MatrixTests.cs
+++ b/tests/Avalonia.Base.UnitTests/MatrixTests.cs
@@ -61,6 +61,20 @@ public void Transform_Point_Should_Return_Correct_Value_For_Rotated_Matrix()
 
         AssertCoordinatesEqualWithReducedPrecision(expected, actual);
     }
+
+    [Fact]
+    public void Transform_Point_Should_Return_Correct_Value_For_Rotate_Matrix_With_Center_Point()
+    {
+        var expected = Vector2.Transform(
+            new Vector2(0, 10), 
+            Matrix3x2.CreateRotation((float)Matrix.ToRadians(30), new Vector2(3, 5)));
+
+        var matrix = Matrix.CreateRotation(Matrix.ToRadians(30), new Point(3, 5));
+        var point = new Point(0, 10);
+        var actual = matrix.Transform(point);
+
+        AssertCoordinatesEqualWithReducedPrecision(expected, actual);
+    }
     
     [Fact]
     public void Transform_Point_Should_Return_Correct_Value_For_Scaled_Matrix()
Repository: AvaloniaUI/Avalonia

Issue:
NumericUpDown - Changes to FormatString are not reflected immediately
### Describe the bug

When FormatString binding value is changed, the new format is applied only after focusing or interacting with the control.

### To Reproduce

1. Create NumericUpDown with binding to FormatString.
2. Change bound value
3. The content of NumericUpDown stays the same.

### Expected behavior

Content of NumericUpDown changes accoring to the new format string immediately.

### Avalonia version

11.1.1

### OS

Windows 10

### Additional context

I believe that the problem is in `SyncTextAndValueProperties` call in `OnFormatStringChanged`.
The call should set `forceTextUpdate=true`, ie. 
```
protected virtual void OnFormatStringChanged(string? oldValue, string? newValue)
{
    if (IsInitialized)
    {
        SyncTextAndValueProperties(false, null, true);
    }
}
```


Hints:

Patch:
diff --git a/src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs b/src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs
index 0edc7984949..f0dde6925d5 100644
--- a/src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs
+++ b/src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs
@@ -479,7 +479,7 @@ protected virtual void OnFormatStringChanged(string? oldValue, string? newValue)
         {
             if (IsInitialized)
             {
-                SyncTextAndValueProperties(false, null);
+                SyncTextAndValueProperties(false, null, true);
             }
         }
 


Test patch:
diff --git a/tests/Avalonia.Controls.UnitTests/NumericUpDownTests.cs b/tests/Avalonia.Controls.UnitTests/NumericUpDownTests.cs
index 24f246d188d..10139be0d45 100644
--- a/tests/Avalonia.Controls.UnitTests/NumericUpDownTests.cs
+++ b/tests/Avalonia.Controls.UnitTests/NumericUpDownTests.cs
@@ -62,6 +62,24 @@ public void Increment_Decrement_Tests(decimal min, decimal max, decimal? value,
             Assert.Equal(control.Value, expected);
         }
 
+        [Fact]
+        public void FormatString_Is_Applied_Immediately()
+        {
+            RunTest((control, textbox) =>
+            {
+                const decimal value = 10.11m;
+
+                // Establish and verify initial conditions.
+                control.FormatString = "F0";
+                control.Value = value;
+                Assert.Equal(value.ToString("F0"), control.Text);
+
+                // Check that FormatString is applied.
+                control.FormatString = "F2";
+                Assert.Equal(value.ToString("F2"), control.Text);
+            });
+        }
+
         public static IEnumerable<object[]> Increment_Decrement_TestData()
         {
             // if min and max are not defined and value was null, 0 should be ne new value after spin