Step 1 : Rewrite the differential equation
The given equation is
$$ (x-y)\frac{dy}{dx}=x+2y. $$
Re-arranging,
$$ \frac{dy}{dx}=\frac{x+2y}{x-y}. $$
Step 2 : Show that it is homogeneous
In the right–hand side numerator $$x+2y$$ each term has degree 1, and in the denominator $$x-y$$ each term also has degree 1. Hence the ratio is a homogeneous function of degree 0, so the differential equation is homogeneous.
Step 3 : Substitute $$y=vx$$
Let $$y=vx \;\;(v\;\text{depends on }x).$$ Then
$$ \frac{dy}{dx}=v+x\,\frac{dv}{dx}. $$
Substituting this and $$y=vx$$ into the differential equation gives
$$ v+x\,\frac{dv}{dx}=\frac{x+2vx}{x-vx}=\frac{1+2v}{1-v}. $$
Step 4 : Obtain a separable equation in $$v$$ and $$x$$
Bring the terms together:
$$ x\,\frac{dv}{dx}=\frac{1+2v}{1-v}-v. $$
Simplify the right–hand side:
$$ \frac{1+2v}{1-v}-v=\frac{1+2v-v(1-v)}{1-v}=\frac{1+2v-v+v^{2}}{1-v}=\frac{v^{2}+v+1}{1-v}. $$
Hence
$$ x\,\frac{dv}{dx}=\frac{v^{2}+v+1}{1-v}. $$
Step 5 : Separate the variables
$$ \frac{1-v}{v^{2}+v+1}\,dv = \frac{dx}{x}. $$
Step 6 : Integrate both sides
We need
$$ I=\int\frac{1-v}{v^{2}+v+1}\,dv. $$
Write
$$ 1-v = -\tfrac12(2v+1)+\tfrac32, $$
so that
$$ I=-\tfrac12\int\frac{2v+1}{v^{2}+v+1}\,dv+\tfrac32\int\frac{dv}{v^{2}+v+1}. $$
The first integral is a logarithm:
$$ -\tfrac12\ln|v^{2}+v+1|. $$
For the second, complete the square:
$$ v^{2}+v+1=(v+\tfrac12)^{2}+\tfrac34, $$
giving
$$ \tfrac32\int\frac{dv}{(v+\tfrac12)^{2}+(\tfrac{\sqrt3}{2})^{2}}=\tfrac32\cdot\frac{2}{\sqrt3}\tan^{-1}\!\left(\frac{2v+1}{\sqrt3}\right)=\sqrt3\,\tan^{-1}\!\left(\frac{2v+1}{\sqrt3}\right). $$
Thus
$$ \int\frac{1-v}{v^{2}+v+1}\,dv = -\tfrac12\ln|v^{2}+v+1| + \sqrt3\,\tan^{-1}\!\left(\frac{2v+1}{\sqrt3}\right)+C. $$
Equating to $$\int\tfrac{dx}{x}=\ln|x|+C,$$ we have
$$ -\tfrac12\ln|v^{2}+v+1| + \sqrt3\,\tan^{-1}\!\left(\frac{2v+1}{\sqrt3}\right)=\ln|x|+C. $$
Step 7 : Replace $$v$$ by $$y/x$$ and simplify
Because $$v=\dfrac{y}{x},$$
$$ v^{2}+v+1=\frac{y^{2}+xy+x^{2}}{x^{2}}, $$
and
$$ \ln|v^{2}+v+1|=\ln|y^{2}+xy+x^{2}|-2\ln|x|. $$
Substituting in the integrated result cancels the $$\ln|x|$$ terms, leaving
$$ \sqrt3\,\tan^{-1}\!\left(\frac{2y+x}{\sqrt3\,x}\right)-\tfrac12\ln|y^{2}+xy+x^{2}|=C. $$
Step 8 : The general solution
The required implicit solution is therefore
$$ \sqrt3\,\tan^{-1}\!\left(\frac{2y+x}{\sqrt3\,x}\right)-\frac12\ln|y^{2}+xy+x^{2}|=C, $$
where $$C$$ is an arbitrary constant.