Skip to content

Commit 9854283

Browse files
committed
Removing nanoFramework.System.Runtime dependency
1 parent 27f0c8b commit 9854283

File tree

9 files changed

+218
-15
lines changed

9 files changed

+218
-15
lines changed

poc/TestOfTestFrameworkByReference/NFUnitTestByReference.nfproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.props')" />
2626
<PropertyGroup>
2727
<RunSettingsFilePath>$(MSBuildProjectDirectory)\nano.runsettings</RunSettingsFilePath>
28+
<LangVersion>latest</LangVersion>
2829
</PropertyGroup>
2930
<ItemGroup>
3031
<Compile Include="DataRowTests.cs" />
@@ -49,6 +50,9 @@
4950
<Reference Include="nanoFramework.Runtime.Native">
5051
<HintPath>..\packages\nanoFramework.Runtime.Native.1.6.12\lib\nanoFramework.Runtime.Native.dll</HintPath>
5152
</Reference>
53+
<Reference Include="nanoFramework.System.Runtime">
54+
<HintPath>..\packages\nanoFramework.System.Runtime.1.0.27\lib\nanoFramework.System.Runtime.dll</HintPath>
55+
</Reference>
5256
</ItemGroup>
5357
<Target Name="CopyTestAdapter" AfterTargets="Build">
5458
<Message Text="Copying TestAdapter" Importance="High" />

poc/TestOfTestFrameworkByReference/Test.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
//
66

77
using System;
8+
using System.Runtime.CompilerServices;
89
using System.Threading;
910
using nanoFramework.TestFramework;
1011
using NFUnitTest.Mock;
@@ -263,7 +264,7 @@ private static void ThrowsException()
263264

