Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit76857c0

Browse files
committed
Add formatting and linting for C# files
1 parent563e369 commit76857c0

File tree

117 files changed

+929
-752
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+929
-752
lines changed

‎.github/workflows/lint.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name:Linting
2+
3+
on:
4+
push:
5+
branches:
6+
-master
7+
pull_request:
8+
9+
jobs:
10+
lint-dotnet:
11+
name:Lint .NET
12+
runs-on:ubuntu-latest
13+
timeout-minutes:15
14+
15+
steps:
16+
-name:Checkout code
17+
uses:actions/checkout@v2
18+
19+
-name:Setup .NET
20+
uses:actions/setup-dotnet@v1
21+
with:
22+
dotnet-version:'7.0.x'
23+
24+
-name:Lint
25+
run:dotnet format -v diag --verify-no-changes --report=format.json
26+
27+
-uses:actions/upload-artifact@v4
28+
with:
29+
name:format-report
30+
path:format.json

‎src/console/pythonconsole.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
usingSystem.Collections.Generic;
33
usingSystem.IO;
44
usingSystem.Reflection;
5+
56
usingPython.Runtime;
67

78
namespacePython.Runtime

‎src/embed_tests/CodecGroups.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ namespace Python.EmbeddingTest
22
{
33
usingSystem;
44
usingSystem.Linq;
5+
56
usingNUnit.Framework;
7+
68
usingPython.Runtime;
79
usingPython.Runtime.Codecs;
810

@@ -20,7 +22,7 @@ public void GetEncodersByType()
2022
};
2123

2224
vargot=group.GetEncoders(typeof(Uri)).ToArray();
23-
CollectionAssert.AreEqual(new[]{encoder1,encoder2},got);
25+
CollectionAssert.AreEqual(new[]{encoder1,encoder2},got);
2426
}
2527

2628
[Test]

