Skip to content

Commit 6e15923

Browse files
authored
Merge pull request #4 from umjammer/1.2.4
1.2.4
2 parents 2442cb0 + 398a12a commit 6e15923

39 files changed

+141
-208
lines changed

.github/workflows/codeql-analysis.yml

+9-5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ jobs:
1818
analyze:
1919
name: Analyze
2020
runs-on: ubuntu-latest
21+
permissions:
22+
actions: read
23+
contents: read
24+
security-events: write
2125

2226
strategy:
2327
fail-fast: false
@@ -30,11 +34,11 @@ jobs:
3034

3135
steps:
3236
- name: Checkout repository
33-
uses: actions/checkout@v3
37+
uses: actions/checkout@v4
3438

3539
# Initializes the CodeQL tools for scanning.
3640
- name: Initialize CodeQL
37-
uses: github/codeql-action/init@v2
41+
uses: github/codeql-action/init@v3
3842
with:
3943
languages: ${{ matrix.language }}
4044
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -45,7 +49,7 @@ jobs:
4549
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
4650
# If this step fails, then you should remove it and run the build manually (see below)
4751
- name: Checkout repository
48-
uses: actions/checkout@v3
52+
uses: actions/checkout@v4
4953

5054
- name: Set up JDK 17
5155
uses: actions/setup-java@v3
@@ -65,7 +69,7 @@ jobs:
6569
# make bootstrap
6670
# make release
6771
- name: Build with Maven
68-
run: mvn -B package --file pom.xml -Dmaven.test.skip=ture
72+
run: mvn -B package --file pom.xml -Dmaven.test.skip=true
6973

7074
- name: Perform CodeQL Analysis
71-
uses: github/codeql-action/analyze@v2
75+
uses: github/codeql-action/analyze@v3

.github/workflows/maven.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ jobs:
99

1010
steps:
1111
- name: Checkout repository
12-
uses: actions/checkout@v3
12+
uses: actions/checkout@v4
1313

1414
- name: Check w/o SNAPSHOT when "bump version"
1515
if: ${{ contains(github.event.head_commit.message, 'bump version') }}
1616
run: grep "<version>" pom.xml | head -1 | grep -v SNAPSHOT
1717

1818
- name: Set up JDK 17
19-
uses: actions/setup-java@v3
19+
uses: actions/setup-java@v4
2020
with:
2121
java-version: '17'
2222
distribution: 'temurin'

