resharper

What does “Access to disposed closure” mean?

独自空忆成欢 提交于 2019-12-01 16:38:30
问题 I have the following code: public void DequeueRecipe(AuthIdentity identity, params Guid[] recipeIds) { using (var session = GetSession()) { var recipes = (from r in recipeIds select new Models.Recipes {RecipeId = r}).ToArray(); var dbRecipes = session.QueryOver<Models.QueuedRecipes>() .Where(Expression.Eq("UserId", identity.UserId)) .Where(Expression.InG("Recipe", recipes)) .List<Models.QueuedRecipes>(); using (ITransaction transaction = session.BeginTransaction()) { dbRecipes.ForEach(r =>

What sort of resharper specific files does resharper generate in your vs.net project?

断了今生、忘了曾经 提交于 2019-12-01 16:19:31
问题 What sort of resharper specific files does resharper generate in your vs.net project? (BTW, did you guys get the full version or just the C# version?) 回答1: The "_Resharper.[Solution Name]" folder stores the Resharper specific cache. You can go to Resahrper > Options dialog and select "Store caches in: system TEMP folder" so that your solution folder is not cluttered. I personally prefer to use the TEMP folder so that the cache does not accidentally get added to the version control. Also, in

How do i automate adding a “using” statement to every files in a folder, namespace or project with Visual Studio 2005 / resharper

守給你的承諾、 提交于 2019-12-01 16:07:54
I am using resharper to do a big refactoring and i keep going from file to file and adding the same namespace over and over again in the "using" section is there anyway to add a "using" statement to every single file in a folder, namespace or project? Even though some files wont need the reference, most do, so it will save lots of time. I'd try a regex in the "Find and Replace" dialog: Replace ^using System;$ with using System;\nusing xxx; This works only for files using the System namespace, but maybe you find another common namespace or structure element. After doing so you can refactor all

Temporarily disable StyleCop warnings on ReSharper 6

懵懂的女人 提交于 2019-12-01 16:03:12
I downloaded StyleCop 4.6.3 which integrates with ReSharper 6 and the results are really fantastic! However on a specific project I would like to disable the StyleCop warnings (temporarily) and enable again later on. Is there any way of doing this? I can't seem to find it on the ReSharper menu (options, etc). You can use different Settings.Stylecop settings for each project, just create one that ignores all the rules. Right click on a project and select Stylecop settings to modify them. I think you can also disable plugins by unticking them from ReSharper->Plugins... (in version 5.1, not sure

using coalescing null operator on nullable types changes implicit type

巧了我就是萌 提交于 2019-12-01 15:12:29
I would expect the next three lines of code to be the same: public static void TestVarCoalescing(DateTime? nullableDateTime) { var dateTimeNullable1 = nullableDateTime.HasValue ? nullableDateTime : DateTime.Now; var dateTimeNullable2 = nullableDateTime != null ? nullableDateTime : DateTime.Now; var dateTimeWhatType = nullableDateTime ?? DateTime.Now; } In all cases, I assign nullableDateTime to the new variable. I would expect the type of all variables to become DateTime? since that is the type of nullableDateTime . But to my surprise, the type of dateTimeWhatType just becomes DateTime , so

Why does resharper suggest “wrap variable in array” for access to modified closure warnings?

泪湿孤枕 提交于 2019-12-01 14:57:55
Given the following (heavily edited, pseudo-)code: int count = 0; thing.Stub(m => m.AddBlah()).WhenCalled(o => count++); thing.Stub(m => m.RemoveBlah()).WhenCalled(o => count--); DoStuff(thing); Assert.AreEqual(1, count); ReSharper provides a warning on count - "Access to modified closure". I understand why I'm getting this warning (the count variable is being modified in two different lambdas, and is likely to have undesirable semantics), but I don't understand ReSharper's advice: "Wrap local variable in array". If I let ReSharper do this, I get: int count[] = { 0 }; thing.Stub(m => m.AddBlah

Convert to Method Group Resharper

戏子无情 提交于 2019-12-01 14:56:25
I have written a method below like this: internal static IList<EmpowerTaxView> GetEmpowerTaxViewsByLongAgencyAndAgencyTaxTypes( IList<EmpowerCompanyTaxData> validEmpowerCompanyTaxDatas, IList<EmpowerTaxView> empowerTaxViews) { IList<EmpowerTaxView> result = new List<EmpowerTaxView>(); foreach (EmpowerCompanyTaxData empowerCompanyTaxData in validEmpowerCompanyTaxDatas) { IList<EmpowerTaxView> validEmpowerTaxViews = GetEmpowerTaxViewsByLongAgencyAndTaxType( empowerCompanyTaxData, empowerTaxViews); validEmpowerTaxViews.ToList().ForEach(delegate(EmpowerTaxView etv) { result.Add(etv); }); } return

Temporarily disable StyleCop warnings on ReSharper 6

喜夏-厌秋 提交于 2019-12-01 14:09:02
问题 I downloaded StyleCop 4.6.3 which integrates with ReSharper 6 and the results are really fantastic! However on a specific project I would like to disable the StyleCop warnings (temporarily) and enable again later on. Is there any way of doing this? I can't seem to find it on the ReSharper menu (options, etc). 回答1: You can use different Settings.Stylecop settings for each project, just create one that ignores all the rules. Right click on a project and select Stylecop settings to modify them.

using coalescing null operator on nullable types changes implicit type

时间秒杀一切 提交于 2019-12-01 14:00:25
问题 I would expect the next three lines of code to be the same: public static void TestVarCoalescing(DateTime? nullableDateTime) { var dateTimeNullable1 = nullableDateTime.HasValue ? nullableDateTime : DateTime.Now; var dateTimeNullable2 = nullableDateTime != null ? nullableDateTime : DateTime.Now; var dateTimeWhatType = nullableDateTime ?? DateTime.Now; } In all cases, I assign nullableDateTime to the new variable. I would expect the type of all variables to become DateTime? since that is the

Overriding GetHashCode()

為{幸葍}努か 提交于 2019-12-01 13:47:24
问题 In this article, Jon Skeet mentioned that he usually uses this kind of algorithm for overriding GetHashCode() . public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hash = 17; // Suitable nullity checks etc, of course :) hash = hash * 23 + Id.GetHashCode(); return hash; } } Now, I've tried using this, but Resharper tells me that the method GetHashCode() should be hashing using only read-only fields (it compiles fine, though). What would be a good practice,