264265
public class SomethingElse
265266
{
266-
public void NothingReally()
267+
public void NothingReally(object value, [CallerArgumentExpression(nameof(value))] string parameter = null)
267268
{
268269
Console.WriteLine("Only classes marked with [TestClass] will run tests.");
269270
}

poc/TestOfTestFrameworkByReference/packages.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
<packages>
33
<package id="nanoFramework.CoreLibrary" version="1.15.5" targetFramework="netnano1.0" />
44
<package id="nanoFramework.Runtime.Native" version="1.6.12" targetFramework="netnano1.0" />
5+
<package id="nanoFramework.System.Runtime" version="1.0.27" targetFramework="netnano1.0" />
56
</packages>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
// ReSharper disable once CheckNamespace
5+
namespace System.Runtime.CompilerServices
6+
{
7+
/// <summary>
8+
/// Indicates that a parameter captures the expression passed for another parameter as a string.
9+
/// </summary>
10+
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
11+
internal sealed class CallerArgumentExpressionAttribute : Attribute
12+
{
13+
/// <summary>
14+
/// Initializes a new instance of the <see cref="CallerArgumentExpressionAttribute"/> class.
15+
/// </summary>
16+
/// <param name="parameterName">The name of the parameter whose expression should be captured as a string.</param>
17+
public CallerArgumentExpressionAttribute(string parameterName)
18+
{
19+
ParameterName = parameterName;
20+
}
21+
22+
/// <summary>
23+
/// Gets the name of the parameter whose expression should be captured as a string.
24+
/// </summary>
25+
public string ParameterName { get; }
26+
}
27+
}
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
// ReSharper disable once CheckNamespace
5+
namespace System.Diagnostics.CodeAnalysis
6+
{
7+
/// <summary>
8+
/// Specifies that <see langword="null"/> is allowed as an input even if the corresponding type disallows it.
9+
/// </summary>
10+
/// <remarks>
11+
/// To override a method that has a parameter annotated with this attribute, use the ? operator. For more information, see Nullable static analysis in the C# guide.
12+
/// </remarks>
13+
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property, Inherited = false)]
14+
internal sealed class AllowNullAttribute : Attribute
15+
{ }
16+
17+
/// <summary>
18+
/// Specifies that null is disallowed as an input even if the corresponding type allows it.
19+
/// </summary>
20+
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property, Inherited = false)]
21+
internal sealed class DisallowNullAttribute : Attribute
22+
{ }
23+
24+
/// <summary>
25+
/// Specifies that an output may be null even if the corresponding type disallows it.
26+
/// </summary>
27+
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, Inherited = false)]
28+
internal sealed class MaybeNullAttribute : Attribute
29+
{ }
30+
31+
/// <summary>
32+
/// Specifies that an output will not be null even if the corresponding type allows it. Specifies that an input argument was not null when the call returns.
33+
/// </summary>
34+
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, Inherited = false)]
35+
internal sealed class NotNullAttribute : Attribute
36+
{ }
37+
38+
/// <summary>
39+
/// Specifies that when a method returns <see cref="ReturnValue"/>, the parameter may be null even if the corresponding type disallows it.
40+
/// </summary>
41+
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
42+
internal sealed class MaybeNullWhenAttribute : Attribute
43+
{
44+
/// <summary>
45+
/// Initializes the attribute with the specified return value condition.
46+
/// </summary>
47+
/// <param name="returnValue">
48+
/// The return value condition. If the method returns this value, the associated parameter may be null.
49+
/// </param>
50+
internal MaybeNullWhenAttribute(bool returnValue) => ReturnValue = returnValue;
51+
52+
/// <summary>
53+
/// Gets the return value condition.
54+
/// </summary>
55+
internal bool ReturnValue { get; }
56+
}
57+
58+
/// <summary>
59+
/// Specifies that when a method returns <see cref="ReturnValue"/>, the parameter will not be null even if the corresponding type allows it.
60+
/// </summary>
61+
internal sealed class NotNullWhenAttribute : Attribute
62+
{
63+
/// <summary>Initializes the attribute with the specified return value condition.</summary>
64+
/// <param name="returnValue">
65+
/// The return value condition. If the method returns this value, the associated parameter will not be null.
66+
/// </param>
67+
internal NotNullWhenAttribute(bool returnValue) => ReturnValue = returnValue;
68+
69+
/// <summary>Gets the return value condition.</summary>
70+
internal bool ReturnValue { get; }
71+
}
72+
73+
/// <summary>
74+
/// Specifies that the output will be non-null if the named parameter is non-null.
75+
/// </summary>
76+
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)]
77+
internal sealed class NotNullIfNotNullAttribute : Attribute
78+
{
79+
/// <summary>Initializes the attribute with the associated parameter name.</summary>
80+
/// <param name="parameterName">
81+
/// The associated parameter name. The output will be non-null if the argument to the parameter specified is non-null.
82+
/// </param>
83+
internal NotNullIfNotNullAttribute(string parameterName) => ParameterName = parameterName;
84+
85+
/// <summary>Gets the associated parameter name.</summary>
86+
internal string ParameterName { get; }
87+
}
88+
89+
/// <summary>
90+
/// Applied to a method that will never return under any circumstance.
91+
/// </summary>
92+
[AttributeUsage(AttributeTargets.Method, Inherited = false)]
93+
internal sealed class DoesNotReturnAttribute : Attribute
94+
{ }
95+
96+
/// <summary>
97+
/// Specifies that the method will not return if the associated Boolean parameter is passed the specified value.
98+
/// </summary>
99+
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
100+
internal sealed class DoesNotReturnIfAttribute : Attribute
101+
{
102+
/// <summary>Initializes the attribute with the specified parameter value.</summary>
103+
/// <param name="parameterValue">
104+
/// The condition parameter value. Code after the method will be considered unreachable by diagnostics if the argument to
105+
/// the associated parameter matches this value.
106+
/// </param>
107+
internal DoesNotReturnIfAttribute(bool parameterValue) => ParameterValue = parameterValue;
108+
109+
/// <summary>
110+
/// Gets the condition parameter value.
111+
/// </summary>
112+
internal bool ParameterValue { get; }
113+
}
114+
115+
/// <summary>
116+
/// Specifies that the method or property will ensure that the listed field and property members have not-null values.
117+
/// </summary>
118+
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
119+
internal sealed class MemberNotNullAttribute : Attribute
120+
{
121+
/// <summary>Initializes the attribute with a field or property member.</summary>
122+
/// <param name="member">
123+
/// The field or property member that is promised to be not-null.
124+
/// </param>
125+
internal MemberNotNullAttribute(string member) => Members = new[] { member };
126+
127+
/// <summary>Initializes the attribute with the list of field and property members.</summary>
128+
/// <param name="members">
129+
/// The list of field and property members that are promised to be not-null.
130+
/// </param>
131+
internal MemberNotNullAttribute(params string[] members) => Members = members;
132+
133+
/// <summary>
134+
/// Gets field or property member names.
135+
/// </summary>
136+
internal string[] Members { get; }
137+
}
138+
139+
/// <summary>
140+
/// Specifies that the method or property will ensure that the listed field and property members have not-null values when returning with the specified return value condition.
141+
/// </summary>
142+
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
143+
internal sealed class MemberNotNullWhenAttribute : Attribute
144+
{
145+
/// <summary>Initializes the attribute with the specified return value condition and a field or property member.</summary>
146+
/// <param name="returnValue">
147+
/// The return value condition. If the method returns this value, the associated parameter will not be null.
148+
/// </param>
149+
/// <param name="member">
150+
/// The field or property member that is promised to be not-null.
151+
/// </param>
152+
internal MemberNotNullWhenAttribute(bool returnValue, string member)
153+
{
154+
ReturnValue = returnValue;
155+
Members = new[] { member };
156+
}
157+
158+
/// <summary>Initializes the attribute with the specified return value condition and list of field and property members.</summary>
159+
/// <param name="returnValue">
160+
/// The return value condition. If the method returns this value, the associated parameter will not be null.
161+
/// </param>
162+
/// <param name="members">
163+
/// The list of field and property members that are promised to be not-null.
164+
/// </param>
165+
internal MemberNotNullWhenAttribute(bool returnValue, params string[] members)
166+
{
167+
ReturnValue = returnValue;
168+
Members = members;
169+
}
170+
171+
/// <summary>
172+
/// Gets the return value condition.
173+
/// </summary>
174+
internal bool ReturnValue { get; }
175+
176+
/// <summary>
177+
/// Gets field or property member names.
178+
/// </summary>
179+
internal string[] Members { get; }
180+
}
181+
}