README.md

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[![Release](https://jitpack.io/v/umjammer/dotnet4j.svg)](https://jitpack.io/#umjammer/dotnet4j)
2-
[![Actions Status](https://github.com/umjammer/dotnet4j/workflows/Java%20CI/badge.svg)](https://github.com/umjammer/dotnet4j/actions)
2+
[![Java CI](https://github.com/umjammer/dotnet4j/actions/workflows/maven.yml/badge.svg)](https://github.com/umjammer/dotnet4j/actions/workflows/maven.yml)
33
[![CodeQL](https://github.com/umjammer/dotnet4j/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/umjammer/dotnet4j/actions/workflows/codeql-analysis.yml)
44
![Java](https://img.shields.io/badge/Java-17-b07219)
55
[![Parent](https://img.shields.io/badge/Parent-vavi--nio--file--discutils-pink)](https://github.com/umjammer/vavi-nio-file-discutils)
66

77
# dotnet4j
88

9-
<img alt="dotnet-logo" src="https://github.com/umjammer/dotnet4j/assets/493908/d0f33f96-4572-4e8f-895b-4482b48425db" width=80 /><sub><a href="https://dotnet.microsoft.com/">© microsoft</a></sub>
9+
<img alt="dotnet-logo" src="https://github.com/umjammer/dotnet4j/assets/493908/efdd10f6-f1d6-4325-8783-3032a000dd60" width="160" />
1010

1111
Helper library for .Net to Java migration.
1212

@@ -18,7 +18,13 @@ Helper library for .Net to Java migration.
1818

1919
Note: this is a fork of [feyris-tan/dotnetIo4j](https://github.com/feyris-tan/dotnetIo4j)
2020

21-
## Projects that use this library
21+
## Install
22+
23+
* [maven](https://jitpack.io/#umjammer/dotnet4j)
24+
25+
## Usage
26+
27+
### user
2228

2329
* [vavi-nio-file-discutils](https://github.com/umjammer/vavi-nio-file-discutils)
2430
* [vavi-apps-z80](https://github.com/umjammer/vavi-apps-z80)
@@ -33,7 +39,7 @@ Note: this is a fork of [feyris-tan/dotnetIo4j](https://github.com/feyris-tan/do
3339
* https://www.crystalnet-tech.com/Products/dotNet4Java/Default (not oss)
3440
* https://github.com/xamarin (obsoleted) -> maui
3541

36-
## Migration Convention
42+
### Migration Convention
3743

3844
https://github.com/umjammer/dotnet4j/wiki/C%23-to-Java-Migration-Convention
3945

pom.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>moe.yo3explorer</groupId>
88
<artifactId>dotnet4j</artifactId>
9-
<version>1.2.3</version>
9+
<version>1.2.4</version>
1010

1111
<packaging>jar</packaging>
1212

@@ -80,7 +80,7 @@
8080
<dependency>
8181
<groupId>org.junit</groupId>
8282
<artifactId>junit-bom</artifactId>
83-
<version>5.10.0</version>
83+
<version>5.10.2</version>
8484
<type>pom</type>
8585
<scope>import</scope>
8686
</dependency>
@@ -98,13 +98,13 @@
9898
<dependency>
9999
<groupId>org.jetbrains</groupId>
100100
<artifactId>annotations</artifactId>
101-
<version>24.0.1</version>
101+
<version>24.1.0</version>
102102
</dependency>
103103

104104
<dependency>
105105
<groupId>com.github.umjammer</groupId>
106106
<artifactId>vavi-commons</artifactId>
107-
<version>1.1.9</version>
107+
<version>1.1.11</version>
108108
</dependency>
109109

110110
<dependency>

src/main/java/dotnet4j/io/BinaryReader.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public BinaryReader(Stream input, Charset encoding, boolean leaveOpen) {
6666
// For Encodings that always use 2 bytes per char (or more),
6767
// special case them here to make read() & Peek() faster.
6868
this.twoBytesPerChar = encoding.contains(StandardCharsets.UTF_16); // is UnicodeEncoding;
69-
// check if BinaryReader is based on MemoryStream, and keep this for it's life
69+
// check if BinaryReader is based on MemoryStream, and keep this for its life
7070
// we cannot use "as" operator, since derived classes are not allowed
7171
this.isMemoryStream = this.stream instanceof MemoryStream;
7272
this.leaveOpen = leaveOpen;

src/main/java/dotnet4j/io/BinaryWriter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ public void write(String value) throws IOException {
342342
int totalBytes = 0;
343343
while (numLeft > 0) {
344344
// Figure out how many chars to process this round.
345-
int charCount = (numLeft > this.maxChars) ? this.maxChars : numLeft;
345+
int charCount = Math.min(numLeft, this.maxChars);
346346
int byteLen;
347347

348348
if (charStart < 0 || charCount < 0 || charStart + charCount > value.length()) {

src/main/java/dotnet4j/io/BufferedStream.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* <p>
1717
* This class buffers reads & writes in a shared buffer. (If you maintained two
1818
* buffers separately, one operation would always trash the other buffer
19-
* anyways, so we might as well use one buffer.) The assumption here is you will
19+
* anyway, so we might as well use one buffer.) The assumption here is you will
2020
* almost always be doing a series of reads or writes, but rarely alternate
2121
* between the two of them on the same stream. /// Class Invariants: The class
2222
* has one buffer, shared for reading & writing. It can only be used for one or

src/main/java/dotnet4j/io/FileOptions.java

-2
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,3 @@ public int getValue() {
3232
this.value = value;
3333
}
3434
}
35-
36-
/* */

src/main/java/dotnet4j/io/FileStream.java

+12-18
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,18 @@
66
import java.nio.ByteBuffer;
77
import java.nio.channels.FileChannel;
88

9+
import vavi.util.Debug;
10+
911

1012
/**
1113
* Created by FT on 27.11.14.
1214
*/
1315
public class FileStream extends Stream {
1416
private FileChannel channel;
15-
private FileMode myMode;
16-
private FileAccess myAccess;
17-
private FileShare myShare;
18-
private String myPath;
17+
private final FileMode myMode;
18+
private final FileAccess myAccess;
19+
private final FileShare myShare;
20+
private final String myPath;
1921

2022
public FileStream(String path, FileMode mode) {
2123
this(path, mode, (mode == FileMode.Append ? FileAccess.Write : FileAccess.ReadWrite));
@@ -31,19 +33,11 @@ public FileStream(String path, FileMode mode, FileAccess access, FileShare share
3133
myAccess = access;
3234
myShare = share;
3335

34-
String rafMode = "";
35-
switch (access) {
36-
37-
case Read:
38-
rafMode = "r";
39-
break;
40-
case Write:
41-
rafMode = "rw";
42-
break;
43-
case ReadWrite:
44-
rafMode = "rw";
45-
break;
46-
}
36+
String rafMode = switch (access) {
37+
case Read -> "r";
38+
case Write -> "rw";
39+
case ReadWrite -> "rw";
40+
};
4741
try {
4842
java.io.File f = new java.io.File(path);
4943
if (mode == FileMode.Create || mode == FileMode.CreateNew || mode == FileMode.OpenOrCreate) {
@@ -167,7 +161,7 @@ public int read(byte[] buffer, int offset, int length) {
167161
return 0;
168162
}
169163
} catch (IOException e) {
170-
e.printStackTrace();
164+
Debug.printStackTrace(e);
171165
throw new dotnet4j.io.IOException(e);
172166
}
173167
return m;

src/main/java/dotnet4j/io/MemoryStream.java

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
package dotnet4j.io;
66

7+
import java.io.Serial;
78
import java.io.Serializable;
89
import java.util.Arrays;
910

@@ -17,6 +18,7 @@
1718
*/
1819
public class MemoryStream extends Stream implements Serializable {
1920

21+
@Serial
2022
private static final long serialVersionUID = -7301303954168934077L;
2123

2224
private byte[] buffer;

0 commit comments

Comments
 (0)