How you shouldn’t implement base classes
public class Entity<T> { public T Id { get; protected set; } }
Motivation for such code it pretty clear: you have a base class that can be reused across multiple projects. For instance, if there is a web application with GUID Id columns in the database and a desktop app with integer Ids, it might seem a good idea to have the same class for both of them. In fact, this approach introduces accidental complexity because of premature generalization.
There is no need in using a single base entity class for more than one project or bounded context. Each domain has its unique path, so let it grow independently. Just copy and paste the base entity class to a new project and specify the exact type that will be used for the Id property.
معرفی ویژگی جدید StringSyntax
با استفاده از ویژگی StringSyntax جدید میتوان مقدار مورد انتظار از رشتهی درخواستی را معنادار کرد. برای مثال، Visual Studio سالهاست که راهنمایی را در حین تعریف عبارات باقاعده ظاهر میکند. اما این راهنما صرفا مختص به ویژوال استودیو است و تا پیش از این راهی وجود نداشت تا عنوان کنیم که برای مثال این رشته قرار است تنها یک عبارت باقاعده باشد. اکنون در دات نت 7 با معرفی ویژگی جدید StringSyntax میتوان یک چنین intellisense ای را در سایر IDEها نیز شاهد بود.
برای نمونه مثال زیر را درنظر بگیرید:
using System.Diagnostics.CodeAnalysis; namespace CS11Tests; public class StringSyntaxAttributeTests { public static void Test() { RegexTest(""); DateTest(""); } private static void RegexTest([StringSyntax(StringSyntaxAttribute.Regex)] string regex) { } private static void DateTest([StringSyntax(StringSyntaxAttribute.DateTimeFormat)] string dateTime) { } }
راهنمای ظاهر شده جهت تعریف سادهتر عبارات باقاعده:
و راهنمای ظاهر شده جهت تعریف سادهتر یک DateTime:
امکان استفاده از StringSyntax در دات نتهای پیش از نگارش 7
هرچند StringSyntax در دات نت 7 تعریف شدهاست؛ اما اگر تعریف کلاس زیر را به همراه فضای نام دقیق آن به پروژههای قدیمیتر هم اضافه کنیم ... برای دات نتهای پیش از نگارش 7 هم کار میکند:
#if !NET7_0_OR_GREATER namespace System.Diagnostics.CodeAnalysis { /// <summary>Specifies the syntax used in a string.</summary> [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] public sealed class StringSyntaxAttribute : Attribute { /// <summary>The syntax identifier for strings containing composite formats for string formatting.</summary> public const string CompositeFormat = "CompositeFormat"; /// <summary>The syntax identifier for strings containing date format specifiers.</summary> public const string DateOnlyFormat = "DateOnlyFormat"; /// <summary>The syntax identifier for strings containing date and time format specifiers.</summary> public const string DateTimeFormat = "DateTimeFormat"; /// <summary>The syntax identifier for strings containing <see cref="T:System.Enum" /> format specifiers.</summary> public const string EnumFormat = "EnumFormat"; /// <summary>The syntax identifier for strings containing <see cref="T:System.Guid" /> format specifiers.</summary> public const string GuidFormat = "GuidFormat"; /// <summary>The syntax identifier for strings containing JavaScript Object Notation (JSON).</summary> public const string Json = "Json"; /// <summary>The syntax identifier for strings containing numeric format specifiers.</summary> public const string NumericFormat = "NumericFormat"; /// <summary>The syntax identifier for strings containing regular expressions.</summary> public const string Regex = "Regex"; /// <summary>The syntax identifier for strings containing time format specifiers.</summary> public const string TimeOnlyFormat = "TimeOnlyFormat"; /// <summary>The syntax identifier for strings containing <see cref="T:System.TimeSpan" /> format specifiers.</summary> public const string TimeSpanFormat = "TimeSpanFormat"; /// <summary>The syntax identifier for strings containing URIs.</summary> public const string Uri = "Uri"; /// <summary>The syntax identifier for strings containing XML.</summary> public const string Xml = "Xml"; /// <summary>Initializes the <see cref="T:System.Diagnostics.CodeAnalysis.StringSyntaxAttribute" /> with the identifier of the syntax used.</summary> /// <param name="syntax">The syntax identifier.</param> public StringSyntaxAttribute(string syntax) { this.Syntax = syntax; this.Arguments = Array.Empty<object>(); } /// <summary>Initializes the <see cref="T:System.Diagnostics.CodeAnalysis.StringSyntaxAttribute" /> with the identifier of the syntax used.</summary> /// <param name="syntax">The syntax identifier.</param> /// <param name="arguments">Optional arguments associated with the specific syntax employed.</param> public StringSyntaxAttribute(string syntax, params object?[] arguments) { this.Syntax = syntax; this.Arguments = arguments; } /// <summary>Gets the identifier of the syntax used.</summary> public string Syntax { get; } /// <summary>Gets the optional arguments associated with the specific syntax employed.</summary> public object?[] Arguments { get; } } } #endif
جایگزینی مناسب برای ASP.Net Identity
MembershipReboot is a user identity management and authentication library. It has nothing to do with the ASP.NET Membership Provider, but was inspired by it due to frustrations with the built-in ASP.NET Membership system. The goals are to improve upon and provide missing features from ASP.NET Membership. It is designed to encapsulate the important security logic while leaving most of the other aspects of account management either configurable or extensible for application developers to customize as needed.
- Merge Conflict: "Take Source"/"Keep Target" is missing
- Crashes when trying to debug uwp application
- Unable to select target platform azure v12 for database project
- Fixed crashes or errors that can occur when running Visual Studio after an install action that requires a reboot.
- Fixed an issue deploying Xamarin.Android apps. This peviously required a manual uninstall of the app from the device or emulator.
- This change fixes a bug where the compiler may sometimes incorrectly remove an instruction in a C++ coroutine.
Based on the above observations, we can conclude that React will be the best framework to learn in 2021, followed by Vue. But there is a high chance of Angular defending second place since it has been there for a longer period of time than Vue, and surely 2021 is not the end of that. So if you are an Angular developer, I suggest you learn React in the upcoming days.