libgit2 / libgit2/libgit2sharp

Repository.Discover() throws exception in Release mode, but not Debug mode

Abierto
#2,122 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
C#
Estrellas
3.5k
Forks
925
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

I'm making a VSIX extension that does Git operations, I ran into this issue while trying to get the corresponding repo for the active document. When testing in the LLVM repo, doing Repository.Discover() on the active file C:\Users\<my_user_name>\source\repos\llvm-project\clang\lib\Format\UnwrappedLineParser.cpp throws in Release mode, but on Debug mode it correctly gets the repository path of C:\Users\<my_user_name>\source\repos\llvm-project\.git\

Reproduction steps
  • Create Visual Studio Extension project and add a command, set build to Release mode
  • Within the command, get active document with DTE applicationObject = (DTE)await AsyncServiceProvider.GlobalProvider.GetServiceAsync(typeof(SDTE));
  • Get full file path with var filePath = applicationObject.ActiveDocument.FullName
  • Call var repoPath = Repository.Discover(filePath)
Expected behavior

repoPath holds the path of the repository

Actual behavior

Exception is thrown with the message The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.

Version of LibGit2Sharp (release number or SHA1)

0.30.0

Operating system(s) tested; .NET runtime tested

Windows 11, .NET Framework 4.8

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza reproduciendo el fallo en modo Release del comando de extensión de Visual Studio, usando Repository.Discover(filePath) con el archivo fuente activo de LLVM. Inspecciona el inicializador de tipo de NativeMethods y compara el comportamiento de Release y Debug en Windows 11 con .NET Framework 4.8. Se considera terminado cuando Repository.Discover devuelve la ruta del repositorio en la compilación Release sin lanzar excepciones.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
csharp, git
Área
tooling
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.