more build errors in Core

This commit is contained in:
Nikolaj Geisle
2022-02-27 21:20:50 +01:00
parent e7b31a22be
commit d1cf640f2a
71 changed files with 281 additions and 226 deletions

View File

@@ -75,7 +75,7 @@ namespace Umbraco.Cms.Core.Models
}
}
SetPropertyValueAndDetectChanges(asArray, ref _translations, nameof(Translations),
SetPropertyValueAndDetectChanges(asArray, ref _translations!, nameof(Translations),
DictionaryTranslationComparer);
}
}

View File

@@ -14,11 +14,11 @@ namespace Umbraco.Cms.Core.Models
public Func<int, ILanguage?>? GetLanguage { get; set; }
private ILanguage? _language;
private string? _value;
private string _value;
//note: this will be memberwise cloned
private int _languageId;
public DictionaryTranslation(ILanguage language, string? value)
public DictionaryTranslation(ILanguage language, string value)
{
if (language == null) throw new ArgumentNullException("language");
_language = language;
@@ -88,10 +88,10 @@ namespace Umbraco.Cms.Core.Models
/// Gets or sets the translated text
/// </summary>
[DataMember]
public string? Value
public string Value
{
get { return _value; }
set { SetPropertyValueAndDetectChanges(value, ref _value, nameof(Value)); }
set { SetPropertyValueAndDetectChanges(value, ref _value!, nameof(Value)); }
}
protected override void PerformDeepClone(object clone)

View File

@@ -8,19 +8,19 @@ namespace Umbraco.Cms.Core.Models.Email
/// </summary>
public class NotificationEmailModel
{
public NotificationEmailAddress From { get; }
public NotificationEmailAddress? From { get; }
public IEnumerable<NotificationEmailAddress> To { get; }
public IEnumerable<NotificationEmailAddress?>? To { get; }
public IEnumerable<NotificationEmailAddress> Cc { get; }
public IEnumerable<NotificationEmailAddress>? Cc { get; }
public IEnumerable<NotificationEmailAddress> Bcc { get; }
public IEnumerable<NotificationEmailAddress>? Bcc { get; }
public IEnumerable<NotificationEmailAddress> ReplyTo { get; }
public IEnumerable<NotificationEmailAddress>? ReplyTo { get; }
public string Subject { get; }
public string? Subject { get; }
public string Body { get; }
public string? Body { get; }
public bool IsBodyHtml { get; }

View File

@@ -8,7 +8,7 @@
/// <summary>
/// Gets or sets the name of the entity.
/// </summary>
string Name { get; set; }
string? Name { get; set; }
/// <summary>
/// Gets or sets the identifier of the user who created this entity.

View File

@@ -23,7 +23,7 @@ namespace Umbraco.Cms.Core.Models.Entities
public string? Name
{
get => _name;
set => SetPropertyValueAndDetectChanges(value, ref _name!, nameof(Name));
set => SetPropertyValueAndDetectChanges(value, ref _name, nameof(Name));
}
/// <inheritdoc />

View File

@@ -19,7 +19,7 @@ namespace Umbraco.Cms.Core.Models
/// Gets or sets the culture name of the language.
/// </summary>
[DataMember]
string CultureName { get; set; }
string? CultureName { get; set; }
/// <summary>
/// Gets the <see cref="CultureInfo"/> object for the language.

View File

@@ -38,7 +38,7 @@ namespace Umbraco.Cms.Core.Models
/// </summary>
/// <remarks>Is a proper Umbraco route eg /path/to/foo or 123/path/tofoo.</remarks>
[DataMember]
string Url { get; set; }
string? Url { get; set; }
}
}

View File

