This answer splits the difference between the traditional and proposed approaches. It introduces \vfrac{}{}
(vary-frac) which will stretch the top of the fraction to the top of the higher of the two components, but never higher than the top of a capital "X".
For x/y fractions, it gives what the OP seeks, I think. But if one of the arguments is tall, it stretches the result accordingly. It is made to work across all math styles.
\documentclass{article}
\usepackage{scalerel}
\newcommand\vfrac[2]{\ThisStyle{%
\setbox0=\hbox{$\SavedStyle#1#2$}%
\setbox2=\hbox{$\SavedStyle X$}%
\ifdim\ht0>\ht2\setlength{\ht0}{\ht2}\fi%
#1\mathord{\stretchto{\raisebox{2.3\LMpt}{$\SavedStyle/$}}{\ht0}}#2}}
\begin{document}
$\vfrac{x}{y} \quad \vfrac{X}{Y}\quad \vfrac{X^2}{y}\quad \vfrac{p}{q}$\par
$\scriptstyle\vfrac{x}{y} \quad \vfrac{X}{Y}\quad \vfrac{X^2}{y}\quad \vfrac{p}{q}$\par
$\scriptscriptstyle\vfrac{x}{y} \quad \vfrac{X}{Y}\quad \vfrac{X^2}{y}\quad \vfrac{p}{q}$\par
\end{document}

FOLLOW UP:
The OP asked for a similar approach but with a 45 degree stroke. Here is such a variation on my approach (though the angle may not be exactly 45 deg). A downside is that since the slash is scaled (rather than extended), its thickness changes with size.
\documentclass{article}
\usepackage{scalerel}
\newcommand\vfrac[2]{\ThisStyle{%
\setbox0=\hbox{$\SavedStyle#1#2$}%
\setbox2=\hbox{$\SavedStyle X$}%
\ifdim\ht0>\ht2\setlength{\ht0}{\ht2}\fi%
#1\mathord{\scaleto{\raisebox{.7pt}{\vstretch{.3}{\SavedStyle/}}}{\ht0}}#2}}
\begin{document}
$\vfrac{x}{y} \quad \vfrac{X}{Y}\quad \vfrac{X^2}{y}\quad \vfrac{p}{q}$\par
$\scriptstyle\vfrac{x}{y} \quad \vfrac{X}{Y}\quad \vfrac{X^2}{y}\quad \vfrac{p}{q}$\par
$\scriptscriptstyle\vfrac{x}{y} \quad \vfrac{X}{Y}\quad \vfrac{X^2}{y}\quad \vfrac{p}{q}$\par
\end{document}
