Skip to content

Commit

Permalink
fix: added auto-generated line to auto generated dotnet files
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianKuesters committed Feb 28, 2024
1 parent 09464ac commit 765d144
Showing 1 changed file with 30 additions and 10 deletions.
40 changes: 30 additions & 10 deletions src/sdk-auto-generate-dotnet/templates/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,36 @@ rm -r $targetDirectory/src
# remove generated test project
rm -r $targetDirectory/$packageName.Test

# fix warning in generated code
# if not already fixed

if ! grep -q ";MSB3245;MSB3243" $projectPath/$packageName.csproj; then
sed -i '' "s|</Project>|\n\
<PropertyGroup>\n\
<NoWarn>\$(NoWarn);MSB3245;MSB3243</NoWarn>\n\
</PropertyGroup>\n\
</Project>|g" $projectPath/$packageName.csproj
fi
generatedFileHeader="// <auto-generated />
#pragma warning disable CS8669"

# Prepend $generatedFileHeader to all files in $projectPath/Api
for file in $(find $projectPath/Api -name '*.cs'); do
# skip the ApiClient`.cs file
if [[ $file == *ApiClient\`.cs ]]; then
continue
fi
# ensure that the file begins with $generatedFileHeader
if ! grep -q "^$generatedFileHeader" $file; then
echo "$generatedFileHeader" | cat - $file > temp && mv temp $file
fi
done

# Prepend $generatedFileHeader to all files in $projectPath/Client
for file in $(find $projectPath/Client -name '*.cs'); do
# ensure that the file begins with $generatedFileHeader
if ! grep -q "^$generatedFileHeader" $file; then
echo "$generatedFileHeader" | cat - $file > temp && mv temp $file
fi
done

# Prepend $generatedFileHeader to all files in $projectPath/Model
for file in $(find $projectPath/Model -name '*.cs'); do
# ensure that the file begins with $generatedFileHeader
if ! grep -q "^$generatedFileHeader" $file; then
echo "$generatedFileHeader" | cat - $file > temp && mv temp $file
fi
done

# Add generated project to root sln
dotnet sln $solution add $projectPath/
Expand Down

0 comments on commit 765d144

Please sign in to comment.