@@ -27,6 +27,7 @@ namespace Umbraco.Cms.Core.Models
_properties.CollectionChanged += PropertiesChanged;
_addedProperties = new List<string>();
_removedProperties = new List<string>();
_macroSource = string.Empty;
}
/// <summary>
@@ -69,7 +70,7 @@ namespace Umbraco.Cms.Core.Models
/// <param name="dontRender"></param>
/// <param name="macroSource"></param>
public Macro(IShortStringHelper shortStringHelper, string @alias, string? name,
string? macroSource,
string macroSource,
bool cacheByPage = false,
bool cacheByMember = false,
bool dontRender = true,
@@ -94,7 +95,7 @@ namespace Umbraco.Cms.Core.Models
private bool _cacheByPage;
private bool _cacheByMember;
private bool _dontRender;
private string? _macroSource;
private string _macroSource;
private MacroPropertyCollection _properties;
private List<string> _addedProperties;
private List<string> _removedProperties;
@@ -245,10 +246,10 @@ namespace Umbraco.Cms.Core.Models
/// Gets or set the path to the Partial View to render
/// </summary>
[DataMember]
public string? MacroSource
public string MacroSource
{
get => _macroSource;
set => SetPropertyValueAndDetectChanges(value, ref _macroSource, nameof(MacroSource));
set => SetPropertyValueAndDetectChanges(value, ref _macroSource!, nameof(MacroSource));
}
/// <summary>

View File

@@ -32,6 +32,7 @@ namespace Umbraco.Cms.Core.Models.Membership
_rawPasswordValue = "";
_username = string.Empty;
_email = string.Empty;
_name = string.Empty;
}
/// <summary>
@@ -72,7 +73,7 @@ namespace Umbraco.Cms.Core.Models.Membership
/// <param name="userGroups"></param>
/// <param name="startContentIds"></param>
/// <param name="startMediaIds"></param>
public User(GlobalSettings globalSettings, int id, string? name, string? email, string? username,
public User(GlobalSettings globalSettings, int id, string? name, string email, string? username,
string? rawPasswordValue, string? passwordConfig,
IEnumerable<IReadOnlyUserGroup> userGroups, int[] startContentIds, int[] startMediaIds)
: this(globalSettings)
@@ -98,7 +99,7 @@ namespace Umbraco.Cms.Core.Models.Membership
_startMediaIds = startMediaIds;
}
private string? _name;
private string _name;
private string? _securityStamp;
private string? _avatar;
private string? _tourData;
@@ -111,7 +112,7 @@ namespace Umbraco.Cms.Core.Models.Membership
private DateTime? _emailConfirmedDate;
private DateTime? _invitedDate;
private string _email;
private string _rawPasswordValue;
private string? _rawPasswordValue;
private string? _passwordConfig;
private IEnumerable<string>? _allowedSections;
private HashSet<IReadOnlyUserGroup> _userGroups;
@@ -158,7 +159,7 @@ namespace Umbraco.Cms.Core.Models.Membership
}
[IgnoreDataMember]
public string RawPasswordValue
public string? RawPasswordValue
{
get => _rawPasswordValue;
set => SetPropertyValueAndDetectChanges(value, ref _rawPasswordValue, nameof(RawPasswordValue));
@@ -237,10 +238,10 @@ namespace Umbraco.Cms.Core.Models.Membership
}
[DataMember]
public string? Name
public string Name
{
get => _name;
set => SetPropertyValueAndDetectChanges(value, ref _name, nameof(Name));
set => SetPropertyValueAndDetectChanges(value, ref _name!, nameof(Name));
}
public IEnumerable<string> AllowedSections

View File

