Quantcast
Channel: YouTrackReSharper (RSRP) - Bug and Issue Tracker
Viewing all 106942 articles
Browse latest View live

RSRP-471811: ReSpeller team shared dictionaries in solution folder.

$
0
0
Reporter Denis A. Gladkiy (DrollerTroller) Denis A. Gladkiy (DrollerTroller)
Created Oct 11, 2018 10:11:10 AM
Updated Oct 11, 2018 10:11:10 AM
Subsystem ReSpeller
Assignee Artem Bukhonov (Artem.Bukhonov)
Priority Normal
State Submitted
Type Usability Problem
Fix version No Fix versions
Affected versions 2018.2
Fixed In Version ReSharper Undefined
VsVersion All Versions

I can't specify relative path to the .dic file in the team-shared options layer from the UI. If I manually fix the path in .DotSettings R# says it can't load dictionary.


RSRP-466423: Restore 'remove empty file' default behavior prior 2017.2.1

$
0
0
Reporter cowboy (cowboy) cowboy (cowboy)
Created Sep 27, 2017 7:49:39 AM
Updated Oct 11, 2018 10:45:27 AM
Subsystem UI
Assignee Alisa Afonina (alisa.afonina)
Priority Normal
State Submitted
Type Usability Problem
Fix version 2018.3
Affected versions 2017.2.1
Fixed In Version ReSharper Undefined
VsVersion VS 2017 15.6


First, the Tab key never activates "remove empty file".


Secondly,


IIRC, this "remove empty file" was always checked by default (on the 2nd UI prompt) in previous versions of R#... now the "remove empty file" is included in the first UI prompt; however, in 2017.2.1, the default is not checked by default. This, coupled with the TAB issue, only adds more friction when refactoring.

So, you should keep the default behavior with prior versions


Or at least REMEMBER my last setting forever. I prefer to have this as the default as it was consistent with previous versions, otherwise, R# slows me down and litters my project with empty files.

Thanks,

  • Windows 7 classic theme
  • VS 2017 15.3 latest update

RSRP-471312: Component StyleCop.ReSharper.ShellComponents.VisualStudio2015.ReferencedAnalyzersCache [Singleton, Corrupted] construction has failed. Component descr

$
0
0
Reporter ReSharper anonymous (resharper) ReSharper anonymous (resharper)
Created Jul 20, 2018 3:01:55 PM
Updated Oct 11, 2018 10:54:25 AM
Subsystem Platform - Project Model
Assignee Sergey Kuks (coox)
Priority Critical
State Submitted
Type Exception
Fix version 2018.3
Affected versions No Affected versions
Fixed In Version ReSharper Undefined
VsVersion All Versions
ReSharperPlatformVs15 Wave 182 Hive _eafc2448 — JetBrains ReSharper Ultimate 2018.2 EAP 4 Build 182.0.20180719.135715-eap04

JetBrains dotCover 182 Build 182.0.20180719.141200-eap04
JetBrains dotMemory 182 Build 182.0.20180719.141056-eap04
JetBrains dotTrace 182 Build 182.0.20180719.141207-eap04
JetBrains ReSharper 182 Build 182.0.20180719.140920-eap04
JetBrains ReSharper C++ 182 Build 182.0.20180719.140918-eap04

Component StyleCop.ReSharper.ShellComponents.VisualStudio2015.ReferencedAnalyzersCache [Singleton, Corrupted] construction has failed. Component descriptor StyleCop.ReSharper.ShellComponents.VisualStudio2015.ReferencedAnalyzersCache [Singleton, Corrupted] is corrupted and cannot be accessed

