Skip to content

Commit

Permalink
Generate sealed class for windows runtime library compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
christianhelle committed Nov 9, 2017
1 parent 0559618 commit 2e0257c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion vs2017/VSPackage.Tests/CSharpCodeGeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void GenerateCodeDoesNotReturnNull()
[TestMethod]
public void GeneratedCodeIsAPublicClass()
{
Assert.IsTrue(actual.Contains("public partial class"));
Assert.IsTrue(actual.Contains("public sealed partial class"));
}

[TestMethod]
Expand Down
2 changes: 1 addition & 1 deletion vs2017/VSPackage.Tests/CSharpCodeGeneratorTestsInternal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void GenerateCodeDoesNotReturnNull()
[TestMethod]
public void GeneratedCodeIsAnInternalClass()
{
Assert.IsTrue(actual.Contains("internal partial class"));
Assert.IsTrue(actual.Contains("internal sealed partial class"));
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void GenerateCodeDoesNotReturnNull()
[TestMethod]
public void GeneratedCodeIsFriendClass()
{
Assert.IsTrue(actual.Contains("Partial Friend Class"));
Assert.IsTrue(actual.Contains("Partial Friend NotInheritable Class"));
}

[TestMethod]
Expand Down
5 changes: 3 additions & 2 deletions vs2017/VSPackage/CustomTool/CodeDomCodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ public override string GenerateCode()
var targetClass = new CodeTypeDeclaration(className)
{
IsClass = true,
IsPartial = true,
TypeAttributes = classAccessibility.HasValue ? classAccessibility.Value : TypeAttributes.Public
IsPartial = true,
TypeAttributes = TypeAttributes.Sealed | (classAccessibility ?? TypeAttributes.Public),
Attributes = MemberAttributes.Public | MemberAttributes.Static | MemberAttributes.Final
};

const string resourceLoaderType = "ResourceLoader";
Expand Down

0 comments on commit 2e0257c

Please sign in to comment.