dotnet / java-interop

Java.Interop provides open-source bindings of Java's Java Native Interface (JNI) for use with .NET managed languages such as C#
Other
201 stars 52 forks source link

[invocation-overhead] git ignore generated source files. #1173

Closed jpobst closed 9 months ago

jpobst commented 10 months ago

Building the Java.Interop.sln solution always produces some generated files that git wants to try to commit:

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   tests/invocation-overhead/jni.cs

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        tests/invocation-overhead/jni-api.h
        tests/invocation-overhead/jni.c

Ignore these files with .gitignore.

Note that the first time we generate jni.cs we need to manually add it to @(Compile) because the wildcard expansion has already executed at that point. Additional times the file gets regenerated we use KeepDuplicates='false' to prevent a duplicate @(Compile) file warning.

jonpryor commented 9 months ago

We should probably instead add tests/invocation-overhead/jni-api.h and tests/invocation-overhead/jni.c, and update tests/invocation-overhead/jni.cs, as these are useful ways to see what build-tools/jnienv-gen output is, without needing to build the repo itself and look at e.g. src/Java.Interop/obj/Debug/net7.0/JniEnvironment.g.cs or src/java-interop/obj/Debug-net7.0/jni.c.

For example, consider 0f1efebd68c4f234eab1e812a0985517f12e66a2, which updated jnienv-gen, and also included updates to tests/invocation-overhead/jni.cs. This made code review easier -- at least I'd like to think so -- because the changes introduced to jnienv-gen were visible in the same PR as changes to jni.cs.

jpobst commented 9 months ago

Sounds good to me. This solution also fulfills my desire of appeasing git. 😁

I'll update this PR to do this instead.

jpobst commented 9 months ago

Superseded by https://github.com/xamarin/java.interop/pull/1175.