diff --git a/ICSharpCode.BamlDecompiler/Rewrite/ConnectionIdRewritePass.cs b/ICSharpCode.BamlDecompiler/Rewrite/ConnectionIdRewritePass.cs
index ed51d50a9..0c082902c 100644
--- a/ICSharpCode.BamlDecompiler/Rewrite/ConnectionIdRewritePass.cs
+++ b/ICSharpCode.BamlDecompiler/Rewrite/ConnectionIdRewritePass.cs
@@ -22,13 +22,12 @@ using System.Linq;
using System.Reflection.Metadata;
using System.Xml.Linq;
+using ICSharpCode.BamlDecompiler.Xaml;
using ICSharpCode.Decompiler.CSharp;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.IL.Transforms;
using ICSharpCode.Decompiler.Util;
-using ICSharpCode.BamlDecompiler.Xaml;
-
namespace ICSharpCode.BamlDecompiler.Rewrite
{
using ICSharpCode.Decompiler.TypeSystem;
@@ -67,6 +66,11 @@ namespace ICSharpCode.BamlDecompiler.Rewrite
{
element.Add(new XAttribute(xName, fieldAssignment.Field.Name));
}
+ // x:FieldModifier can only be "public" or "internal" (in C#), where "internal" is the default and thus omitted
+ if (fieldAssignment.Field.Accessibility is Accessibility.Public)
+ {
+ element.Add(new XAttribute(ctx.GetKnownNamespace("FieldModifier", XamlContext.KnownNamespace_Xaml, element), "public"));
+ }
ctx.GeneratedMembers.Add(fieldAssignment.Field.MetadataToken);
found = true;
}
diff --git a/ILSpy.BamlDecompiler.Tests/BamlTestRunner.cs b/ILSpy.BamlDecompiler.Tests/BamlTestRunner.cs
index 61aa2fb11..951d3c5c6 100644
--- a/ILSpy.BamlDecompiler.Tests/BamlTestRunner.cs
+++ b/ILSpy.BamlDecompiler.Tests/BamlTestRunner.cs
@@ -17,10 +17,8 @@
// DEALINGS IN THE SOFTWARE.
using System;
-using System.Collections;
using System.IO;
using System.Linq;
-using System.Threading;
using System.Xml.Linq;
using ICSharpCode.BamlDecompiler;
@@ -155,6 +153,12 @@ namespace ILSpy.BamlDecompiler.Tests
RunTest("cases/issue2116");
}
+ [Test]
+ public void Issue3318()
+ {
+ RunTest("cases/issue3318");
+ }
+
[Test]
public void ReadonlyProperty()
{
diff --git a/ILSpy.BamlDecompiler.Tests/Cases/Issue3318.xaml b/ILSpy.BamlDecompiler.Tests/Cases/Issue3318.xaml
new file mode 100644
index 000000000..d873046b1
--- /dev/null
+++ b/ILSpy.BamlDecompiler.Tests/Cases/Issue3318.xaml
@@ -0,0 +1,3 @@
+
+
+
diff --git a/ILSpy.BamlDecompiler.Tests/Cases/Issue3318.xaml.cs b/ILSpy.BamlDecompiler.Tests/Cases/Issue3318.xaml.cs
new file mode 100644
index 000000000..17789b0b5
--- /dev/null
+++ b/ILSpy.BamlDecompiler.Tests/Cases/Issue3318.xaml.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace ILSpy.BamlDecompiler.Tests.Cases
+{
+ ///
+ /// Interaction logic for Issue3318.xaml
+ ///
+ public partial class Issue3318 : UserControl
+ {
+ public Issue3318()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/ILSpy.BamlDecompiler.Tests/ILSpy.BamlDecompiler.Tests.csproj b/ILSpy.BamlDecompiler.Tests/ILSpy.BamlDecompiler.Tests.csproj
index ca43a1bbc..aa80040c3 100644
--- a/ILSpy.BamlDecompiler.Tests/ILSpy.BamlDecompiler.Tests.csproj
+++ b/ILSpy.BamlDecompiler.Tests/ILSpy.BamlDecompiler.Tests.csproj
@@ -62,6 +62,7 @@
+
MyControl.xaml
@@ -104,6 +105,9 @@
MSBuild:Compile
+
+ MSBuild:Compile
+
Designer