Change figure numbering for appendix - when using endfloat and double spacing

I am trying to change the format of the figure numbering for the appendix of my document. I also want to use double spacing in the document and to use the endfloat package. For the basic case of just changing the format of figure numbering, I can follow along perfectly with the example in this answer to this question: Change figure numbering for appendix. But, when I try to add both the endfloat package and double spacing, the solution falls apart. What is curious is that either on their own works fine. Below is a minimal working example, based on the answer cited above. If I make either of the below two modifications, the example successfully changes the format of the figure numbering, but lacking that, it does not:

1. Comment out \begin{spacing}{2} and \end{spacing}

2. Comment out \usepackage[notablist,nofiglist,nomarkers]{endfloat} and \processdelayedfloats

.

\documentclass{article}
\usepackage[notablist,nofiglist,nomarkers]{endfloat}  %% places all figures and tables at the end.
\usepackage{setspace} % Allows for double spacing
\begin{document}

\begin{spacing}{2}

Body Text.

\begin{figure}
\centering\rule{1cm}{1cm}
\caption{This is a figure}
\end{figure}

\processdelayedfloats

\appendix
\renewcommand\thefigure{\thesection.\arabic{figure}}
\section{Appendix}
\setcounter{figure}{0}

Appendix Text.

\begin{figure}
\centering\rule{1cm}{1cm}
\caption{This is a figure in appendix A}
\end{figure}

\end{spacing}
\end{document}


I also tried the solution suggested here. I don't believe it worked, but the question was not set up with any kind of reproducible example, nor did the answer make very clear how / where it was to be implemented, so it is possible there is a mechanism using those techniques that is eluding me.

The nesting introduced by \begin{spacing}...\end{spacing} prevents \thefigure working as desired -- the change done with \renewcommand is only local, but not working outside, i.e. during the writing process with endfloat at the end of the document, i.e. beyond the spacing environment. The solution is to use \gdef\thefigure{...} to enable the change globally.

This will change any \thefigure of course, but since this is to be done in the appendix, this should not cause troubles, in my opinion.

\documentclass{article}
\usepackage[notablist,nofiglist,nomarkers]{endfloat}  %% places all figures and tables at the end.
\usepackage{setspace} % Allows for double spacing
\begin{document}

\begin{spacing}{2}

Body Text.

\begin{figure}
\centering\rule{1cm}{1cm}
\caption{This is a figure}
\end{figure}

\processdelayedfloats

\appendix
\gdef\thefigure{\thesection.\arabic{figure}}
\section{Appendix}
\setcounter{figure}{0}

Appendix Text.

\begin{figure}
\centering\rule{1cm}{1cm}
\caption{This is a figure in appendix A}
\end{figure}

\end{spacing}
\end{document}