Skip to content

Commit eba52dc

Browse files
author
Sébastien Geiser
committed
Correct 64 bits bugs
1 parent d799003 commit eba52dc

20 files changed

+153
-77
lines changed

CSharpRegexTools4Npp/CSharpRegexTools4Npp.csproj

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="..\packages\MethodDecorator.Fody.1.0.2\build\MethodDecorator.Fody.props" Condition="Exists('..\packages\MethodDecorator.Fody.1.0.2\build\MethodDecorator.Fody.props')" />
34
<Import Project="..\packages\Costura.Fody.3.3.2\build\Costura.Fody.props" Condition="Exists('..\packages\Costura.Fody.3.3.2\build\Costura.Fody.props')" />
45
<PropertyGroup>
56
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -68,11 +69,20 @@
6869
<Reference Include="Costura, Version=3.3.2.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
6970
<HintPath>..\packages\Costura.Fody.3.3.2\lib\net40\Costura.dll</HintPath>
7071
</Reference>
72+
<Reference Include="MethodDecorator, Version=1.0.2.0, Culture=neutral, PublicKeyToken=0de10386fb6c39dd, processorArchitecture=MSIL">
73+
<HintPath>..\packages\MethodDecorator.Fody.1.0.2\lib\net452\MethodDecorator.dll</HintPath>
74+
</Reference>
75+
<Reference Include="Microsoft.CSharp" />
7176
<Reference Include="PresentationCore" />
7277
<Reference Include="PresentationFramework" />
7378
<Reference Include="System" />
79+
<Reference Include="System.Configuration" />
7480
<Reference Include="System.Data" />
7581
<Reference Include="System.Drawing" />
82+
<Reference Include="System.IO.Compression" />
83+
<Reference Include="System.Runtime.Serialization" />
84+
<Reference Include="System.ServiceModel" />
85+
<Reference Include="System.Transactions" />
7686
<Reference Include="System.Windows.Forms" />
7787
<Reference Include="System.Xaml" />
7888
<Reference Include="System.Xml" />
@@ -103,6 +113,7 @@
103113
<DesignTime>True</DesignTime>
104114
<DependentUpon>Resources.resx</DependentUpon>
105115
</Compile>
116+
<Compile Include="Utils\Interceptor.cs" />
106117
</ItemGroup>
107118
<ItemGroup>
108119
<EmbeddedResource Include="Resources.resx">
@@ -132,16 +143,18 @@
132143
<Name>RegexDialog</Name>
133144
</ProjectReference>
134145
</ItemGroup>
146+
<ItemGroup />
135147
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
136148
<Import Project="$(MSBuildProjectDirectory)\PluginInfrastructure\DllExport\NppPlugin.DllExport.targets" />
149+
<Import Project="..\packages\Fody.4.0.2\build\Fody.targets" Condition="Exists('..\packages\Fody.4.0.2\build\Fody.targets')" />
137150
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
138151
<PropertyGroup>
139152
<ErrorText>Ce projet fait référence à des packages NuGet qui sont manquants sur cet ordinateur. Utilisez l'option de restauration des packages NuGet pour les télécharger. Pour plus d'informations, consultez http://go.microsoft.com/fwlink/?LinkID=322105. Le fichier manquant est : {0}.</ErrorText>
140153
</PropertyGroup>
141154
<Error Condition="!Exists('..\packages\Fody.4.0.2\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.4.0.2\build\Fody.targets'))" />
142155
<Error Condition="!Exists('..\packages\Costura.Fody.3.3.2\build\Costura.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.3.3.2\build\Costura.Fody.props'))" />
156+
<Error Condition="!Exists('..\packages\MethodDecorator.Fody.1.0.2\build\MethodDecorator.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MethodDecorator.Fody.1.0.2\build\MethodDecorator.Fody.props'))" />
143157
</Target>
144-
<Import Project="..\packages\Fody.4.0.2\build\Fody.targets" Condition="Exists('..\packages\Fody.4.0.2\build\Fody.targets')" />
145158
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
146159
Other similar extension points exist, see Microsoft.Common.targets.
147160
<Target Name="BeforeBuild">

CSharpRegexTools4Npp/FodyWeavers.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
3+
<MethodDecorator />
34
<Costura />
45
</Weavers>

