-
Notifications
You must be signed in to change notification settings - Fork 324
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#124 added missing nullable attributes from net6-8
- Loading branch information
1 parent
03ed9af
commit a8b207f
Showing
19 changed files
with
657 additions
and
3 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/log4net/Diagnostics/CodeAnalysis/AllowNullAttribute.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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#region Apache License | ||
// | ||
// Licensed to the Apache Software Foundation (ASF) under one or more | ||
// contributor license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright ownership. | ||
// The ASF licenses this file to you under the Apache License, Version 2.0 | ||
// (the "License"); you may not use this file except in compliance with | ||
// the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// 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. | ||
// | ||
#endregion | ||
|
||
#if !NET6_0_OR_GREATER | ||
namespace System.Diagnostics.CodeAnalysis; | ||
|
||
/// <summary> | ||
/// Specifies that null is allowed as an input even if the corresponding type disallows it. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)] | ||
internal sealed class AllowNullAttribute : Attribute | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the System.Diagnostics.CodeAnalysis.AllowNullAttribute class. | ||
/// </summary> | ||
public AllowNullAttribute() | ||
{ } | ||
} | ||
#endif |
37 changes: 37 additions & 0 deletions
37
src/log4net/Diagnostics/CodeAnalysis/CallerArgumentExpressionAttribute.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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#region Apache License | ||
// | ||
// Licensed to the Apache Software Foundation (ASF) under one or more | ||
// contributor license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright ownership. | ||
// The ASF licenses this file to you under the Apache License, Version 2.0 | ||
// (the "License"); you may not use this file except in compliance with | ||
// the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// 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. | ||
// | ||
#endregion | ||
|
||
#if !NET6_0_OR_GREATER | ||
namespace System.Runtime.CompilerServices; | ||
|
||
/// <summary> | ||
/// Indicates that a parameter captures the expression passed for another parameter as a string. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] | ||
internal sealed class CallerArgumentExpressionAttribute : Attribute | ||
{ | ||
/// <summary> | ||
/// Name of the parameter whose expression should be captured as a string | ||
/// </summary> | ||
public string ParameterName { get; } | ||
|
||
/// <inheritdoc/> | ||
public CallerArgumentExpressionAttribute(string parameterName) => ParameterName = parameterName; | ||
} | ||
#endif |
56 changes: 56 additions & 0 deletions
56
src/log4net/Diagnostics/CodeAnalysis/CompilerFeatureRequiredAttribute.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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#region Apache License | ||
// | ||
// Licensed to the Apache Software Foundation (ASF) under one or more | ||
// contributor license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright ownership. | ||
// The ASF licenses this file to you under the Apache License, Version 2.0 | ||
// (the "License"); you may not use this file except in compliance with | ||
// the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// 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. | ||
// | ||
#endregion | ||
|
||
#if !NET7_0_OR_GREATER | ||
namespace System.Runtime.CompilerServices; | ||
|
||
/// <summary> | ||
/// Indicates that compiler support for a particular feature is required for the location where this attribute is applied | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)] | ||
internal sealed class CompilerFeatureRequiredAttribute : Attribute | ||
{ | ||
/// <summary> | ||
/// The <see cref="FeatureName" /> used for the ref structs C# feature | ||
/// </summary> | ||
public const string RefStructs = nameof(RefStructs); | ||
|
||
/// <summary> | ||
/// The <see cref="FeatureName" /> used for the required members C# feature | ||
/// </summary> | ||
public const string RequiredMembers = nameof(RequiredMembers); | ||
|
||
/// <summary> | ||
/// The name of the compiler feature | ||
/// </summary> | ||
public string FeatureName { get; } | ||
|
||
/// <summary> | ||
/// Gets a value that indicates whether the compiler can choose to allow access to the location | ||
/// where this attribute is applied if it does not understand <see cref="FeatureName" /> | ||
/// </summary> | ||
public bool IsOptional { get; init; } | ||
|
||
/// <summary> | ||
/// Initializes a <see cref="CompilerFeatureRequiredAttribute" /> instance for the passed in compiler feature | ||
/// </summary> | ||
/// <param name="featureName">The name of the compiler feature</param> | ||
public CompilerFeatureRequiredAttribute(string featureName) => FeatureName = featureName; | ||
} | ||
#endif |
34 changes: 34 additions & 0 deletions
34
src/log4net/Diagnostics/CodeAnalysis/DisallowNullAttribute.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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#region Apache License | ||
// | ||
// Licensed to the Apache Software Foundation (ASF) under one or more | ||
// contributor license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright ownership. | ||
// The ASF licenses this file to you under the Apache License, Version 2.0 | ||
// (the "License"); you may not use this file except in compliance with | ||
// the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// 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. | ||
// | ||
#endregion | ||
|
||
#if !NET6_0_OR_GREATER | ||
namespace System.Diagnostics.CodeAnalysis; | ||
|
||
/// <summary> | ||
/// Specifies that null is disallowed as an input even if the corresponding type allows it. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)] | ||
internal sealed class DisallowNullAttribute : Attribute | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the System.Diagnostics.CodeAnalysis.DisallowNullAttribute class. | ||
/// </summary> | ||
public DisallowNullAttribute() { } | ||
} | ||
#endif |
35 changes: 35 additions & 0 deletions
35
src/log4net/Diagnostics/CodeAnalysis/DoesNotReturnAttribute.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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#region Apache License | ||
// | ||
// Licensed to the Apache Software Foundation (ASF) under one or more | ||
// contributor license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright ownership. | ||
// The ASF licenses this file to you under the Apache License, Version 2.0 | ||
// (the "License"); you may not use this file except in compliance with | ||
// the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// 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. | ||
// | ||
#endregion | ||
|
||
#if !NET6_0_OR_GREATER | ||
namespace System.Diagnostics.CodeAnalysis; | ||
|
||
/// <summary> | ||
/// Specifies that a method that will never return under any circumstance. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Method, Inherited = false)] | ||
internal sealed class DoesNotReturnAttribute : Attribute | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute class. | ||
/// </summary> | ||
public DoesNotReturnAttribute() | ||
{ } | ||
} | ||
#endif |
49 changes: 49 additions & 0 deletions
49
src/log4net/Diagnostics/CodeAnalysis/DoesNotReturnIfAttribute.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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#region Apache License | ||
// | ||
// Licensed to the Apache Software Foundation (ASF) under one or more | ||
// contributor license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright ownership. | ||
// The ASF licenses this file to you under the Apache License, Version 2.0 | ||
// (the "License"); you may not use this file except in compliance with | ||
// the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// 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. | ||
// | ||
#endregion | ||
|
||
#if !NET6_0_OR_GREATER | ||
namespace System.Diagnostics.CodeAnalysis; | ||
|
||
/// <summary> | ||
/// Specifies that the method will not return if the associated System.Boolean parameter is passed the specified value. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)] | ||
internal sealed class DoesNotReturnIfAttribute : Attribute | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the System.Diagnostics.CodeAnalysis.DoesNotReturnIfAttribute class | ||
/// with the specified parameter value. | ||
/// </summary> | ||
/// <param name="parameterValue"> | ||
/// The condition parameter value. | ||
/// Code after the method is considered unreachable by diagnostics if the argument to the associated parameter | ||
/// matches this value. | ||
/// </param> | ||
public DoesNotReturnIfAttribute(bool parameterValue) => ParameterValue = parameterValue; | ||
|
||
/// <summary> | ||
/// Gets the condition parameter value. | ||
/// </summary> | ||
/// <returns>The condition parameter value. Code after the method is considered unreachable | ||
/// by diagnostics if the argument to the associated parameter matches this value. | ||
/// </returns> | ||
public bool ParameterValue { get; } | ||
} | ||
|
||
#endif |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#region Apache License | ||
// | ||
// Licensed to the Apache Software Foundation (ASF) under one or more | ||
// contributor license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright ownership. | ||
// The ASF licenses this file to you under the Apache License, Version 2.0 | ||
// (the "License"); you may not use this file except in compliance with | ||
// the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// 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. | ||
// | ||
#endregion | ||
|
||
#if !NET6_0_OR_GREATER | ||
using System.ComponentModel; | ||
|
||
namespace System.Runtime.CompilerServices; | ||
|
||
/// <inheritdoc/> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
internal static class IsExternalInit | ||
{ } | ||
#endif |
10 changes: 10 additions & 0 deletions
10
src/log4net/Diagnostics/CodeAnalysis/MaybeNullAttribute.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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#if !NET6_0_OR_GREATER | ||
namespace System.Diagnostics.CodeAnalysis; | ||
|
||
/// <summary> | ||
/// Specifies that an output may be null even if the corresponding type disallows it. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)] | ||
internal sealed class MaybeNullAttribute : Attribute | ||
{ } | ||
#endif |
22 changes: 22 additions & 0 deletions
22
src/log4net/Diagnostics/CodeAnalysis/MaybeNullWhenAttribute.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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#if !NET6_0_OR_GREATER | ||
namespace System.Diagnostics.CodeAnalysis; | ||
|
||
/// <summary> | ||
/// Specifies that when a method returns System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute.ReturnValue, | ||
/// the parameter may be null even if the corresponding type disallows it. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)] | ||
internal sealed class MaybeNullWhenAttribute : Attribute | ||
{ | ||
/// <summary> | ||
/// Initializes the attribute with the specified return value condition. | ||
/// </summary> | ||
/// <param name="returnValue">The return value condition. If the method returns this value, the associated parameter may be null.</param> | ||
public MaybeNullWhenAttribute(bool returnValue) => ReturnValue = returnValue; | ||
|
||
/// <summary> | ||
/// Gets the return value condition. | ||
/// </summary> | ||
public bool ReturnValue { get; } | ||
} | ||
#endif |
49 changes: 49 additions & 0 deletions
49
src/log4net/Diagnostics/CodeAnalysis/MemberNotNullAttribute.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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#region Apache License | ||
// | ||
// Licensed to the Apache Software Foundation (ASF) under one or more | ||
// contributor license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright ownership. | ||
// The ASF licenses this file to you under the Apache License, Version 2.0 | ||
// (the "License"); you may not use this file except in compliance with | ||
// the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// 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. | ||
// | ||
#endregion | ||
|
||
#if !NET6_0_OR_GREATER | ||
namespace System.Diagnostics.CodeAnalysis; | ||
|
||
/// <summary> | ||
/// Specifies that the method or property will ensure that the listed field and property members have values that aren't null. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)] | ||
internal sealed class MemberNotNullAttribute : Attribute | ||
{ | ||
/// <summary> | ||
/// Initializes the attribute with list of field or property members. | ||
/// </summary> | ||
/// <param name="members">The list of field and property members that are promised to be non-null.</param> | ||
public MemberNotNullAttribute(params string[] members) => Members = members; | ||
|
||
/// <summary> | ||
/// Initializes the attribute with a field or property member. | ||
/// </summary> | ||
/// <param name="member">The field or property member that is promised to be non-null.</param> | ||
[SuppressMessage("Design", "CA1019:Define accessors for attribute arguments", Justification = "LuGe: 1-zu-1 von DotNet geklaut")] | ||
public MemberNotNullAttribute(string member) | ||
: this(new[] { member }) | ||
{ } | ||
|
||
/// <summary> | ||
/// Gets field or property member names. | ||
/// </summary> | ||
public string[] Members { get; } | ||
} | ||
#endif |
Oops, something went wrong.