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!
نظرات مطالب
آموزش نصب مک بر روی 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
وبلاگها و سایتهای ایرانی
Visual Studio
امنیت
ASP. Net
- مثالی از نحوه استفاده از کنترلهای جدید چارت مایکروسافت و همچنین مثالی دیگر و مثال بعدی!
طراحی وب
اسکیوال سرور
سیشارپ
عمومی دات نت
متفرقه
- نحوه به تاخیر انداختن ارسال تمامی ایمیلها در آوت لوک (جدا مهم است! به شخصه این مشکل ارسال زود هنگام ایمیل را چندین بار داشتهام!)
اشتراکها
پیاده سازی 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 را غیر فعال نکرده قابل اطمینان است.