@@ -10,8 +10,8 @@ namespace Umbraco.Cms.Core.Models.Packaging
/// </summary>
public class CompiledPackage
{
public FileInfo PackageFile { get; set; } = null!;
public string Name { get; set; } = string.Empty;
public FileInfo? PackageFile { get; set; }
public string? Name { get; set; }
public InstallWarnings Warnings { get; set; } = new InstallWarnings();
public IEnumerable<XElement> Macros { get; set; } = null!; // TODO: make strongly typed
public IEnumerable<XElement> MacroPartialViews { get; set; } = null!; // TODO: make strongly typed

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.Serialization;
using Umbraco.Extensions;
@@ -145,7 +146,7 @@ namespace Umbraco.Cms.Core.Models
}
}
public bool TryGetValue(string propertyTypeAlias, out IProperty? property)
public bool TryGetValue(string propertyTypeAlias, [MaybeNullWhen(false)] out IProperty property)
{
property = this.FirstOrDefault(x => x.Alias?.InvariantEquals(propertyTypeAlias) ?? false);
return property != null;

View File

@@ -25,7 +25,7 @@ namespace Umbraco.Extensions
var tagAttribute = editor?.GetTagAttribute();
if (tagAttribute == null) return null;
var configurationObject = property.PropertyType is null ? null : dataTypeService.GetDataType(property.PropertyType.DataTypeId).Configuration;
var configurationObject = property.PropertyType is null ? null : dataTypeService.GetDataType(property.PropertyType.DataTypeId)?.Configuration;
var configuration = ConfigurationEditor.ConfigurationAs<TagConfiguration>(configurationObject);
if (configuration?.Delimiter == default && configuration?.Delimiter is not null)
@@ -165,7 +165,7 @@ namespace Umbraco.Extensions
case TagsStorageType.Json:
try
{
return serializer.Deserialize<string[]>(value).Select(x => x.Trim());
return serializer.Deserialize<string[]>(value)?.Select(x => x.Trim()) ?? Enumerable.Empty<string>();
}
catch (Exception)
{

View File

@@ -89,6 +89,7 @@ namespace Umbraco.Cms.Core.Models
_forceValueStorageType = forceValueStorageType;
_alias = propertyTypeAlias == null ? string.Empty : SanitizeAlias(propertyTypeAlias);
_variations = ContentVariation.Nothing;
_name = string.Empty;
}
/// <summary>

View File

@@ -12,7 +12,7 @@ namespace Umbraco.Cms.Core.Models.PublishedContent
public IPublishedElement CreateModel(IPublishedElement element) => element;
/// <inheritdoc />
public IList CreateModelList(string alias) => new List<IPublishedElement>();
public IList CreateModelList(string? alias) => new List<IPublishedElement>();
/// <inheritdoc />
public Type MapModelType(Type type) => typeof(IPublishedElement);

View File

@@ -78,19 +78,19 @@ namespace Umbraco.Cms.Core.Models.PublishedContent
/// <inheritdoc />
public PublishedDataType GetDataType(int id)
{
Dictionary<int, PublishedDataType> publishedDataTypes;
Dictionary<int, PublishedDataType>? publishedDataTypes;
lock (_publishedDataTypesLocker)
{
if (_publishedDataTypes == null)
{
var dataTypes = _dataTypeService.GetAll();
_publishedDataTypes = dataTypes.ToDictionary(x => x.Id, CreatePublishedDataType);
_publishedDataTypes = dataTypes?.ToDictionary(x => x.Id, CreatePublishedDataType);
}
publishedDataTypes = _publishedDataTypes;
}
if (!publishedDataTypes.TryGetValue(id, out var dataType))
if (publishedDataTypes is null || !publishedDataTypes.TryGetValue(id, out var dataType))
throw new ArgumentException($"Could not find a datatype with identifier {id}.", nameof(id));
return dataType;
@@ -104,7 +104,7 @@ namespace Umbraco.Cms.Core.Models.PublishedContent
if (_publishedDataTypes == null)
{
var dataTypes = _dataTypeService.GetAll();
_publishedDataTypes = dataTypes.ToDictionary(x => x.Id, CreatePublishedDataType);
_publishedDataTypes = dataTypes?.ToDictionary(x => x.Id, CreatePublishedDataType);
}
else
{
@@ -112,8 +112,11 @@ namespace Umbraco.Cms.Core.Models.PublishedContent
_publishedDataTypes.Remove(id);
var dataTypes = _dataTypeService.GetAll(ids);
foreach (var dataType in dataTypes)
_publishedDataTypes[dataType.Id] = CreatePublishedDataType(dataType);
if (dataTypes is not null)
{
foreach (var dataType in dataTypes)
_publishedDataTypes[dataType.Id] = CreatePublishedDataType(dataType);
}
}
}
}

