Skip to content

Commit c027f32

Browse files
committed
Bringing gh-pages up to date
2 parents b3674d1 + 7c3f4a4 commit c027f32

File tree

9 files changed

+248
-2
lines changed

9 files changed

+248
-2
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Sync master to gh-pages
2+
on:
3+
push:
4+
branches:
5+
- master
6+
7+
jobs:
8+
sync:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout master
12+
uses: actions/checkout@v4
13+
14+
- name: Switch to gh-pages
15+
run: |
16+
git config user.name "GitHub Actions"
17+
git config user.email "actions@github.com"
18+
# Fetch all branches from the remote
19+
git fetch origin
20+
# Check if the gh-pages branch exists on the remote
21+
if git ls-remote --exit-code --heads origin gh-pages; then
22+
# If it exists, check it out
23+
git checkout gh-pages
24+
git pull origin gh-pages
25+
else
26+
# If it doesn't exist, create it
27+
git checkout --orphan gh-pages
28+
git rm -rf . # Remove all files to start with a clean branch
29+
git commit --allow-empty -m "Initial commit on gh-pages"
30+
git push origin gh-pages
31+
fi
32+
# Merge master into gh-pages
33+
git merge master --allow-unrelated-histories --no-edit
34+
git push origin gh-pages

.github/workflows/static.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Simple workflow for deploying static content to GitHub Pages
2+
name: Deploy static content to Pages
3+
4+
on:
5+
# Runs on pushes targeting the default branch
6+
push:
7+
branches: ["gh-pages"]
8+
9+
# Allows you to run this workflow manually from the Actions tab
10+
workflow_dispatch:
11+
12+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
18+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
19+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
20+
concurrency:
21+
group: "pages"
22+
cancel-in-progress: false
23+
24+
jobs:
25+
# Single deploy job since we're just deploying
26+
deploy:
27+
environment:
28+
name: github-pages
29+
url: ${{ steps.deployment.outputs.page_url }}
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
with:
35+
ref: gh-pages # Specify the branch to checkout
36+
37+
- name: Setup Pages
38+
uses: actions/configure-pages@v5
39+
40+
- name: Upload 'Docs' folder as artifact
41+
uses: actions/upload-pages-artifact@v3
42+
with:
43+
# Upload only the 'Docs' folder
44+
path: './Docs'
45+
46+
- name: Deploy to GitHub Pages
47+
id: deployment
48+
uses: actions/deploy-pages@v4

