-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable nullability and fix all warnings
- Loading branch information
1 parent
933c91d
commit 718a7a4
Showing
82 changed files
with
1,779 additions
and
2,536 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,10 @@ | ||
# Inspired by, but heavily reduced version of this: | ||
# https://github.com/github/gitignore/blob/master/VisualStudio.gitignore | ||
|
||
# User-specific files | ||
*.suo | ||
*.user | ||
|
||
# Build results | ||
[Dd]ebug/ | ||
[Rr]elease/ | ||
x64/ | ||
x86/ | ||
[Oo]bj/ | ||
[Bb]in/ | ||
packages/ | ||
|
||
# Logs | ||
[Ll]og/ | ||
|
||
# Visual Studio 2015 cache/options directory | ||
.vs/ | ||
|
||
# Node.js Tools for Visual Studio | ||
.vscode/ | ||
.config/ | ||
.github/ | ||
bin/ | ||
obj/ | ||
node_modules/ | ||
|
||
# Typescript v1 declaration files | ||
typings/ | ||
|
||
## Ignore Umbraco files/folders generated for each instance | ||
## | ||
## Get latest from https://github.com/github/gitignore/blob/master/Umbraco.gitignore | ||
|
||
# Umbraco | ||
# Ignore unimportant folders generated by Umbraco | ||
**/App_Data/Logs/ | ||
**/App_Data/[Pp]review/ | ||
**/App_Data/TEMP/ | ||
**/App_Data/NuGetBackup/ | ||
**/App_Data/NuCache* | ||
**/[Mm]edia | ||
**/App_Data/umbraco.config | ||
**/App_Data/cache/ | ||
# ModelsBuilder out of date flag | ||
ood.flag | ||
|
||
# Don't ignore Umbraco packages (VisualStudio.gitignore mistakes this for a NuGet packages folder) | ||
# Make sure to include details from VisualStudio.gitignore BEFORE this | ||
!**/App_Data/[Pp]ackages/ | ||
!**/[Uu]mbraco/[Dd]eveloper/[Pp]ackages | ||
|
||
# DemoWebsite | ||
src/DemoWebsite*/App_Plugins/Perplex.ContentBlocks | ||
src/DemoWebsite*/App_Data/Models | ||
src/DemoWebsite*/App_Data/Umbraco.sdf | ||
src/DemoWebsite*/[Uu]mbraco/* | ||
!src/DemoWebsite.v9/[Uu]mbraco/models | ||
*.css | ||
|
||
# NuGet / Our Umbraco packages | ||
pkg/**/*.nupkg | ||
pkg/**/*.zip | ||
/src/.vscode/ | ||
**/*.nupkg | ||
**/App_Plugins/**/*.css |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,25 @@ | ||
<Project> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<TreatWarningsAsErrors>True</TreatWarningsAsErrors> | ||
<DebugType>embedded</DebugType> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Label="NuGet Package"> | ||
<Version>3.0.0-alpha.1</Version> | ||
<Authors>Perplex Digital</Authors> | ||
<Company>Perplex Digital</Company> | ||
<Authors>$(Company)</Authors> | ||
<Copyright>© $(Company)</Copyright> | ||
<PackageProjectUrl>https://github.com/PerplexDigital/Perplex.ContentBlocks</PackageProjectUrl> | ||
<PackageIcon>icon.png</PackageIcon> | ||
<PackageIconUrl /> | ||
<RepositoryUrl>https://github.com/PerplexDigital/Perplex.ContentBlocks</RepositoryUrl> | ||
<RepositoryType>git</RepositoryType> | ||
<PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
<NoWarn>$(NoWarn);CS1591</NoWarn> | ||
</PropertyGroup> | ||
|
||
</Project> |
13 changes: 6 additions & 7 deletions
13
src/Perplex.ContentBlocks.Core/Categories/Constants.Categories.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
using System; | ||
|
||
namespace Perplex.ContentBlocks | ||
namespace Perplex.ContentBlocks; | ||
|
||
public static partial class Constants | ||
{ | ||
public static partial class Constants | ||
public static partial class Categories | ||
{ | ||
public static partial class Categories | ||
{ | ||
public static readonly Guid Headers = new Guid("0a893d02-9166-437d-90e8-264524f410c0"); | ||
public static readonly Guid Content = new Guid("337cdd43-b90f-4aee-82f4-3c991b3cb8eb"); | ||
} | ||
public static readonly Guid Headers = new Guid("0a893d02-9166-437d-90e8-264524f410c0"); | ||
public static readonly Guid Content = new Guid("337cdd43-b90f-4aee-82f4-3c991b3cb8eb"); | ||
} | ||
} |
19 changes: 8 additions & 11 deletions
19
src/Perplex.ContentBlocks.Core/Categories/ContentBlockCategory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,11 @@ | ||
using System; | ||
namespace Perplex.ContentBlocks.Categories; | ||
|
||
namespace Perplex.ContentBlocks.Categories | ||
public class ContentBlockCategory : IContentBlockCategory | ||
{ | ||
public class ContentBlockCategory : IContentBlockCategory | ||
{ | ||
public Guid Id { get; set; } | ||
public string Name { get; set; } | ||
public string Icon { get; set; } | ||
public bool IsHidden { get; set; } | ||
public bool IsEnabledForHeaders { get; set; } | ||
public bool IsDisabledForBlocks { get; set; } | ||
} | ||
public Guid Id { get; set; } | ||
public string Name { get; set; } = ""; | ||
public string Icon { get; set; } = ""; | ||
public bool IsHidden { get; set; } | ||
public bool IsEnabledForHeaders { get; set; } | ||
public bool IsDisabledForBlocks { get; set; } | ||
} |
29 changes: 6 additions & 23 deletions
29
src/Perplex.ContentBlocks.Core/Categories/ContentBlockCategoryComposer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,13 @@ | ||
#if NET5_0 | ||
using Umbraco.Cms.Core.Composing; | ||
using Umbraco.Cms.Core.Composing; | ||
using Umbraco.Cms.Core.DependencyInjection; | ||
using Umbraco.Extensions; | ||
#elif NET472 | ||
using Umbraco.Core; | ||
using Umbraco.Core.Composing; | ||
#endif | ||
|
||
namespace Perplex.ContentBlocks.Categories | ||
namespace Perplex.ContentBlocks.Categories; | ||
|
||
public class ContentBlockCategoriesComposer : IComposer | ||
{ | ||
#if NET5_0 | ||
public class ContentBlockCategoriesComposer : IComposer | ||
{ | ||
public void Compose(IUmbracoBuilder builder) | ||
{ | ||
builder.Services.AddUnique<IContentBlockCategoryRepository, InMemoryContentBlockCategoryRepository>(); | ||
} | ||
} | ||
#elif NET472 | ||
[RuntimeLevel(MinLevel = RuntimeLevel.Run)] | ||
public class ContentBlockCategoriesComposer : IUserComposer | ||
public void Compose(IUmbracoBuilder builder) | ||
{ | ||
public void Compose(Composition composition) | ||
{ | ||
composition.RegisterUnique<IContentBlockCategoryRepository, InMemoryContentBlockCategoryRepository>(); | ||
} | ||
builder.Services.AddUnique<IContentBlockCategoryRepository, InMemoryContentBlockCategoryRepository>(); | ||
} | ||
#endif | ||
} |
37 changes: 18 additions & 19 deletions
37
src/Perplex.ContentBlocks.Core/Categories/IContentBlockCategory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,25 @@ | ||
using System; | ||
|
||
namespace Perplex.ContentBlocks.Categories | ||
namespace Perplex.ContentBlocks.Categories; | ||
|
||
public interface IContentBlockCategory | ||
{ | ||
public interface IContentBlockCategory | ||
{ | ||
Guid Id { get; } | ||
string Name { get; } | ||
string Icon { get; } | ||
Guid Id { get; } | ||
string Name { get; } | ||
string Icon { get; } | ||
|
||
/// <summary> | ||
/// Hidden categories do not show up in the UI | ||
/// </summary> | ||
bool IsHidden { get; } | ||
/// <summary> | ||
/// Hidden categories do not show up in the UI | ||
/// </summary> | ||
bool IsHidden { get; } | ||
|
||
/// <summary> | ||
/// Enables this category when selecting a header | ||
/// </summary> | ||
bool IsEnabledForHeaders { get; } | ||
/// <summary> | ||
/// Enables this category when selecting a header | ||
/// </summary> | ||
bool IsEnabledForHeaders { get; } | ||
|
||
/// <summary> | ||
/// Disables this category when selecting a block | ||
/// </summary> | ||
bool IsDisabledForBlocks { get; } | ||
} | ||
/// <summary> | ||
/// Disables this category when selecting a block | ||
/// </summary> | ||
bool IsDisabledForBlocks { get; } | ||
} |
16 changes: 6 additions & 10 deletions
16
src/Perplex.ContentBlocks.Core/Categories/IContentBlockCategoryRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,12 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
namespace Perplex.ContentBlocks.Categories; | ||
|
||
namespace Perplex.ContentBlocks.Categories | ||
public interface IContentBlockCategoryRepository | ||
{ | ||
public interface IContentBlockCategoryRepository | ||
{ | ||
void Add(IContentBlockCategory category); | ||
void Add(IContentBlockCategory category); | ||
|
||
void Remove(Guid id); | ||
void Remove(Guid id); | ||
|
||
IContentBlockCategory GetById(Guid id); | ||
IContentBlockCategory? GetById(Guid id); | ||
|
||
IEnumerable<IContentBlockCategory> GetAll(bool includeHidden); | ||
} | ||
IEnumerable<IContentBlockCategory> GetAll(bool includeHidden); | ||
} |
76 changes: 36 additions & 40 deletions
76
src/Perplex.ContentBlocks.Core/Categories/InMemoryContentBlockCategoryRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,50 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using static Perplex.ContentBlocks.Constants.PropertyEditor; | ||
using static Perplex.ContentBlocks.Constants.PropertyEditor; | ||
using categories = Perplex.ContentBlocks.Constants.Categories; | ||
|
||
namespace Perplex.ContentBlocks.Categories | ||
namespace Perplex.ContentBlocks.Categories; | ||
|
||
public class InMemoryContentBlockCategoryRepository : IContentBlockCategoryRepository | ||
{ | ||
public class InMemoryContentBlockCategoryRepository : IContentBlockCategoryRepository | ||
private readonly IDictionary<Guid, IContentBlockCategory> _categories = new IContentBlockCategory[] | ||
{ | ||
private readonly IDictionary<Guid, IContentBlockCategory> _categories = new IContentBlockCategory[] | ||
new ContentBlockCategory | ||
{ | ||
Id = categories.Headers, | ||
Name = "Headers", | ||
Icon = $"{AssetsFolder}/icons.svg#icon-cat-header", | ||
IsEnabledForHeaders = true, | ||
IsDisabledForBlocks = true, | ||
}, | ||
|
||
new ContentBlockCategory | ||
{ | ||
new ContentBlockCategory | ||
{ | ||
Id = categories.Headers, | ||
Name = "Headers", | ||
Icon = $"{AssetsFolder}/icons.svg#icon-cat-header", | ||
IsEnabledForHeaders = true, | ||
IsDisabledForBlocks = true, | ||
}, | ||
Id = categories.Content, | ||
Name = "Content", | ||
Icon = $"{AssetsFolder}/icons.svg#icon-cat-content", | ||
}, | ||
}.ToDictionary(d => d.Id); | ||
|
||
new ContentBlockCategory | ||
{ | ||
Id = categories.Content, | ||
Name = "Content", | ||
Icon = $"{AssetsFolder}/icons.svg#icon-cat-content", | ||
}, | ||
}.ToDictionary(d => d.Id); | ||
public IContentBlockCategory? GetById(Guid id) | ||
{ | ||
return _categories.TryGetValue(id, out var definition) ? definition : null; | ||
} | ||
|
||
public IContentBlockCategory GetById(Guid id) | ||
public IEnumerable<IContentBlockCategory> GetAll(bool includeHidden) | ||
{ | ||
var categories = _categories.Values; | ||
if (includeHidden) | ||
{ | ||
return _categories.TryGetValue(id, out var definition) ? definition : null; | ||
return categories; | ||
} | ||
|
||
public IEnumerable<IContentBlockCategory> GetAll(bool includeHidden) | ||
else | ||
{ | ||
var categories = _categories.Values; | ||
if (includeHidden) | ||
{ | ||
return categories; | ||
} | ||
else | ||
{ | ||
return categories.Where(category => !category.IsHidden); | ||
} | ||
return categories.Where(category => !category.IsHidden); | ||
} | ||
} | ||
|
||
public void Add(IContentBlockCategory category) | ||
=> _categories[category.Id] = category; | ||
public void Add(IContentBlockCategory category) | ||
=> _categories[category.Id] = category; | ||
|
||
public void Remove(Guid id) | ||
=> _categories.Remove(id); | ||
} | ||
public void Remove(Guid id) | ||
=> _categories.Remove(id); | ||
} |
37 changes: 18 additions & 19 deletions
37
src/Perplex.ContentBlocks.Core/Definitions/ContentBlockDefinition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,23 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
namespace Perplex.ContentBlocks.Definitions; | ||
|
||
namespace Perplex.ContentBlocks.Definitions | ||
public class ContentBlockDefinition : IContentBlockDefinition | ||
{ | ||
public class ContentBlockDefinition : IContentBlockDefinition | ||
{ | ||
public Guid Id { get; set; } | ||
public string Name { get; set; } | ||
public string Description { get; set; } | ||
public string PreviewImage { get; set; } | ||
public int? DataTypeId { get; set; } | ||
public Guid? DataTypeKey { get; set; } | ||
public IEnumerable<Guid> CategoryIds { get; set; } | ||
public IEnumerable<IContentBlockLayout> Layouts { get; set; } | ||
public Guid Id { get; set; } | ||
public string Name { get; set; } = ""; | ||
public string Description { get; set; } = ""; | ||
public string PreviewImage { get; set; } = ""; | ||
public int? DataTypeId { get; set; } | ||
public Guid? DataTypeKey { get; set; } | ||
|
||
public virtual IEnumerable<string> LimitToDocumentTypes { get; set; } | ||
= Enumerable.Empty<string>(); | ||
public IEnumerable<Guid> CategoryIds { get; set; } | ||
= Array.Empty<Guid>(); | ||
|
||
public virtual IEnumerable<string> LimitToCultures { get; set; } | ||
= Enumerable.Empty<string>(); | ||
} | ||
public IEnumerable<IContentBlockLayout> Layouts { get; set; } | ||
= Array.Empty<IContentBlockLayout>(); | ||
|
||
public virtual IEnumerable<string> LimitToDocumentTypes { get; set; } | ||
= Array.Empty<string>(); | ||
|
||
public virtual IEnumerable<string> LimitToCultures { get; set; } | ||
= Array.Empty<string>(); | ||
} |
Oops, something went wrong.