source/TestFramework/nanoFramework.TestFramework.nfproj

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@
3737
</Compile>
3838
<Compile Include="Assert.AreNotEqual.cs">
3939
<DependentUpon>Assert.cs</DependentUpon>
40-
</Compile>
40+
</Compile>
4141
<Compile Include="Assert.Obsolete.cs">
4242
<DependentUpon>Assert.cs</DependentUpon>
4343
</Compile>
44+
<Compile Include="CallerArgumentExpressionAttribute.cs" />
4445
<Compile Include="CollectionAssert.cs" />
46+
<Compile Include="NullableAttributes.cs" />
4547
<Compile Include="OutputHelper.cs" />
4648
<Compile Include="TestExtensions.cs" />
4749
</ItemGroup>
@@ -57,9 +59,6 @@
5759
<HintPath>..\..\packages\nanoFramework.CoreLibrary.1.15.5\lib\mscorlib.dll</HintPath>
5860
<Private>True</Private>
5961
</Reference>
60-
<Reference Include="nanoFramework.System.Runtime, Version=1.0.27.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
61-
<HintPath>..\..\packages\nanoFramework.System.Runtime.1.0.27\lib\nanoFramework.System.Runtime.dll</HintPath>
62-
</Reference>
6362
</ItemGroup>
6463
<ItemGroup>
6564
<Content Include="packages.lock.json" />

source/TestFramework/packages.config

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="nanoFramework.CoreLibrary" version="1.15.5" targetFramework="netnano1.0" />
4-
<package id="nanoFramework.System.Runtime" version="1.0.27" targetFramework="netnano1.0" />
54
<package id="Nerdbank.GitVersioning" version="3.6.133" developmentDependency="true" targetFramework="netnano1.0" />
65
</packages>

source/TestFramework/packages.lock.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@
88
"resolved": "1.15.5",
99
"contentHash": "u2+GvAp1uxLrGdILACAZy+EVKOs28EQ52j8Lz7599egXZ3GBGejjnR2ofhjMQwzrJLlgtyrsx8nSLngDfJNsAg=="
1010
},
11-
"nanoFramework.System.Runtime": {
12-
"type": "Direct",
13-
"requested": "[1.0.27, 1.0.27]",
14-
"resolved": "1.0.27",
15-
"contentHash": "aMwvQV6AR+XlDc+dHR/fWWnTe5dc7LDaqZS0ccfmd31Y39dZnmX3iQB2wXWtZGvXLCC+obc3IF3Vc70FiG0raw=="
16-
},
1711
"Nerdbank.GitVersioning": {
1812
"type": "Direct",
1913
"requested": "[3.6.133, 3.6.133]",

source/package.nuspec

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
<packageTypes>
2121
<packageType name="Dependency" />
2222
</packageTypes>
23-
<dependencies>
24-
<dependency id="nanoFramework.System.Runtime" version="1.0.27" />
25-
</dependencies>
2623
</metadata>
2724
<files>
2825
<file src="TestAdapter\bin\Release\net4.8\*.dll" target="lib/net48" />

0 commit comments

Comments
 (0)