Code/PropertyGridHelpers/UIEditors/CollectionUIEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public CollectionUIEditor() : base(type: typeof(List<T>))
2626
/// <returns></returns>
2727
protected override object CreateInstance(Type itemType)
2828
{
29-
return typeof(T) == typeof(string) ? string.Empty : (object)Activator.CreateInstance<T>();
29+
return itemType == typeof(string) ? string.Empty : (object)Activator.CreateInstance(itemType);
3030
}
3131
}
3232
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
using PropertyGridHelpers.Attributes;
2+
using System.Linq;
3+
using Xunit;
4+
#if NET35
5+
#else
6+
using Xunit.Abstractions;
7+
#endif
8+
9+
#if NET35
10+
namespace PropertyGridHelpersTest.net35.Attributes
11+
#elif NET452
12+
namespace PropertyGridHelpersTest.net452.Attributes
13+
#elif NET462
14+
namespace PropertyGridHelpersTest.net462.Attributes
15+
#elif NET472
16+
namespace PropertyGridHelpersTest.net472.Attributes
17+
#elif NET481
18+
namespace PropertyGridHelpersTest.net481.Attributes
19+
#elif WINDOWS7_0
20+
namespace PropertyGridHelpersTest.net60.W7.Attributes
21+
#elif WINDOWS10_0
22+
namespace PropertyGridHelpersTest.net60.W10.Attributes
23+
#elif NET8_0
24+
namespace PropertyGridHelpersTest.net80.Attributes
25+
#elif NET9_0
26+
namespace PropertyGridHelpersTest.net90.Attributes
27+
#endif
28+
{
29+
/// <summary>
30+
/// Tests for the Enum Image Attribute
31+
/// </summary>
32+
public class EnumImageAttributeTest
33+
{
34+
#if NET35
35+
#else
36+
readonly ITestOutputHelper OutputHelper;
37+
38+
/// <summary>
39+
/// Initializes a new instance of the <see cref="EnumImageAttributeTest"/> class.
40+
/// </summary>
41+
/// <param name="output">The output.</param>
42+
public EnumImageAttributeTest(
43+
ITestOutputHelper output)
44+
45+
{
46+
OutputHelper = output;
47+
}
48+
#endif
49+
enum TestEnum
50+
{
51+
[EnumImage("TestItem1")]
52+
Test1,
53+
[EnumImage]
54+
Test2
55+
}
56+
57+
/// <summary>
58+
/// Get the attribute with a string test
59+
/// </summary>
60+
[Fact]
61+
public void EnumImageWithTextTest()
62+
{
63+
// Retrieve the attributes from TestEnum.Test1
64+
var memberInfo = typeof(TestEnum).GetField(nameof(TestEnum.Test1));
65+
var attributes = memberInfo.GetCustomAttributes(typeof(EnumImageAttribute), false);
66+
67+
// Ensure an attribute is found
68+
Assert.NotEmpty(attributes);
69+
70+
// Cast to EnumImageAttribute and verify the EnumImage property
71+
var attribute = (EnumImageAttribute)attributes.FirstOrDefault();
72+
Assert.NotNull(attribute);
73+
Assert.Equal("TestItem1", attribute.EnumImage);
74+
}
75+
76+
/// <summary>
77+
/// Verify the EnumImageAttribute without any parameter.
78+
/// </summary>
79+
[Fact]
80+
public void EnumImageWithoutTextTest()
81+
{
82+
// Retrieve the attributes from TestEnum.Test2
83+
var memberInfo = typeof(TestEnum).GetField(nameof(TestEnum.Test2));
84+
var attributes = memberInfo.GetCustomAttributes(typeof(EnumImageAttribute), false);
85+
86+
// Ensure an attribute is found
87+
Assert.NotEmpty(attributes);
88+
89+
// Cast to EnumImageAttribute and verify the EnumImage property
90+
var attribute = (EnumImageAttribute)attributes.FirstOrDefault();
91+
Assert.NotNull(attribute);
92+
Assert.Null(attribute.EnumImage);
93+
}
94+
}
95+
}

Code/PropertyGridHelpersTest/Controls/FlagCheckedListBoxItemTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using PropertyGridHelpers.Controls;
2-
using System;
32
using Xunit;
43
#if NET35
4+
using System;
55
#else
66
using Xunit.Abstractions;
77
#endif

Code/PropertyGridHelpersTest/GlobalSuppressions.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,42 +12,50 @@
1212
[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "<Pending>", Scope = "namespace", Target = "~N:PropertyGridHelpersTest.net35.UIEditor")]
1313
[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "<Pending>", Scope = "namespace", Target = "~N:PropertyGridHelpersTest.net35.Converters")]
1414
[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "<Pending>", Scope = "namespace", Target = "~N:PropertyGridHelpersTest.net35.Controls")]
15+
[assembly: SuppressMessage("Assertions", "xUnit2006:Do not use invalid string equality check", Justification = "<Pending>", Scope = "member", Target = "~M:PropertyGridHelpersTest.net35.Attributes.EnumImageAttributeTest.EnumImageWithTextTest")]
16+
[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "<Pending>", Scope = "namespace", Target = "~N:PropertyGridHelpersTest.net35.Attributes")]
1517
#endif
1618