— EXCEPTION #1/3 [InvalidOperationException]
Message = “Component descriptor StyleCop.ReSharper.ShellComponents.VisualStudio2015.ReferencedAnalyzersCache [Singleton, Corrupted] is corrupted and cannot be accessed”
ExceptionPath = Root.InnerException.InnerException
ClassName = System.InvalidOperationException
HResult = COR_E_INVALIDOPERATION=80131509
Source = JetBrains.Platform.ComponentModel
StackTraceString = “
 at JetBrains.Application.Components.SingletonDescriptor.GetValue()
 at JetBrains.Application.Components.SingletonDescriptor.GetValue()
 at JetBrains.Application.Components.InitializationStrategyDefault.Schedule(Lifetime lifetime, ICollection`1 dscs, IComponentContainer container)


— Outer —

— EXCEPTION #2/3 [TargetInvocationException]
Message = “Component StyleCop.ReSharper.ShellComponents.VisualStudio2015.ReferencedAnalyzersCache [Singleton, Corrupted] construction has failed.”
ExceptionPath = Root.InnerException
ClassName = System.Reflection.TargetInvocationException
Data.Descriptor = “StyleCop.ReSharper.ShellComponents.VisualStudio2015.ReferencedAnalyzersCache [Singleton, Corrupted]”
InnerException = “Exception #1 at Root.InnerException.InnerException”
HResult = COR_E_TARGETINVOCATION=80131604

— Outer —

— EXCEPTION #3/3 [LoggerException]
Message = “Component StyleCop.ReSharper.ShellComponents.VisualStudio2015.ReferencedAnalyzersCache [Singleton, Corrupted] construction has failed.”
ExceptionPath = Root
ClassName = JetBrains.Util.LoggerException
Data.ManagedThreadName = <NULL>
Data.SccRevisionShell = “<there are no packages matching the criteria>”
Data.HostProductInfo = “JetBrains ReSharper Ultimate 2018.2 EAP 4 Build 182.0.20180719.135715-eap04”
Data.SubProducts.#0 = “JetBrains dotCover 182 Build 182.0.20180719.141200-eap04”
Data.SubProducts.#1 = “JetBrains dotTrace 182 Build 182.0.20180719.141207-eap04”
Data.SubProducts.#2 = “JetBrains ReSharper C++ 182 Build 182.0.20180719.140918-eap04”
Data.SubProducts.#3 = “JetBrains ReSharper 182 Build 182.0.20180719.140920-eap04”
Data.SubProducts.#4 = “JetBrains dotMemory 182 Build 182.0.20180719.141056-eap04”
Data.SccRevisionEnv = “
Platform\Core\Shell:
    git::refs/heads/182-eap4::a7c3bfa8750975ef8e674393fccaa4e138ea92f3


Platform\VisualStudio:
    git::refs/heads/182-eap4

Data.VsVersion = 15.7.27703.2042
InnerException = “Exception #2 at Root.InnerException”
HResult = COR_E_APPLICATION=80131600
StackTraceString = “
 at JetBrains.Application.Components.InitializationStrategyDefault.Schedule(Lifetime lifetime, ICollection`1 dscs, IComponentContainer container)
 at JetBrains.Application.Components.InitializationStrategyDefault.Schedule(Lifetime lifetime, ICollection`1 dscs, IComponentContainer container)
 at JetBrains.Application.Components.ComponentStorage.ComposeDescriptors(ICollection`1 descriptors)
 at JetBrains.Application.Components.ComponentStorage.Compose()
 at JetBrains.ProjectModel.SolutionInstance.OpenSolution(ISolutionOwner solutionOwner)
 at JetBrains.ProjectModel.SolutionManagerBase.<>c__DisplayClass23_0.<CreateSolutionInstance>b__1()
 at JetBrains.ProjectModel.Tasks.SolutionLoadTasksSchedulerBase.<>c__DisplayClass21_0.<ExecuteTask>b__1()
 at JetBrains.Util.ILoggerEx.Catch(ILogger thіs, Action F, ExceptionOrigin origin, LoggingLevel loggingLevel)
 at JetBrains.ProjectModel.Tasks.SolutionLoadTasksSchedulerBase.ExecuteTask(SolutionLoadTask task)
 at JetBrains.ProjectModel.Tasks.SolutionLoadTasksSchedulerAsync.<Schedule>b__5_0()
 at JetBrains.Application.Threading.IShellLocksEx.ExecuteWithReadLock(IShellLocks thіs, Action F)
 at JetBrains.Application.Threading.IShellLocksEx.<>c__DisplayClass11_0.<QueueReadLock>b__0()
 at JetBrains.Threading.ReentrancyGuardEx.<>c__DisplayClass0_1.<Queue>b__3()
 at JetBrains.Threading.ReentrancyGuard.Execute(String name, Action action)
 at JetBrains.Threading.ReentrancyGuard.ExecutePendingActions()
 at JetBrains.Threading.JetDispatcher.Closure.Execute()
 at JetBrains.Util.Concurrency.WinJetDispatcher.ProcessQueue(Int32 nMinBucket)
 at JetBrains.Util.Concurrency.WinJetDispatcher.ExternalIdleProcessing.OnExternalDriverIdle()
 at JetBrains.VsIntegration.Shell.VsDoIdleDispatcherSink.Microsoft.VisualStudio.OLE.Interop.IOleComponent.FDoIdle(UInt32 grfidlef)