‎src/embed_tests/Codecs.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
namespacePython.EmbeddingTest{
1+
namespacePython.EmbeddingTest
2+
{
23
usingSystem;
34
usingSystem.Collections.Generic;
45
usingSystem.Linq;
6+
57
usingNUnit.Framework;
8+
69
usingPython.Runtime;
710
usingPython.Runtime.Codecs;
811

@@ -169,7 +172,8 @@ public void SequenceDecoderTest()
169172
ICollection<string>stringCollection=null;
170173
Assert.DoesNotThrow(()=>{codec.TryDecode(pyList,outstringCollection);});
171174
Assert.AreEqual(3,stringCollection.Count());
172-
Assert.Throws(typeof(InvalidCastException),()=>{
175+
Assert.Throws(typeof(InvalidCastException),()=>
176+
{
173177
string[]array=newstring[3];
174178
stringCollection.CopyTo(array,0);
175179
});
@@ -206,7 +210,8 @@ public void SequenceDecoderTest()
206210
ICollection<string>stringCollection2=null;
207211
Assert.DoesNotThrow(()=>{codec.TryDecode(pyTuple,outstringCollection2);});
208212
Assert.AreEqual(3,stringCollection2.Count());
209-
Assert.Throws(typeof(InvalidCastException),()=>{
213+
Assert.Throws(typeof(InvalidCastException),()=>
214+
{
210215
string[]array=newstring[3];
211216
stringCollection2.CopyTo(array,0);
212217
});
@@ -255,13 +260,15 @@ public void IterableDecoderTest()
255260
IEnumerable<string>stringEnumerable=null;
256261
Assert.DoesNotThrow(()=>{codec.TryDecode(pyList,outstringEnumerable);});
257262

258-
Assert.Throws(typeof(InvalidCastException),()=>{
263+
Assert.Throws(typeof(InvalidCastException),()=>
264+
{
259265
foreach(stringiteminstringEnumerable)
260266
{
261267
varx=item;
262268
}
263269
});
264-
Assert.Throws(typeof(InvalidCastException),()=>{
270+
Assert.Throws(typeof(InvalidCastException),()=>
271+
{
265272
stringEnumerable.Count();
266273
});
267274

@@ -390,7 +397,7 @@ public void ExceptionDecodedNoInstance()
390397
}
391398
}
392399

393-
publicstaticvoidAcceptsDateTime(DateTimev){}
400+
publicstaticvoidAcceptsDateTime(DateTimev){}
394401

395402
[Test]
396403
publicvoidAs_Object_AffectedByDecoders()

‎src/embed_tests/GlobalTestsSetup.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
usingNUnit.Framework;
2+
23
usingPython.Runtime;
34

45
namespacePython.EmbeddingTest

‎src/embed_tests/Inheritance.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@ public class PropertyAccessorBase
206206
publicvirtualstringVirtualProp{get;set;}
207207
}
208208

209-
publicclassPropertyAccessorIntermediate:PropertyAccessorBase{}
209+
publicclassPropertyAccessorIntermediate:PropertyAccessorBase{}
210210

211-
publicclassPropertyAccessorDerived:PropertyAccessorIntermediate
211+
publicclassPropertyAccessorDerived:PropertyAccessorIntermediate
212212
{
213213
publicoverridestringVirtualProp{set=>base.VirtualProp=value.ToUpperInvariant();}
214214
}
@@ -217,7 +217,7 @@ public class ContainerClass
217217
{
218218
publicvoidBaseMethod(){}
219219

220-
publicclassInnerClass:ContainerClass
220+
publicclassInnerClass:ContainerClass
221221
{
222222

223223
}

‎src/embed_tests/Modules.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
usingSystem;
22
usingSystem.Threading;
3+
34
usingNUnit.Framework;
5+
46
usingPython.Runtime;
57

68
namespacePython.EmbeddingTest
@@ -385,8 +387,8 @@ public void TestThread()
385387
//add function to the scope
386388
//can be call many times, more efficient than ast
387389
ps.Exec(
388-
"import threading\n"+
389-
"lock = threading.Lock()\n"+
390+
"import threading\n"+
391+
"lock = threading.Lock()\n"+
390392
"def update():\n"+
391393
" global res, th_cnt\n"+
392394
" with lock:\n"+

‎src/embed_tests/NumPyTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void VarArg()
6868
{
6969
dynamiczX=np.array(new[,]{{1,2,3},{4,5,6},{8,9,0}});
7070
dynamicgrad=np.gradient(zX,4.0,5.0);
71-
dynamicgrad2=np.InvokeMethod("gradient",newPyObject[]{zX,newPyFloat(4.0),newPyFloat(5.0)});
71+
dynamicgrad2=np.InvokeMethod("gradient",newPyObject[]{zX,newPyFloat(4.0),newPyFloat(5.0)});
7272

7373
Assert.AreEqual(4.125,grad[0].sum().__float__().As<double>(),0.001);
7474
Assert.AreEqual(-1.2,grad[1].sum().__float__().As<double>(),0.001);

‎src/embed_tests/References.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
namespacePython.EmbeddingTest
22
{
33
usingNUnit.Framework;
4+
45
usingPython.Runtime;
56

67
publicclassReferences

‎src/embed_tests/TestCallbacks.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,35 @@
11
usingSystem;
22

33
usingNUnit.Framework;
4+
45
usingPython.Runtime;
56

6-
namespacePython.EmbeddingTest{
7-
publicclassTestCallbacks{
7+
namespacePython.EmbeddingTest
8+
{
9+
publicclassTestCallbacks
10+
{
811
[OneTimeSetUp]
9-
publicvoidSetUp(){
12+
publicvoidSetUp()
13+
{
1014
PythonEngine.Initialize();
1115
}
1216

1317
[OneTimeTearDown]
14-
publicvoidDispose(){
18+
publicvoidDispose()
19+
{
1520
PythonEngine.Shutdown();
1621
}
1722

1823
[Test]
19-
publicvoidTestNoOverloadException(){
24+
publicvoidTestNoOverloadException()
25+
{
2026
intpassed=0;
2127
varaFunctionThatCallsIntoPython=newAction<int>(value=>passed=value);
22-
using(Py.GIL()){
28+
using(Py.GIL())
29+
{
2330
usingdynamiccallWith42=PythonEngine.Eval("lambda f: f([42])");
2431
usingvarpyFunc=aFunctionThatCallsIntoPython.ToPython();
25-
varerror=Assert.Throws<PythonException>(()=>callWith42(pyFunc));
32+
varerror=Assert.Throws<PythonException>(()=>callWith42(pyFunc));
2633
Assert.AreEqual("TypeError",error.Type.Name);
2734
stringexpectedArgTypes="(<class 'list'>)";
2835
StringAssert.EndsWith(expectedArgTypes,error.Message);

‎src/embed_tests/TestConverter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void TestConvertSingleToManaged(
4646
varconverted=Converter.ToManaged(pyFloat,typeof(float),outconvertedValue,false);
4747

4848
Assert.IsTrue(converted);
49-
Assert.IsTrue(((float)convertedValue).Equals(testValue));
49+
Assert.IsTrue(((float)convertedValue).Equals(testValue));
5050
}
5151

5252
[Test]
@@ -60,7 +60,7 @@ public void TestConvertDoubleToManaged(
6060
varconverted=Converter.ToManaged(pyFloat,typeof(double),outconvertedValue,false);
6161

6262
Assert.IsTrue(converted);
63-
Assert.IsTrue(((double)convertedValue).Equals(testValue));
63+
Assert.IsTrue(((double)convertedValue).Equals(testValue));
6464
}
6565

6666
[Test]
@@ -164,7 +164,7 @@ public void ToPyList()
164164
[Test]
165165
publicvoidRawListProxy()
166166
{
167-
varlist=newList<string>{"hello","world"};
167+
varlist=newList<string>{"hello","world"};
168168
varlistProxy=PyObject.FromManagedObject(list);
169169
varclrObject=(CLRObject)ManagedType.GetManagedObject(listProxy);
170170
Assert.AreSame(list,clrObject.inst);

‎src/embed_tests/TestCustomMarshal.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
usingSystem;
2+
23
usingNUnit.Framework;
4+
35
usingPython.Runtime;
46

57
namespacePython.EmbeddingTest

‎src/embed_tests/TestDomainReload.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
usingSystem.Diagnostics;
44
usingSystem.Reflection;
55
usingSystem.Runtime.InteropServices;
6+
67
usingNUnit.Framework;
8+
79
usingPython.Runtime;
810

911
usingPyRuntime=Python.Runtime.Runtime;

‎src/embed_tests/TestFinalizer.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
usingNUnit.Framework;
2-
usingPython.Runtime;
31
usingSystem;
42
usingSystem.Collections.Generic;
53
usingSystem.Diagnostics;
64
usingSystem.Linq;
75
usingSystem.Runtime.CompilerServices;
86
usingSystem.Threading;
97

8+
usingNUnit.Framework;
9+
10+
usingPython.Runtime;
11+
1012
namespacePython.EmbeddingTest
1113
{
1214
publicclassTestFinalizer
@@ -237,7 +239,7 @@ private static IntPtr CreateStringGarbage()
237239
PyStrings1=newPyString("test_string");
238240
// s2 steal a reference from s1
239241
IntPtraddress=s1.Reference.DangerousGetAddress();
240-
PyStrings2=new(StolenReference.DangerousFromPointer(address));
242+
PyStrings2=new(StolenReference.DangerousFromPointer(address));
241243
returnaddress;
242244
}
243245
}

‎src/embed_tests/TestGILState.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
namespacePython.EmbeddingTest
22
{
33
usingNUnit.Framework;
4+
45
usingPython.Runtime;
56

67
publicclassTestGILState
@@ -13,7 +14,7 @@ public void CanDisposeMultipleTimes()
1314
{
1415
using(vargilState=Py.GIL())
1516
{
16-
for(inti=0;i<50;i++)
17+
for(inti=0;i<50;i++)
1718
gilState.Dispose();
1819
}
1920
}

‎src/embed_tests/TestInstanceWrapping.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
usingSystem;
22
usingSystem.Globalization;
3+
34
usingNUnit.Framework;
5+
46
usingPython.Runtime;
57

68
namespacePython.EmbeddingTest
@@ -44,10 +46,10 @@ public void WeakRefIsNone_AfterObjectIsGone()
4446
Assert.IsTrue(weakref.Invoke().IsNone());
4547
}
4648

47-
classBase{}
48-
classDerived:Base{}
49+
classBase{}
50+
classDerived:Base{}
4951

50-
classOverloaded:Derived
52+
classOverloaded:Derived
5153
{
5254
publicintValue{get;set;}
5355
publicvoidIntOrStr(intarg)=>this.Value=arg;

‎src/embed_tests/TestNamedArguments.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
usingSystem;
2+
23
usingNUnit.Framework;
4+
35
usingPython.Runtime;
46

57
namespacePython.EmbeddingTest

‎src/embed_tests/TestOperator.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1+
usingSystem;
2+
usingSystem.Linq;
3+
usingSystem.Reflection;
4+
15
usingNUnit.Framework;
26

37
usingPython.Runtime;
48
usingPython.Runtime.Codecs;
59

6-
usingSystem;
7-
usingSystem.Linq;
8-
usingSystem.Reflection;
9-
1010
namespacePython.EmbeddingTest
1111
{
1212
publicclassTestOperator
@@ -541,12 +541,12 @@ public void ForwardOperatorOverloads()
541541
[Test]
542542
publicvoidTupleComparisonOperatorOverloads()
543543
{
544-
TupleCodec<ValueTuple>.Register();
545-
stringname=string.Format("{0}.{1}",
546-
typeof(OperableObject).DeclaringType.Name,
547-
typeof(OperableObject).Name);
544+
TupleCodec<ValueTuple>.Register();
545+
stringname=string.Format("{0}.{1}",
546+
typeof(OperableObject).DeclaringType.Name,
547+
typeof(OperableObject).Name);
548548
stringmodule=MethodBase.GetCurrentMethod().DeclaringType.Namespace;
549-
PythonEngine.Exec($@"
549+
PythonEngine.Exec($@"
550550
from{module} import *
551551
cls ={name}
552552
a = cls(2)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp