Skip to content

Commit 354a027

Browse files
authored
Fix/Janky filepath manipulation with subprojects (#116)
* Fixed subproject not being found if root folder was . * Fixed bad extracted path if project name isn't in namespace * Update .napirc * Fixed duplicate project names
1 parent 62ff2ac commit 354a027

File tree

3 files changed

+14
-7
lines changed
  • examples/csharp/EndpointExample
  • packages/cli/src

3 files changed

+14
-7
lines changed

examples/csharp/EndpointExample/.napirc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"language": "c-sharp",
33
"project": {
44
"include": ["**/*"],
5-
"exclude": ["bin/**", "obj/**"]
5+
"exclude": ["bin/**", "obj/**", "napi-output/**"]
66
},
77
"outDir": "napi-output",
88
"metrics": {

packages/cli/src/languagePlugins/csharp/projectMapper/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,10 @@ export class CSharpProjectMapper {
130130
// We assume that the most precise project is the one with the longest rootFolder
131131
// (In case there are nested projects)
132132
for (const project of this.subprojects) {
133-
if (filePath.startsWith(project.rootFolder)) {
133+
if (
134+
filePath.startsWith(project.rootFolder) ||
135+
project.rootFolder === "."
136+
) {
134137
if (
135138
mostPreciseProject === null ||
136139
project.rootFolder.length > mostPreciseProject.rootFolder.length

packages/cli/src/symbolExtractor/csharp/index.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,16 @@ export function extractCSharpSymbols(
4949
// File path for the extracted file
5050
const fakeprojectpath = subproject.name.split(".").join(path.sep);
5151
const spindex = namespace.split(".").indexOf(subproject.name);
52+
const nspath = namespace
53+
.split(".")
54+
.slice(spindex !== -1 ? spindex : 0)
55+
.join(path.sep)
56+
.replace(fakeprojectpath, subproject.name);
5257
const key = path.join(
53-
namespace
54-
.split(".")
55-
.slice(spindex !== -1 ? spindex : 0)
56-
.join(path.sep)
57-
.replace(fakeprojectpath, subproject.name),
58+
spindex !== -1 || nspath.startsWith(subproject.name)
59+
? ""
60+
: subproject.name,
61+
nspath,
5862
`${name}.cs`,
5963
);
6064
if (!extractedFilesMap.has(key)) {

0 commit comments

Comments
 (0)