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/