RSRP-471813: ToDo items are not discovered in given *.js and *.ts files

$
0
0
Reporter Anna Milova (anna.milova) Anna Milova (anna.milova)
Created Oct 11, 2018 10:56:54 AM
Updated Oct 11, 2018 10:56:54 AM
Subsystem TODO Items
Assignee Andrew Karpov (andrew.karpov)
Priority Normal
State Submitted
Type Bug
Fix version No Fix versions
Affected versions No Affected versions
Fixed In Version ReSharper Undefined
VsVersion All Versions
Though R# 2018.1 discovered these items.
Compare:
R# 2018.1

R# 2018.3

See the solution attached.

RSRP-410848: Non optimal refactor result for: "Use format string for all argument"

$
0
0
Reporter Jens Odborg (JensO) Jens Odborg (JensO)
Created Mar 21, 2014 5:53:32 PM
Updated Oct 11, 2018 11:26:52 AM
Resolved Oct 11, 2018 11:26:52 AM
Subsystem Quick Fixes
Assignee Alisa Afonina (alisa.afonina)
Priority Normal
State Fixed
Type Bug
Fix version Unidentified prior version
Affected versions 8.1
Fixed In Version ReSharper Undefined
VsVersion VS 2013 RTM
Given the following methods:
[StringFormatMethod("format")] public void DebugFormat(string message)
{ ... }

[StringFormatMethod("format")] public void DebugFormat(string format, object arg0)
{ ... }

[StringFormatMethod("format")] public void DebugFormat(string format, object arg0, object arg1)
{ ... }

[StringFormatMethod("format")] public void DebugFormat(string format, object arg0, object arg1, object arg2)
{ ... }

[StringFormatMethod("format")]
// ReSharper disable once MethodOverloadWithOptionalParameter
public void DebugFormat(Exception ex, string format, params object[] args)
{ ... }
The following code:
_Log.DebugFormat("Hello " + name);
Will refactor to:
_Log.DebugFormat(string.Format("Hello {0}", name));
Should be:
_Log.DebugFormat("Hello {0}", name);

RSRP-412942: Does not work "Remove redundant qulifiers" refactoring for file\project\solution

$
0
0
Reporter Eduard Kibort (advard) Eduard Kibort (advard)
Created Apr 16, 2014 9:16:41 PM
Updated Oct 11, 2018 11:32:04 AM
Resolved Oct 11, 2018 11:32:04 AM
Subsystem Quick Fixes
Assignee Alisa Afonina (alisa.afonina)
Priority Normal
State Fixed
Type Bug
Fix version Unidentified prior version
Affected versions 8.2
Fixed In Version ReSharper Undefined
VsVersion VS 2013 RTM
Then I tries to fix all "base." warnings in file\solution or project. I get prompt to open 129 files and no changes in code after that. Then I tries to use it for line it works.


public void TestableAddDbParamsToCommand(IDbCommand cmd, List<DbParam> dbparams)
{
base.AddDbParamsToCommand(cmd, dbparams);
}

RSRP-471685: Required parentheses are removed during cleanup

$
0
0
Reporter Richard Waliser (richwaliser05) Richard Waliser (richwaliser05)
Created Sep 28, 2018 7:46:15 PM
Updated Oct 11, 2018 11:50:49 AM
Resolved Oct 11, 2018 11:50:49 AM
Subsystem Code Style - Cleanup
Assignee Ivan Serduk (IvanSerduk)
Priority Critical
State Fixed
Type Bug
Fix version 2018.3
Affected versions No Affected versions
Fixed In Version ReSharper Undefined
VsVersion All Versions

ReSharper cleanup removes the parentheses around the expression below, thereby changing the implied type of result.

var result = await (
   id == "a"
      ? Task.FromResult("a")
      : Task.FromResult("b")
);

It should not be doing this. I have confirmed that updating from 2018.1.3 to 2018.2.3 introduces this bug.

RSRP-471673: Redundant parens false positive

$
0
0
Reporter Alexandra Kuks (Asia.Rudenko) Alexandra Kuks (Asia.Rudenko)
Created Sep 28, 2018 1:33:36 PM
Updated Oct 11, 2018 11:50:55 AM
Resolved Oct 11, 2018 11:50:55 AM
Subsystem Quick Fixes
Assignee Ivan Serduk (IvanSerduk)
Priority Major
State Fixed
Type Bug
Fix version 2018.3
Affected versions No Affected versions
Fixed In Version ReSharper Undefined
VsVersion All Versions
From https://youtrack.jetbrains.com/issue/RSRP-453762#focus=streamItem-27-3077389-0-0

