Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial addition of Nullable property to Abstractions Project. #2139

Merged
merged 3 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(SrcTargets)</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">$(SrcStandardTargets)</TargetFrameworks>
<NetStandardImplicitPackageVersion>$(NetStandardVersion)</NetStandardImplicitPackageVersion>
<LangVersion>7.3</LangVersion>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(TF_BUILD)' == 'true'">
Expand Down
12 changes: 6 additions & 6 deletions src/Microsoft.IdentityModel.Abstractions/ITelemetryClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ void TrackEvent(
/// <param name="guidProperties">Key value pair of Guids to long with the event.</param>
void TrackEvent(
string eventName,
IDictionary<string, string> stringProperties = null,
IDictionary<string, long> longProperties = null,
IDictionary<string, bool> boolProperties = null,
IDictionary<string, DateTime> dateTimeProperties = null,
IDictionary<string, double> doubleProperties = null,
IDictionary<string, Guid> guidProperties = null);
IDictionary<string, string>? stringProperties = null,
IDictionary<string, long>? longProperties = null,
IDictionary<string, bool>? boolProperties = null,
IDictionary<string, DateTime>? dateTimeProperties = null,
IDictionary<string, double>? doubleProperties = null,
IDictionary<string, Guid>? guidProperties = null);
}
}
4 changes: 2 additions & 2 deletions src/Microsoft.IdentityModel.Abstractions/LogEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ public class LogEntry
/// <summary>
/// Message to be logged.
/// </summary>
public string Message { get; set; }
public string? Message { get; set; }