CSharpRegexTools4Npp/FodyWeavers.xsd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<xs:element name="Weavers">
55
<xs:complexType>
66
<xs:all>
7+
<xs:element name="MethodDecorator" minOccurs="0" maxOccurs="1" type="xs:anyType" />
78
<xs:element name="Costura" minOccurs="0" maxOccurs="1">
89
<xs:complexType>
910
<xs:all>

CSharpRegexTools4Npp/Main.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
namespace CSharpRegexTools4Npp
1212
{
13-
class Main
13+
14+
public class Main
1415
{
1516
internal const string PluginName = "C# Regex Tools 4 Npp";
1617
static int idMyDlg = 0;

CSharpRegexTools4Npp/PluginInfrastructure/ClikeStringArray.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
namespace CSharpRegexTools4Npp.PluginInfrastructure
77
{
8+
89
public class ClikeStringArray : IDisposable
910
{
1011
IntPtr _nativeArray;

CSharpRegexTools4Npp/PluginInfrastructure/GatewayDomain.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace CSharpRegexTools4Npp.PluginInfrastructure
1111
/// If you set all intensities to 255, the colour is white. If you set all intensities to 0, the colour is black.
1212
/// When you set a colour, you are making a request. What you will get depends on the capabilities of the system and the current screen mode.
1313
/// </summary>
14+
1415
public class Colour
1516
{
1617
public readonly int Red, Green, Blue;
@@ -61,6 +62,7 @@ public int Value
6162
/// If you use messages, there is nothing to stop you setting a position that is in the middle of a CRLF pair, or in the middle of a 2 byte character.
6263
/// However, keyboard commands will not move the caret into such positions.
6364
/// </summary>
65+
6466
public class Position : IEquatable<Position>
6567
{
6668
private readonly int pos;
@@ -162,6 +164,7 @@ public override int GetHashCode()
162164
/// On OS X, the Command key is mapped to SCMOD_CTRL and the Control key to SCMOD_META.SCMOD_SUPER is only available on GTK+ which is commonly the Windows key.
163165
/// If you are building a table, you might want to use SCMOD_NORM, which has the value 0, to mean no modifiers.
164166
/// </summary>
167+
165168
public class KeyModifier
166169
{
167170
private readonly int value;
@@ -194,6 +197,7 @@ public struct CharacterRange
194197
public int cpMax;
195198
}
196199

200+
197201
public class Cells
198202
{
199203
char[] charactersAndStyles;
@@ -206,6 +210,7 @@ public Cells(char[] charactersAndStyles)
206210
public char[] Value { get { return charactersAndStyles; } }
207211
}
208212

213+
209214
public class TextRange : IDisposable
210215
{
211216
Sci_TextRange _sciTextRange;

CSharpRegexTools4Npp/PluginInfrastructure/NotepadPPGateway.cs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ public interface INotepadPPGateway
1414
void SetCurrentLanguage(LangType language);
1515
}
1616

17-
/// <summary>
18-
/// This class holds helpers for sending messages defined in the Msgs_h.cs file. It is at the moment
19-
/// incomplete. Please help fill in the blanks.
20-
/// </summary>
21-
public class NotepadPPGateway : INotepadPPGateway
17+
/// <summary>
18+
/// This class holds helpers for sending messages defined in the Msgs_h.cs file. It is at the moment
19+
/// incomplete. Please help fill in the blanks.
20+
/// </summary>
21+
22+
public class NotepadPPGateway : INotepadPPGateway
2223
{
2324
private const int Unused = 0;
2425

@@ -53,11 +54,12 @@ public void SetCurrentLanguage(LangType language)
5354
}
5455
}
5556

56-
/// <summary>
57-
/// This class holds helpers for sending messages defined in the Resource_h.cs file. It is at the moment
58-
/// incomplete. Please help fill in the blanks.
59-
/// </summary>
60-
class NppResource
57+
/// <summary>
58+
/// This class holds helpers for sending messages defined in the Resource_h.cs file. It is at the moment
59+
/// incomplete. Please help fill in the blanks.
60+
/// </summary>
61+
62+
public class NppResource
6163
{
6264
private const int Unused = 0;
6365

CSharpRegexTools4Npp/PluginInfrastructure/NppPluginNETBase.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
namespace CSharpRegexTools4Npp.PluginInfrastructure
55
{
6-
class PluginBase
6+
7+
public class PluginBase
78
{
89
internal static NppData nppData;
910
internal static FuncItems _funcItems = new FuncItems();

CSharpRegexTools4Npp/PluginInfrastructure/NppPluginNETHelper.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public struct FuncItem
4545
public ShortcutKey _pShKey;
4646
}
4747

48+
4849
public class FuncItems : IDisposable
4950
{
5051
List<FuncItem> _funcItems;

CSharpRegexTools4Npp/PluginInfrastructure/ScintillaGateway.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ namespace CSharpRegexTools4Npp.PluginInfrastructure
1212
///
1313
/// See http://www.scintilla.org/ScintillaDoc.html for further details.
1414
/// </summary>
15+
1516
public class ScintillaGateway : IScintillaGateway
1617
{
1718
private const int Unused = 0;

CSharpRegexTools4Npp/PluginInfrastructure/Scintilla_iface.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2968,6 +2968,7 @@ public enum SciMsg : uint
29682968
SC_SEARCHRESULT_LINEBUFFERMAXLENGTH = 1024
29692969
}
29702970

2971+
29712972
public class TextToFind : IDisposable
29722973
{
29732974
Sci_TextToFind _sciTextToFind;

CSharpRegexTools4Npp/PluginInfrastructure/UnmanagedExports.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace CSharpRegexTools4Npp
88
{
9+
910
class UnmanagedExports
1011
{
1112
[DllExport(CallingConvention=CallingConvention.Cdecl)]

CSharpRegexTools4Npp/PluginInfrastructure/Win32.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace CSharpRegexTools4Npp.PluginInfrastructure
88
{
9+
910
public class Win32
1011
{
1112
/// <summary>
@@ -266,7 +267,7 @@ public static IntPtr SendMessage(IntPtr hWnd, SciMsg Msg, IntPtr wParam, IntPtr
266267
/// If gateways are missing or incomplete, please help extend them and send your code to the project
267268
/// at https://github.com/kbilsted/NotepadPlusPlusPluginPack.Net
268269
/// </summary>
269-
public static IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, ref LangType lParam)
270+
public static IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, ref LangType lParam)
270271
{
271272
IntPtr outVal;
272273
IntPtr retval = SendMessage(hWnd, (UInt32)Msg, new IntPtr(wParam), out outVal);

CSharpRegexTools4Npp/Properties/AssemblyInfo.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Reflection;
1+
using CSharpRegexTools4Npp.Utils;
2+
using System.Reflection;
23
using System.Runtime.CompilerServices;
34
using System.Runtime.InteropServices;
45

@@ -34,3 +35,5 @@
3435
// [assembly: AssemblyVersion("1.0.*")]
3536
[assembly: AssemblyVersion("1.0.1.0")]
3637
[assembly: AssemblyFileVersion("1.0.1.0")]
38+
[module: Interceptor]
39+
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using MethodDecorator.Fody.Interfaces;
2+
using System;
3+
using System.Diagnostics;
4+
using System.IO;
5+
using System.Reflection;
6+
7+
namespace CSharpRegexTools4Npp.Utils
8+
{
9+
10+
// Any attribute which provides OnEntry/OnExit/OnException with proper args
11+
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Assembly | AttributeTargets.Module)]
12+
public class InterceptorAttribute : Attribute, IMethodDecorator
13+
{
14+
private object instance;
15+
private string method;
16+
private object[] args;
17+
18+
// instance, method and args can be captured here and stored in attribute instance fields
19+
// for future usage in OnEntry/OnExit/OnException
20+
public void Init(object instance, MethodBase method, object[] args)
21+
{
22+
this.instance = instance;
23+
this.method = method.Name;
24+
this.args = args;
25+
}
26+
27+
public void OnEntry()
28+
{
29+
File.AppendAllText(@"C:\logs.log", $"Entry in {method} on {instance} with {string.Join(",", args)}");
30+
}
31+
32+
public void OnExit()
33+
{
34+
File.AppendAllText(@"C:\logs.log", $"Exit in {method} on {instance} with {string.Join(",", args)}");
35+
}
36+
37+
public void OnException(Exception exception)
38+
{
39+
File.AppendAllText(@"C:\logs.log", $"Exception in {method} on {instance} with {string.Join(",", args)}");
40+
}
41+
}
42+
}

CSharpRegexTools4Npp/app.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
3-
<startup useLegacyV2RuntimeActivationPolicy="true" />
3+
<startup useLegacyV2RuntimeActivationPolicy="true"><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" /></startup>
44
<runtime>
55
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
66
<dependentAssembly>
@@ -93,4 +93,4 @@
9393
</dependentAssembly>
9494
</assemblyBinding>
9595
</runtime>
96-
</configuration>
96+
</configuration>

CSharpRegexTools4Npp/packages.config

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Costura.Fody" version="3.3.2" targetFramework="net46" />
3+
<package id="Costura.Fody" version="3.3.2" targetFramework="net46" developmentDependency="true" />
44
<package id="Fody" version="4.0.2" targetFramework="net46" developmentDependency="true" />
5+
<package id="MethodDecorator.Fody" version="1.0.2" targetFramework="net46" />
56
</packages>

RegexDialog/RegExToolDialog.xaml.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,16 +174,11 @@ private void Init()
174174
//CSScript.GlobalSettings.RoslynDir = Environment.ExpandEnvironmentVariables(@"%USERPROFILE%\.nuget\packages\Microsoft.Net.Compilers\2.2.0\tools");
175175

176176
// Initialisation des delegates de base
177-
GetText = delegate()
178-
{ return ""; };
177+
GetText = () => string.Empty;
179178

180-
SetText = delegate(string text)
181-
{ };
179+
SetText = (string text) => { };
182180

183-
SetTextInNew = delegate(string text)
184-
{
185-
MessageBox.Show("Not Implemented");
186-
};
181+
SetTextInNew = (string text) => MessageBox.Show("Not Implemented");
187182

188183
// Application de la coloration syntaxique pour les expressions régulières
189184
XmlReader reader = XmlReader.Create(new StringReader(Res.Regex_syntax_color));
@@ -954,7 +949,7 @@ private void TreeViewItem_MouseDoubleClick(object sender, MouseButtonEventArgs e
954949
if (TryOpen?.Invoke(regexResult.FileName, false) ?? false)
955950
{
956951
if(!(regexResult is RegexFileResult))
957-
SetPosition(regexResult.Index, regexResult.Length);
952+
SetPosition?.Invoke(regexResult.Index, regexResult.Length);
958953
}
959954
}
960955

@@ -971,7 +966,7 @@ private void TreeViewItem_KeyDown(object sender, KeyEventArgs e)
971966
if (TryOpen?.Invoke(regexResult.FileName, false) ?? false)
972967
{
973968
if (!(regexResult is RegexFileResult))
974-
SetPosition(regexResult.Index, regexResult.Length);
969+
SetPosition?.Invoke(regexResult.Index, regexResult.Length);
975970
}
976971

977972
e.Handled = true;
@@ -1310,10 +1305,13 @@ private void ReplaceInEditor_MenuItem_Click(object sender, RoutedEventArgs e)
13101305
index++;
13111306
return script.Replace(match, index, regexFileResult.FileName, index + (regexFileResult.Children.Count > 0 ? regexFileResult.Children[0].RegexElementNb : 0), regexFileResult.RegexElementNb - 1);
13121307
}));
1308+
1309+
SaveCurrentDocument?.Invoke();
13131310
}
13141311
else
13151312
{
13161313
SetText(regex.Replace(text, ReplaceEditor.Text));
1314+
SaveCurrentDocument?.Invoke();
13171315
}
13181316

13191317
MessageBox.Show(nbrOfElementToReplace.ToString() + " elements has been replaced");
@@ -1390,6 +1388,8 @@ private void ReplaceInEditor_MenuItem_Click(object sender, RoutedEventArgs e)
13901388
{
13911389
SetText(newText);
13921390

1391+
SaveCurrentDocument?.Invoke();
1392+
13931393
SetPosition(regexResult.Index, ReplaceEditor.Text.Length);
13941394
}
13951395

RegexDialog/Utils/Config.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ private Config()
7171
public virtual void OnPropertyChanged([CallerMemberName] string propertyName = "")
7272
{
7373
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
74-
}
74+
}
7575

76-
#endregion
76+
#endregion
7777

78-
private void Init()
78+
private void Init()
7979
{
8080
}
8181

0 commit comments

Comments
 (0)