Since ReSharper 2018.2.3 (maybe one or two releases ealier), the quickfix 'Remove redundant parentheses' is appearing for non-suitable code fragments; when applied, it removes parentheses that are not redundant, thus breaking evaluation order of expressions and semantical correctness, leading to compilation errors.

Reproducible with the following code fragments and VS 2013 (and likely other VS's as well):

before 'Remove redundant parentheses':

unsafe
{
*(pData + position) = value;
}
after 'Remove redundant parentheses':

unsafe
{
*pData + position = value;
}
before 'Remove redundant parentheses':

return (idx < array.Length ? array[idx] : null) as ISomeInterface;
after 'Remove redundant parentheses':

return idx < array.Length ? array[idx] : null as ISomeInterface;

RSRP-471594: Wrong "Invalid Possible InvalidOperatiorException"

$
0
0
Reporter Viacheslav Ivanov (_FRED_) Viacheslav Ivanov (_FRED_)
Created Sep 21, 2018 3:18:50 PM
Updated Oct 11, 2018 11:50:59 AM
Resolved Oct 11, 2018 11:50:59 AM
Subsystem Code Analysis - Control Flow
Assignee Ivan Serduk (IvanSerduk)
Priority Normal
State Fixed
Type Bug
Fix version 2018.3
Affected versions 2018.2.3
Fixed In Version ReSharper Undefined
VsVersion All Versions
Code:
using System.Data.SqlTypes;


private static DateTime? M(DateTime? value)
=> value != null && value.Value < SqlDateTime.MinValue ? default(DateTime?) : value;
// ^~~~~~~~~~^ Possible InvalidOperationException

When I use DateTime instead of SqlDateTime all is OK

RSRP-463819: ReSharper CLT InspectCode.exe variance

$
0
0
Reporter Josh Pharis (jrpharis) Josh Pharis (jrpharis)
Created Mar 20, 2017 6:59:11 PM
Updated Oct 11, 2018 11:59:11 AM
Subsystem ReSharper Automation Tools (Command Line)
Assignee Slava Trenogin (derigel)
Priority Critical
State Submitted
Type Bug
Fix version 2018.3
Affected versions No Affected versions
Fixed In Version ReSharper Undefined
VsVersion All Versions
I am having issues using InspectCode.exe as a MSBuild build step to fail a build when errors and warnings against the ReSharper code inspection rules occur. If I run ReSharper -> Inspect -> Code Issues in Solution, I get no errors (using default rules). When I run inspectcode.exe (either from the command line or as a build step), I get numerous errors with the message "Cannot resolve symbol '<type>'".

I have tried this with the inspectcode.exe executable that is downloaded with the JetBrains.ReSharper.CommandLineTools (v2016.3.20170126.124346) Nuget package and with the download from the JetBrains website. I confirmed I am able to build my solution with MsBuild.exe with no parameters.

RSRP-413843: VB.NET: Incorrect Quick Fix

$
0
0
Reporter Denis Abramov (sparky2708) Denis Abramov (sparky2708)
Created Apr 30, 2014 9:12:21 PM
Updated Oct 11, 2018 11:59:19 AM
Subsystem Quick Fixes
Assignee Alisa Afonina (alisa.afonina)
Priority Normal
State Submitted
Type Bug
Fix version Backlog
Affected versions 7.1.3, 8.0.2, 8.1, 8.0.1, 2018.3
Fixed In Version ReSharper Undefined
VsVersion All Versions
    Public Shared Sub ArrayListToArray(ByRef arr As Array,
ByVal arrLst As ArrayList)
Dim numArrLstElems As Integer
arr = Nothing
If arrLst Is Nothing Then
Exit Sub
End If
numArrLstElems = arrLst.Count
If numArrLstElems = 0 Then
arr = Nothing
Exit Sub
End If

Try
arr = arrLst.ToArray(arrLst.Item(0).GetType()) '<-- Resharper complains about this one'
Catch ie As System.InvalidCastException
Throw
End Try
End Sub

When quick fix is applied to the line commented above, the line is changed to:

arr = arrLst.ToArray(arrLst.Item(0))

THIS IS WRONG. It should be:

arr = arrLst.ToArray(arrLst.Item(0).GetType) 

RSRP-414298: "Introduce and initialize field" should copy nullness annotations

$
0
0
Reporter Andrey Shchekin (ashmind) Andrey Shchekin (ashmind)
Created May 10, 2014 2:57:09 PM
Updated Oct 11, 2018 12:01:42 PM
Resolved Oct 11, 2018 12:01:42 PM
Subsystem Quick Fixes
Assignee Alisa Afonina (alisa.afonina)
Priority Normal
State Fixed
Type Feature
Fix version Unidentified prior version
Affected versions 8.2
Fixed In Version ReSharper Undefined
VsVersion All Versions
When using "Introduce and initialize field" on constructor argument with [NotNull]/[CanBeNull] attribute, it would make sense to copy the attribute to the field.

RSRP-414461: API improvement request for bulk quick fixes + in-file scope

$
0
0
Reporter Matt Ellis (citizenmatt) Matt Ellis (citizenmatt)
Created May 13, 2014 1:47:51 PM
Updated Oct 11, 2018 12:05:51 PM
Subsystem Quick Fixes
Assignee Alisa Afonina (alisa.afonina)
Priority Normal
State Submitted
Type Task
Fix version No Fix versions
Affected versions 8.2.1
Fixed In Version ReSharper Undefined
VsVersion All Versions
The BulkQuickFixWithCommonTransactionBuilder class makes adding "in file" scope difficult. It requires a QuickFixBase to implement the caret position quick fix, and a delegate to handle fixes in various scopes (folder, project, solution). But the "in file" scope requires another class to be created.

Ideally, it should require just the one quick fix class for the current caret position, and use the passed delegate to implement file, folder, project and solution scope.

RSRP-471758: Running an xUnit from xUnit.net Test icon (as opposed to xUnit.net Test Class icon) always ends up Inconclusive

$
0
0
Reporter Jacob Mojiwat (jmojiwat) Jacob Mojiwat (jmojiwat)
Created Oct 5, 2018 3:42:34 AM
Updated Oct 11, 2018 12:06:16 PM
Subsystem Unit Testing
Assignee Eugene Strizhok (Eugene.Strizhok)
Priority Normal
State Submitted
Type Bug
Fix version No Fix versions
Affected versions No Affected versions
Fixed In Version ReSharper Undefined
VsVersion All Versions

Clicking the class level icon runner will run the tests, but clicking on the method level icon runner will return inconclusive.

Error returned by Resharper:

2018.10.05 08:34:05.678 ERROR JetBrains.Util.InternalErrorException: Unexpected: Unable to find any matching test cases
at JetBrains.ReSharper.UnitTestRunner.Xunit.TestRunner.Run(XunitTestAssemblyTask assemblyTask)

2018.10.05 08:34:05.698 WARN Element Testing was left pending after its run completion.
2018.10.05 08:34:05.698 WARN Element Test1 was left pending after its run completion.

Source code to reproduce the error:

public class Testing
{
    [Theory, TestAutoData]
    public void Test1(Multiplier sut)
    {
        var x = sut.Execute(1);
        x.Should().Be(2);
    }

    [Theory, TestAutoData]
    public void Test2(Multiplier sut)
    {
        var x = sut.Execute(1);
        x.Should().Be(2);
    }

    public class Multiplier
    {
        public int Execute(int i)
        {
            return i * 2;
        }
    }

    private class TestAutoDataAttribute : AutoDataAttribute
    {
        public TestAutoDataAttribute() : base(() => 
            new Fixture().Customize(new CompositeCustomization(new Customization(), new AutoNSubstituteCustomization())))
        {}
    }

    private class Customization : ICustomization
    {
        public void Customize(IFixture fixture)
        {
            fixture.Register(() => new Multiplier());
        }
    }
}

Using
Resharper 2018.2.3
Visual Studio 15.8.6

Compiling against .Net 4.7.2

RSRP-415388: "update all xml-comments" quickfix

$
0
0
Reporter Alexander Kurakin (Alexander.Kurakin) Alexander Kurakin (Alexander.Kurakin)
Created May 26, 2014 3:57:57 PM
Updated Oct 11, 2018 12:08:47 PM
Subsystem Quick Fixes
Assignee Alisa Afonina (alisa.afonina)
Priority Normal
State Submitted
Type Feature
Fix version Backlog
Affected versions 2018.3
Fixed In Version ReSharper Undefined
VsVersion All Versions
when I add multiple parameters to a method, when you suggest, please ask "update all xml-comments" rather than make me do it one at a time.

RSRP-415524: “Use var” cleanup may introduce compilation error

$
0
0
Reporter Guest 256 (guest256) Guest 256 (guest256)
Created May 28, 2014 12:48:15 AM
Updated Oct 11, 2018 12:12:02 PM
Resolved Oct 11, 2018 12:12:02 PM
Subsystem Quick Fixes
Assignee Alisa Afonina (alisa.afonina)
Priority Normal
State Fixed
Type Bug
Fix version Unidentified prior version
Affected versions 8.2
Fixed In Version ReSharper Undefined
VsVersion VS 2012 RTM U2
Recently found stupid code, thanks to applying “use var” refactoring to whole solution.

before
int a = a = 42; // meaningless, but works

after
var a = a = 42; // Cannot use local variable 'a' before it is declared

Useful bug however, helps to make code better =)

