Skip to content

Commit

Permalink
Add Action, Function and EventHandler (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
josesimoes authored Dec 7, 2020
1 parent d1fdb44 commit 9466adc
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,23 @@
<TargetFrameworkVersion>v1.0</TargetFrameworkVersion>
<DocumentationFile>bin\$(Configuration)\mscorlib.xml</DocumentationFile>
<Deterministic>true</Deterministic>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<Deterministic>true</Deterministic>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<ContinuousIntegrationBuild Condition="'$(TF_BUILD)' == 'true'">True</ContinuousIntegrationBuild>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<DebugType>portable</DebugType>
<Optimize>false</Optimize>
<DefineConstants>$(DefineConstants);DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<DebugType>portable</DebugType>
<Optimize>true</Optimize>
<DefineConstants>$(DefineConstants);TRACE</DefineConstants>
</PropertyGroup>
Expand All @@ -60,6 +65,9 @@
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.props')" />
<ItemGroup>
<Compile Include="..\nanoFramework.CoreLibrary\Friends.cs" Link="Friends.cs" />
<Compile Include="..\nanoFramework.CoreLibrary\System\Action.cs">
<Link>System\Action.cs</Link>
</Compile>
<Compile Include="..\nanoFramework.CoreLibrary\System\AppDomain.cs" Link="System\AppDomain.cs" />
<Compile Include="..\nanoFramework.CoreLibrary\System\AppDomainUnloadedException.cs" Link="System\AppDomainUnloadedException.cs" />
<Compile Include="..\nanoFramework.CoreLibrary\System\ApplicationException.cs" Link="System\ApplicationException.cs" />
Expand Down Expand Up @@ -97,6 +105,12 @@
<Compile Include="..\nanoFramework.CoreLibrary\System\Double.cs" Link="System\Double.cs" />
<Compile Include="..\nanoFramework.CoreLibrary\System\Enum.cs" Link="System\Enum.cs" />
<Compile Include="..\nanoFramework.CoreLibrary\System\Console.cs" Link="System\Console.cs" />
<Compile Include="..\nanoFramework.CoreLibrary\System\EventArgs.cs">
<Link>System\EventArgs.cs</Link>
</Compile>
<Compile Include="..\nanoFramework.CoreLibrary\System\EventHandler.cs">
<Link>System\EventHandler.cs</Link>
</Compile>
<Compile Include="..\nanoFramework.CoreLibrary\System\Exception.cs" Link="System\Exception.cs" />
<Compile Include="..\nanoFramework.CoreLibrary\System\FlagsAttribute.cs" Link="System\FlagsAttribute.cs" />
<Compile Include="..\nanoFramework.CoreLibrary\System\GC.cs" Link="System\GC.cs" />
Expand Down
5 changes: 5 additions & 0 deletions nanoFramework.CoreLibrary.NoReflection/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project>
<ItemGroup>
<SourceRoot Include="$(MSBuildThisFileDirectory)/"/>
</ItemGroup>
</Project>
12 changes: 10 additions & 2 deletions nanoFramework.CoreLibrary/CoreLibrary.nfproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,23 @@
<TargetFrameworkVersion>v1.0</TargetFrameworkVersion>
<DocumentationFile>bin\$(Configuration)\mscorlib.xml</DocumentationFile>
<Deterministic>true</Deterministic>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<Deterministic>true</Deterministic>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<ContinuousIntegrationBuild Condition="'$(TF_BUILD)' == 'true'">True</ContinuousIntegrationBuild>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<DebugType>portable</DebugType>
<Optimize>false</Optimize>
<DefineConstants>$(DefineConstants);NANOCLR_REFLECTION;DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<DebugType>portable</DebugType>
<Optimize>true</Optimize>
<DefineConstants>$(DefineConstants);NANOCLR_REFLECTION;TRACE</DefineConstants>
</PropertyGroup>
Expand All @@ -60,6 +65,7 @@
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.props')" />
<ItemGroup>
<Compile Include="Friends.cs" />
<Compile Include="System\Action.cs" />
<Compile Include="System\AppDomain.cs" />
<Compile Include="System\AppDomainUnloadedException.cs" />
<Compile Include="System\ApplicationException.cs" />
Expand Down Expand Up @@ -97,6 +103,8 @@
<Compile Include="System\Double.cs" />
<Compile Include="System\Enum.cs" />
<Compile Include="System\Console.cs" />
<Compile Include="System\EventArgs.cs" />
<Compile Include="System\EventHandler.cs" />
<Compile Include="System\Exception.cs" />
<Compile Include="System\FlagsAttribute.cs" />
<Compile Include="System\GC.cs" />
Expand Down
5 changes: 5 additions & 0 deletions nanoFramework.CoreLibrary/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project>
<ItemGroup>
<SourceRoot Include="$(MSBuildThisFileDirectory)/"/>
</ItemGroup>
</Project>
65 changes: 65 additions & 0 deletions nanoFramework.CoreLibrary/System/Action.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//
// Copyright (c) .NET Foundation and Contributors
// Portions Copyright (c) Microsoft Corporation. All rights reserved.
// See LICENSE file in the project root for full license information.
//

namespace System
{
using System.Runtime.CompilerServices;

/// <summary>
/// Encapsulates a method that has no parameters and does not return a value.
/// </summary>
public delegate void Action();

/// <summary>
/// Encapsulates a method that has a single parameter and does not return a value.
/// </summary>
/// <typeparam name="T">The type of the parameter of the method that this delegate encapsulates.
/// This type parameter is covariant.That is, you can use either the type you specified or any type that is more derived.For more information about covariance and contravariance, see <see href="https://docs.microsoft.com/en-us/dotnet/standard/generics/covariance-and-contravariance">Covariance and Contravariance in Generics</see>.</typeparam>
/// <param name="obj">The parameter of the method that this delegate encapsulates.</param>
public delegate void Action<in T>(T obj);

/// <summary>
/// Encapsulates a method that has a single parameter and does not return a value.
/// </summary>
/// <typeparam name="T1">The type of the first parameter of the method that this delegate encapsulates.
/// This type parameter is covariant.That is, you can use either the type you specified or any type that is more derived.For more information about covariance and contravariance, see <see href="https://docs.microsoft.com/en-us/dotnet/standard/generics/covariance-and-contravariance">Covariance and Contravariance in Generics</see>.</typeparam>
/// <typeparam name="T2">The type of the second parameter of the method that this delegate encapsulates.
/// This type parameter is covariant.That is, you can use either the type you specified or any type that is more derived.For more information about covariance and contravariance, see <see href="https://docs.microsoft.com/en-us/dotnet/standard/generics/covariance-and-contravariance">Covariance and Contravariance in Generics</see>.</typeparam>
/// <param name="arg1">The first parameter of the method that this delegate encapsulates.</param>
/// <param name="arg2">The second parameter of the method that this delegate encapsulates.</param>
public delegate void Action<in T1, in T2>(T1 arg1, T2 arg2);

/// <summary>
/// Encapsulates a method that has no parameters and returns a value of the type specified by the <typeparamref name="TResult"/> parameter.
/// </summary>
/// <typeparam name="TResult">The type of the return value of the method that this delegate encapsulates.
/// This type parameter is covariant.That is, you can use either the type you specified or any type that is more derived.For more information about covariance and contravariance, see <see href="https://docs.microsoft.com/en-us/dotnet/standard/generics/covariance-and-contravariance">Covariance and Contravariance in Generics</see>.</typeparam>
/// <returns>The return value of the method that this delegate encapsulates.</returns>
public delegate TResult Func<out TResult>();

/// <summary>
/// Encapsulates a method that has one parameter and returns a value of the type specified by the <typeparamref name="TResult"/> parameter.
/// </summary>
/// <typeparam name="T">The type of the parameter of the method that this delegate encapsulates.
/// This type parameter is covariant.That is, you can use either the type you specified or any type that is more derived.For more information about covariance and contravariance, see <see href="https://docs.microsoft.com/en-us/dotnet/standard/generics/covariance-and-contravariance">Covariance and Contravariance in Generics</see>.</typeparam>
/// <typeparam name="TResult">The type of the return value of the method that this delegate encapsulates.
/// This type parameter is covariant.That is, you can use either the type you specified or any type that is more derived.For more information about covariance and contravariance, see <see href="https://docs.microsoft.com/en-us/dotnet/standard/generics/covariance-and-contravariance">Covariance and Contravariance in Generics</see>.</typeparam>
/// <param name="arg">The parameter of the method that this delegate encapsulates.</param>
/// <returns>The return value of the method that this delegate encapsulates.</returns>
public delegate TResult Func<in T, out TResult>(T arg);

/// <summary>
/// Encapsulates a method that has one parameter and returns a value of the type specified by the <typeparamref name="TResult"/> parameter.
/// </summary>
/// <typeparam name="T1">The type of the parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="T2">The type of the parameter of the method that this delegate encapsulates.</typeparam>
/// <typeparam name="TResult">The type of the return value of the method that this delegate encapsulates.
/// This type parameter is covariant.That is, you can use either the type you specified or any type that is more derived.For more information about covariance and contravariance, see <see href="https://docs.microsoft.com/en-us/dotnet/standard/generics/covariance-and-contravariance">Covariance and Contravariance in Generics</see>.</typeparam>
/// <param name="arg1">The first parameter of the method that this delegate encapsulates.</param>
/// <param name="arg2">The second parameter of the method that this delegate encapsulates.</param>
/// <returns>The return value of the method that this delegate encapsulates.</returns>
public delegate TResult Func<in T1, in T2, out TResult>(T1 arg1, T2 arg2);
}
2 changes: 1 addition & 1 deletion nanoFramework.CoreLibrary/System/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
[assembly: AssemblyProduct("nanoFramework mscorlib")]
[assembly: AssemblyCopyright("Copyright (c) .NET Foundation and Contributors")]

[assembly: AssemblyNativeVersion("100.5.0.2")]
[assembly: AssemblyNativeVersion("100.5.0.3")]
26 changes: 26 additions & 0 deletions nanoFramework.CoreLibrary/System/EventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// Copyright (c) .NET Foundation and Contributors
// Portions Copyright (c) Microsoft Corporation. All rights reserved.
// See LICENSE file in the project root for full license information.
//

namespace System
{
/// <summary>
/// Represents the base class for classes that contain event data, and provides a value to use for events that do not include event data.
/// </summary>
public class EventArgs
{
/// <summary>
/// Provides a value to use with events that do not have event data.
/// </summary>
public static readonly EventArgs Empty = new EventArgs();

/// <summary>
/// Initializes a new instance of the <see cref="EventArgs"/> class.
/// </summary>
public EventArgs()
{
}
}
}
25 changes: 25 additions & 0 deletions nanoFramework.CoreLibrary/System/EventHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// Copyright (c) .NET Foundation and Contributors
// Portions Copyright (c) Microsoft Corporation. All rights reserved.
// See LICENSE file in the project root for full license information.
//

namespace System
{
/// <summary>
/// Represents the method that will handle an event that has no event data.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">An object that contains no event data.</param>
public delegate void EventHandler(object sender, EventArgs e);

/// <summary>
/// Represents the method that will handle an event when the event provides data.
/// </summary>
/// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
/// <param name="sender">The source of the event.</param>
/// <param name="e">An object that contains the event data.</param>
#pragma warning disable S3246 // This is nanoFramework implementation of the EventHandler. It's meant to be this way.
public delegate void EventHandler<TEventArgs>(object sender, TEventArgs e);
#pragma warning restore S3246 // Generic type parameters should be co/contravariant when possible
}
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "1.9.1-preview.{height}",
"version": "1.10.0-preview.{height}",
"assemblyVersion": {
"precision": "revision"
},
Expand Down

0 comments on commit 9466adc

Please sign in to comment.