Permalink
Browse files

Renamed events, updated to .Net Core RTM

  • Loading branch information...
1 parent cde014e commit 54860e7048c2a0b76a206739d1bc1a2795e31199 @MrRoundRobin committed Jun 28, 2016
View
@@ -1,4 +1,4 @@
-version: 10.2.0-alpha-{build}
+version: 10.3.0-alpha-{build}
pull_requests:
do_not_increment_build_number: true
branches:
@@ -26,7 +26,7 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s
}
long val;
- if (value is DateTime)
+ if (value is DateTime || value is Nullable<DateTime>)
{
#if NET46
val = new DateTimeOffset((DateTime)value).ToUnixTimeSeconds();
@@ -55,7 +55,7 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s
{
if (reader.TokenType == JsonToken.Null)
{
- if (objectType == typeof(DateTime))
+ if (Nullable.GetUnderlyingType(objectType) != null)
return default(DateTime);
return null;
@@ -58,80 +58,141 @@ public partial class TelegramBotClient
#region Events
/// <summary>
- /// Raises the <see cref="UpdateReceived" />, <see cref="MessageReceived"/>, <see cref="InlineQueryReceived"/>, <see cref="ChosenInlineResultReceived"/> and <see cref="CallbackQueryReceived"/> events.
+ /// Raises the <see cref="OnUpdate" />, <see cref="OnMessage"/>, <see cref="OnInlineQuery"/>, <see cref="OnInlineResultChosen"/> and <see cref="OnCallbackQuery"/> events.
/// </summary>
/// <param name="e">The <see cref="UpdateEventArgs"/> instance containing the event data.</param>
protected virtual void OnUpdateReceived(UpdateEventArgs e)
{
- UpdateReceived?.Invoke(this, e);
+ OnUpdate?.Invoke(this, e);
switch (e.Update.Type)
{
case UpdateType.MessageUpdate:
- MessageReceived?.Invoke(this, e);
+ OnMessage?.Invoke(this, e);
break;
case UpdateType.InlineQueryUpdate:
- InlineQueryReceived?.Invoke(this, e);
+ OnInlineQuery?.Invoke(this, e);
break;
case UpdateType.ChosenInlineResultUpdate:
- ChosenInlineResultReceived?.Invoke(this, e);
+ OnInlineResultChosen?.Invoke(this, e);
break;
case UpdateType.CallbackQueryUpdate:
- CallbackQueryReceived?.Invoke(this, e);
+ OnCallbackQuery?.Invoke(this, e);
break;
case UpdateType.EditedMessage:
- MessageEdited?.Invoke(this, e);
+ OnMessageEdited?.Invoke(this, e);
break;
}
}
/// <summary>
- /// Raises the <see cref="ReceiveError" /> event.
+ /// Occurs when an <see cref="Update"/> is received.
+ /// </summary>
+ public event EventHandler<UpdateEventArgs> OnUpdate;
+
+ /// <summary>
+ /// Occurs when an <see cref="Update"/> is received.
/// </summary>
- /// <param name="e">The <see cref="ReceiveErrorEventArgs"/> instance containing the event data.</param>
- protected virtual void OnReceiveError(ReceiveErrorEventArgs e)
+ [Obsolete("Use OnUpdate")]
+ public event EventHandler<UpdateEventArgs> UpdateReceived
{
- ReceiveError?.Invoke(this, e);
+ add { OnUpdate += value; }
+ remove { OnUpdate -= value; }
}
/// <summary>
- /// Occurs when an <see cref="Update"/> is received.
+ /// Occurs when a <see cref="Message"/> is recieved.
/// </summary>
- public event EventHandler<UpdateEventArgs> UpdateReceived;
+ public event EventHandler<MessageEventArgs> OnMessage;
/// <summary>
/// Occurs when a <see cref="Message"/> is recieved.
/// </summary>
- public event EventHandler<MessageEventArgs> MessageReceived;
+ [Obsolete("Use OnMessage")]
+ public event EventHandler<MessageEventArgs> MessageReceived
+ {
+ add { OnMessage += value; }
+ remove { OnMessage -= value; }
+ }
+
+ /// <summary>
+ /// Occurs when <see cref="Message"/> was edited.
+ /// </summary>
+ public event EventHandler<MessageEventArgs> OnMessageEdited;
/// <summary>
/// Occurs when <see cref="Message"/> was edited.
/// </summary>
- public event EventHandler<MessageEventArgs> MessageEdited;
+ [Obsolete("Use OnMessageEdited")]
+ public event EventHandler<MessageEventArgs> MessageEdited
+ {
+ add { OnMessageEdited += value; }
+ remove { OnMessageEdited -= value; }
+ }
/// <summary>
/// Occurs when an <see cref="InlineQuery"/> is received.
/// </summary>
- public event EventHandler<InlineQueryEventArgs> InlineQueryReceived;
+ public event EventHandler<InlineQueryEventArgs> OnInlineQuery;
+
+ /// <summary>
+ /// Occurs when an <see cref="InlineQuery"/> is received.
+ /// </summary>
+ [Obsolete("Use OnInlineQuery")]
+ public event EventHandler<InlineQueryEventArgs> InlineQueryReceived
+ {
+ add { OnInlineQuery += value; }
+ remove { OnInlineQuery -= value; }
+ }
+
+ /// <summary>
+ /// Occurs when a <see cref="ChosenInlineResult"/> is received.
+ /// </summary>
+ public event EventHandler<ChosenInlineResultEventArgs> OnInlineResultChosen;
/// <summary>
/// Occurs when a <see cref="ChosenInlineResult"/> is received.
/// </summary>
- public event EventHandler<ChosenInlineResultEventArgs> ChosenInlineResultReceived;
+ [Obsolete("Use OnInlineResultChosen")]
+ public event EventHandler<ChosenInlineResultEventArgs> ChosenInlineResultReceived
+ {
+ add { OnInlineResultChosen += value; }
+ remove { OnInlineResultChosen -= value; }
+ }
/// <summary>
/// Occurs when an <see cref="CallbackQuery"/> is received
/// </summary>
- public event EventHandler<CallbackQueryEventArgs> CallbackQueryReceived;
+ public event EventHandler<CallbackQueryEventArgs> OnCallbackQuery;
+
+ /// <summary>
+ /// Occurs when an <see cref="CallbackQuery"/> is received
+ /// </summary>
+ [Obsolete("Use OnCallbackQuery")]
+ public event EventHandler<CallbackQueryEventArgs> CallbackQueryReceived
+ {
+ add { OnCallbackQuery += value; }
+ remove { OnCallbackQuery -= value; }
+ }
/// <summary>
/// Occurs when an error occures during the background update pooling.
/// </summary>
- public event EventHandler<ReceiveErrorEventArgs> ReceiveError;
+ public event EventHandler<ReceiveErrorEventArgs> OnReceiveError;
+
+ /// <summary>
+ /// Occurs when an error occures during the background update pooling.
+ /// </summary>
+ [Obsolete("Use OnReceiveError")]
+ public event EventHandler<ReceiveErrorEventArgs> ReceiveError
+ {
+ add { OnReceiveError += value; }
+ remove { OnReceiveError -= value; }
+ }
#endregion
@@ -222,7 +283,7 @@ public void StartReceiving(TimeSpan timeout, CancellationToken cancellationToken
catch (OperationCanceledException) {}
catch (ApiRequestException e)
{
- OnReceiveError(e);
+ OnReceiveError?.Invoke(this, e);
}
}
@@ -1,5 +1,5 @@
{
- "version": "10.2.0-*",
+ "version": "10.3.0-*",
"title": "Telegram Bot API",
"description": "Telegram Bot API Class Library",
"authors": [ "Robin Müller" ],
@@ -8,7 +8,7 @@
"iconUrl": "https://telegram.org/file/811140058/2/7GzMJk4Ij54/a1649c56fa9f805828",
"projectUrl": "https://github.com/MrRoundRobin/telegram.bot",
"licenseUrl": "https://raw.githubusercontent.com/MrRoundRobin/telegram.bot/master/LICENSE.txt",
- "releaseNotes": "Added .NET Core RC2, API 2.1, Task Cancellation",
+ "releaseNotes": "Added .NET Core, API 2.1, Task Cancellation",
"tags": [ "Telegram", "Api", "Bot" ],
"repository": {
"type": "git",
@@ -37,16 +37,16 @@
"debugType": "portable"
},
"dependencies": {
- "Microsoft.CSharp": "4.0.1-rc2-24027",
- "System.Net.Http": "4.0.1-rc2-24027",
- "System.Reflection": "4.1.0-rc2-24027",
- "System.Runtime": "4.1.0-rc2-24027",
- "System.Runtime.Serialization.Json": "4.0.2-rc2-24027"
+ "Microsoft.CSharp": "4.0.1",
+ "System.Net.Http": "4.1.0",
+ "System.Reflection": "4.1.0",
+ "System.Runtime": "4.1.0",
+ "System.Runtime.Serialization.Json": "4.0.2"
}
}
},
"dependencies": {
- "Newtonsoft.Json": "9.0.1-beta1"
+ "Newtonsoft.Json": "9.0.1"
},
"buildOptions": {
"xmlDoc": true

4 comments on commit 54860e7

@thoemmi
Contributor

May I ask you for the rational behind renaming the events? As far as I can see you have prefixed all events with On. However, Microsoft's guideline for naming events says:

✓ DO name events with a verb or a verb phrase.
Examples include Clicked, Painting, DroppedDown, and so on.
✓ DO give events names with a concept of before and after, using the present and past tenses.
For example, a close event that is raised before a window is closed would be called Closing, and one that is raised after the window is closed would be called Closed.

Even more explicitely the Event Naming Guildelines for .NET Framework 1.1 says:

  • Do not use a prefix or suffix on the event declaration on the type. For example, use Close instead of OnClose.
@MrRoundRobin
Owner

@thoemmi
I read the docs for .NET Core, in the Events Overview it says

[...] There are a number of conventions that you should follow when declaring an event. Typically, the event delegate type has a void return. Prefix event declarations with 'On'. The remainder of the name is a verb. [...]

@thoemmi
Contributor

Oh, so Microsoft changed the guidelines? Oh my... 😕

Then forget my comment 😉

@MrRoundRobin
Owner

yes, microsoft likes changin their mind 👅

Please sign in to comment.