RSRP-471814: Extension cant't start when Resharper is installed

$
0
0
Reporter Raphael Kuster (rfkuster) Raphael Kuster (rfkuster)
Created Oct 11, 2018 12:14:23 PM
Updated Oct 11, 2018 12:14:23 PM
Subsystem No Subsystem
Assignee Unassigned
Priority Normal
State Submitted
Type Unspecified
Fix version No Fix versions
Affected versions No Affected versions
Fixed In Version ReSharper Undefined
VsVersion All Versions

Our companies own Development extension(that does config file management) won't start with the error "Specified cast not valid." as soon as resharper is installed

RSRP-471584: use var in file and project not working

$
0
0
Reporter Tim Ford (tford) Tim Ford (tford)
Created Sep 21, 2018 2:44:47 AM
Updated Oct 11, 2018 12:23:42 PM
Subsystem Context Actions
Assignee Alexander Shvedov (shvedov)
Priority Normal
State Open
Type Bug
Fix version Backlog
Affected versions 2018.3
Fixed In Version ReSharper Undefined
VsVersion All Versions

I am trying to refactor a decent size project and when I click on use var in file or project nothing happens

RSRP-415563: Using directives added in weird place if comments exist above namespace.

$
0
0
Reporter Sam Rueby (Sam.Rueby) Sam Rueby (Sam.Rueby)
Created May 29, 2014 5:37:12 AM
Updated Oct 11, 2018 12:27:11 PM
Resolved Oct 11, 2018 12:27:10 PM
Subsystem Quick Fixes
Assignee Alisa Afonina (alisa.afonina)
Priority Normal
State Fixed
Type Bug
Fix version Unidentified prior version
Affected versions 8.2.1
Fixed In Version ReSharper Undefined
VsVersion VS 2013 RTM

