From 6ebe7b5bb3da97036ce36ae93053776063aaa37e Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Tue, 18 Apr 2017 23:43:09 -0700 Subject: [PATCH 1/3] change encoding to UTF-8 --- .../StringMarshalling/LPSTR/LPSTRTest.cs | Bin 17120 -> 8563 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/tests/src/Interop/StringMarshalling/LPSTR/LPSTRTest.cs b/tests/src/Interop/StringMarshalling/LPSTR/LPSTRTest.cs index f704791cfd8776486e52b90d7b116e0ccf220264..4838872f28a6f1fd5a0e4ff05a901ec82b106dfa 100755 GIT binary patch literal 8563 zcmcgx+iu%N5PhzJ{KG~@Vi_@XvEy3LvrNGfFo!~j1uXKG#2Tt6rFb`m*P#FMZT8?aU}3T zDiKFg#7azJC51OuQch%)CY>iM-LAN-c`7to6Q~RlF$zLS`oG1Q)kiCxon8tnXA})2 zq%iUJ^yuW>;KV!@M0#wh;@{;k6)KKXF>uT>?-6vEbpg!!p>;{{=+WXsGZDO3za5WyczB;r8yUWsm3$ziOJ4g`Y6MU+i$ zq)N;~2>1ItslwRv#YCpJv5)8?8cI%Mm6ALb_^Gl048XKqzn!Ft!j!BVIoM0q((5RW zk~ox|4=PCI+aQwdmN+;#(3bz)5-;!!+%>WSi>8^1MEk`H?SPy5KHu{4>lAU`5Y`%R zm}XwMph@CHE0Ml7&S->{t*gk{D8y^6SPR%Smga&llc5T30()(fvsqxV^Q z55^q&QgtC|KeczgV<_{&58kQ2?*+oilcFBL(r;7rb9BVL@x-!R&3DLRgeB!%xs#s8^MUNIlB|I z3VPaF!XM97V+HJ{tDbx3QgsVJxe4ApSvilvGg4hsYT_()uGdfi@leaK+f{F%nWE@0 zEY|EXi-|MXy+6=!v({l2gj8@`Dz7c9FnegBRTNZJ$|woQG)Wb_isTnjm}-NVP0WqI zEy{Zdkg9VTn}^!#4x2TKJiw;E&SW2q-KxVy0J|#EvAzhv*AGS`sZfzoHM~d|7Lq;z z`k%k>pF6>^&G4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#v>IB^IH62OO!CyP1aqGAzxR8wsf-@4 zr>yI$Wf`^+nc)*s(LJ|XHHu*!=b3fzOzeqayk6FRV|>i@$cz|Lv*4r@vg#vcC_PqV zs+9DU-&_W}o!*-ctEF%*_F^pmQWej}7joSOo|jN|`M$ZZhRE;Eu9@=QwdRN(<6O3Ji@B`I`Ys-sRHrqCYARx?@mNaw?cuR1o|_Jbr7$k`V2s1Y zz12#daNlaxeAOeLnH9aI$|poi0h5gz(-?WXjLa5)GLy16=aV>py}}#2u5D%Bx1}Yl zBjs(->DNZpbu6xmd=|-{$?2O{{GS89*?R~JQ@9Ej#3Cu?)v&`PnZuaSCvjTOmmfVY zI^uJt?3qlQ#OG{SJFicil;N%E#)!V_(L;>6@7XJx=rLp^i4Kn8^XqYM+p82A6~4FV zzC+JQ)Tcy#Bo>Wo1aJFu9= zNM25V)r?1Y+z+#06e5(uv>KBk;f#r<#1GBy-v ieGd}z|JweN-IUg=dMsNd`x-E6`G5MZhlM9ToBsf5O9`w1 From 235b28b1b460699c5aef982cb89fe66b06a16a92 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Tue, 18 Apr 2017 23:54:42 -0700 Subject: [PATCH 2/3] change line ending to UNIX --- .../StringMarshalling/LPSTR/CMakeLists.txt | 2 +- .../StringMarshalling/LPSTR/LPSTRTest.cs | 448 +++++++++--------- .../StringMarshalling/LPSTR/LPSTRTest.csproj | 2 +- .../StringMarshalling/LPSTR/PinvokeDef.cs | 2 +- 4 files changed, 227 insertions(+), 227 deletions(-) diff --git a/tests/src/Interop/StringMarshalling/LPSTR/CMakeLists.txt b/tests/src/Interop/StringMarshalling/LPSTR/CMakeLists.txt index aa3fd76ff6e1..3d30d825b7e7 100755 --- a/tests/src/Interop/StringMarshalling/LPSTR/CMakeLists.txt +++ b/tests/src/Interop/StringMarshalling/LPSTR/CMakeLists.txt @@ -7,4 +7,4 @@ add_library (LPSTRTestNative SHARED ${SOURCES}) target_link_libraries(LPSTRTestNative ${LINK_LIBRARIES_ADDITIONAL}) # add the install targets -install (TARGETS LPSTRTestNative DESTINATION bin) \ No newline at end of file +install (TARGETS LPSTRTestNative DESTINATION bin) diff --git a/tests/src/Interop/StringMarshalling/LPSTR/LPSTRTest.cs b/tests/src/Interop/StringMarshalling/LPSTR/LPSTRTest.cs index 4838872f28a6..12cff704388e 100755 --- a/tests/src/Interop/StringMarshalling/LPSTR/LPSTRTest.cs +++ b/tests/src/Interop/StringMarshalling/LPSTR/LPSTRTest.cs @@ -1,224 +1,224 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Runtime.InteropServices; -using System; -using System.Reflection; -using System.Text; -using NativeDefs; - -class Test -{ - - #region "Reprot Failure" - static int fails = 0; //record the fail numbers - // Overload methods for reportfailure - static int ReportFailure(string s) - { - Console.WriteLine(" === Fail:" + s); - return (++fails); - } - static int ReportFailure(string expect, string actual) - { - Console.WriteLine(" === Fail: Expected:" + expect + "\n Actual:" + actual); - return (++fails); - } - static int ReportFailure(string describe, string expect, string actual) - { - Console.WriteLine(" === Fail: " + describe + "\n\tExpected:" + expect + "\n\tActual:" + actual); - return (++fails); - } - #endregion - - #region ReversePInvoke - - public static string Call_DelMarshal_InOut(string s) - { - string strRet; - if (!s.Equals("ň")) - { - ReportFailure("Method Call_DelMarshal_InOut[Managed Side],The passed string is wrong", "ň", s); - strRet = "\0\0\0"; - return strRet; - } - s = "Managed"; - strRet = "Return\0Return\0"; - return strRet; - } - - public static string Call_DelMarshalPointer_Out(out string s) - { - s = "Native\0String\0"; - string strRet = "Return\0Return\0"; - return strRet; - } - - public static StringBuilder Call_Del_MarshalStrB_InOut(StringBuilder r) - { - StringBuilder retstr = new StringBuilder("Return\0Native"); - - if (!r.ToString().Equals(new StringBuilder("a", 1).ToString())) - { - ReportFailure("Method Call_Del_MarshalStrB_InOut[Managed Side] Failure. String is different than expected", "ă", r.ToString()); - } - r.Replace('a', 'm'); - return retstr; - } - - public static StringBuilder Call_Del_MarshalStrB_Out(out StringBuilder r) - { - StringBuilder retstr = new StringBuilder("Native\0Native"); - r = new StringBuilder("Managed", 7); - return retstr; - } - - #endregion - - [DllImport("user32.dll", CharSet = CharSet.Ansi)] - public static extern int MessageBox(IntPtr hWnd, String text, String caption, uint type); - - public static int Main(string[] args) - { -#if BUG750509 - if ((args != null) && (args.Length == 1) && (args[0] == "/mb")) - { - MessageBox(new IntPtr(0), "Hello World!", "Hello Dialog", 0); - } -#endif - -#pragma warning disable 0219 - string strManaged = "Managed"; - string strRet = "a"; - StringBuilder strBRet = new StringBuilder("a", 1); - string strNative = " Native"; - StringBuilder strBNative = new StringBuilder(" Native", 7); -#pragma warning restore 0219 - - PInvokeDef.Writeline("Format i=%d c=%c d=%f, s=%d, u=%d", 100, 'A', 3.1415926, 32767, 32768); - - //since the out attributes doesnt work for string, so i dont check the out value. - string strPara2 = strManaged; - string strRet2 = PInvokeDef.Marshal_InOut(strPara2); - if (!strRet2.Equals(strRet)) - { - ReportFailure("Method PInvokeDef.Marshal_InOut[Managed Side],The Return string is wrong", strRet, strRet2); - } - if (!strPara2.Equals(strManaged)) - { - ReportFailure("Method PInvokeDef.Marshal_InOut[Managed Side],The Parameter string is Changed", strManaged, strPara2); - } - - //TestMethod3 - string strPara3 = strManaged; - string strRet3 = PInvokeDef.Marshal_Out(strPara3); - if (!strRet.Equals(strRet3)) - { - ReportFailure("Method PInvokeDef.Marshal_Out[Managed Side],The Return string is wrong", strRet, strRet3); - } - if (!strPara3.Equals(strManaged)) - { - ReportFailure("Method PInvokeDef.Marshal_Out[Managed Side],The Parameter string is not Changed", strManaged, strPara3); - } - - //TestMethod5 - string strPara5 = strManaged; - string strRet5 = PInvokeDef.MarshalPointer_InOut(ref strPara5); - - if (!strRet5.Equals(strRet)) - { - ReportFailure("Method PInvokeDef.MarshalPointer_InOut[Managed Side],The Return string is wrong", strRet, strRet5); - } - if (!strPara5.Equals(strNative)) - { - ReportFailure("Method PInvokeDef.MarshalPointer_InOut[Managed Side],The Passed string is wrong", strNative, strPara5); - } - - - //TestMethod6 - string strPara6 = strManaged; - string strRet6 = PInvokeDef.MarshalPointer_Out(out strPara6); - if (!strRet6.Equals(strRet)) - { - ReportFailure("Method PInvokeDef.MarshalPointer_Out[Managed Side],The Return string is wrong", strRet, strRet6); - } - if (!strPara6.Equals(strNative)) - { - ReportFailure("Method PInvokeDef.MarshalPointer_Out[Managed Side],The Passed string is wrong", strNative, strPara6); - } - - //TestMethod7 - StringBuilder strPara7 = new StringBuilder(strManaged, strManaged.Length); - StringBuilder strRet7 = PInvokeDef.MarshalStrB_InOut(strPara7); - - if (!strRet7.ToString().Equals(strBRet.ToString())) - { - ReportFailure("Method PInvokeDef.MarshalStrB_InOut[Managed Side],The Return string is wrong", strRet, strRet7.ToString()); - } - if (!strPara7.ToString().Equals(strBNative.ToString())) - { - ReportFailure("Method PInvokeDef.MarshalStrB_InOut[Managed Side],The Passed string is wrong", strNative, strPara7.ToString()); - } - - //TestMethod8 - StringBuilder strPara8;// = new StringBuilder(strManaged); - StringBuilder strRet8 = PInvokeDef.MarshalStrB_Out(out strPara8); - if (!strRet8.ToString().Equals(strBRet.ToString())) - { - ReportFailure("Method PInvokeDef.MarshalStrB_Out[Managed Side],The Return string is wrong", strRet, strRet8.ToString()); - } - if (!strPara8.ToString().Equals(strBNative.ToString())) - { - ReportFailure("Method PInvokeDef.MarshalStrB_Out[Managed Side],The Passed string is wrong", strNative, strPara8.ToString()); - } - - #region ReversePinvoke - DelMarshal_InOut d1 = new DelMarshal_InOut(Call_DelMarshal_InOut); - if (!PInvokeDef.RPinvoke_DelMarshal_InOut(d1, "ň")) - { - ReportFailure("Method RPinvoke_DelMarshal_InOut[Managed Side],Return value is false"); - } - - DelMarshalPointer_Out d2 = new DelMarshalPointer_Out(Call_DelMarshalPointer_Out); - if (!PInvokeDef.RPinvoke_DelMarshalPointer_Out(d2)) - { - ReportFailure("Method RPinvoke_DelMarshal_Out[Managed Side],Return value is false"); - } - - #endregion - #region DelegatePInvoke - - Del_Marshal_InOut d3 = new Del_Marshal_InOut(PInvokeDef.Marshal_InOut); - string strPara9 = strManaged; - string strRet9 = d3(strPara9); - if (!strRet9.Equals(strRet)) - { - ReportFailure("Method Del_Marshal_InOut[Managed Side],The Return string is wrong", strRet, strRet9); - } - if (!strPara9.Equals(strManaged)) - { - ReportFailure("Method Del_Marshal_InOut[Managed Side],The Parameter string is Changed", strManaged, strPara9); - } - - Del_MarshalPointer_Out d4 = new Del_MarshalPointer_Out(PInvokeDef.MarshalPointer_Out); - string strPara10 = strManaged; - string strRet10 = d4(out strPara10); - if (!strRet10.Equals(strRet)) - { - ReportFailure("Method Del_MarshalPointer_Out[Managed Side],The Return string is wrong", strRet, strRet10); - } - if (!strPara10.Equals(strNative)) - { - ReportFailure("Method Del_MarshalPointer_Out[Managed Side],The Passed string is wrong", strNative, strPara10); - } - - Del_MarshalStrB_InOut d5 = new Del_MarshalStrB_InOut(Call_Del_MarshalStrB_InOut); - - if (!PInvokeDef.ReverseP_MarshalStrB_InOut(d5, new string('a', 1))) - { - ReportFailure("Method ReverseP_MarshalStrB_InOut[Managed Side],return value is false"); - } - #endregion - return 100; - } -} \ No newline at end of file +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.InteropServices; +using System; +using System.Reflection; +using System.Text; +using NativeDefs; + +class Test +{ + + #region "Reprot Failure" + static int fails = 0; //record the fail numbers + // Overload methods for reportfailure + static int ReportFailure(string s) + { + Console.WriteLine(" === Fail:" + s); + return (++fails); + } + static int ReportFailure(string expect, string actual) + { + Console.WriteLine(" === Fail: Expected:" + expect + "\n Actual:" + actual); + return (++fails); + } + static int ReportFailure(string describe, string expect, string actual) + { + Console.WriteLine(" === Fail: " + describe + "\n\tExpected:" + expect + "\n\tActual:" + actual); + return (++fails); + } + #endregion + + #region ReversePInvoke + + public static string Call_DelMarshal_InOut(string s) + { + string strRet; + if (!s.Equals("ň")) + { + ReportFailure("Method Call_DelMarshal_InOut[Managed Side],The passed string is wrong", "ň", s); + strRet = "\0\0\0"; + return strRet; + } + s = "Managed"; + strRet = "Return\0Return\0"; + return strRet; + } + + public static string Call_DelMarshalPointer_Out(out string s) + { + s = "Native\0String\0"; + string strRet = "Return\0Return\0"; + return strRet; + } + + public static StringBuilder Call_Del_MarshalStrB_InOut(StringBuilder r) + { + StringBuilder retstr = new StringBuilder("Return\0Native"); + + if (!r.ToString().Equals(new StringBuilder("a", 1).ToString())) + { + ReportFailure("Method Call_Del_MarshalStrB_InOut[Managed Side] Failure. String is different than expected", "ă", r.ToString()); + } + r.Replace('a', 'm'); + return retstr; + } + + public static StringBuilder Call_Del_MarshalStrB_Out(out StringBuilder r) + { + StringBuilder retstr = new StringBuilder("Native\0Native"); + r = new StringBuilder("Managed", 7); + return retstr; + } + + #endregion + + [DllImport("user32.dll", CharSet = CharSet.Ansi)] + public static extern int MessageBox(IntPtr hWnd, String text, String caption, uint type); + + public static int Main(string[] args) + { +#if BUG750509 + if ((args != null) && (args.Length == 1) && (args[0] == "/mb")) + { + MessageBox(new IntPtr(0), "Hello World!", "Hello Dialog", 0); + } +#endif + +#pragma warning disable 0219 + string strManaged = "Managed"; + string strRet = "a"; + StringBuilder strBRet = new StringBuilder("a", 1); + string strNative = " Native"; + StringBuilder strBNative = new StringBuilder(" Native", 7); +#pragma warning restore 0219 + + PInvokeDef.Writeline("Format i=%d c=%c d=%f, s=%d, u=%d", 100, 'A', 3.1415926, 32767, 32768); + + //since the out attributes doesnt work for string, so i dont check the out value. + string strPara2 = strManaged; + string strRet2 = PInvokeDef.Marshal_InOut(strPara2); + if (!strRet2.Equals(strRet)) + { + ReportFailure("Method PInvokeDef.Marshal_InOut[Managed Side],The Return string is wrong", strRet, strRet2); + } + if (!strPara2.Equals(strManaged)) + { + ReportFailure("Method PInvokeDef.Marshal_InOut[Managed Side],The Parameter string is Changed", strManaged, strPara2); + } + + //TestMethod3 + string strPara3 = strManaged; + string strRet3 = PInvokeDef.Marshal_Out(strPara3); + if (!strRet.Equals(strRet3)) + { + ReportFailure("Method PInvokeDef.Marshal_Out[Managed Side],The Return string is wrong", strRet, strRet3); + } + if (!strPara3.Equals(strManaged)) + { + ReportFailure("Method PInvokeDef.Marshal_Out[Managed Side],The Parameter string is not Changed", strManaged, strPara3); + } + + //TestMethod5 + string strPara5 = strManaged; + string strRet5 = PInvokeDef.MarshalPointer_InOut(ref strPara5); + + if (!strRet5.Equals(strRet)) + { + ReportFailure("Method PInvokeDef.MarshalPointer_InOut[Managed Side],The Return string is wrong", strRet, strRet5); + } + if (!strPara5.Equals(strNative)) + { + ReportFailure("Method PInvokeDef.MarshalPointer_InOut[Managed Side],The Passed string is wrong", strNative, strPara5); + } + + + //TestMethod6 + string strPara6 = strManaged; + string strRet6 = PInvokeDef.MarshalPointer_Out(out strPara6); + if (!strRet6.Equals(strRet)) + { + ReportFailure("Method PInvokeDef.MarshalPointer_Out[Managed Side],The Return string is wrong", strRet, strRet6); + } + if (!strPara6.Equals(strNative)) + { + ReportFailure("Method PInvokeDef.MarshalPointer_Out[Managed Side],The Passed string is wrong", strNative, strPara6); + } + + //TestMethod7 + StringBuilder strPara7 = new StringBuilder(strManaged, strManaged.Length); + StringBuilder strRet7 = PInvokeDef.MarshalStrB_InOut(strPara7); + + if (!strRet7.ToString().Equals(strBRet.ToString())) + { + ReportFailure("Method PInvokeDef.MarshalStrB_InOut[Managed Side],The Return string is wrong", strRet, strRet7.ToString()); + } + if (!strPara7.ToString().Equals(strBNative.ToString())) + { + ReportFailure("Method PInvokeDef.MarshalStrB_InOut[Managed Side],The Passed string is wrong", strNative, strPara7.ToString()); + } + + //TestMethod8 + StringBuilder strPara8;// = new StringBuilder(strManaged); + StringBuilder strRet8 = PInvokeDef.MarshalStrB_Out(out strPara8); + if (!strRet8.ToString().Equals(strBRet.ToString())) + { + ReportFailure("Method PInvokeDef.MarshalStrB_Out[Managed Side],The Return string is wrong", strRet, strRet8.ToString()); + } + if (!strPara8.ToString().Equals(strBNative.ToString())) + { + ReportFailure("Method PInvokeDef.MarshalStrB_Out[Managed Side],The Passed string is wrong", strNative, strPara8.ToString()); + } + + #region ReversePinvoke + DelMarshal_InOut d1 = new DelMarshal_InOut(Call_DelMarshal_InOut); + if (!PInvokeDef.RPinvoke_DelMarshal_InOut(d1, "ň")) + { + ReportFailure("Method RPinvoke_DelMarshal_InOut[Managed Side],Return value is false"); + } + + DelMarshalPointer_Out d2 = new DelMarshalPointer_Out(Call_DelMarshalPointer_Out); + if (!PInvokeDef.RPinvoke_DelMarshalPointer_Out(d2)) + { + ReportFailure("Method RPinvoke_DelMarshal_Out[Managed Side],Return value is false"); + } + + #endregion + #region DelegatePInvoke + + Del_Marshal_InOut d3 = new Del_Marshal_InOut(PInvokeDef.Marshal_InOut); + string strPara9 = strManaged; + string strRet9 = d3(strPara9); + if (!strRet9.Equals(strRet)) + { + ReportFailure("Method Del_Marshal_InOut[Managed Side],The Return string is wrong", strRet, strRet9); + } + if (!strPara9.Equals(strManaged)) + { + ReportFailure("Method Del_Marshal_InOut[Managed Side],The Parameter string is Changed", strManaged, strPara9); + } + + Del_MarshalPointer_Out d4 = new Del_MarshalPointer_Out(PInvokeDef.MarshalPointer_Out); + string strPara10 = strManaged; + string strRet10 = d4(out strPara10); + if (!strRet10.Equals(strRet)) + { + ReportFailure("Method Del_MarshalPointer_Out[Managed Side],The Return string is wrong", strRet, strRet10); + } + if (!strPara10.Equals(strNative)) + { + ReportFailure("Method Del_MarshalPointer_Out[Managed Side],The Passed string is wrong", strNative, strPara10); + } + + Del_MarshalStrB_InOut d5 = new Del_MarshalStrB_InOut(Call_Del_MarshalStrB_InOut); + + if (!PInvokeDef.ReverseP_MarshalStrB_InOut(d5, new string('a', 1))) + { + ReportFailure("Method ReverseP_MarshalStrB_InOut[Managed Side],return value is false"); + } + #endregion + return 100; + } +} diff --git a/tests/src/Interop/StringMarshalling/LPSTR/LPSTRTest.csproj b/tests/src/Interop/StringMarshalling/LPSTR/LPSTRTest.csproj index 88a033057895..d78ecb19e685 100755 --- a/tests/src/Interop/StringMarshalling/LPSTR/LPSTRTest.csproj +++ b/tests/src/Interop/StringMarshalling/LPSTR/LPSTRTest.csproj @@ -39,4 +39,4 @@ - \ No newline at end of file + diff --git a/tests/src/Interop/StringMarshalling/LPSTR/PinvokeDef.cs b/tests/src/Interop/StringMarshalling/LPSTR/PinvokeDef.cs index ce8455f9fa77..31d0ebaf7345 100755 --- a/tests/src/Interop/StringMarshalling/LPSTR/PinvokeDef.cs +++ b/tests/src/Interop/StringMarshalling/LPSTR/PinvokeDef.cs @@ -70,4 +70,4 @@ public static class PInvokeDef [DllImport(NativeBinaryName)] public static extern bool ReverseP_MarshalStrB_Out(Del_MarshalStrB_Out d); } -} \ No newline at end of file +} From d934d5b9e57be3860deeea1c5eca397791e13a62 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Wed, 19 Apr 2017 00:03:13 -0700 Subject: [PATCH 3/3] remove executable attribute --- .../Interop/StringMarshalling/LPSTR/CMakeLists.txt | 0 .../Interop/StringMarshalling/LPSTR/LPSTRTest.cs | 0 .../StringMarshalling/LPSTR/LPSTRTest.csproj | 0 .../StringMarshalling/LPSTR/LPSTRTestNative.cpp | 0 .../Interop/StringMarshalling/LPSTR/PinvokeDef.cs | 0 .../Interop/StringMarshalling/LPTSTR/CMakeLists.txt | 0 .../Interop/StringMarshalling/LPTSTR/LPTSTRTest.cs | Bin .../StringMarshalling/LPTSTR/LPTSTRTestNative.cpp | 0 .../LPTSTR/LPTSTRTestPInvokeDef.cs | 0 9 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 tests/src/Interop/StringMarshalling/LPSTR/CMakeLists.txt mode change 100755 => 100644 tests/src/Interop/StringMarshalling/LPSTR/LPSTRTest.cs mode change 100755 => 100644 tests/src/Interop/StringMarshalling/LPSTR/LPSTRTest.csproj mode change 100755 => 100644 tests/src/Interop/StringMarshalling/LPSTR/LPSTRTestNative.cpp mode change 100755 => 100644 tests/src/Interop/StringMarshalling/LPSTR/PinvokeDef.cs mode change 100755 => 100644 tests/src/Interop/StringMarshalling/LPTSTR/CMakeLists.txt mode change 100755 => 100644 tests/src/Interop/StringMarshalling/LPTSTR/LPTSTRTest.cs mode change 100755 => 100644 tests/src/Interop/StringMarshalling/LPTSTR/LPTSTRTestNative.cpp mode change 100755 => 100644 tests/src/Interop/StringMarshalling/LPTSTR/LPTSTRTestPInvokeDef.cs diff --git a/tests/src/Interop/StringMarshalling/LPSTR/CMakeLists.txt b/tests/src/Interop/StringMarshalling/LPSTR/CMakeLists.txt old mode 100755 new mode 100644 diff --git a/tests/src/Interop/StringMarshalling/LPSTR/LPSTRTest.cs b/tests/src/Interop/StringMarshalling/LPSTR/LPSTRTest.cs old mode 100755 new mode 100644 diff --git a/tests/src/Interop/StringMarshalling/LPSTR/LPSTRTest.csproj b/tests/src/Interop/StringMarshalling/LPSTR/LPSTRTest.csproj old mode 100755 new mode 100644 diff --git a/tests/src/Interop/StringMarshalling/LPSTR/LPSTRTestNative.cpp b/tests/src/Interop/StringMarshalling/LPSTR/LPSTRTestNative.cpp old mode 100755 new mode 100644 diff --git a/tests/src/Interop/StringMarshalling/LPSTR/PinvokeDef.cs b/tests/src/Interop/StringMarshalling/LPSTR/PinvokeDef.cs old mode 100755 new mode 100644 diff --git a/tests/src/Interop/StringMarshalling/LPTSTR/CMakeLists.txt b/tests/src/Interop/StringMarshalling/LPTSTR/CMakeLists.txt old mode 100755 new mode 100644 diff --git a/tests/src/Interop/StringMarshalling/LPTSTR/LPTSTRTest.cs b/tests/src/Interop/StringMarshalling/LPTSTR/LPTSTRTest.cs old mode 100755 new mode 100644 diff --git a/tests/src/Interop/StringMarshalling/LPTSTR/LPTSTRTestNative.cpp b/tests/src/Interop/StringMarshalling/LPTSTR/LPTSTRTestNative.cpp old mode 100755 new mode 100644 diff --git a/tests/src/Interop/StringMarshalling/LPTSTR/LPTSTRTestPInvokeDef.cs b/tests/src/Interop/StringMarshalling/LPTSTR/LPTSTRTestPInvokeDef.cs old mode 100755 new mode 100644