/// <summary>
/// A unique identifier for a request that can help with diagnostics across components.
/// </summary>
/// <remarks>
/// Also referred to as ActivityId in Microsoft.IdentityModel.Tokens.CallContext.
/// </remarks>
public string CorrelationId { get; set; }
public string? CorrelationId { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<PackageId>Microsoft.IdentityModel.Abstractions</PackageId>
<PackageTags>.NET;Windows;Authentication;Identity;Abstractions</PackageTags>
<IsTrimmable>true</IsTrimmable>
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Debug'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ public class NullTelemetryClient : ITelemetryClient
/// <remarks>
/// Private constructor to prevent the default constructor being exposed.
/// </remarks>
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
jmprieur marked this conversation as resolved.
Show resolved Hide resolved
private NullTelemetryClient() { }
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.

/// <inheritdoc />
public bool IsEnabled() => false;
Expand All @@ -48,12 +50,12 @@ public void TrackEvent(TelemetryEventDetails eventDetails)
/// <inheritdoc/>
public void TrackEvent(
string eventName,
IDictionary<string, string> stringProperties = null,
IDictionary<string, long> longProperties = null,
IDictionary<string, bool> boolProperties = null,
IDictionary<string, DateTime> dateTimeProperties = null,
IDictionary<string, double> doubleProperties = null,
IDictionary<string, Guid> guidProperties = null)
IDictionary<string, string>? stringProperties = null,
IDictionary<string, long>? longProperties = null,
IDictionary<string, bool>? boolProperties = null,
IDictionary<string, DateTime>? dateTimeProperties = null,
IDictionary<string, double>? doubleProperties = null,
IDictionary<string, Guid>? guidProperties = null)
{
// no-op
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public abstract class TelemetryEventDetails
/// <summary>
/// Name of the telemetry event, should be unique between events.
/// </summary>
public virtual string Name { get; set; }
public virtual string? Name { get; set; }

/// <summary>
/// Properties which describe the event.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
[assembly: SuppressMessage("Globalization", "CA1307:Specify StringComparison", Justification = "Vendored component", Scope = "module")]
[assembly: SuppressMessage("Design", "CA1001:Types that own disposable fields should be disposable", Justification = "Breaking change", Scope = "type", Target = "~T:Microsoft.IdentityModel.Protocols.SignedHttpRequest.SignedHttpRequestHandler")]
[assembly: SuppressMessage("Usage", "CA2227:Collection properties should be read only", Justification = "Previously released as read / write", Scope = "member", Target = "~P:Microsoft.IdentityModel.Protocols.SignedHttpRequest.SignedHttpRequestInvalidNonceClaimException.PropertyBag")]
[assembly: SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "Breaking Change", Scope = "member", Target = "~T:Microsoft.IdentityModel.Protocols.SignedHttpRequest.SignedHttpRequestHandler)")]
FuPingFranco marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public WsFederationConfiguration()
/// <summary>
/// The <see cref="Xml.Signature"/> element that was found when reading metadata.
/// </summary>
public Signature Signature
public Signature? Signature
{
get;
set;
Expand All @@ -31,7 +31,7 @@ public Signature Signature
/// <summary>
/// The <see cref="Tokens.SigningCredentials"/> that was used to sign the metadata.
/// </summary>
public SigningCredentials SigningCredentials
public SigningCredentials? SigningCredentials
{
get;
set;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public ConfigurationValidationResult Validate(WsFederationConfiguration configur
var signatureCertData = signatureX509Data.Current.Certificates.GetEnumerator();
if (signatureCertData.MoveNext() && !string.IsNullOrWhiteSpace(signatureCertData.Current))
{
X509Certificate2 cert = null;
X509Certificate2? cert = null;

try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageId>Microsoft.IdentityModel.Protocols.WsFederation</PackageId>
<PackageTags>.NET;Windows;Authentication;Identity;WsFederation</PackageTags>
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Debug'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static IDictionary<string, IList<string>> ParseQuery(string queryString)
/// </summary>
/// <param name="queryString">The raw query string value, with or without the leading '?'.</param>
/// <returns>A collection of parsed keys and values, null if there are no entries.</returns>
public static IDictionary<string, IList<string>> ParseNullableQuery(string queryString)
public static IDictionary<string, IList<string>>? ParseNullableQuery(string queryString)
{
var accumulator = new KeyValueAccumulator();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public List<KeyInfo> KeyInfos
/// Passive Requestor Token endpoint
/// fed:PassiveRequestorEndpoint, https://docs.oasis-open.org/wsfed/federation/v1.2/os/ws-federation-1.2-spec-os.html#:~:text=fed%3ASecurityTokenServiceType/fed%3APassiveRequestorEndpoint
/// </summary>
public string TokenEndpoint
public string? TokenEndpoint
{
get;
set;
Expand All @@ -34,7 +34,7 @@ public string TokenEndpoint
/// Active Requestor Token Endpoint
/// fed:SecurityTokenServiceType, http://docs.oasis-open.org/wsfed/federation/v1.2/os/ws-federation-1.2-spec-os.html#:~:text=fed%3ASecurityTokenSerivceEndpoint
/// </summary>
public string ActiveTokenEndpoint
public string? ActiveTokenEndpoint
{
get;
set;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public string CreateSignOutUrl()
/// </summary>
/// <returns>the 'SecurityToken'.</returns>
/// <exception cref="WsFederationException">if exception occurs while reading security token.</exception>
public virtual string GetToken()
public virtual string? GetToken()
{
return GetTokenUsingXmlReader();
}
Expand All @@ -149,7 +149,7 @@ public virtual string GetToken()
/// This is only called after it is determined the Wresult is well formed xml. A successful call the GetTokenUsingXmlReader should be made first.
/// </summary>
/// <returns>the string version of the security token.</returns>
internal static string GetToken(string wresult)
internal static string? GetToken(string wresult)
{
if (string.IsNullOrEmpty(wresult))
{
Expand Down Expand Up @@ -217,15 +217,15 @@ internal static string GetToken(string wresult)
/// </summary>
/// <returns>the 'SecurityToken'.</returns>
/// <exception cref="WsFederationException">if exception occurs while reading security token.</exception>
public virtual string GetTokenUsingXmlReader()
public virtual string? GetTokenUsingXmlReader()
{
if (Wresult == null)
{
LogHelper.LogWarning(FormatInvariant(LogMessages.IDX22000, LogHelper.MarkAsNonPII(nameof(Wresult))));
return null;
}

string token = null;
string? token = null;
using (var sr = new StringReader(Wresult))
using (var xmlReader = new XmlTextReader(sr) { DtdProcessing = DtdProcessing.Prohibit, XmlResolver = null })
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ protected virtual string ReadPassiveRequestorEndpoint(XmlReader reader)
/// <param name="reader"><see cref="XmlReader"/> used to read SecurityTokenServiceEndpoint.</param>
/// <returns>Active token endpoint string</returns>
/// <exception cref="XmlReadException">If an error occurs while reading the SecurityTokenServiceEndpoint</exception>
protected virtual string ReadSecurityTokenServiceEndpoint(XmlReader reader)
protected virtual string? ReadSecurityTokenServiceEndpoint(XmlReader reader)
{
XmlUtil.CheckReaderOnEntry(reader, Elements.SecurityTokenServiceEndpoint, Namespace);

Expand All @@ -286,7 +286,7 @@ protected virtual string ReadSecurityTokenServiceEndpoint(XmlReader reader)
if (reader.IsEmptyElement)
throw XmlUtil.LogReadException(LogMessages.IDX22814);

string tokenEndpoint = null;
string? tokenEndpoint = null;

while (reader.IsStartElement())
{
Expand Down