1719
#if NET452
1820
[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "<Pending>", Scope = "namespace", Target = "~N:PropertyGridHelpersTest.net452.Controls")]
1921
[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "<Pending>", Scope = "namespace", Target = "~N:PropertyGridHelpersTest.net452.Converters")]
2022
[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "<Pending>", Scope = "namespace", Target = "~N:PropertyGridHelpersTest.net452.UIEditor")]
23+
[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "<Pending>", Scope = "namespace", Target = "~N:PropertyGridHelpersTest.net452.Attributes")]
2124
#endif
2225

2326
#if NET462
2427
[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "<Pending>", Scope = "namespace", Target = "~N:PropertyGridHelpersTest.net462.Converters")]
2528
[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "<Pending>", Scope = "namespace", Target = "~N:PropertyGridHelpersTest.net462.Controls")]
2629
[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "<Pending>", Scope = "namespace", Target = "~N:PropertyGridHelpersTest.net462.UIEditor")]
30+
[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "<Pending>", Scope = "namespace", Target = "~N:PropertyGridHelpersTest.net462.Attributes")]
2731
#endif
2832

2933
#if NET472
3034
[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "<Pending>", Scope = "namespace", Target = "~N:PropertyGridHelpersTest.net472.Converters")]
3135
[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "<Pending>", Scope = "namespace", Target = "~N:PropertyGridHelpersTest.net472.Controls")]
3236
[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "<Pending>", Scope = "namespace", Target = "~N:PropertyGridHelpersTest.net472.UIEditor")]
37+
[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "<Pending>", Scope = "namespace", Target = "~N:PropertyGridHelpersTest.net472.Attributes")]
3338
#endif
3439

3540
#if NET481
3641
[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "<Pending>", Scope = "namespace", Target = "~N:PropertyGridHelpersTest.net481.Converters")]
3742
[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "<Pending>", Scope = "namespace", Target = "~N:PropertyGridHelpersTest.net481.Controls")]
3843
[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "<Pending>", Scope = "namespace", Target = "~N:PropertyGridHelpersTest.net481.UIEditor")]
44+
[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "<Pending>", Scope = "namespace", Target = "~N:PropertyGridHelpersTest.net481.Attributes")]
3945
#endif
4046

4147
#if WINDOWS7_0
4248
[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "<Pending>", Scope = "namespace", Target = "~N:PropertyGridHelpersTest.net60.W7.Controls")]
4349
[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "<Pending>", Scope = "namespace", Target = "~N:PropertyGridHelpersTest.net60.W7.Converters")]
4450
[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "<Pending>", Scope = "namespace", Target = "~N:PropertyGridHelpersTest.net60.W7.UIEditor")]
51+
[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "<Pending>", Scope = "namespace", Target = "~N:PropertyGridHelpersTest.net60.W7.Attributes")]
4552
#endif
4653

4754
#if WINDOWS10_0
4855
[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "<Pending>", Scope = "namespace", Target = "~N:PropertyGridHelpersTest.net60.W10.UIEditor")]
4956
[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "<Pending>", Scope = "namespace", Target = "~N:PropertyGridHelpersTest.net60.W10.Controls")]
5057
[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "<Pending>", Scope = "namespace", Target = "~N:PropertyGridHelpersTest.net60.W10.Converters")]
58+
[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "<Pending>", Scope = "namespace", Target = "~N:PropertyGridHelpersTest.net60.W10.Attributes")]
5159
#endif
5260