View File

@@ -104,13 +104,13 @@ namespace Umbraco.Cms.Core.Models.PublishedContent
}
/// <inheritdoc />
public IList? CreateModelList(string alias)
public IList? CreateModelList(string? alias)
{
// fail fast
if (_modelInfos == null)
return new List<IPublishedElement>();
if (!_modelInfos.TryGetValue(alias, out var modelInfo) || modelInfo.ModelType is null)
if (alias is null || !_modelInfos.TryGetValue(alias, out var modelInfo) || modelInfo.ModelType is null)
return new List<IPublishedElement>();
var ctor = modelInfo.ListCtor;

View File

@@ -240,12 +240,12 @@ namespace Umbraco.Cms.Core.Models.PublishedContent
}
/// <inheritdoc />
public Type? ModelClrType
public Type ModelClrType
{
get
{
if (!_initialized) Initialize();
return _modelClrType;
return _modelClrType!;
}
}

View File

@@ -14,7 +14,7 @@ namespace Umbraco.Cms.Core.Models
//NOTE: The datetime column from umbracoRelation is set on CreateDate on the Entity
private int _parentId;
private int _childId;
private IRelationType? _relationType;
private IRelationType _relationType;
private string? _comment;
/// <summary>
@@ -38,7 +38,7 @@ namespace Umbraco.Cms.Core.Models
/// <param name="parentObjectType"></param>
/// <param name="childObjectType"></param>
/// <param name="relationType"></param>
public Relation(int parentId, int childId, Guid parentObjectType, Guid childObjectType, IRelationType? relationType)
public Relation(int parentId, int childId, Guid parentObjectType, Guid childObjectType, IRelationType relationType)
{
_parentId = parentId;
_childId = childId;

View File

@@ -11,8 +11,8 @@ namespace Umbraco.Cms.Core.Models
[DataContract(IsReference = true)]
public class Tag : EntityBase, ITag
{
private string? _group;
private string? _text;
private string _group = string.Empty;
private string _text = string.Empty;
private int? _languageId;
/// <summary>
@@ -24,7 +24,7 @@ namespace Umbraco.Cms.Core.Models
/// <summary>
/// Initializes a new instance of the <see cref="Tag"/> class.
/// </summary>
public Tag(int id, string? group, string? text, int? languageId = null)
public Tag(int id, string group, string text, int? languageId = null)
{
Id = id;
Text = text;
@@ -33,17 +33,17 @@ namespace Umbraco.Cms.Core.Models
}
/// <inheritdoc />
public string? Group
public string Group
{
get => _group;
set => SetPropertyValueAndDetectChanges(value, ref _group, nameof(Group));
set => SetPropertyValueAndDetectChanges(value, ref _group!, nameof(Group));
}
/// <inheritdoc />
public string? Text
public string Text
{
get => _text;
set => SetPropertyValueAndDetectChanges(value, ref _text, nameof(Text));
set => SetPropertyValueAndDetectChanges(value, ref _text!, nameof(Text));
}
/// <inheritdoc />

View File

@@ -25,7 +25,7 @@ namespace Umbraco.Cms.Core.Models
/// <returns>
/// A list of 5 different sized avatar URLs
/// </returns>
public static string[] GetUserAvatarUrls(this IUser user, IAppCache cache, MediaFileManager mediaFileManager, IImageUrlGenerator imageUrlGenerator)
public static string?[] GetUserAvatarUrls(this IUser user, IAppCache cache, MediaFileManager mediaFileManager, IImageUrlGenerator imageUrlGenerator)
{
// If FIPS is required, never check the Gravatar service as it only supports MD5 hashing.
// Unfortunately, if the FIPS setting is enabled on Windows, using MD5 will throw an exception