1. This is the top of the file.


2. Remove the last using directive so Resharper will suggest to us the namespace to import.


3. Resharper suggests to us the namespace to import. Accept it.


4. Using directive was placed below the comment.

RSRP-415653: Quickfix 'Check if variable not null' generates wrong code

$
0
0
Reporter Alexander Kurakin (Alexander.Kurakin) Alexander Kurakin (Alexander.Kurakin)
Created May 30, 2014 5:55:49 PM
Updated Oct 11, 2018 12:30:06 PM
Subsystem Context Actions
Assignee Alisa Afonina (alisa.afonina)
Priority Major
State Submitted
Type Bug
Fix version Backlog
Affected versions 8.2, 8.2.1, 2018.3
Fixed In Version ReSharper Undefined
VsVersion All Versions
This code produces an invalid refactoring suggestion
protected SqlConnection Connection() 
{
var conn = new SqlConnection(ConnectionString);
conn.Open();
return conn;
}

public int GetTotalSize()
{
using (var connection = Connection())
{
using (var cmd = new SqlCommand(QueryBuilder.GetTotalSizeCmd))
{
cmd.Connection = connection;
return (int)cmd.ExecuteScalar();
}
}
}
The construct
using (var connection = Connection())
creates a refactoring 'Check if variable not null' when the cursor is on the 'connection'. When executing the refactoring, code with error is produced
using (var connection = Connection()) 
{
using (var cmd = new SqlCommand(QueryBuilder.GetTotalSizeCmd))
{
cmd.Connection = connection;
return (int)cmd.ExecuteScalar();
}
}
// the following lines where added by R#
if (connection == null)
{
throw new ArgumentNullException("connection");
}
Viewing all 106942 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>