اشتراک‌ها
10تا از جالبترین باگهای پیدا شده در پروژه های C# در سال 2020

This tough year, 2020, will soon be over at last, which means it's time to look back at our accomplishments! Over the year, the PVS-Studio team has written quite a number of articles covering a large variety of bugs found in open-source projects with the help of PVS-Studio. This 2020 Top-10 list of bugs in C# projects presents the most interesting specimens. Enjoy the reading! 

10تا از جالبترین باگهای پیدا شده در پروژه های C# در سال 2020
نظرات مطالب
آموزش نصب مک بر روی Virtual Box
هنگام اجری خط فرمان این error را در cmd مشاهده می‌کنم. ممنون میشم راهنمایی کنید که مشکل از کجاست.
VBoxManage.exe : The term 'VBoxManage.exe' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At line:1 char:1
+ VBoxManage.exe modifyvm "my mac" --cpuidset 00000001 000106e5 0010080 ...
+ ~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (VBoxManage.exe:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

بازخوردهای پروژه‌ها
متود IsIn
متاسفانه من ابزار لازم را برای pull request ندارم برای همین به جاش اینجا مواردی را که دوست دارم ارائه میدهم:
        /// <summary>
        /// (Syntactic Sugar) Checks if the given value is among a list of values or not.
        /// </summary>
        /// <remarks>
        /// This method is for syntactic sugar. What it actually does is to allow developers to wrtie a code like this
        /// <code>
        /// xVariable.IsIn(MyEnum.Value1,MyEnum.Value2)
        /// </code>
        /// Instead of these codes:
        /// <code>
        /// new []{ MyEnum.Value1, MyEnum.Value2 }.Contains(xVariable);
        /// </code>
        /// Or more commonly:
        /// <code>
        /// xVariable == MyEnum.Value1 || xVariable == MyEnum.Value2
        /// </code>
        /// </remarks>
        /// <typeparam name="T"></typeparam>
        /// <param name="source"></param>
        /// <param name="list"></param>
        /// <returns></returns>
        public static bool IsIn<T>(this T source, params T[] list)
        {
            Func<T, T, bool> compare = (v1, v2) => EqualityComparer<T>.Default.Equals(v1, v2);
            return list.Any(item => compare(item, source));
        }
اشتراک‌ها
آینده SQL Server CE

SQL Server compact edition is in deprecation mode with no new releases planned near future 

آینده SQL Server CE
مطالب
لینک‌های هفته دوم آذر

وبلاگ‌ها و سایت‌های ایرانی


Visual Studio


امنیت

ASP. Net


طراحی وب


اس‌کیوال سرور


سی‌شارپ


عمومی دات نت


متفرقه


اشتراک‌ها
پیاده سازی Row Level Security در EF6

In this article we are going to implement row level security, its solution makes our application refactoring based and this feature let us manage our project easily.

and this way will reduce your business code and if you use DDD can significantly reduce codes in services. 

پیاده سازی Row Level Security در EF6
مطالب
بررسی سایز و پسوند فایل آپلود شده قبل از ارسال به سرور
می توان قبل از اینکه کاربر فایلی را سمت سرور ارسال کند پسوند فایل را چک کرد و از یک رفت و برگشت بیهوده به سرور جلوگیری کرد .
یک پیاده سازی ساده به کمک jQuery :
var ext = $('#my_file_field').val().split('.').pop().toLowerCase();
if($.inArray(ext, ['gif','png','jpg','jpeg']) == -1) {
    alert('invalid extension!');
}
 
 در کد بالا ابتدا پسوند فایل انتخاب شده توسط کاربر پیدا می‌شود ، سپس به کمک متد inArray با آرایه ای از پسوند‌های دلخواه ما مقایسه می‌شود و در صورت معتبر نبودن پیغامی به کاربر نشان می‌دهد.
کد بالا را می‌توان در رویداد Change کنترل فایل یا در هنگام Post شدن Form اطلاعات قرار داد.
کاملا واضح است که این روش را می‌توان به راحتی دور زد و نباید به آن اکتفا کرد.
مثال این روش را اینجا بررسی کنید.
بررسی سایز فایل :
در اکثر برنامه‌های تحت وب کاربرها محدود به Upload فایل تا سایز خاصی هستند ، این مورد را هم می‌توان قبل از Upload کنترل و اعتبارسنجی کرد : 
//binds to onchange event of your input field
$('#myFile').bind('change', function() {

  //this.files[0].size gets the size of your file.
  alert(this.files[0].size);

});
این روش تا زمانی که کاربر JavaScript را غیر فعال نکرده قابل اطمینان است.