Reporter | Joshua Harley (gibwar) |
---|---|
Created | Jan 11, 2012 1:00:17 AM |
Updated | Jan 11, 2012 1:15:37 AM |
Priority | Normal |
Type | Unspecified |
Fix versions | No Fix versions |
State | Submitted |
Assignee | Unassigned |
Subsystem | No subsystem |
Affected versions | No Affected versions |
Fixed in build | No Fixed in build |
I use a custom class to wrap my database objects to ensure consistent handling and disposing. However, with ReSharper, it gets confused when the database execution is done indirectly. The current database wrapper uses .Net 3.5's System.Data.OracleClient.
As I was writing this bug report I originally had use the native OracleCommand and thankfully I tested that. In the case above when DatabaseEngineCommand is replaced by OracleCommand and command.ExecuteNonQuery(); is called, the issue does not appear. Is there a way to direct ReSharper to understand that the object is modified by the call as its passed in so that I don't have to suppress this warning all over my code?
The following code works as expected and will throw the same message if the ExecuteNonQuery method is commented out:
I am using the full version of the ReSharper 6.1 EAP:
JetBrains ReSharper 6.1 Full Edition
Build 6.1.38.146 on 2011-12-30T20:18:32
var engineCommand = new DatabaseEngineCommand(DatabaseConnection.Application, CommandType.StoredProcedure) { CommandText = "SCHEMA.procedure" }; engineCommand.Parameters.Add("inout_PARAMETER", OracleType.VarChar, 128).Direction = ParameterDirection.InputOutput; engineCommand.Parameters["inout_PARAMETER"].Value = "somevalue"; if (this.ExecuteNonQueryCommand(engineCommand)) { // the line below is tagged "Expression is always true" in ReSharper. if (engineCommand.Parameters["inout_PARAMETER"].Value is string) { // process results } }
As I was writing this bug report I originally had use the native OracleCommand and thankfully I tested that. In the case above when DatabaseEngineCommand is replaced by OracleCommand and command.ExecuteNonQuery(); is called, the issue does not appear. Is there a way to direct ReSharper to understand that the object is modified by the call as its passed in so that I don't have to suppress this warning all over my code?
The following code works as expected and will throw the same message if the ExecuteNonQuery method is commented out:
using (OracleCommand command = new OracleCommand()) { command.Parameters.Add("inout_PARAMETER", OracleType.VarChar, 128).Direction = ParameterDirection.InputOutput; command.Parameters["inout_PARAMETER"].Value = "someparam"; command.ExecuteNonQuery(); // if this line is commented, the message is shown. if (command.Parameters["inout_PARAMETER"].Value is string) { } }
I am using the full version of the ReSharper 6.1 EAP:
JetBrains ReSharper 6.1 Full Edition
Build 6.1.38.146 on 2011-12-30T20:18:32