From 765d1448c7ca6bab531f372fc5d42194c102c9f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCsters?= Date: Wed, 28 Feb 2024 09:08:54 +0100 Subject: [PATCH] fix: added auto-generated line to auto generated dotnet files --- .../templates/script.sh | 40 ++++++++++++++----- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/src/sdk-auto-generate-dotnet/templates/script.sh b/src/sdk-auto-generate-dotnet/templates/script.sh index 7b94402..4b2e3ce 100644 --- a/src/sdk-auto-generate-dotnet/templates/script.sh +++ b/src/sdk-auto-generate-dotnet/templates/script.sh @@ -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||\n\ - \n\ - \$(NoWarn);MSB3245;MSB3243\n\ - \n\ -|g" $projectPath/$packageName.csproj -fi +generatedFileHeader="// +#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/