diff --git a/common.props b/common.props
index e62e7cf6..4cb66769 100644
--- a/common.props
+++ b/common.props
@@ -48,6 +48,10 @@ projects from the command-line or the IDE. -->
+
+
+
+
diff --git a/src/Cadru.AspNetCore.Mvc.TagHelpers/Cadru.AspNetCore.Mvc.TagHelpers.csproj b/src/Cadru.AspNetCore.Mvc.TagHelpers/Cadru.AspNetCore.Mvc.TagHelpers.csproj
index 8e82ebbe..56fa7e69 100644
--- a/src/Cadru.AspNetCore.Mvc.TagHelpers/Cadru.AspNetCore.Mvc.TagHelpers.csproj
+++ b/src/Cadru.AspNetCore.Mvc.TagHelpers/Cadru.AspNetCore.Mvc.TagHelpers.csproj
@@ -3,6 +3,8 @@
netstandard2.0;netstandard2.1;net5.0Provides additional ASP.NET Core TagHelpers.$(CommonPackageTags) aspnetcore taghelper rendering
+ latest
+ enable
diff --git a/src/Cadru.AspNetCore.Mvc.TagHelpers/Cadru.AspNetCore.Mvc.TagHelpers.xml b/src/Cadru.AspNetCore.Mvc.TagHelpers/Cadru.AspNetCore.Mvc.TagHelpers.xml
index 673e1961..d615ac00 100644
--- a/src/Cadru.AspNetCore.Mvc.TagHelpers/Cadru.AspNetCore.Mvc.TagHelpers.xml
+++ b/src/Cadru.AspNetCore.Mvc.TagHelpers/Cadru.AspNetCore.Mvc.TagHelpers.xml
@@ -232,5 +232,217 @@
A new representing the HTML tag.
+
+
+ Specifies that is allowed as an input even if the
+ corresponding type disallows it.
+
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+ Specifies that is disallowed as an input even if the
+ corresponding type allows it.
+
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+ Specifies that a method that will never return under any circumstance.
+
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+
+ Specifies that the method will not return if the associated
+ parameter is passed the specified value.
+
+
+
+
+ Gets the condition parameter value.
+ Code after the method is considered unreachable by diagnostics if the argument
+ to the associated parameter matches this value.
+
+
+
+
+ Initializes a new instance of the
+ class with the specified parameter value.
+
+
+ The condition parameter value.
+ Code after the method is considered unreachable by diagnostics if the argument
+ to the associated parameter matches this value.
+
+
+
+
+ Specifies that an output may be even if the
+ corresponding type disallows it.
+
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+ Specifies that when a method returns ,
+ the parameter may be even if the corresponding type disallows it.
+
+
+
+
+ Gets the return value condition.
+ If the method returns this value, the associated parameter may be .
+
+
+
+
+ Initializes the attribute with the specified return value condition.
+
+
+ The return value condition.
+ If the method returns this value, the associated parameter may be .
+
+
+
+
+ Specifies that the method or property will ensure that the listed field and property members have
+ not- values.
+
+
+
+
+ Gets field or property member names.
+
+
+
+
+ Initializes the attribute with a field or property member.
+
+
+ The field or property member that is promised to be not-null.
+
+
+
+
+ Initializes the attribute with the list of field and property members.
+
+
+ The list of field and property members that are promised to be not-null.
+
+
+
+
+ Specifies that the method or property will ensure that the listed field and property members have
+ non- values when returning with the specified return value condition.
+
+
+
+
+ Gets the return value condition.
+
+
+
+
+ Gets field or property member names.
+
+
+
+
+ Initializes the attribute with the specified return value condition and a field or property member.
+
+
+ The return value condition. If the method returns this value,
+ the associated parameter will not be .
+
+
+ The field or property member that is promised to be not-.
+
+
+
+
+ Initializes the attribute with the specified return value condition and list
+ of field and property members.
+
+
+ The return value condition. If the method returns this value,
+ the associated parameter will not be .
+
+
+ The list of field and property members that are promised to be not-null.
+
+
+
+
+ Specifies that an output is not even if the
+ corresponding type allows it.
+
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+ Specifies that the output will be non- if the
+ named parameter is non-.
+
+
+
+
+ Gets the associated parameter name.
+ The output will be non- if the argument to the
+ parameter specified is non-.
+
+
+
+
+ Initializes the attribute with the associated parameter name.
+
+
+ The associated parameter name.
+ The output will be non- if the argument to the
+ parameter specified is non-.
+
+
+
+
+ Specifies that when a method returns ,
+ the parameter will not be even if the corresponding type allows it.
+
+
+
+
+ Gets the return value condition.
+ If the method returns this value, the associated parameter will not be .
+
+
+
+
+ Initializes the attribute with the specified return value condition.
+
+
+ The return value condition.
+ If the method returns this value, the associated parameter will not be .
+
+
diff --git a/src/Cadru.AspNetCore.Mvc/Extensions/StateManagementExtensions.cs b/src/Cadru.AspNetCore.Mvc/Extensions/StateManagementExtensions.cs
index f29da85f..f386769f 100644
--- a/src/Cadru.AspNetCore.Mvc/Extensions/StateManagementExtensions.cs
+++ b/src/Cadru.AspNetCore.Mvc/Extensions/StateManagementExtensions.cs
@@ -37,6 +37,12 @@ namespace Cadru.AspNetCore.Mvc.Extensions
///
public static class StateManagementExtensions
{
+ private static string GetTypeName()
+ {
+ var type = typeof(T);
+ return $"{type.Namespace}.{type.Name}";
+ }
+
///
/// Gets the value associated with the specified key.
///
@@ -57,7 +63,7 @@ public static class StateManagementExtensions
[return: MaybeNull]
public static T Get(this ITempDataDictionary storageProvider)
{
- storageProvider.TryGetValue(typeof(T).FullName, out var value);
+ storageProvider.TryGetValue(GetTypeName(), out var value);
return value;
}
@@ -99,7 +105,7 @@ public static T Get(this ITempDataDictionary storageProvider, string key)
[return: MaybeNull]
public static T Get(this ISession storageProvider)
{
- storageProvider.TryGetValue(typeof(T).FullName, out var value);
+ storageProvider.TryGetValue(GetTypeName(), out var value);
return value;
}
@@ -141,7 +147,7 @@ public static T Get(this ISession storageProvider, string key)
[return: MaybeNull]
public static T Get(this ViewDataDictionary storageProvider)
{
- storageProvider.TryGetValue(typeof(T).FullName, out var value);
+ storageProvider.TryGetValue(GetTypeName(), out var value);
return value;
}
@@ -184,7 +190,7 @@ public static T Get(this ViewDataDictionary storageProvider, string key)
[return: MaybeNull]
public static T Peek(this ITempDataDictionary storageProvider)
{
- storageProvider.TryPeekValue(typeof(T).FullName, out var value);
+ storageProvider.TryPeekValue(GetTypeName(), out var value);
return value;
}
@@ -228,7 +234,7 @@ public static T Peek(this ITempDataDictionary storageProvider, string key)
[return: MaybeNull]
public static T Peek(this ISession storageProvider)
{
- return storageProvider.Get(typeof(T).FullName);
+ return storageProvider.Get(GetTypeName());
}
///
@@ -321,7 +327,7 @@ public static T Peek(this ViewDataDictionary storageProvider, string key)
///
public static void Put(this ITempDataDictionary storageProvider, T value)
{
- storageProvider.Put(typeof(T).FullName, value);
+ storageProvider.Put(GetTypeName(), value);
}
///
@@ -355,7 +361,7 @@ public static void Put(this ITempDataDictionary storageProvider, string key,
///
public static void Put(this ISession storageProvider, T value)
{
- storageProvider.Put(typeof(T).FullName, value);
+ storageProvider.Put(GetTypeName(), value);
}
///
@@ -389,7 +395,7 @@ public static void Put(this ISession storageProvider, string key, T value)
///
public static void Put(this ViewDataDictionary storageProvider, T value)
{
- storageProvider.Put(typeof(T).FullName, value);
+ storageProvider.Put(GetTypeName(), value);
}
///
@@ -423,7 +429,6 @@ public static void Put(this ViewDataDictionary storageProvider, string key, T
/// contains an element with the
/// specified key; otherwise, .
///
- [SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "")]
public static bool TryGetValue(this ITempDataDictionary storageProvider, string key, [MaybeNull] out T value)
{
var valid = false;
@@ -461,7 +466,6 @@ public static bool TryGetValue(this ITempDataDictionary storageProvider, stri
/// contains an element with the
/// specified key; otherwise, .
///
- [SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "")]
public static bool TryGetValue(this ISession storageProvider, string key, [MaybeNull] out T value)
{
var valid = false;
@@ -500,7 +504,6 @@ public static bool TryGetValue(this ISession storageProvider, string key, [Ma
/// contains an element with the
/// specified key; otherwise, .
///
- [SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "")]
public static bool TryGetValue(this ViewDataDictionary storageProvider, string key, [MaybeNull] out T value)
{
var valid = false;
@@ -539,7 +542,6 @@ public static bool TryGetValue(this ViewDataDictionary storageProvider, strin
/// contains an element with the
/// specified key; otherwise, .
///
- [SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "")]
public static bool TryPeekValue(this ITempDataDictionary storageProvider, string key, [MaybeNull] out T value)
{
var valid = false;
diff --git a/src/Cadru.Build.Tasks/Cadru.Build.Tasks.csproj b/src/Cadru.Build.Tasks/Cadru.Build.Tasks.csproj
index 38a071d3..891172f3 100644
--- a/src/Cadru.Build.Tasks/Cadru.Build.Tasks.csproj
+++ b/src/Cadru.Build.Tasks/Cadru.Build.Tasks.csproj
@@ -3,6 +3,8 @@
netstandard2.0;netstandard2.1;net5.0Provides additional MSBuild tasks.$(CommonPackageTags) collections logical natural string comparison date comparison comparer
+ latest
+ enable
diff --git a/src/Cadru.Caching/CacheKey.cs b/src/Cadru.Caching/CacheKey.cs
index 248df7f8..dabd3d97 100644
--- a/src/Cadru.Caching/CacheKey.cs
+++ b/src/Cadru.Caching/CacheKey.cs
@@ -87,14 +87,22 @@ public CacheKey(string prefix, IEnumerable
///
- [SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes", Justification = "Reviewed.")]
public static string? GetDescription(TEnum value)
{
return GetDescription(value, useNameAsFallback: true);
@@ -116,11 +113,10 @@ public static class Enum where TEnum : struct
/// type as .
///
///
- [SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes", Justification = "Reviewed.")]
public static string? GetDescription(TEnum value, bool useNameAsFallback)
{
- var fieldInfo = value.GetType().GetTypeInfo().GetDeclaredField(value.ToString());
- return fieldInfo.GetDescription(useNameAsFallback);
+ var fieldInfo = value.GetType().GetTypeInfo().GetDeclaredField(value.ToString()!);
+ return fieldInfo?.GetDescription(useNameAsFallback);
}
///
@@ -130,7 +126,6 @@ public static class Enum where TEnum : struct
///
/// is not an .
///
- [SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes", Justification = "Reviewed.")]
public static IEnumerable GetDescriptions()
{
return GetDescriptions(useNameAsFallback: true);
@@ -153,7 +148,6 @@ public static class Enum where TEnum : struct
/// , then the name of the enumerated constant is
/// used; otherwise, a is used.
///
- [SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes", Justification = "Reviewed.")]
public static IEnumerable GetDescriptions(bool useNameAsFallback)
{
var type = typeof(TEnum).GetTypeInfo();
@@ -196,8 +190,7 @@ public static class Enum where TEnum : struct
/// type as .
///
///
- [SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes", Justification = "Reviewed.")]
- public static string GetName(TEnum value)
+ public static string? GetName(TEnum value)
{
return Enum.GetName(typeof(TEnum), value);
}
@@ -209,8 +202,6 @@ public static string GetName(TEnum value)
///
/// is not an .
///
- [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Reviewed.")]
- [SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes", Justification = "Reviewed.")]
public static IEnumerable GetNames()
{
return Enum.GetNames(typeof(TEnum));
@@ -223,8 +214,6 @@ public static IEnumerable GetNames()
///
/// is not an .
///
- [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Reviewed.")]
- [SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes", Justification = "Reviewed.")]
public static Type GetUnderlyingType()
{
return Enum.GetUnderlyingType(typeof(TEnum));
@@ -247,8 +236,6 @@ public static Type GetUnderlyingType()
/// reflection-only context.
///
///
- [SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes", Justification = "Reviewed.")]
- [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Reviewed.")]
public static IEnumerable GetValues()
{
return Enum.GetValues(typeof(TEnum)).OfType();
@@ -284,7 +271,6 @@ public static IEnumerable GetValues()
/// , , ,
/// , or .
///
- [SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes", Justification = "Reviewed.")]
public static bool IsDefined(object value)
{
return Enum.IsDefined(typeof(TEnum), value);
@@ -319,7 +305,6 @@ public static bool IsDefined(object value)
/// is outside the range of the underlying type
/// of .
///
- [SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes", Justification = "Reviewed.")]
public static TEnum Parse(string value)
{
return Parse(value, true);
@@ -359,7 +344,6 @@ public static TEnum Parse(string value)
/// is outside the range of the underlying type
/// of .
///
- [SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes", Justification = "Reviewed.")]
public static TEnum Parse(string value, bool ignoreCase)
{
return (TEnum)Enum.Parse(typeof(TEnum), value, ignoreCase);
@@ -384,7 +368,6 @@ public static TEnum Parse(string value, bool ignoreCase)
/// , or .
///
///
- [SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes", Justification = "Reviewed.")]
public static TEnum ToEnum(object value)
{
return (TEnum)Enum.ToObject(typeof(TEnum), value);
@@ -411,7 +394,6 @@ public static TEnum ToEnum(object value)
///
/// is not an enumeration type.
///
- [SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes", Justification = "Reviewed.")]
public static bool TryParse(string value, out TEnum result)
{
return TryParse(value, true, out result);
@@ -443,7 +425,6 @@ public static bool TryParse(string value, out TEnum result)
///
/// is not an enumeration type.
///
- [SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes", Justification = "Reviewed.")]
public static bool TryParse(string value, bool ignoreCase, out TEnum result)
{
return Enum.TryParse(value, ignoreCase, out result);
diff --git a/src/Cadru.Core/Extensions/DictionaryExtensions.cs b/src/Cadru.Core/Extensions/DictionaryExtensions.cs
index 2d5ad497..d3374671 100644
--- a/src/Cadru.Core/Extensions/DictionaryExtensions.cs
+++ b/src/Cadru.Core/Extensions/DictionaryExtensions.cs
@@ -23,6 +23,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using Validation;
@@ -100,7 +101,7 @@ public static class DictionaryExtensions
///
/// is .
///
- public static TValue GetValueOrDefault(this IDictionary source, object key, TValue defaultValue)
+ public static TValue? GetValueOrDefault(this IDictionary source, object key, TValue defaultValue)
{
Requires.NotNull(source, nameof(source));
@@ -252,7 +253,7 @@ public static TValue GetValueOrDefault(this IDictionary source, object k
///
/// is .
///
- public static bool TryGetValueOrDefault(this IDictionary dictionary, TKey key, TValue defaultValue, out TValue value)
+ public static bool TryGetValueOrDefault(this IDictionary dictionary, TKey key, TValue defaultValue, [MaybeNullWhen(false)] out TValue value)
{
Requires.NotNull(dictionary, nameof(dictionary));
@@ -289,7 +290,7 @@ public static TValue GetValueOrDefault(this IDictionary source, object k
///
/// is .
///
- public static bool TryGetValueOrDefault(this IDictionary dictionary, object key, TValue defaultValue, out TValue value)
+ public static bool TryGetValueOrDefault(this IDictionary dictionary, object key, TValue defaultValue, [MaybeNullWhen(false)] out TValue value)
{
Requires.NotNull(dictionary, nameof(dictionary));
diff --git a/src/Cadru.Core/Extensions/EnumExtensions.cs b/src/Cadru.Core/Extensions/EnumExtensions.cs
index bce91369..cbd57f25 100644
--- a/src/Cadru.Core/Extensions/EnumExtensions.cs
+++ b/src/Cadru.Core/Extensions/EnumExtensions.cs
@@ -103,7 +103,7 @@ public static string GetDescription(this Enum value)
Requires.That(value.GetType().IsEnum, nameof(value), Strings.ArgumentExceptionMustBeEnum);
var fieldInfo = value.GetType().GetTypeInfo().GetDeclaredField(value.ToString());
- return fieldInfo.GetDescription(useNameAsFallback);
+ return fieldInfo?.GetDescription(useNameAsFallback);
}
}
}
\ No newline at end of file
diff --git a/src/Cadru.Core/Extensions/NameValueCollectionExtensions.cs b/src/Cadru.Core/Extensions/NameValueCollectionExtensions.cs
index 95b231f5..26d17a36 100644
--- a/src/Cadru.Core/Extensions/NameValueCollectionExtensions.cs
+++ b/src/Cadru.Core/Extensions/NameValueCollectionExtensions.cs
@@ -36,7 +36,7 @@ public static class NameValueCollectionExtensions
///The index of the first matching item, or -1 if no items match.
public static int GetKeyIndex(this NameValueCollection nameValueCollection, string key)
{
- return nameValueCollection.AllKeys.FindIndex(e => e.Equals(key, StringComparison.OrdinalIgnoreCase));
+ return nameValueCollection.AllKeys.FindIndex(e => (e?.Equals(key, StringComparison.OrdinalIgnoreCase) ?? false));
}
}
}
\ No newline at end of file
diff --git a/src/Cadru.Core/Extensions/TypeExtensions.cs b/src/Cadru.Core/Extensions/TypeExtensions.cs
index 661eac30..d0404f48 100644
--- a/src/Cadru.Core/Extensions/TypeExtensions.cs
+++ b/src/Cadru.Core/Extensions/TypeExtensions.cs
@@ -53,9 +53,9 @@ public static class TypeExtensions
/// A custom attribute that matches , or
/// if no such attribute is found.
///
- public static T GetAttributeOfType(this FieldInfo element, bool inherit = false) where T : Attribute
+ public static T? GetAttributeOfType(this FieldInfo element, bool inherit = false) where T : Attribute
{
- return element.GetCustomAttributes(inherit).FirstOrDefault();
+ return element.GetCustomAttributes(inherit)?.FirstOrDefault();
}
///
@@ -117,7 +117,6 @@ public static class TypeExtensions
///
/// A custom attribute type cannot be loaded.
///
- [SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Justification = "Reviewed.")]
public static bool HasCustomAttribute(this Type element, bool inherit = false) where T : Attribute
{
Requires.NotNull(element, nameof(element));
@@ -166,7 +165,6 @@ public static class TypeExtensions
/// if the specified type implements the
/// interface; otherwise, .
///
- [SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Justification = "Reviewed.")]
public static bool HasInterface(this Type element)
{
Requires.NotNull(element, nameof(element));
@@ -261,7 +259,7 @@ public static bool IsDate(this TypeInfo element)
if (element.IsNullable())
{
var underlyingType = Nullable.GetUnderlyingType(type);
- return underlyingType.IsDate();
+ return underlyingType?.IsDate() ?? false;
}
return type == typeof(DateTime);
@@ -297,7 +295,7 @@ public static bool IsDateOffset(this TypeInfo element)
if (element.IsNullable())
{
var underlyingType = Nullable.GetUnderlyingType(type);
- return underlyingType.IsDateOffset();
+ return underlyingType?.IsDateOffset() ?? false;
}
return type == typeof(DateTimeOffset);
@@ -371,7 +369,6 @@ public static bool IsFlagsEnum(this TypeInfo element)
///
/// if the specified type is nullable; otherwise, .
///
- [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "Reviewed.")]
public static bool IsNullable(this Type element)
{
Requires.NotNull(element, nameof(element));
@@ -428,7 +425,7 @@ public static bool IsNumeric(this TypeInfo element)
if (element.IsNullable())
{
var underlyingType = Nullable.GetUnderlyingType(type);
- return underlyingType.IsNumeric();
+ return underlyingType?.IsNumeric() ?? false;
}
return type == typeof(decimal);
diff --git a/src/Cadru.Core/UnixTimestamp.cs b/src/Cadru.Core/UnixTimestamp.cs
index ae89bf6b..25ad1e6b 100644
--- a/src/Cadru.Core/UnixTimestamp.cs
+++ b/src/Cadru.Core/UnixTimestamp.cs
@@ -534,7 +534,7 @@ public UnixTimestamp AddYears(int years)
///
/// is not a .
///
- public int CompareTo(object obj)
+ public int CompareTo(object? obj)
{
if (obj == null)
{
@@ -596,7 +596,7 @@ public int CompareTo(UnixTimestamp other)
/// The current instance and are equal if their
/// property values are equal.
///
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
if (obj is UnixTimestamp timestamp)
{
@@ -714,12 +714,11 @@ public override string ToString()
///
/// is invalid or not supported.
///
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string? format, IFormatProvider? formatProvider)
{
return this.seconds.ToString(format, formatProvider);
}
- [SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "")]
private static long DateToSeconds(int year, int month, int day, int hour, int minute, int second)
{
long sec;
diff --git a/src/Cadru.Core/WeakReference{T}.cs b/src/Cadru.Core/WeakReference{T}.cs
index f21075ce..2b37ac58 100644
--- a/src/Cadru.Core/WeakReference{T}.cs
+++ b/src/Cadru.Core/WeakReference{T}.cs
@@ -73,9 +73,9 @@ public WeakReference(T target, bool trackResurrection)
/// thrown while setting this property if the value is a null reference
/// or if the object has been finalized during the set operation.
///
- public new T Target
+ public new T? Target
{
- get => (T)base.Target;
+ get => (T?)base.Target;
set => base.Target = value;
}
}
diff --git a/src/Cadru.Data.Dapper/Cadru.Data.Dapper.xml b/src/Cadru.Data.Dapper/Cadru.Data.Dapper.xml
index 00e1d536..ec8a6b8a 100644
--- a/src/Cadru.Data.Dapper/Cadru.Data.Dapper.xml
+++ b/src/Cadru.Data.Dapper/Cadru.Data.Dapper.xml
@@ -1780,217 +1780,5 @@
The context which contains this entity.
-
-
- Specifies that is allowed as an input even if the
- corresponding type disallows it.
-
-
-
-
- Initializes a new instance of the class.
-
-
-
-
- Specifies that is disallowed as an input even if the
- corresponding type allows it.
-
-
-
-
- Initializes a new instance of the class.
-
-
-
-
- Specifies that a method that will never return under any circumstance.
-
-
-
-
- Initializes a new instance of the class.
-
-
-
-
-
- Specifies that the method will not return if the associated
- parameter is passed the specified value.
-
-
-
-
- Gets the condition parameter value.
- Code after the method is considered unreachable by diagnostics if the argument
- to the associated parameter matches this value.
-
-
-
-
- Initializes a new instance of the
- class with the specified parameter value.
-
-
- The condition parameter value.
- Code after the method is considered unreachable by diagnostics if the argument
- to the associated parameter matches this value.
-
-
-
-
- Specifies that an output may be even if the
- corresponding type disallows it.
-
-
-
-
- Initializes a new instance of the class.
-
-
-
-
- Specifies that when a method returns ,
- the parameter may be even if the corresponding type disallows it.
-
-
-
-
- Gets the return value condition.
- If the method returns this value, the associated parameter may be .
-
-
-
-
- Initializes the attribute with the specified return value condition.
-
-
- The return value condition.
- If the method returns this value, the associated parameter may be .
-
-
-
-
- Specifies that the method or property will ensure that the listed field and property members have
- not- values.
-
-
-
-
- Gets field or property member names.
-
-
-
-
- Initializes the attribute with a field or property member.
-
-
- The field or property member that is promised to be not-null.
-
-
-
-
- Initializes the attribute with the list of field and property members.
-
-
- The list of field and property members that are promised to be not-null.
-
-
-
-
- Specifies that the method or property will ensure that the listed field and property members have
- non- values when returning with the specified return value condition.
-
-
-
-
- Gets the return value condition.
-
-
-
-
- Gets field or property member names.
-
-
-
-
- Initializes the attribute with the specified return value condition and a field or property member.
-
-
- The return value condition. If the method returns this value,
- the associated parameter will not be .
-
-
- The field or property member that is promised to be not-.
-
-
-
-
- Initializes the attribute with the specified return value condition and list
- of field and property members.
-
-
- The return value condition. If the method returns this value,
- the associated parameter will not be .
-
-
- The list of field and property members that are promised to be not-null.
-
-
-
-
- Specifies that an output is not even if the
- corresponding type allows it.
-
-
-
-
- Initializes a new instance of the class.
-
-
-
-
- Specifies that the output will be non- if the
- named parameter is non-.
-
-
-
-
- Gets the associated parameter name.
- The output will be non- if the argument to the
- parameter specified is non-.
-
-
-
-
- Initializes the attribute with the associated parameter name.
-
-
- The associated parameter name.
- The output will be non- if the argument to the
- parameter specified is non-.
-
-
-
-
- Specifies that when a method returns ,
- the parameter will not be even if the corresponding type allows it.
-
-
-
-
- Gets the return value condition.
- If the method returns this value, the associated parameter will not be .
-
-
-
-
- Initializes the attribute with the specified return value condition.
-
-
- The return value condition.
- If the method returns this value, the associated parameter will not be .
-
-
diff --git a/src/Cadru.Data/Cadru.Data.xml b/src/Cadru.Data/Cadru.Data.xml
index 43a59ec2..e8d130cf 100644
--- a/src/Cadru.Data/Cadru.Data.xml
+++ b/src/Cadru.Data/Cadru.Data.xml
@@ -1472,5 +1472,217 @@
Looks up a localized string similar to TextFieldParser does not support comment tokens that contain white space..
+
+
+ Specifies that is allowed as an input even if the
+ corresponding type disallows it.
+
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+ Specifies that is disallowed as an input even if the
+ corresponding type allows it.
+
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+ Specifies that a method that will never return under any circumstance.
+
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+
+ Specifies that the method will not return if the associated
+ parameter is passed the specified value.
+
+
+
+
+ Gets the condition parameter value.
+ Code after the method is considered unreachable by diagnostics if the argument
+ to the associated parameter matches this value.
+
+
+
+
+ Initializes a new instance of the
+ class with the specified parameter value.
+
+
+ The condition parameter value.
+ Code after the method is considered unreachable by diagnostics if the argument
+ to the associated parameter matches this value.
+
+
+
+
+ Specifies that an output may be even if the
+ corresponding type disallows it.
+
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+ Specifies that when a method returns ,
+ the parameter may be even if the corresponding type disallows it.
+
+
+
+
+ Gets the return value condition.
+ If the method returns this value, the associated parameter may be .
+
+
+
+
+ Initializes the attribute with the specified return value condition.
+
+
+ The return value condition.
+ If the method returns this value, the associated parameter may be .
+
+
+
+
+ Specifies that the method or property will ensure that the listed field and property members have
+ not- values.
+
+
+
+
+ Gets field or property member names.
+
+
+
+
+ Initializes the attribute with a field or property member.
+
+
+ The field or property member that is promised to be not-null.
+
+
+
+
+ Initializes the attribute with the list of field and property members.
+
+
+ The list of field and property members that are promised to be not-null.
+
+
+
+
+ Specifies that the method or property will ensure that the listed field and property members have
+ non- values when returning with the specified return value condition.
+
+
+
+
+ Gets the return value condition.
+
+
+
+
+ Gets field or property member names.
+
+
+
+
+ Initializes the attribute with the specified return value condition and a field or property member.
+
+
+ The return value condition. If the method returns this value,
+ the associated parameter will not be .
+
+
+ The field or property member that is promised to be not-.
+
+
+
+
+ Initializes the attribute with the specified return value condition and list
+ of field and property members.
+
+
+ The return value condition. If the method returns this value,
+ the associated parameter will not be .
+
+
+ The list of field and property members that are promised to be not-null.
+
+
+
+
+ Specifies that an output is not even if the
+ corresponding type allows it.
+
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+ Specifies that the output will be non- if the
+ named parameter is non-.
+
+
+
+
+ Gets the associated parameter name.
+ The output will be non- if the argument to the
+ parameter specified is non-.
+
+
+
+
+ Initializes the attribute with the associated parameter name.
+
+
+ The associated parameter name.
+ The output will be non- if the argument to the
+ parameter specified is non-.
+
+
+
+
+ Specifies that when a method returns ,
+ the parameter will not be even if the corresponding type allows it.
+
+
+
+
+ Gets the return value condition.
+ If the method returns this value, the associated parameter will not be .
+
+
+
+
+ Initializes the attribute with the specified return value condition.
+
+
+ The return value condition.
+ If the method returns this value, the associated parameter will not be .
+
+
diff --git a/src/Cadru.Data/Excel/ExcelDataReader.IDataReader.cs b/src/Cadru.Data/Excel/ExcelDataReader.IDataReader.cs
index 28133f95..ec009d3c 100644
--- a/src/Cadru.Data/Excel/ExcelDataReader.IDataReader.cs
+++ b/src/Cadru.Data/Excel/ExcelDataReader.IDataReader.cs
@@ -257,12 +257,12 @@ private IList GetFirstRowAsHeaders(OpenXmlPart worksheetPart)
return result;
}
- private Sheet GetSheetByIndex(int sheetIndex)
+ private Sheet? GetSheetByIndex(int sheetIndex)
{
return this.sheets.ElementAtOrDefault(sheetIndex);
}
- private Sheet GetSheetByName(string sheetName)
+ private Sheet? GetSheetByName(string sheetName)
{
return this.sheets.FirstOrDefault(x => x.Name == sheetName);
}
diff --git a/src/Cadru.Data/Excel/ExcelDataReader.IDataRecord.cs b/src/Cadru.Data/Excel/ExcelDataReader.IDataRecord.cs
index 5f99b2cd..568a7be3 100644
--- a/src/Cadru.Data/Excel/ExcelDataReader.IDataRecord.cs
+++ b/src/Cadru.Data/Excel/ExcelDataReader.IDataRecord.cs
@@ -62,7 +62,7 @@ public long GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, i
}
///
- public IDataReader? GetData(int i)
+ public IDataReader GetData(int i)
{
return null;
}
diff --git a/src/Cadru.Environment/Cadru.Environment.csproj b/src/Cadru.Environment/Cadru.Environment.csproj
index 91639005..4062fba9 100644
--- a/src/Cadru.Environment/Cadru.Environment.csproj
+++ b/src/Cadru.Environment/Cadru.Environment.csproj
@@ -1,6 +1,6 @@
- netstandard2.0;netstandard2.1;net5.0
+ netstandard2.0;netstandard2.1;net5.0-windowslatestenableProvides support for determining framework versions, IIS version and feature detection.
diff --git a/src/Cadru.Environment/FrameworkVersionDetection.cs b/src/Cadru.Environment/FrameworkVersionDetection.cs
index e01fc6ad..84ec1d97 100644
--- a/src/Cadru.Environment/FrameworkVersionDetection.cs
+++ b/src/Cadru.Environment/FrameworkVersionDetection.cs
@@ -543,7 +543,7 @@ private static bool GetCoreFrameworkVersion(FrameworkVersion frameworkVersion, o
if (!String.IsNullOrEmpty(installPath))
{
var fvi = FileVersionInfo.GetVersionInfo(installPath);
- if (fvi != null)
+ if (fvi != null && fvi.ProductVersion != null)
{
version = new Version(fvi.ProductVersion);
valid = true;
@@ -667,9 +667,6 @@ private static Version GetNetfx10ExactVersion()
/// determine what service pack for the .NET Framework 1.0 is installed
/// on the machine.
///
- [SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults",
- MessageId = "System.Int32.TryParse(System.String,System.Int32@)",
- Justification = "In this case, we're already defaulting the out parameter but want to make sure the Parse isn't going to throw an exception.")]
private static int GetNetfx10SPLevel()
{
var servicePackLevel = -1;
@@ -692,7 +689,10 @@ private static int GetNetfx10SPLevel()
var index = regValue.LastIndexOf(',');
if (index > 0)
{
- Int32.TryParse(regValue.Substring(index + 1), out servicePackLevel);
+ if (!Int32.TryParse(regValue.Substring(index + 1), out servicePackLevel))
+ {
+ servicePackLevel = -1;
+ }
}
}
@@ -737,7 +737,6 @@ private static Version GetNetfx11ExactVersion()
/// returned that represents a 0.0.0.0 version number if the .NET
/// Framework 2.0 is not found.
///
- [SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "")]
private static Version GetNetfx20ExactVersion()
{
var emptyVersion = new Version(0, 0, 0, 0);
@@ -799,8 +798,14 @@ private static Version GetNetfx30CardSpaceExactVersion()
if (GetRegistryValue(RegistryHive.LocalMachine, CardSpaceServicesRegKeyName, CardSpaceServicesPlusImagePathRegName, RegistryValueKind.ExpandString, out string regValue) && !String.IsNullOrEmpty(regValue))
{
var fileVersionInfo = FileVersionInfo.GetVersionInfo(regValue.Trim('"'));
- var index = fileVersionInfo.FileVersion.IndexOf(' ');
- version = new Version(fileVersionInfo.FileVersion.Substring(0, index));
+ if (!String.IsNullOrWhiteSpace(fileVersionInfo.FileVersion))
+ {
+ var index = fileVersionInfo.FileVersion.IndexOf(' ');
+ if (index > 0)
+ {
+ version = new Version(fileVersionInfo.FileVersion.Substring(0, index));
+ }
+ }
}
return version;
@@ -1072,7 +1077,6 @@ private static string GetRegistryKey(FrameworkVersion frameworkVersion)
///
/// if the registry value was found; otherwise, .
///
- [SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "")]
private static bool GetRegistryValue(RegistryHive hive, string key, string value, RegistryValueKind kind, out T data)
{
var success = false;
diff --git a/src/Cadru.Environment/InternetInformationServicesDetection.cs b/src/Cadru.Environment/InternetInformationServicesDetection.cs
index 59acefd6..45e824d3 100644
--- a/src/Cadru.Environment/InternetInformationServicesDetection.cs
+++ b/src/Cadru.Environment/InternetInformationServicesDetection.cs
@@ -264,8 +264,6 @@ public static bool IsInstalled(InternetInformationServicesSubcomponent subcompon
/// Services feature is installed; otherwise .
///
/// Features only apply to IIS versions 7 and later.
- [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity",
- Justification = "This method appears to be complex because of it's length, but it's almost all just a switch statement which then calls out to other methods to do the work.")]
public static bool IsInstalled(InternetInformationServicesFeature feature)
{
var ret = false;
@@ -491,7 +489,6 @@ private static Version GetInstalledVersion()
///
/// if the registry value was found; otherwise, .
///
- [SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "")]
private static bool GetRegistryValue(RegistryHive hive, string key, string value, RegistryValueKind kind, out T data)
{
var success = false;
diff --git a/src/Cadru.Net.Http/Cadru.Net.Http.xml b/src/Cadru.Net.Http/Cadru.Net.Http.xml
index 3bc6f655..2b6646cf 100644
--- a/src/Cadru.Net.Http/Cadru.Net.Http.xml
+++ b/src/Cadru.Net.Http/Cadru.Net.Http.xml
@@ -101,6 +101,24 @@
inner handler.
+
+
+ Provides HTTP content based on an empty string.
+
+
+
+
+ Creates a new instance of the class.
+
+ A instance.
+
+
+
+ Creates a new instance of the class.
+
+ The media type to use for the content.
+ A instance.
+
Extension methods that aid in making formatted requests using .
diff --git a/src/Cadru.Net.Http/Extensions/HttpExtensions.cs b/src/Cadru.Net.Http/Extensions/HttpExtensions.cs
index a28a6927..46b9eec2 100644
--- a/src/Cadru.Net.Http/Extensions/HttpExtensions.cs
+++ b/src/Cadru.Net.Http/Extensions/HttpExtensions.cs
@@ -134,31 +134,12 @@ public static string AsString(this HttpContent content)
/// A valid .
public static HttpRequestMessage CreateRequestMessage(this HttpClient httpClient, HttpMethod method, Uri uri, QueryStringParametersDictionary? queryStringParameters = null, IDictionary? headerCollection = null)
{
- Uri? requestUri = null;
- if ((uri == null) && (httpClient.BaseAddress == null))
+ if (httpClient.BaseAddress == null && (uri == null || !uri.IsAbsoluteUri))
{
throw new InvalidOperationException(Strings.net_http_client_invalid_requesturi);
}
- if (uri == null)
- {
- requestUri = httpClient.BaseAddress;
- }
- else
- {
- // If the request Uri is an absolute Uri, just use it. Otherwise
- // try to combine it with the base Uri.
- if (!uri.IsAbsoluteUri)
- {
- if (httpClient.BaseAddress == null)
- {
- throw new InvalidOperationException(Strings.net_http_client_invalid_requesturi);
- }
- else
- {
- requestUri = new Uri(httpClient.BaseAddress, uri);
- }
- }
- }
+
+ var requestUri = uri == null ? httpClient.BaseAddress! : new Uri(httpClient.BaseAddress!, uri);
if (queryStringParameters != null)
{
diff --git a/src/Cadru.Net.Http/HttpRequestWithStatusException.cs b/src/Cadru.Net.Http/HttpRequestWithStatusException.cs
index 379b722c..a0ff6f83 100644
--- a/src/Cadru.Net.Http/HttpRequestWithStatusException.cs
+++ b/src/Cadru.Net.Http/HttpRequestWithStatusException.cs
@@ -42,7 +42,10 @@ public class HttpRequestWithStatusException : HttpRequestException
public HttpRequestWithStatusException(HttpResponseMessage responseMessage) :
base(GetFormattedMessage(responseMessage))
{
+#if !NET5_0
this.StatusCode = responseMessage.StatusCode;
+#endif
+
this.ReasonPhrase = responseMessage.ReasonPhrase;
}
@@ -57,7 +60,10 @@ public class HttpRequestWithStatusException : HttpRequestException
public HttpRequestWithStatusException(HttpResponseMessage responseMessage, Exception inner) :
base(GetFormattedMessage(responseMessage), inner)
{
+#if !NET5_0
this.StatusCode = responseMessage.StatusCode;
+#endif
+
this.ReasonPhrase = responseMessage.ReasonPhrase;
}
@@ -98,13 +104,15 @@ public HttpRequestWithStatusException(string message, Exception inner) : base(me
/// with the status code.
///
/// The reason phrase sent by the server.
- public string ReasonPhrase { get; }
+ public string? ReasonPhrase { get; }
+#if !NET5_0
///
/// Gets the status code of the HTTP response.
///
/// The status code of the HTTP response.
public HttpStatusCode? StatusCode { get; }
+#endif
private static string GetFormattedMessage(HttpResponseMessage responseMessage)
{
diff --git a/src/Cadru.Net.Http/UriScheme.cs b/src/Cadru.Net.Http/UriScheme.cs
index d3904790..6d45d201 100644
--- a/src/Cadru.Net.Http/UriScheme.cs
+++ b/src/Cadru.Net.Http/UriScheme.cs
@@ -30,8 +30,6 @@ namespace Cadru.Net.Http
///
/// A helper class for retrieving and comparing standard URI schemes.
///
- [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1311:StaticReadonlyFieldsMustBeginWithUpperCaseLetter", Justification = "Reviewed.")]
- [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1623:PropertySummaryDocumentationMustMatchAccessors", Justification = "Reviewed.")]
public sealed class UriScheme : IEquatable
{
private static readonly UriScheme fileScheme = new UriScheme("file");
@@ -141,7 +139,7 @@ internal UriScheme(string scheme)
/// if both objects represent the same scheme;
/// otherwise, .
///
- public static bool operator ==(UriScheme left, UriScheme right)
+ public static bool operator ==(UriScheme? left, UriScheme? right)
{
if (left is null || right is null)
{
@@ -160,7 +158,7 @@ internal UriScheme(string scheme)
/// if the parameter
/// equals the value of this instance; otherwise, .
///
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
if (obj is UriScheme uriScheme)
{
@@ -181,7 +179,7 @@ public override bool Equals(object obj)
/// if the parameter
/// equals the value of this instance; otherwise, .
///
- public bool Equals(UriScheme other)
+ public bool Equals(UriScheme? other)
{
if (other == null!)
{
diff --git a/src/Cadru.Net.Http/UrlBuilder.cs b/src/Cadru.Net.Http/UrlBuilder.cs
index f5693b32..14e9e6fd 100644
--- a/src/Cadru.Net.Http/UrlBuilder.cs
+++ b/src/Cadru.Net.Http/UrlBuilder.cs
@@ -69,8 +69,6 @@ public UrlBuilder()
/// -or-
/// paramref name="uri"/> is not a valid URI.
///
- [SuppressMessage("Microsoft.Usage", "CA2234:PassSystemUriObjectsInsteadOfStrings", Justification = "Reviewed.")]
- [SuppressMessage("Microsoft.Design", "CA1057:StringUriOverloadsCallSystemUriOverloads", Justification = "Reviewed.")]
public UrlBuilder(string uri)
{
this.builder = new UriBuilder(uri);
@@ -100,8 +98,6 @@ public UrlBuilder(string uri)
/// -or-
/// paramref name="uri"/> is not a valid URI.
///
- [SuppressMessage("Microsoft.Usage", "CA2234:PassSystemUriObjectsInsteadOfStrings", Justification = "Reviewed.")]
- [SuppressMessage("Microsoft.Design", "CA1057:StringUriOverloadsCallSystemUriOverloads", Justification = "Reviewed.")]
public UrlBuilder(string uri, string path)
{
this.builder = new UriBuilder(uri);
@@ -344,7 +340,7 @@ public string UserName
/// as the constructed
/// by this instance; otherwise, .
///
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
this.builder.Query = this.Query;
return this.builder.Equals(obj);
diff --git a/src/Cadru.Net.NetworkInformation/Cadru.Net.NetworkInformation.xml b/src/Cadru.Net.NetworkInformation/Cadru.Net.NetworkInformation.xml
index d4436847..73754724 100644
--- a/src/Cadru.Net.NetworkInformation/Cadru.Net.NetworkInformation.xml
+++ b/src/Cadru.Net.NetworkInformation/Cadru.Net.NetworkInformation.xml
@@ -1112,13 +1112,13 @@
system running on the computer.
-
+
-
+
-
+
diff --git a/src/Cadru.Net.NetworkInformation/Collections/IPAddressComparer.cs b/src/Cadru.Net.NetworkInformation/Collections/IPAddressComparer.cs
index 6fce4dd7..b1821e47 100644
--- a/src/Cadru.Net.NetworkInformation/Collections/IPAddressComparer.cs
+++ b/src/Cadru.Net.NetworkInformation/Collections/IPAddressComparer.cs
@@ -46,38 +46,46 @@ public IPAddressComparer()
/// Represents an instance of .
///
/// The default
- [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1623:PropertySummaryDocumentationMustMatchAccessors", Justification = "Reviewed.")]
public static IComparer Default => new IPAddressComparer();
///
- public int Compare(IPAddress x, IPAddress y)
+ public int Compare(IPAddress? x, IPAddress? y)
{
- Requires.NotNull(x, "x");
- Requires.NotNull(y, "y");
-
int result;
- var u1 = Convert(x.GetAddressBytes());
- var u2 = Convert(y.GetAddressBytes());
-
- if (u1 < u2)
- {
- result = -1;
- }
- else if (u1 == u2)
+ result = x switch
{
- result = 0;
- }
- else
+ null when y is null => 0,
+ null => -1,
+ _ => CompareBytes(x.GetAddressBytes(), y!.GetAddressBytes())
+ };
+
+ int CompareBytes(byte[] b1, byte[] b2)
{
- result = 1;
+ var u1 = Convert(b1);
+ var u2 = Convert(b2);
+
+ if (u1 < u2)
+ {
+ result = -1;
+ }
+ else if (u1 == u2)
+ {
+ result = 0;
+ }
+ else
+ {
+ result = 1;
+ }
+
+ return result;
}
return result;
}
///
- public int Compare(object x, object y)
+ public int Compare(object? x, object? y)
{
int result;
@@ -115,12 +123,8 @@ public int Compare(object x, object y)
///
/// The strings should be a valid date time format.
- public int Compare(string x, string y)
+ public int Compare(string? x, string? y)
{
- Requires.NotNull(x, "x");
- Requires.NotNull(y, "y");
-
-
if (!IPAddress.TryParse(x, out var t1))
{
throw new FormatException(Resources.Strings.Format_Dns_Bad_Ip_Address);
@@ -135,7 +139,7 @@ public int Compare(string x, string y)
}
///
- public bool Equals(IPAddress x, IPAddress y)
+ public bool Equals(IPAddress? x, IPAddress? y)
{
if (x == null)
{
@@ -146,7 +150,7 @@ public bool Equals(IPAddress x, IPAddress y)
}
///
- public bool Equals(string x, string y)
+ public bool Equals(string? x, string? y)
{
if (x == null && y == null)
{
@@ -208,7 +212,7 @@ public int GetHashCode(object obj)
}
else
{
- if (!(obj is string s1))
+ if (obj is not string s1)
{
hashCode = obj.GetHashCode();
}
@@ -255,7 +259,7 @@ public int GetHashCode(string obj)
}
///
- bool IEqualityComparer.Equals(object x, object y)
+ bool IEqualityComparer.Equals(object? x, object? y)
{
return Equals(x, y);
}
diff --git a/src/Cadru.Net.NetworkInformation/NetworkStatus.cs b/src/Cadru.Net.NetworkInformation/NetworkStatus.cs
index a6633339..f41771f6 100644
--- a/src/Cadru.Net.NetworkInformation/NetworkStatus.cs
+++ b/src/Cadru.Net.NetworkInformation/NetworkStatus.cs
@@ -90,7 +90,7 @@ private void ChangeNetworkStatus(ConnectionStatus current)
}
}
- private void NetworkAddressChanged(object sender, EventArgs e)
+ private void NetworkAddressChanged(object? sender, EventArgs e)
{
var current = NetworkInterface.GetIsNetworkAvailable() ? ConnectionStatus.Connected : ConnectionStatus.Disconnected;
this.ChangeNetworkStatus(current);
diff --git a/src/Cadru.Net.NetworkInformation/ServerInfo.cs b/src/Cadru.Net.NetworkInformation/ServerInfo.cs
index 470e78a8..1dc56f5f 100644
--- a/src/Cadru.Net.NetworkInformation/ServerInfo.cs
+++ b/src/Cadru.Net.NetworkInformation/ServerInfo.cs
@@ -103,27 +103,25 @@ internal ServerInfo(SERVER_INFO_101 info)
public ServerTypes ServerType { get; }
///
- [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1625:ElementDocumentationMustNotBeCopiedAndPasted", Justification = "Reviewed.")]
- public static bool operator ==(ServerInfo left, ServerInfo right)
+ public static bool operator ==(ServerInfo? left, ServerInfo? right)
{
return left.Equals(right);
}
///
- [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1625:ElementDocumentationMustNotBeCopiedAndPasted", Justification = "Reviewed.")]
- public static bool operator !=(ServerInfo left, ServerInfo right)
+ public static bool operator !=(ServerInfo? left, ServerInfo? right)
{
return !left.Equals(right);
}
///
- public static bool Equals(ServerInfo left, ServerInfo right)
+ public static bool Equals(ServerInfo? left, ServerInfo? right)
{
return left == right;
}
///
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
if (obj is ServerInfo s)
{
diff --git a/src/Cadru.Polly/Cadru.Polly.xml b/src/Cadru.Polly/Cadru.Polly.xml
index 7df34ad0..d7d7aa63 100644
--- a/src/Cadru.Polly/Cadru.Polly.xml
+++ b/src/Cadru.Polly/Cadru.Polly.xml
@@ -1221,5 +1221,217 @@
A representing the timeout.
+
+
+ Specifies that is allowed as an input even if the
+ corresponding type disallows it.
+
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+ Specifies that is disallowed as an input even if the
+ corresponding type allows it.
+
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+ Specifies that a method that will never return under any circumstance.
+
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+
+ Specifies that the method will not return if the associated
+ parameter is passed the specified value.
+
+
+
+
+ Gets the condition parameter value.
+ Code after the method is considered unreachable by diagnostics if the argument
+ to the associated parameter matches this value.
+
+
+
+
+ Initializes a new instance of the
+ class with the specified parameter value.
+
+
+ The condition parameter value.
+ Code after the method is considered unreachable by diagnostics if the argument
+ to the associated parameter matches this value.
+
+
+
+
+ Specifies that an output may be even if the
+ corresponding type disallows it.
+
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+ Specifies that when a method returns ,
+ the parameter may be even if the corresponding type disallows it.
+
+
+
+
+ Gets the return value condition.
+ If the method returns this value, the associated parameter may be .
+
+
+
+
+ Initializes the attribute with the specified return value condition.
+
+
+ The return value condition.
+ If the method returns this value, the associated parameter may be .
+
+
+
+
+ Specifies that the method or property will ensure that the listed field and property members have
+ not- values.
+
+
+
+
+ Gets field or property member names.
+
+
+
+
+ Initializes the attribute with a field or property member.
+
+
+ The field or property member that is promised to be not-null.
+
+
+
+
+ Initializes the attribute with the list of field and property members.
+
+
+ The list of field and property members that are promised to be not-null.
+
+
+
+
+ Specifies that the method or property will ensure that the listed field and property members have
+ non- values when returning with the specified return value condition.
+
+
+
+
+ Gets the return value condition.
+
+
+
+
+ Gets field or property member names.
+
+
+
+
+ Initializes the attribute with the specified return value condition and a field or property member.
+
+
+ The return value condition. If the method returns this value,
+ the associated parameter will not be .
+
+
+ The field or property member that is promised to be not-.
+
+
+
+
+ Initializes the attribute with the specified return value condition and list
+ of field and property members.
+
+
+ The return value condition. If the method returns this value,
+ the associated parameter will not be .
+
+
+ The list of field and property members that are promised to be not-null.
+
+
+
+
+ Specifies that an output is not even if the
+ corresponding type allows it.
+
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+ Specifies that the output will be non- if the
+ named parameter is non-.
+
+
+
+
+ Gets the associated parameter name.
+ The output will be non- if the argument to the
+ parameter specified is non-.
+
+
+
+
+ Initializes the attribute with the associated parameter name.
+
+
+ The associated parameter name.
+ The output will be non- if the argument to the
+ parameter specified is non-.
+
+
+
+
+ Specifies that when a method returns ,
+ the parameter will not be even if the corresponding type allows it.
+
+
+
+
+ Gets the return value condition.
+ If the method returns this value, the associated parameter will not be .
+
+
+
+
+ Initializes the attribute with the specified return value condition.
+
+
+ The return value condition.
+ If the method returns this value, the associated parameter will not be .
+
+
diff --git a/tests/Cadru.Net.Tests/Http/HttpExtensionsTests.cs b/tests/Cadru.Net.Tests/Http/HttpExtensionsTests.cs
new file mode 100644
index 00000000..35678a6f
--- /dev/null
+++ b/tests/Cadru.Net.Tests/Http/HttpExtensionsTests.cs
@@ -0,0 +1,86 @@
+//------------------------------------------------------------------------------
+//
+// Copyright (C) 2001-2020 Scott Dorman.
+//
+//
+//
+// Licensed under the Microsoft Public License (Ms-PL) (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://opensource.org/licenses/Ms-PL.html
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//------------------------------------------------------------------------------
+
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net.Http;
+
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Cadru.Net.Http.Extensions;
+using Cadru.UnitTest.Framework;
+using Cadru.Net.Http.Collections;
+
+namespace Cadru.Net.Http.Tests
+{
+ [TestClass, ExcludeFromCodeCoverage]
+ public class HttpExtensionsTests
+ {
+ [TestMethod]
+ public void AsFormattedString()
+ {
+ HttpRequestMessage request = null;
+
+ Assert.ThrowsException(() => { request.AsFormattedString(); });
+
+ request = new HttpRequestMessage();
+ Assert.That.IsNotEmpty(request.AsFormattedString());
+
+ request.Content = new StringContent("body content");
+ Assert.That.IsNotEmpty(request.AsFormattedString());
+ StringAssert.Contains(request.AsFormattedString(), "Body:");
+ }
+
+ [TestMethod]
+ public void CreateRequestMessage()
+ {
+ var client = new HttpClient();
+
+ Assert.ThrowsException(() => { client.CreateRequestMessage(HttpMethod.Get, null); });
+ Assert.ThrowsException(() => { client.CreateRequestMessage(HttpMethod.Get, new Uri("test", UriKind.Relative)); });
+
+ client.BaseAddress = new Uri("https://example.com/");
+
+ var requestMessage = client.CreateRequestMessage(HttpMethod.Get, null);
+
+ Assert.IsNotNull(requestMessage);
+ Assert.IsTrue(requestMessage.Method == HttpMethod.Get);
+ Assert.AreEqual("https://example.com/", requestMessage.RequestUri.AbsoluteUri);
+
+// Assert.ThrowsException(() => { client.CreateRequestMessage(HttpMethod.Get, null); });
+
+ requestMessage = client.CreateRequestMessage(HttpMethod.Get, new Uri("test", UriKind.Relative));
+
+ Assert.IsNotNull(requestMessage);
+ Assert.IsTrue(requestMessage.Method == HttpMethod.Get);
+ Assert.AreEqual("https://example.com/test", requestMessage.RequestUri.AbsoluteUri);
+
+ var queryStringParameters = new QueryStringParametersDictionary();
+ queryStringParameters.Add("test", "testvalue");
+
+ requestMessage = client.CreateRequestMessage(HttpMethod.Get, new Uri("test", UriKind.Relative), queryStringParameters);
+ Assert.IsNotNull(requestMessage);
+ Assert.IsTrue(requestMessage.Method == HttpMethod.Get);
+ Assert.AreEqual("https://example.com/test?test=testvalue", requestMessage.RequestUri.AbsoluteUri);
+ Assert.That.IsNotEmpty(requestMessage.RequestUri.Query);
+ }
+ }
+}
\ No newline at end of file