5361
#if NET8_0
@@ -59,6 +67,7 @@
5967
[assembly: SuppressMessage("Style", "IDE0290:Use primary constructor", Justification = "<Pending>", Scope = "member", Target = "~M:PropertyGridHelpersTest.net80.Converters.TypeConverterTest.#ctor(Xunit.Abstractions.ITestOutputHelper)")]
6068
[assembly: SuppressMessage("Style", "IDE0290:Use primary constructor", Justification = "<Pending>", Scope = "member", Target = "~M:PropertyGridHelpersTest.net80.UIEditor.CollectionUIEditorTest.#ctor(Xunit.Abstractions.ITestOutputHelper)")]
6169
[assembly: SuppressMessage("Style", "IDE0290:Use primary constructor", Justification = "<Pending>", Scope = "member", Target = "~M:PropertyGridHelpersTest.net80.UIEditor.FlagEnumUIEditorTest.#ctor(Xunit.Abstractions.ITestOutputHelper)")]
70+
[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "<Pending>", Scope = "namespace", Target = "~N:PropertyGridHelpersTest.net80.Attributes")]
6271
#endif
6372

6473
#if NET9_0
@@ -70,4 +79,5 @@
7079
[assembly: SuppressMessage("Style", "IDE0290:Use primary constructor", Justification = "<Pending>", Scope = "member", Target = "~M:PropertyGridHelpersTest.net90.UIEditor.FlagEnumUIEditorTest.#ctor(Xunit.Abstractions.ITestOutputHelper)")]
7180
[assembly: SuppressMessage("Style", "IDE0290:Use primary constructor", Justification = "<Pending>", Scope = "member", Target = "~M:PropertyGridHelpersTest.net90.Converters.TypeConverterTest.#ctor(Xunit.Abstractions.ITestOutputHelper)")]
7281
[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "<Pending>", Scope = "namespace", Target = "~N:PropertyGridHelpersTest.net90.UIEditor")]
82+
[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "<Pending>", Scope = "namespace", Target = "~N:PropertyGridHelpersTest.net90.Attributes")]
7383
#endif

Code/PropertyGridHelpersTest/PropertyGridHelpersTest.xml

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Code/PropertyGridHelpersTest/UIEditor/CollectionUIEditorTest.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using PropertyGridHelpers.UIEditors;
22
using System;
3+
using System.Reflection;
34
using Xunit;
45
#if NET35
56
#else
@@ -52,6 +53,40 @@ public void AddItemToListTest()
5253
Output(testItem.ToString());
5354
}
5455

56+
/// <summary>
57+
/// Tests the CreateInstance method.
58+
/// </summary>
59+
[Fact]
60+
public void CreateInstanceTest()
61+
{
62+
// Arrange
63+
var collectionEditor = new CollectionUIEditor<string>();
64+
65+
// Use reflection to access the protected CreateInstance method
66+
var method = typeof(CollectionUIEditor<string>).GetMethod(
67+
"CreateInstance",
68+
BindingFlags.Instance | BindingFlags.NonPublic
69+
);
70+
71+
Assert.NotNull(method); // Ensure the method exists
72+
73+
// Act
74+
var result = method.Invoke(collectionEditor, new object[] { typeof(string) });
75+
76+
// Assert
77+
Assert.NotNull(result);
78+
Assert.IsType<string>(result);
79+
Assert.Equal(string.Empty, result); // Verify it returns an empty string for typeof(string)
80+
81+
// Test with a different type
82+
var intResult = method.Invoke(collectionEditor, new object[] { typeof(int) });
83+
Assert.NotNull(intResult);
84+
Assert.IsType<int>(intResult);
85+
Assert.Equal(0, intResult); // Default value of int
86+
87+
Output($"CreateInstance returned: {result} for string, {intResult} for int.");
88+
}
89+
5590
/// <summary>
5691
/// Outputs the specified message.
5792
/// </summary>

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ The following has been done to the project:
66
* The dll is now built for eight different versions of the .NET framework. (If you need one that is not covered by what is available, let me know and I will try to add it to the list)
77
* There is a sample control and form in the source code now.
88
* There are some unit tests for the code, and they are able to run in every .NET framework version the library is compiled in.
9+
10+
Related Locations
11+
* [Code Coverage Report](https://dparvin.github.io/PropertyGridHelpers/)
12+
* [Publish Package](https://www.nuget.org/packages/PropertyGridHelpers)

0 commit comments

Comments
 (0)