Skip to content

Commit 3e1b0ea

Browse files
committed
Merge branch 'release/1.1.1' into main
2 parents ecb69b4 + 64253ac commit 3e1b0ea

File tree

11 files changed

+242
-50
lines changed

11 files changed

+242
-50
lines changed

PlsqlDeveloperUtPlsqlPlugin/PlsqlDeveloperUtPlsqlPlugin/PlsqlDeveloperUtPlsqlPlugin.cs

Lines changed: 67 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
namespace utPLSQL
1212
{
13+
//*FUNC: 4*/ extern char *(*SYS_OracleHome)();
14+
internal delegate IntPtr SysOracleHome();
15+
1316
//*FUNC: 11*/ BOOL (*IDE_Connected)();
1417
internal delegate bool IdeConnected();
1518

@@ -23,8 +26,7 @@ namespace utPLSQL
2326
internal delegate void IdeCreatePopupItem(int id, int index, string name, string objectType);
2427

2528
//*FUNC: 74*/ int (*IDE_GetPopupObject)(char **ObjectType, char **ObjectOwner, char **ObjectName, char **SubObject);
26-
internal delegate int IdeGetPopupObject(out IntPtr objectType, out IntPtr objectOwner, out IntPtr objectName,
27-
out IntPtr subObject);
29+
internal delegate int IdeGetPopupObject(out IntPtr objectType, out IntPtr objectOwner, out IntPtr objectName, out IntPtr subObject);
2830

2931
//*FUNC: 79*/ char *(*IDE_GetObjectSource)(char *ObjectType, char *ObjectOwner, char *ObjectName);
3032
internal delegate IntPtr IdeGetObjectSource(string objectType, string objectOwner, string objectName);
@@ -44,6 +46,8 @@ public class PlsqlDeveloperUtPlsqlPlugin
4446
private const int PluginPopupIndex = 1;
4547
private const int PluginPopupIndexWithCoverage = 2;
4648

49+
private static SysOracleHome sysOracleHome;
50+
4751
private static IdeConnected connected;
4852
private static IdeGetConnectionInfo getConnectionInfo;
4953

@@ -59,9 +63,9 @@ public class PlsqlDeveloperUtPlsqlPlugin
5963
private static string password;
6064
private static string database;
6165
private static string connectAs;
66+
private static string oracleHome;
6267

6368
private static PlsqlDeveloperUtPlsqlPlugin _plugin;
64-
6569
private static readonly List<TestRunnerWindow> Windows = new List<TestRunnerWindow>();
6670

6771
#region DLL exported API
@@ -83,7 +87,7 @@ public static void OnActivate()
8387
{
8488
try
8589
{
86-
ConnectToDatabase();
90+
getDatabaseInformation();
8791

8892
// Separate streams are needed!
8993
var assembly = Assembly.GetExecutingAssembly();
@@ -150,6 +154,9 @@ public static void RegisterCallback(int index, IntPtr function)
150154
{
151155
switch (index)
152156
{
157+
case 4:
158+
sysOracleHome = (SysOracleHome)Marshal.GetDelegateForFunctionPointer(function, typeof(SysOracleHome));
159+
break;
153160
case 11:
154161
connected = (IdeConnected)Marshal.GetDelegateForFunctionPointer(function, typeof(IdeConnected));
155162
break;
@@ -181,7 +188,7 @@ public static void RegisterCallback(int index, IntPtr function)
181188
[DllExport("OnConnectionChange", CallingConvention = CallingConvention.Cdecl)]
182189
public static void OnConnectionChange()
183190
{
184-
ConnectToDatabase();
191+
getDatabaseInformation();
185192
}
186193

187194
[DllExport("CreateMenuItem", CallingConvention = CallingConvention.Cdecl)]
@@ -205,48 +212,55 @@ public static string CreateMenuItem(int index)
205212
[DllExport("OnMenuClick", CallingConvention = CallingConvention.Cdecl)]
206213
public static void OnMenuClick(int index)
207214
{
208-
if (index == PluginMenuIndexAllTests)
215+
try
209216
{
210-
if (connected() && !Sydba())
217+
if (index == PluginMenuIndexAllTests)
211218
{
212-
var testResultWindow = new TestRunnerWindow(_plugin, username, password, database, connectAs);
213-
Windows.Add(testResultWindow);
214-
testResultWindow.RunTestsAsync("_ALL", username, null, null, false);
219+
if (isConnected() && !isSydba())
220+
{
221+
var testResultWindow = new TestRunnerWindow(_plugin, username, password, database, connectAs, oracleHome);
222+
Windows.Add(testResultWindow);
223+
testResultWindow.RunTestsAsync("_ALL", username, null, null, false);
224+
}
215225
}
216-
}
217-
else if (index == PluginMenuIndexAllTestsWithCoverage)
218-
{
219-
if (connected() && !Sydba())
226+
else if (index == PluginMenuIndexAllTestsWithCoverage)
220227
{
221-
var testResultWindow = new TestRunnerWindow(_plugin, username, password, database, connectAs);
222-
Windows.Add(testResultWindow);
223-
testResultWindow.RunTestsAsync("_ALL", username, null, null, true);
228+
if (isConnected() && !isSydba())
229+
{
230+
var testResultWindow = new TestRunnerWindow(_plugin, username, password, database, connectAs, oracleHome);
231+
Windows.Add(testResultWindow);
232+
testResultWindow.RunTestsAsync("_ALL", username, null, null, true);
233+
}
224234
}
225-
}
226-
else if (index == PluginPopupIndex)
227-
{
228-
if (connected() && !Sydba())
235+
else if (index == PluginPopupIndex)
229236
{
230-
getPopupObject(out IntPtr type, out IntPtr owner, out IntPtr name, out IntPtr subType);
237+
if (isConnected() && !isSydba())
238+
{
239+
getPopupObject(out IntPtr type, out IntPtr owner, out IntPtr name, out IntPtr subType);
231240

232-
var testResultWindow = new TestRunnerWindow(_plugin, username, password, database, connectAs);
233-
Windows.Add(testResultWindow);
234-
testResultWindow.RunTestsAsync(Marshal.PtrToStringAnsi(type), Marshal.PtrToStringAnsi(owner),
235-
Marshal.PtrToStringAnsi(name), Marshal.PtrToStringAnsi(subType), false);
241+
var testResultWindow = new TestRunnerWindow(_plugin, username, password, database, connectAs, oracleHome);
242+
Windows.Add(testResultWindow);
243+
testResultWindow.RunTestsAsync(Marshal.PtrToStringAnsi(type), Marshal.PtrToStringAnsi(owner),
244+
Marshal.PtrToStringAnsi(name), Marshal.PtrToStringAnsi(subType), false);
245+
}
236246
}
237-
}
238-
else if (index == PluginPopupIndexWithCoverage)
239-
{
240-
if (connected() && !Sydba())
247+
else if (index == PluginPopupIndexWithCoverage)
241248
{
242-
getPopupObject(out IntPtr type, out IntPtr owner, out IntPtr name, out IntPtr subType);
249+
if (isConnected() && !isSydba())
250+
{
251+
getPopupObject(out IntPtr type, out IntPtr owner, out IntPtr name, out IntPtr subType);
243252

244-
var testResultWindow = new TestRunnerWindow(_plugin, username, password, database, connectAs);
245-
Windows.Add(testResultWindow);
246-
testResultWindow.RunTestsAsync(Marshal.PtrToStringAnsi(type), Marshal.PtrToStringAnsi(owner),
247-
Marshal.PtrToStringAnsi(name), Marshal.PtrToStringAnsi(subType), true);
253+
var testResultWindow = new TestRunnerWindow(_plugin, username, password, database, connectAs, oracleHome);
254+
Windows.Add(testResultWindow);
255+
testResultWindow.RunTestsAsync(Marshal.PtrToStringAnsi(type), Marshal.PtrToStringAnsi(owner),
256+
Marshal.PtrToStringAnsi(name), Marshal.PtrToStringAnsi(subType), true);
257+
}
248258
}
249259
}
260+
catch (Exception e)
261+
{
262+
MessageBox.Show($"{e.Message}\n\n{e.StackTrace}", "Unexpected Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
263+
}
250264
}
251265

252266
[DllExport("About", CallingConvention = CallingConvention.Cdecl)]
@@ -263,16 +277,27 @@ public void OpenPackageBody(string owner, string name)
263277
var source = getObjectSource("PACKAGE BODY", owner, name);
264278
createWindow(3, Marshal.PtrToStringAnsi(source), false);
265279
}
266-
private static bool Sydba()
280+
private static bool isSydba()
267281
{
268-
if (connectAs.ToLower().Equals("sysdba")) {
282+
if (connectAs.ToLower().Equals("sysdba"))
283+
{
269284
MessageBox.Show("You shouldn't run utPLSQL as SYSDBA.\n\nTest will not run.", "Connected as SYSDBA", MessageBoxButtons.OK, MessageBoxIcon.Error);
270285
return true;
271286
}
272287
return false;
273288
}
274289

275-
private static void ConnectToDatabase()
290+
private static bool isConnected()
291+
{
292+
if (!connected())
293+
{
294+
MessageBox.Show("Please connect before running tests!", "No connection", MessageBoxButtons.OK, MessageBoxIcon.Error);
295+
return false;
296+
}
297+
return true;
298+
}
299+
300+
private static void getDatabaseInformation()
276301
{
277302
try
278303
{
@@ -287,6 +312,10 @@ private static void ConnectToDatabase()
287312
IntPtr ptrConnectAs = getConnectAs();
288313

289314
connectAs = Marshal.PtrToStringAnsi(ptrConnectAs);
315+
316+
IntPtr ptrOracleHome = sysOracleHome();
317+
318+
oracleHome = Marshal.PtrToStringAnsi(ptrOracleHome);
290319
}
291320
}
292321
catch (Exception e)

PlsqlDeveloperUtPlsqlPlugin/PlsqlDeveloperUtPlsqlPlugin/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("1.1.0.0")]
35-
[assembly: AssemblyFileVersion("1.1.0.0")]
34+
[assembly: AssemblyVersion("1.1.1.0")]
35+
[assembly: AssemblyFileVersion("1.1.1.0")]

PlsqlDeveloperUtPlsqlPlugin/utPLSQL.UI.Standalone/LoginForm.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ public LoginForm()
1212

1313
private void BtnRunTests_Click(object sender, EventArgs e)
1414
{
15-
var testRunnerWindow = new TestRunnerWindow(null, txtUsername.Text, txtPassword.Text, txtDatabase.Text, null);
15+
var testRunnerWindow = new TestRunnerWindow(null, txtUsername.Text, txtPassword.Text, txtDatabase.Text, null, null);
1616
testRunnerWindow.RunTestsAsync("USER", null, txtUsername.Text, null, false);
1717
}
1818

1919
private void btnCodeCoverage_Click(object sender, EventArgs e)
2020
{
21-
var testRunnerWindow = new TestRunnerWindow(null, txtUsername.Text, txtPassword.Text, txtDatabase.Text, null);
21+
var testRunnerWindow = new TestRunnerWindow(null, txtUsername.Text, txtPassword.Text, txtDatabase.Text, null, null);
2222
testRunnerWindow.RunTestsAsync("USER", null, txtUsername.Text, null, true);
2323
}
2424
}

PlsqlDeveloperUtPlsqlPlugin/utPLSQL.UI.Standalone/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.1.0.0")]
36-
[assembly: AssemblyFileVersion("1.1.0.0")]
35+
[assembly: AssemblyVersion("1.1.1.0")]
36+
[assembly: AssemblyFileVersion("1.1.1.0")]

PlsqlDeveloperUtPlsqlPlugin/utPLSQL.UI.Standalone/utPLSQL.UI.Standalone.csproj

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="..\packages\Costura.Fody.4.1.0\build\Costura.Fody.props" Condition="Exists('..\packages\Costura.Fody.4.1.0\build\Costura.Fody.props')" />
34
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
45
<PropertyGroup>
56
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -12,6 +13,8 @@
1213
<FileAlignment>512</FileAlignment>
1314
<Deterministic>true</Deterministic>
1415
<TargetFrameworkProfile />
16+
<NuGetPackageImportStamp>
17+
</NuGetPackageImportStamp>
1518
</PropertyGroup>
1619
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1720
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -35,6 +38,9 @@
3538
<Prefer32Bit>false</Prefer32Bit>
3639
</PropertyGroup>
3740
<ItemGroup>
41+
<Reference Include="Costura, Version=4.1.0.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
42+
<HintPath>..\packages\Costura.Fody.4.1.0\lib\net40\Costura.dll</HintPath>
43+
</Reference>
3844
<Reference Include="System" />
3945
<Reference Include="System.Core" />
4046
<Reference Include="System.Xml.Linq" />
@@ -69,6 +75,7 @@
6975
<DesignTime>True</DesignTime>
7076
</Compile>
7177
<None Include="App.config" />
78+
<None Include="packages.config" />
7279
<None Include="Properties\Settings.settings">
7380
<Generator>SettingsSingleFileGenerator</Generator>
7481
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -86,4 +93,12 @@
8693
</ProjectReference>
8794
</ItemGroup>
8895
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
96+
<Import Project="..\packages\Fody.6.0.0\build\Fody.targets" Condition="Exists('..\packages\Fody.6.0.0\build\Fody.targets')" />
97+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
98+
<PropertyGroup>
99+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
100+
</PropertyGroup>
101+
<Error Condition="!Exists('..\packages\Fody.6.0.0\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.6.0.0\build\Fody.targets'))" />
102+
<Error Condition="!Exists('..\packages\Costura.Fody.4.1.0\build\Costura.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.4.1.0\build\Costura.Fody.props'))" />
103+
</Target>
89104
</Project>

PlsqlDeveloperUtPlsqlPlugin/utPLSQL.UI/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.1.0.0")]
36-
[assembly: AssemblyFileVersion("1.1.0.0")]
35+
[assembly: AssemblyVersion("1.1.1.0")]
36+
[assembly: AssemblyFileVersion("1.1.1.0")]

PlsqlDeveloperUtPlsqlPlugin/utPLSQL.UI/TestRunnerWindow.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public partial class TestRunnerWindow : Form
2828
private readonly string password;
2929
private readonly string database;
3030
private readonly string connectAs;
31+
private readonly string oracleHome;
3132

3233
private readonly List<TestResult> testResults = new List<TestResult>();
3334

@@ -39,13 +40,14 @@ public partial class TestRunnerWindow : Form
3940
private int rowIndexOnRightClick;
4041
private int completedTests;
4142

42-
public TestRunnerWindow(object pluginIntegration, string username, string password, string database, string connectAs)
43+
public TestRunnerWindow(object pluginIntegration, string username, string password, string database, string connectAs, string oracleHome)
4344
{
4445
this.pluginIntegration = pluginIntegration;
4546
this.username = username;
4647
this.password = password;
4748
this.database = database;
4849
this.connectAs = connectAs;
50+
this.oracleHome = oracleHome;
4951

5052
InitializeComponent();
5153
}
@@ -72,8 +74,20 @@ public async Task RunTestsAsync(string type, string owner, string name, string p
7274
SetWindowTitle(type, owner, name, procedure);
7375

7476
testRunner = new RealTimeTestRunner();
75-
testRunner.Connect(username, password, database);
7677

78+
try
79+
{
80+
if (oracleHome != null)
81+
{
82+
Environment.SetEnvironmentVariable("ORACLE_HOME", oracleHome);
83+
}
84+
testRunner.Connect(username, password, database);
85+
}
86+
catch (Exception e)
87+
{
88+
MessageBox.Show(e.Message, "Connect failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
89+
return;
90+
}
7791
try
7892
{
7993
testRunner.GetVersion();
@@ -599,15 +613,15 @@ private async void menuItemRunTests_ClickAsync(object sender, EventArgs e)
599613
{
600614
var testResult = testResults[rowIndexOnRightClick];
601615

602-
var testResultWindow = new TestRunnerWindow(pluginIntegration, username, password, database, connectAs);
616+
var testResultWindow = new TestRunnerWindow(pluginIntegration, username, password, database, connectAs, oracleHome);
603617
await testResultWindow.RunTestsAsync("PROCEDURE", testResult.Owner, testResult.Package, testResult.Procedure, false);
604618
}
605619

606620
private async void menuItemCoverage_ClickAsync(object sender, EventArgs e)
607621
{
608622
var testResult = testResults[rowIndexOnRightClick];
609623

610-
var testResultWindow = new TestRunnerWindow(pluginIntegration, username, password, database, connectAs);
624+
var testResultWindow = new TestRunnerWindow(pluginIntegration, username, password, database, connectAs, oracleHome);
611625
await testResultWindow.RunTestsAsync("PROCEDURE", testResult.Owner, testResult.Package, testResult.Procedure, true);
612626
}
613627

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
2+
<Costura />
3+
</Weavers>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy